cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.8k stars 379 forks source link

Cross build with `-Zbuild-std` for `x86_64-unknown-freebsd` got failed linking error. #1563

Open Wyvern opened 1 month ago

Wyvern commented 1 month ago

Detail message like below:

error: linking with `x86_64-unknown-freebsd13-gcc.sh` failed: exit status: 1
...
          /usr/local/lib/gcc/x86_64-unknown-freebsd13/6.4.0/../../../../x86_64-unknown-freebsd13/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status

What's wrong and how to fix it?

Emilgardis commented 1 month ago

It's not possible to help you with the information you've given. Need more information.

Wyvern commented 1 month ago

rustc 1.83.0-nightly (ed04567ba 2024-09-28) linking failed only on -Zbuild-std, build without it succeeded.

Wyvern commented 1 month ago

This is the full error output:

error: linking with `x86_64-unknown-freebsd13-gcc.sh` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin" VSLANG="1033" "x86_64-unknown-freebsd13-gcc.sh" "-Wl,--version-script=/tmp/rustcxcoybW/list" "-Wl,--no-undefined-version" "-m64" "/tmp/rustcxcoybW/symbols.o" "/target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e6f0.Img.3e18e81114b9f627-cgu.0.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/target/x86_64-unknown-freebsd/src/deps/libcompiler_builtins-5fa8f84ee86bdccf.rlib" "-Wl,-Bdynamic" "-lrt" "-lutil" "-lexecinfo" "-lkvm" "-lmemstat" "-lkvm" "-lutil" "-lprocstat" "-lrt" "-ldevstat" "-lexecinfo" "-
  = note: + set -euo pipefail
          + main -Wl,--version-script=/tmp/rustcxcoybW/list -Wl,--no-undefined-version -m64 /tmp/rustcxcoybW/symbols.o /target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e6f0.Img.3e18e81114b9f627-cgu.0.rcgu.o -Wl,--as-needed -Wl,-Bstatic /target/x86_64-unknown-freebsd/src/deps/libcompiler_builtins-5fa8f84ee86bdccf.rlib -Wl,-Bdynamic -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat -lexecinfo -lpthread -lgcc_s -lc -lm -lrt -lpthread -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -Wl,--eh-frame-hdr -Wl,-z,noexecstack -o /target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e6f0 -Wl,--no-gc-sections -pie
          + [[ 59 -eq 0 ]]
          + exec x86_64-unknown-freebsd13-gcc -Wl,--version-script=/tmp/rustcxcoybW/list -Wl,--no-undefined-version -m64 /tmp/rustcxcoybW/symbols.o /target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e6f0.Img.3e18e81114b9f627-cgu.0.rcgu.o -Wl,--as-needed -Wl,-Bstatic /target/x86_64-unknown-freebsd/src/deps/libcompiler_builtins-5fa8f84ee86bdccf.rlib -Wl,-Bdynamic -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat -lexecinfo -lpthread -lgcc_s -lc -lm -lrt -lpthread -lrt -lutil -lexecinfo -lkvm -lmemstat -lkvm -lutil -lprocstat -lrt -ldevstat -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -B/home/runner/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld -Wl,--eh-frame-hdr -Wl,-z,noexecstack -o /target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e
          /usr/local/lib/gcc/x86_64-unknown-freebsd13/6.4.0/../../../../x86_64-unknown-freebsd13/bin/ld: /target/x86_64-unknown-freebsd/src/deps/Img-ad24612e0952e6f0: local symbol `environ' in /usr/local/lib/gcc/x86_64-unknown-freebsd13/6.4.0/../../../../x86_64-unknown-freebsd13/lib/Scrt1.o is referenced by DSO
          /usr/local/lib/gcc/x86_64-unknown-freebsd13/6.4.0/../../../../x86_64-unknown-freebsd13/bin/ld: final link failed: bad value
          collect2: error: ld returned 1 exit status
Emilgardis commented 1 month ago

Same thing here, can you try https://github.com/cross-rs/cross/issues/1564#issuecomment-2381401919

Wyvern commented 1 month ago

try #1564 (comment)

Tried install cross using main branch but still show install tagged version 0.2.5 of cross. Not sure whether cargo install cross --git https://github.com/cross-rs/cross --branch main is the right way to do.