rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
133 stars 8 forks source link

-lunwind despite build_std=["panic_abort","std"] on powerpc-unknown-linux-musl #81

Open george-hopkins opened 1 year ago

george-hopkins commented 1 year ago

Rust wants to link to libunwind despite specifying panic=abort and build-std = ["panic_abort","std"]:

cargo build

error: linking with `powerpc-openwrt-linux-musl-gcc` failed: exit status: 1
  |
  = note: "powerpc-openwrt-linux-musl-gcc" "-m32" "crt1.o" "crti.o" "crtbegin.o" "/tmp/rustc1ebVyM/symbols.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.17hp3jls561h3f32.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.1gp3lpkjgqgu756k.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.1t033r9onn7ecs3h.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.2drrymktdtaldlkg.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.2qtmdnxrb99op7va.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.5ok19t0amylp4of.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.gq5i93i01zy6cxf.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.o05lin4m45dsjcp.rcgu.o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c.545lpn4xg3kavb2u.rcgu.o" "-Wl,--as-needed" "-L" "/work/example/target/powerpc-unknown-linux-musl/debug/deps" "-L" "/work/example/target/debug/deps" "-L" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib" "-Wl,-Bstatic" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libstd-b8b84a9f0393368d.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libpanic_abort-7f09494103ebf55a.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/librustc_demangle-f05f240a2dc423dd.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libstd_detect-5f10a3ba32160695.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libcfg_if-51c0451feea39f8d.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libhashbrown-0d3f6ec9280d20da.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/librustc_std_workspace_alloc-a128db2f183ef749.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libunwind-7cbfb230258816ef.rlib" "-lunwind" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libcfg_if-a4d03a14ac46d5b4.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/liblibc-7c76d9ce79c2879c.rlib" "-lc" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/liballoc-f826196aa76e38c1.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/librustc_std_workspace_core-2ce7bdc323d893e3.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libcore-ad5e12a6c3575cec.rlib" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/libcompiler_builtins-d2bcda9d20ce94b3.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib" "-L" "/home/user/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/powerpc-unknown-linux-musl/lib/self-contained" "-o" "/work/example/target/powerpc-unknown-linux-musl/debug/deps/example-39cfa1cb2de2650c" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs" "crtend.o" "crtn.o"
  = note: /work/toolchain/bin/../lib/gcc/powerpc-openwrt-linux-musl/11.2.0/../../../../powerpc-openwrt-linux-musl/bin/ld: cannot find -lunwind
          collect2: error: ld returned 1 exit status

Cargo.toml

[package]
name = "example"
version = "0.1.0"
edition = "2021"

[profile.dev]
panic = "abort"

.cargo/config

[target.powerpc-unknown-linux-musl]
linker = "powerpc-openwrt-linux-musl-gcc"

[unstable]
build-std = ["panic_abort","std"]
build-std-features = ["panic_immediate_abort"]

[build]
target = "powerpc-unknown-linux-musl"

Is it possible to avoid linking to libunwind?

irontigran commented 1 year ago

This looks similar to this question: https://stackoverflow.com/questions/73614370/how-do-i-remove-the-dependency-on-libunwind-when-cross-compiling-rust-programs-w