The compile configure paremeter for rust musl target

I want to install rust from source code(release 1.46) with target gnu and musl, I run it on aarch64 host.

I use this configure

./configure --musl-root-aarch64=/usr/local/musl --target=aarch64-unknown-linux-musl --enable-extended --tools=analysis,cargo,clippy,rls,rustfmt,src --release-channel=stable --enable-lld

The compile and install is success, but when I run 'cargo build --target aarch64-unknown-linux-musl' ,it report a error:

	/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9.3.1/../../../../lib64/libfdt.a(fdt_ro.o): in function `nextprop_':
          (.text+0x70): undefined reference to `__stack_chk_guard'
          /usr/bin/ld: (.text+0x84): undefined reference to `__stack_chk_guard'
          /usr/bin/ld: (.text+0xd0): undefined reference to `__stack_chk_guard'
          /usr/bin/ld: (.text+0xe4): undefined reference to `__stack_chk_fail'

So I download rust-std for musl form '', and copy the manifest and lib file to /usr/local/lib/rustlib, overwrite the lib which is compile from source code. The error is gone, I can build my project successfully.

I am confuse with this situation, :confused: Can anybody help me and tell me the exact compile configure for a runable rust-std for musl target?

By the way. I can't use rustup for my project which is the root cause of this problem :frowning_face:

It looks like one of your dependencies is using libfdt, which is a native library for a GNU target, and can't be used with a MUSL target.

You must ensure that dependencies can't find anything GNU-flavored on your system. Try forbidding use of pkg-config, configure all your Rust dependencies to compile native from source instead of looking for precompiled libraries on your GNU OS.

Alternatively, compile inside a virtual machine that's running a MUSL OS, and not a GNU one.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.