Skip to content

fixes for RISC-V ABI Implementation #1567#2937

Merged
lerno merged 7 commits intoc3lang:masterfrom
ManuLinares:riscv_fixes
Feb 20, 2026
Merged

fixes for RISC-V ABI Implementation #1567#2937
lerno merged 7 commits intoc3lang:masterfrom
ManuLinares:riscv_fixes

Conversation

@ManuLinares
Copy link
Copy Markdown
Member

@ManuLinares ManuLinares commented Feb 14, 2026

Fixed RISC-V floating-point ABI by correcting the target triple to riscv64-unknown-linux-gnu, adding the target-abi module flag, and ensuring ABI-required CPU features are enabled.

I tested this with:

build/c3c compile-only --target linux-riscv64 rv_hello.c3
readelf -h obj/linux-riscv64/rv_hello.o | grep Flags
# Output: Flags: 0x5, RVC, double-float ABI
# and qemu because I don't have a riscv machine :/
qemu-riscv64-static -L /usr/riscv64-linux-gnu ./rv_hello

@lerno I purposedly left these two failing tests to clearly see the difference, so these will make CI fail. Please check this when you have the time.

test/test_suite/abi/riscv64-lp64-lp64f-abi-1.c3t
test/test_suite/abi/riscv64-lp64-abi.c3t

#1567
#2014 (this one refers to the stdlib, not the abi)

Fixed RISC-V floating-point ABI by correcting the target triple to
`riscv64-unknown-linux-gnu`, adding the `target-abi` module flag, and
ensuring ABI-required CPU features are enabled.

I tested this with:
```bash
build/c3c compile-only --target linux-riscv64 rv_hello.c3
readelf -h obj/linux-riscv64/rv_hello.o | grep Flags
# Output: Flags: 0x5, RVC, double-float ABI
```

```bash
# and qemu because I don't have a riscv machine :/
qemu-riscv64-static -L /usr/riscv64-linux-gnu ./rv_hello
```

---

@lerno I purposedly left these two failing tests to clearly see the
difference.

`test/test_suite/abi/riscv64-lp64-lp64f-abi-1.c3t`
`test/test_suite/abi/riscv64-lp64-abi.c3t`
@ManuLinares ManuLinares marked this pull request as draft February 14, 2026 19:50
- Implement automatic sysroot and CRT object discovery for RISC-V.
- Fix dynamic linker paths and emulation flags for LLD.
- Link against libgcc to resolve required arithmetic symbols.
@ManuLinares ManuLinares marked this pull request as ready for review February 14, 2026 20:57
@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Feb 17, 2026

There is something failing here?

@ManuLinares
Copy link
Copy Markdown
Member Author

There is something failing here?

I don't think so. There are two tests that needs the expected output corrected but I left those without change so you could take a look, as you are more familiar with LLVM IR

test/test_suite/abi/riscv64-lp64-lp64f-abi-1.c3t
test/test_suite/abi/riscv64-lp64-abi.c3t

@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Feb 19, 2026

We seem to have something else failing?

Comment thread src/compiler/linker.c
@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Feb 19, 2026

Alpine Linux to be specific

@ManuLinares
Copy link
Copy Markdown
Member Author

ManuLinares commented Feb 19, 2026

We seem to have something else failing?
Alpine Linux to be specific

Fixed now, my bad, forgot to commit a macro.

I moved target_host_arch() from hostinfo.c to target.c and set linker.c to use that instead.

@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Feb 19, 2026

Looks like the android builds are not passing now?

@ManuLinares
Copy link
Copy Markdown
Member Author

Looks like the android builds are not passing now?

nah, that's just termux servers intermittently not working

@lerno lerno merged commit 4b13ad6 into c3lang:master Feb 20, 2026
43 of 45 checks passed
@lerno
Copy link
Copy Markdown
Collaborator

lerno commented Feb 20, 2026

Thank you!

@ManuLinares ManuLinares deleted the riscv_fixes branch February 20, 2026 00:59
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 this pull request may close these issues.

2 participants