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

ABI mismatch for riscv64gc-unknown-none-elf #795

Open
dramforever opened this issue Mar 4, 2023 · 0 comments · May be fixed by #796
Open

ABI mismatch for riscv64gc-unknown-none-elf #795

dramforever opened this issue Mar 4, 2023 · 0 comments · May be fixed by #796

Comments

@dramforever
Copy link

Currently cc builds for riscv*-unknown-none-elf targets with -mabi=lp64:

cc-rs/src/lib.rs

Lines 1973 to 1975 in 06c1289

} else if arch.starts_with("64") {
cmd.args.push(("-march=rv".to_owned() + arch).into());
cmd.args.push("-mabi=lp64".into());

However for riscv64gc-unknown-none-elf rustc produces lp64d binaries, which would fail to link with lp64 binaries. Adding .flag("-mabi=lp64d") works around this issue.

See this demo repo: https://github.com/dramforever/demo-cc-rs-riscv64gc

$ cargo build --target riscv64gc-unknown-none-elf
   Compiling demo-cc-rs-riscv64gc v0.1.0 (/home/dram/code/virtiotic/demo-cc-rs-riscv64gc)
error: linking with `rust-lld` failed: exit status: 1
  |
  = note: [omitted]
  = note: rust-lld: error: /home/dram/code/virtiotic/demo-cc-rs-riscv64gc/target/riscv64gc-unknown-none-elf/debug/build/demo-cc-rs-riscv64gc-add89ab8ebfbee8b/out/libanswer.a(answer.o): cannot link object files with different floating-point ABI
          

error: could not compile `demo-cc-rs-riscv64gc` due to previous error

Maybe we should copy the default ABI settings from rustc instead of using the current detection scheme. Unfortunately I couldn't find any docs on this.

dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 5, 2023
Currently all the riscv*gc targets use the 'd' double-float ABI, and
soft-float otherwise. There's no need to detect the operating system
type. Fixes rust-lang#795.
@dramforever dramforever linked a pull request Mar 5, 2023 that will close this issue
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Mar 19, 2023
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Jun 25, 2024
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Jun 25, 2024
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
dramforever added a commit to dramforever/cc-rs that referenced this issue Jun 26, 2024
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
tea pushed a commit to tea/cc-rs that referenced this issue Sep 29, 2024
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
tea pushed a commit to tea/cc-rs that referenced this issue Oct 6, 2024
Instead of adding cases for all the operating systems, Use target
architecture directly as ISA string, replacing "riscv" with "rv", and
detect floating point ABI based on support for the D and F extensions.

Fixes rust-lang#795
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