riscv icon indicating copy to clipboard operation
riscv copied to clipboard

`riscv-rt`: ABI incompatibility

Open rslawson opened this issue 1 year ago • 1 comments

I'm working on a project right now that's using a RISCV-32 core with the I, M, F, and C extensions. I know it wouldn't be too difficult to define a custom target for this, but project CI stuff would make actually doing that very difficult (I don't understand Nix). As such, I'm using riscv32imc with --target-features=+f. However, this causes something of an issue - this target uses the ilp32 ABI, but riscv-rt sees the riscvf cfg flag and thus puts some FP instructions into global assembly, which requires ilp32f (as far as I can tell?). Thus I get 33 errors of things like

error: instruction requires the following: 'F' (Single-Precision Floating-Point)
   |
note: instantiated into assembly here
  --> <inline asm>:99:1
   |
99 | fscsr x0
   | ^

error: instruction requires the following: 'F' (Single-Precision Floating-Point)
    |
note: instantiated into assembly here
   --> <inline asm>:100:5
    |
100 |     fmv.w.x f0, x0
    |     ^

So then the question is: should I just bite the bullet and figure out Nix well enough to get it happy enough to accept a custom riscv32imfc-uknown-none-elf.json, or would it be acceptable for me to add a no-float-init = [] feature to the crate that would mask out those global_asm! invocations?

rslawson avatar Dec 11 '24 10:12 rslawson

Ah, sorry, looks like this can actually be fixed by adjusting the provisional patch at asm.rs line 22. I'll PR this soon.

rslawson avatar Dec 11 '24 13:12 rslawson

Hi @rslawson ! Any news on this?

romancardenas avatar Jun 19 '25 07:06 romancardenas

Not since last working on this sometime last year, no. At least I haven't had any issues with it since then, so I think I can close it for now. I can always reopen this later if the same issue comes up again later.

rslawson avatar Jun 19 '25 08:06 rslawson