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

Cannot create rv64gc binary anymore since nightly-2019-05-10 #60747

Closed
laanwj opened this issue May 11, 2019 · 8 comments · Fixed by #60841
Closed

Cannot create rv64gc binary anymore since nightly-2019-05-10 #60747

laanwj opened this issue May 11, 2019 · 8 comments · Fixed by #60841
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-riscv Target: RISC-V architecture P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@laanwj
Copy link

laanwj commented May 11, 2019

Here's a minimal reproduction: rv64gc-build-test.tar.gz

This works:

rustup toolchain install nightly-2019-05-09
rustup target  add riscv64gc-unknown-none-elf --toolchain nightly-2019-05-09
rustup toolchain install nightly-2019-05-10
rustup target  add riscv64gc-unknown-none-elf --toolchain nightly-2019-05-10
$ cargo +nightly-2019-05-09 build

This fails with a long linker error message:

$ cargo +nightly-2019-05-10 build

   Compiling rv64gc-build-test v0.1.0 (/home/user/rv64-build-test)
error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "-L" "/home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/rv64gc_build_test-ceeff793f013ca85.2n9gt1sqfhboah09.rcgu.o" "-o" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/rv64gc_build_test-ceeff793f013ca85" "--gc-sections" "-L" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps" "-L" "/home/user/rv64-build-test/target/debug/deps" "-L" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/build/rv64gc-build-test-6fe9523ab53da0fd/out" "-L" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/build/riscv-74e5b865e4a295cf/out" "-L" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/build/riscv-rt-7d092076a17d09e9/out" "-L" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/build/riscv-rt-7d092076a17d09e9/out" "-L" "/home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib" "-Bstatic" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libriscv_rt-9090a4f920915543.rlib" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libr0-3c380a49758184f1.rlib" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libriscv-42d4fa3f5d6ba30e.rlib" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libbit_field-45876c749a94e638.rlib" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libbare_metal-aa54f9169ec1e607.rlib" "--start-group" "/home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/libpanic_halt-d30ee6629201fb4c.rlib" "/home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib/librustc_std_workspace_core-330c94737850f50a.rlib" "/home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib/libcore-2e0fb004fad6ca66.rlib" "--end-group" "/home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib/libcompiler_builtins-afe13c5355265d4c.rlib" "-Tmemory.x" "-Tlink.x" "-Bdynamic"
  = note: rust-lld: error: /home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib/libcompiler_builtins-afe13c5355265d4c.rlib(clzsi2.o) is incompatible with /home/user/rv64-build-test/target/riscv64gc-unknown-none-elf/debug/deps/rv64gc_build_test-ceeff793f013ca85.2n9gt1sqfhboah09.rcgu.o

error: aborting due to previous error

error: Could not compile `rv64gc-build-test`.

I do not yet know what causes this incompatibility.

@laanwj
Copy link
Author

laanwj commented May 11, 2019

What is strange (to me) is that most of the objects in the referenced rlib are for X86-64, not RISC-V, this might be the source of the incompatibility:

$ readelf -a /home/user/.rustup/toolchains/nightly-2019-05-10-x86_64-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-none-elf/lib/libcompiler_builtins-afe13c5355265d4c.rlib|grep Machine
  Machine:                           RISC-V
  Machine:                           Advanced Micro Devices X86-64
  Machine:                           Advanced Micro Devices X86-64
... lots more

(I've checked and this is the case for all RISC-V 64 and 32 libcompiler_builtins libraries, for all versions I've looked at, even on stable, but apparently only today it started causing issues. It was not the case for AARCH64)

The object it's trying to link against, however, is RISC-V:

$ readelf -a /home/user/rv64gc-build-test/target/riscv64gc-unknown-none-elf/debug/deps/rv64gc_build_test-4cd742fb8def7147.xeu8wy2g6icc2av.rcgu.o | grep Machine:
  Machine:                           RISC-V

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. O-riscv Target: RISC-V architecture T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-linkage Area: linking into static, shared libraries and binaries labels May 11, 2019
@mati865
Copy link
Contributor

mati865 commented May 13, 2019

Does nightly-2019-05-10 work after running cargo clean (without running the older one)?

@laanwj
Copy link
Author

laanwj commented May 13, 2019

Yes, this is not an issue with stale files: I even completely removed the target folder a few times.

@jonas-schievink jonas-schievink added I-nominated regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 13, 2019
@mati865
Copy link
Contributor

mati865 commented May 13, 2019

alexcrichton added a commit to alexcrichton/compiler-builtins that referenced this issue May 14, 2019
This fixes a longstanding bug in compiler-builtins where C code was
compiled for the riscv targets but when distributed in rust-lang/rust
all the C code was actually compiled for x86_64 since there is no
configured C compiler for riscv. This was exposed by rust-lang#286 by accident
but the underlying cause was somewhat unrelated.

For now we forcibly disable C code for riscv targets, and when the C
compiler story is sorted out in rust-lang/rust and with `cc-rs` we can
reenable. For now just use all the Rust definitions.

cc rust-lang/rust#60747
@alexcrichton
Copy link
Member

Thanks for the report @laanwj and the cc @mati865, this should be fixed by rust-lang/compiler-builtins#291

@laanwj
Copy link
Author

laanwj commented May 15, 2019

Great, thanks for the fast fix!
I'll test with tomorrow's nightly.

@pnkfelix
Copy link
Member

triage: P-high. (I'm not 100% sure that prioritization is warranted for this target, but given that it may already be fixed, I don't mind err'ing on the side of too-high a priority.)

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels May 16, 2019
alexcrichton added a commit to alexcrichton/rust that referenced this issue May 17, 2019
This updates to 0.1.13 for `compiler_builtins`, published to fix a few
issues. The feature changes here are updated because `compiler_builtins`
no longer enables the `c` feature by default but we want to do so
through our build still.

Closes rust-lang#60747
Closes rust-lang#60782
bors added a commit that referenced this issue May 17, 2019
Update the compiler_builtins crate

This updates to 0.1.13 for `compiler_builtins`, published to fix a few
issues. The feature changes here are updated because `compiler_builtins`
no longer enables the `c` feature by default but we want to do so
through our build still.

Closes #60747
Closes #60782
@laanwj
Copy link
Author

laanwj commented May 18, 2019

verified that this problem is gone in rustc 1.36.0-nightly (73a3a90d2 2019-05-17)
great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-riscv Target: RISC-V architecture P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants