Skip to content

riscv: allow single-precision float ABI (lp64f / ilp32f)#349

Merged
ViralBShah merged 2 commits into
JuliaMath:masterfrom
ViralBShah:fix-262-riscv-lp64f
Jun 23, 2026
Merged

riscv: allow single-precision float ABI (lp64f / ilp32f)#349
ViralBShah merged 2 commits into
JuliaMath:masterfrom
ViralBShah:fix-262-riscv-lp64f

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

Summary

Fixes #262. The RISC-V fenv header rejected __riscv_float_abi_single (lp64f, ilp32f) with an `#error`, but the rejection isn't warranted: the F and D extensions share the same `fcsr` / `fflags` CSRs. The hard-float inline implementations below the guard use only `csrr`/`csrw`/`csrc` on those CSRs, all of which are present whenever F is present.

So lp64f / ilp32f can use the existing hard-float code path unchanged.

```diff
-#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)
-#if defined(__riscv_float_abi_single)
-#error single precision floating point ABI not supported
-#else
+#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double) && \

  • !defined(__riscv_float_abi_single)
    #error compiler did not set soft/hard float macros
    #endif
    -#endif
    ```

Test plan

  • CI green (no behavior change for existing double ABI users; lp64f users no longer hit the `#error`).
  • If a future native riscv lp64f CI matrix entry lands, openlibm-test should pass there too.

🤖 Generated with Claude Code

ViralBShah and others added 2 commits June 22, 2026 23:32
The header rejected __riscv_float_abi_single with an #error, but
the F and D extensions share the same FCSR. The hard-float inline
implementations below the guard use only csrr/csrw/csrc on fcsr
and fflags, both of which are present whenever F is present. So
lp64f / ilp32f can use the same code path as the double ABI.

Closes JuliaMath#262.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The lp64f / ilp32f ABI used to be rejected by openlibm_fenv_riscv.h with
an #error. Add a compile-only cross job that rebuilds the static library
with -mabi=lp64f so the removed #error stays removed. A full lp64f
shared-lib link or qemu run is impossible because Ubuntu's
gcc-riscv64-linux-gnu ships only the lp64d sysroot; the static archive
needs no libc link, so it still compiles riscv64/fenv.c (and every other
source) under the single-float ABI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ViralBShah
ViralBShah force-pushed the fix-262-riscv-lp64f branch from 4ed0692 to ef48409 Compare June 22, 2026 23:33
@ViralBShah
ViralBShah merged commit 2ce6c05 into JuliaMath:master Jun 23, 2026
23 checks passed
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.

RISCV single precision ABI is not supported

1 participant