-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
RISC-V64: command line argument --riscvfloat does not work #1567
Comments
From what I read, setting it to double should indeed set compiler.platform.riscv.flen = 8, perhaps there is some additional flag that has to be packed into the LLVM IR for this. Could you perhaps dump the LLVM IR for a proper C compilation of a particular function that fails with C3? |
This is a flag in the ELF header: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#e-flags-layout LLVM IR: int main(void) { return 0; }
C3:
|
Well, I guess there should be the ABI setup : https://github.com/c3lang/c3c/blob/master/src/compiler/target.c#L2016 |
And just to make that clear: the compiler does not generate working binaries at_all on a RISC-V CPU which supports either 32 or 64 bit floats. |
From what I can see, these are the possible ABI types:
The f/d variants are clear, but what is e, and what is the difference between i and non-i? |
If I've read that correctly,
Oh, I've found that regarding the Btw. you really want to make
|
Ok, so hang on, let's see if we can break this down:
Should riscvfloat be changed to abi? And we have default/float/double/embedded? |
(We don't have a CI for Riscv, so everything is a bit experimental BTW, it would be great to have something, all we have is a baremetal riscv test) |
To be honest, I do not know why GCC and LLVM do it that way (with the ABI string). As you have to somehow set the ISA extensions anyway, other ABIs either are not possible at all or make no sense. The list of extensions: https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154732/Ratified+Extensions The (current) official documents: https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-ae98787-2024-10-19 And additionally the overview of all standard extensions (single letter extensions): https://en.wikichip.org/wiki/risc-v/standard_extensions - although there is e.g. |
So what would you propose? |
To keep the command line minimal (like for x86_64) and not add every single RISC-V ISA extensions, I'd say: Ditch the float ABI command line argument and use the float ABI suitable for the selected ISA:
I don't know too much about 32 bit RISC-V, I'd start with
On RISC-V64, make RV64GC the default for now1 and maybe in the near future (some years) switch to RVA23U64 as the default, when it is widely supported by CPUs. Add command line arguments to set RV64GCV and RVA23U64 (this is RV64GCV with additional extensions, see2). As for RISC-V32, I'd guess make RVI32 the default. Footnotes
|
The files generated by
./c3c --target linux-riscv64 --riscvfloat=double compile
use thesoft-float
ABI instead of thedouble-float
ABI on RISC-V64. This leads to the following errors:An object file generated by the above compiler invocation:
but should be:
The text was updated successfully, but these errors were encountered: