LDC 1.42.0
kinke
noone at nowhere.com
Mon Mar 2 02:16:15 UTC 2026
On Monday, 2 March 2026 at 00:53:45 UTC, Witold Baryluk wrote:
> Any pointers and instruction on musl usage?
> […]
> Without `-static` it compiles, but links to glibc.
This happens when running the Alpine package on a non-musl
distro. The Alpine compiler targets musl by default, as do its
bundled druntime and Phobos libraries - incl. 64-bit `real` for
example (not the 80-bit x87 as for glibc on x86[_64]). For
linking, it defaults to the `cc` C compiler, assuming that it's a
matching musl-toolchain one (as on Alpine). On Debian/Ubuntu, you
can set it via e.g. `-gcc=x86_64-linux-musl-gcc` after installing
the `musl-dev` apt package. - But it's probably best/easiest when
using the prebuilt Alpine package in an Alpine-based container.
As for Phobos' `std.net.curl`, AFAIK that is just plain
incompatible with fully-static executables, because it's based on
libdl (dlopen/sym/close). While you can theoretically link
libcurl and all of its dependencies statically, and make sure the
`curl_*` C symbols are all exported as dynamic symbols (so that
`std.net.curl` can `dlsym()` them from the executable), you still
cannot make any executable depending on `std.net.curl` fully
static via `-static`. This is e.g. the reason why some bundled
tools in the LDC Alpine packages aren't fully static and depend
on a (musl-targeting) libcurl loaded at runtime, e.g.,
`ldc-build-runtime`.
FWIW, Phobos also has raw C bindings in `etc.c.curl`.
More information about the Digitalmars-d-announce
mailing list