Can't cross-compile hello_world to powerpc musl

I'm trying to cross-compile hello_world to powerpc musl. I have configured my config.toml to use rust-lld, however, I get a linker error:

root@ip-172-31-33-100 ~/hello_world #  cargo build -Z build-std --target powerpc-unknown-linux-musl --release
   Compiling hello_world v0.1.0 (/root/hello_world)
error: linking with `rust-lld` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "rust-lld" "-flavor" "gnu" "crt1.o" "crti.o" "crtbegin.o" "/tmp/rustcx1IGTT/symbols.o" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/hello_world-9162f3ae144a79af.hello_world.cb9da37d195d71e-cgu.0.rcgu.o" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/hello_world-9162f3ae144a79af.2zbfb0iiaup7px44.rcgu.o" "--as-needed" "-L" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps" "-L" "/root/hello_world/target/release/deps" "-L" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib" "-Bstatic" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libstd-602c669cac526a61.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libpanic_unwind-f6062f6b6bb4845c.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libobject-cd7e0657e955c65f.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libmemchr-1ea44e68bec5eca8.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libaddr2line-0c68ee321b7fc89b.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libgimli-611d6461e9813fb6.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/librustc_demangle-8209ecde9deb0660.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libstd_detect-cd05966c2c354802.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libhashbrown-4c1e895d2fe655d0.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/librustc_std_workspace_alloc-1fcc94105de3f7ba.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libminiz_oxide-3448b479ee7af690.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libadler-7c83421a3a66717c.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libunwind-385d89d86e719a69.rlib" "-lunwind" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libcfg_if-75749084f4d8c41f.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/liblibc-cff30d5f5e38d8d0.rlib" "-lc" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/liballoc-9d3d172921718c81.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/librustc_std_workspace_core-e763f899d0e4a992.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libcore-0016fbd5838138cb.rlib" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/libcompiler_builtins-394ba544b9dcfe53.rlib" "-Bdynamic" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib" "-L" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib/self-contained" "-o" "/root/hello_world/target/powerpc-unknown-linux-musl/release/deps/hello_world-9162f3ae144a79af" "--gc-sections" "-static" "-z" "relro" "-z" "now" "-O1" "crtend.o" "crtn.o"
  = note: rust-lld: error: cannot open crt1.o: No such file or directory
          rust-lld: error: cannot open crti.o: No such file or directory
          rust-lld: error: cannot open crtbegin.o: No such file or directory
          rust-lld: error: unable to find library -lunwind
          rust-lld: error: unable to find library -lc
          rust-lld: error: cannot open crtend.o: No such file or directory
          rust-lld: error: cannot open crtn.o: No such file or directory


error: could not compile `hello_world` (bin "hello_world") due to previous error

I'm a little bit confused, why is it trying to link these objects in? What are these objects? If I don't have them.. how can I get them?

I'm on a Debian 11 virtual machine, on x86-64 arch

These object files are part of musl libc. For musl targets we ship with rustup a copy of musl is already included, but if you use -Zbuild-std you have to get a copy for the target yourself and use something like RUSTFLAGS="-Clink-arg=-L -Clink-arg=/path/to/musl" to tell the linker where to find it.

1 Like

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.