Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nightly builds fail on many platforms now that nightly sets -fuse-ld=lld #1496

Closed
4 of 11 tasks
autarch opened this issue May 18, 2024 · 4 comments
Closed
4 of 11 tasks
Labels

Comments

@autarch
Copy link

autarch commented May 18, 2024

Checklist

Describe your issue

Compilation fails on many platforms (maybe all?) because of this change in nightly:

cross -v +nightly build --locked --release --target x86_64-unknown-freebsd

...

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin:/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/rust/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcVrgDOH/symbols.o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4.build_script_build.26c1efd651742760-cgu.0.rcgu.o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4.build_script_build.26c1efd651742760-cgu.1.rcgu.o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4.build_script_build.26c1efd651742760-cgu.2.rcgu.o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4.build_script_build.26c1efd651742760-cgu.3.rcgu.o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4.0p8wefs2ijwvpbvkr3biqh6z0.rcgu.o" "-Wl,--as-needed" "-L" "/target/release/deps" "-L" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-de48b8168d6cf4fa.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9f3477fb95a0bba7.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-210d920812faea91.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-f3d3451767410a17.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-1a79dd36d08251de.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-886230e7120831b2.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-2caea079085a58a2.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-a9d7d97cdc65a449.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-5727477b0a78105a.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-7e555563aa211118.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-c8f13465f1a795b2.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-ee5b5774583426df.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-14df174c91007922.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-e8bfe52be756260a.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6275035a459b3ada.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-b6892f3c52c68f01.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-f72b956e24d1de70.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-632ae0f28c5e55ff.rlib" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-e8b7e96e438f08f6.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-B/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld" "-fuse-ld=lld" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/rust/lib/rustlib/x86_64-unknown-linux-gnu/lib/self-contained" "-o" "/target/release/build/libc-ac0b713d0dd5a2f4/build_script_build-ac0b713d0dd5a2f4" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: cc: error: unrecognized command line option '-fuse-ld=lld'

I've tried lots of different methods of passing in the flag to tell it not to use lld, including:

Setting RUSTFLAGS when I invoke cross.

Various changes to my Cargo.toml:

[package.metadata.cross.target.x86_64-unknown-freebsd]
pre-build = [
    'set -x',
    'mkdir -p ~/.cargo',
    'echo "rustflags = [\"-Z linker-features=-lld\"]" >> ~/.cargo/config.toml',
    'cat ~/.cargo/config.toml',
]

And also:

[package.metadata.cross.target.x86_64-unknown-freebsd]
rustflags = ["-Z linker-features=-lld"]

None of these worked.

What target(s) are you cross-compiling for?

aarch64-unknown-freebsd

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

cross -v +nightly build --target x86_64-unknown-freebsd

I think this will fail on any project.

Additional information / notes

No response

@autarch
Copy link
Author

autarch commented May 18, 2024

This doesn't seem to be an issue with the latest repo version of cross for some reason. I don't see -fuse-ld=lld in the rustc commands that are run. This didn't require any changes to my crate's config.

@Emilgardis
Copy link
Member

Emilgardis commented May 18, 2024

fuse-ld=lld requires GCC 9. The new feature enabled in nightly-2024-05-18 for toolchain x86_64-unknown-linux-gnu doesn't use the system LLVM, instead it uses a self-contained lld called rust-lld inside the toolchain bin folder (which is also put in path).

I'll have to investigate why it doesn't work on 0.2.5

The pre-build you shared should not work, ~ refers to the home of root. The rustflags setting you shared should have worked though.

upstream changes:
rust-lang/rust#124129
announcement:
https://blog.rust-lang.org/2024/05/17/enabling-rust-lld-on-linux.html

@VorpalBlade
Copy link

Running into this too when cross compiling nightly from x86-64 to Aarch64. Seems like a regression in Rust to me.

@Emilgardis
Copy link
Member

Emilgardis commented May 24, 2024

This should now be fixed with new nightly builds, thanks @VorpalBlade for reporting it upstream!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants