Hello! I have a set of binaries and libraries written in C++ that I cross compile for different architectures. I only have dynamically linked binaries. I want to rewrite some of them in Rust.
I tried to compile for aarch64-unknown-linux-musl with cargo build --target aarch64-unknown-linux-musl and the following .cargo/config:
Dynamic section at offset 0x28aa0 contains 30 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so]
0x000000000000000c (INIT) 0x31c8
0x000000000000000d (FINI) 0x1f204
[...]
I was expecting rust's libstd.so to be linked dynamically as well, similarly to libgcc_s.so and libc.so or similarly to the libstdc++.so library for C++ binaries:
Dynamic section at offset 0x8ada0 contains 31 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so]
I also tried the suggestion with -C prefer-dynamic from here and it works when not cross compiling. When specifying the target as above, I get a statically linked binary.
Is there an extra flag or compiling option I do not know of? Thank you!
It does the same as for aarch64-unknown-linux-musl if I use -C target-feature=-crt-static though. So the question now would be: why doesn't -C prefer-dynamic work for the musl target?
Ah, of course they are. In trying to find the shared libraries for musl I ended up pasting nonsense. You are right, thank you! I can see that the aarch64-unknown-linux-gnu ships the shared libraries, while aarch64-unknown-linux-musl does not.