Description
Hi, I am building dynamic libraries that I call from scripting languages (elixir nif, nodejs native addon, etc) on Alpine Linux. I have been successful using the x86_64-unknown-linux-musl
target with -C target-feature=-crt-static
to enable building cdylib
s. However, I find that any cdylib
produced this way links dynamically not only to musl
but also to libgcc_s
:
$ ldd target/release/libhello.so
/lib/ld-musl-x86_64.so.1 (0x7ffa2d2fb000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7ffa2d1cd000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7ffa2d2fb000)
Unfortunately, the Alpine Linux docker image does not include the libgcc
package by default, and the packages for most scripting languages do not depend on it, so users of my library will be required to explicitly install it, which is an inconvenience.
Below is the line in the unwind
crate that dynamically links to libgcc_s
on musl
targets when crt-static
is disabled:
rust/library/unwind/src/lib.rs
Line 41 in b36f770
Is there a path to compiling cdylib
s for musl
without dynamically linking to libgcc_s
? Perhaps while unwinding across FFI boundaries remains undefined behavior, -crt-static
on musl
could statically link the unwind functionality like it does with +crt-static
?
rustc --version --verbose
:
rustc 1.50.0 (cb75ad5db 2021-02-10)
binary: rustc
commit-hash: cb75ad5db02783e8b0222fee363c5f63f7e2cf5b
commit-date: 2021-02-10
host: x86_64-unknown-linux-musl
release: 1.50.0