rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.55k stars 57 forks source link

Regression: Link failed on `armv7-unknown-linux-{gnu, musl}eabihf` due to missing symbols #94

Closed NobodyXu closed 1 year ago

NobodyXu commented 1 year ago

release-builds / armv7-unknown-linux-musleabihf

release-builds / armv7-unknown-linux-gnueabihf

This can be reproduced by running:

git clone https://github.com/cargo-bins/cargo-binstall
cd cargo-binstall

export CI=true
export JUST_FOR_RELEASE=true
export CARGO_BUILD_TARGET="armv7-unknown-linux-gnueabihf"
export GLIBC_VERSION='2.17'
export JUST_USE_CARGO_ZIGBUILD=true
just build

Or by running the following cmds on the clone:

export RUSTFLAGS='-Z share-generics -C linker-plugin-lto -C link-arg=-static-libgcc -C link-arg=-Wl,--icf=safe'

cargo-zigbuild build  --release --target armv7-unknown-linux-musleabihf -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort --config='profile.release.split-debuginfo="packed"' --config=profile.release.debug=2 --features static,rustls,trust-dns,fancy-no-backtrace,zstd-thin,log_release_max_level_debug,cross-lang-fat-lto

The CI failed with several missing symbols.

Also, cargo-zigbuild failed to handle several link args:

  = note: warning: unsupported linker arg: -znoexecstack
          warning: unsupported linker arg: -plugin-opt
          warning: unsupported linker arg: O2
          warning: unsupported linker arg: -plugin-opt
          warning: unsupported linker arg: mcpu=generic
          warning: unsupported linker arg: -zrelro
          warning: unsupported linker arg: -znow
          warning: unsupported linker arg: --icf
          warning: unsupported linker arg: safe
NobodyXu commented 1 year ago

It works until I removed -Z mir-opt-level=4 from RUSTFLAGS and I'm not sure what caused the regression.

NobodyXu commented 1 year ago

The linking process failed even if I disabled cross lang LTO.

NobodyXu commented 1 year ago

Last working rustc version is rust version 1.69.0-nightly (7aa413d59 2023-02-19) and it failed in rust version 1.69.0-nightly (5243ea5c2 2023-02-20).

NobodyXu commented 1 year ago

Opened https://github.com/rust-lang/rust/issues/108392 at rust-lang/rust