I am trying to compile targeting x86_64-unknown-linux-musl
(cargo build --release --target x86_64-unknown-linux-musl
) and and no matter what I do I keep getting different linking errors.
(1) If I don't define anything related to the linked in .cargo/config.toml
I get this error (simplified as the rest shown):
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
(2) If instead I define (trying to guide myself from this post Enable rust-lld on x86_64-unknown-linux-musl):
[target.x86_64-unknown-linux-musl]
linker = "rust-lld"
rustflags = ["-C", "target-feature=-crt-static"]
I get:
error: linking with `rust-lld` failed: exit code: 1
= note: rust-lld: error: unable to find library -lgcc_s
(3) And if I define:
[target.x86_64-unknown-linux-musl]
linker = "rust-lld"
I get:
= note: rust-lld: error: undefined symbol: __strncpy_chk
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(bool _parse_number<double, hb_parse_double(char const**, char const*, double*, bool)::'lambda'(char const*, char**)>(char const**, char const*, double*, bool, hb_parse_double(char const**, char const*, double*, bool)::'lambda'(char const*, char**)) (.constprop.0)) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
rust-lld: error: undefined symbol: __memmove_chk
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(reorder_marks_arabic(hb_ot_shape_plan_t const*, hb_buffer_t*, unsigned int, unsigned int)) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
rust-lld: error: undefined symbol: __vsnprintf_chk
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(hb_buffer_t::message_impl(hb_font_t*, char const*, __va_list_tag*)) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
rust-lld: error: undefined symbol: __memcpy_chk
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(hb_language_from_string) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(void AAT::StateTableDriver<AAT::ObsoleteTypes, void>::drive<AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t*)) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
>>> referenced by harfbuzz.cc
>>> harfbuzz.o:(void AAT::StateTableDriver<AAT::ObsoleteTypes, void>::drive<AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t>(AAT::RearrangementSubtable<AAT::ObsoleteTypes>::driver_context_t*)) in archive /tmp/rustcAie9yo/libharfbuzz_sys-104a993656c30b7b.rlib
>>> referenced 2 more times
The closest I suppose I am to finally perform linking is by doing the alternative (2) but haven't found a solution to it. Doing `cannot find "-lgcc_s"` from gcc-3.4 on Ubuntu 11.04 - Server Fault yielded that the link already existed.