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 link object files with different floating-point ABI" (nightly-2021-03-23) #69

Closed
yvt opened this issue Mar 29, 2021 · 1 comment · Fixed by #73
Closed

"cannot link object files with different floating-point ABI" (nightly-2021-03-23) #69

yvt opened this issue Mar 29, 2021 · 1 comment · Fixed by #73

Comments

@yvt
Copy link

yvt commented Mar 29, 2021

riscv and riscv-rt crates cause a linker error when building with a recent nightly compiler for a hard-float target.

git clone https://github.com/riscv-rust/k210-crates.git --recursive
cd k210-crates
cd k210-example
sed -i .bak -e 's/riscv64imac/riscv64gc/g' .cargo/config
cargo +nightly-2021-03-23 build --release

Output:

error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "gnu" "-L" [...]
  = note: rust-lld: error: [redacted]/target/riscv64gc-unknown-none-elf/release/deps/libriscv-3f21992281a58781.rlib(riscv.o): cannot link object files with different floating-point ABI
          rust-lld: error: [redacted]/target/riscv64gc-unknown-none-elf/release/deps/libriscv_rt-db1e8f195a4770c0.rlib(riscv-rt.o): cannot link object files with different floating-point ABI


error: aborting due to previous error

error: could not compile `k210-example`

To learn more, run the command again with --verbose.

It appears that this started happening somewhere between nightly-2021-03-10 and nightly-2021-03-23 (inclusive).

  • 1.50.0: ok
  • nightly-2021-02-19: ok
  • nightly-2021-02-23: ok
  • nightly-2021-03-09: ok
  • nightly-2021-03-23: fail
@yvt
Copy link
Author

yvt commented Mar 29, 2021

This might have been caused by rust-lang/rust#83231

yvt added a commit to r3-os/r3 that referenced this issue Mar 31, 2021
This commit replaces `riscv` and `riscv-rt` with a customized version to
work around <rust-embedded/riscv#69>.

The long-term solution is simple: wait until `asm!` is stabilized and
rewrite all assembler code of `riscv` and `riscv-rt` in inline
assembler. The short-term solution is complicated by multiple factors:

 - `asm!` and `#[naked]` are not stable yet. Therefore, the precompiled
   object files are still needed to support the stable Rust.

 - There is no reliable way to check the target floating-point ABI from
   the build script.

 - Many crates depend on older versions of `riscv` and `riscv-rt` that
   use the old form of `asm!` and have lower MSRVs.

This commit skips over these considerations by assuming the target
compiler version. Specifically:

 - The customized version of `riscv 0.5` uses `llvm_asm!`, which is
   supported by our target compiler version but not by the target
   compiler of the original version.

 - The customized version of `riscv-rt` replaces all assembler code with
   inline assembler wrapped in naked functions.
bors bot added a commit that referenced this issue Jul 17, 2021
73: Add additional binaries for floating-point ABIs r=almindor a=TechnoElf

Fixes #69

Co-authored-by: TechnoElf <[email protected]>
@bors bors bot closed this as completed in e54d3fd Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant