Open polarathene opened 1 month ago
I remember snmalloc
emits references to certain __atomic*
symbols. Many platforms does not ship a static version of libatomic
due to its nature (there is some datum inside libatomic that ought to be shared by processes). Tweaking architectural feature flags can eliminate such symbol references but I need to check with @mjp41 and test it on my side.
Problem
libatomic
is forced to link dynamically, preventing static builds. Is there a reason for this?Reproduction
Failure linking
libatomic.so
:libatomic.a
is available:Adding to the
RUSTFLAGS
ENV value with-C link-arg=/usr/lib/libatomic.a
,-L /usr/lib -l static=atomic
, or-C prefer-dynamic=no
all fail to get this library linked statically.Cause
This is also the case with snmalloc?
cc:
https://github.com/SchrodingerZhu/snmalloc-rs/blob/a564ef910b1209aedd4de4941baa69788c83d740/snmalloc-sys/build.rs#L131-L137
cmake:
https://github.com/SchrodingerZhu/snmalloc-rs/blob/a564ef910b1209aedd4de4941baa69788c83d740/snmalloc-sys/build.rs#L290
https://github.com/SchrodingerZhu/snmalloc-rs/blob/a564ef910b1209aedd4de4941baa69788c83d740/snmalloc-sys/build.rs#L295-L298
Reference -
mimalloc-sys
For the
mimalloc-sys
rust crate this was resolved with an additional conditional (_related report, associated issue/PR was resolved in May 2024_):However the use of
dylib
forced dynamically linking the library breaking support for static builds. That was fixed in June 2024.