Skip to content

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

Open
@dramforever

Description

@dramforever

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions