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

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
maleadt added a commit to JuliaLang/julia that referenced this pull request Sep 3, 2026
Picks up JuliaMath/openlibm#360, which stops the riscv64 port from
exporting its fenv functions. Those symbols shadowed glibc's through the
dynamic linker while carrying FreeBSD's pre-shifted `FE_*` encodings, so
`fesetround` rejected every constant a caller had compiled against the
system header and left the rounding mode untouched. Julia's own rounding
path stopped going through that symbol in `6081d7ceb7`, but anything
else linked against the bundled library still did.

The release also carries three riscv64 fixes that never reached the
0.8.7 build: JuliaMath/openlibm#324 (`feholdexcept` always returned -1),
and JuliaMath/openlibm#330 and JuliaMath/openlibm#349 for the lp64f ABI.

Assisted-by: Claude Code (Opus 5)
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
openlibm 0.8.8

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* Update riscv64 fenv.c initialization to fix warnings by @ViralBShah in JuliaMath/openlibm#330
* Musl compatibility fixes for s390 and powerpc by @sertonix in JuliaMath/openlibm#331
* Fix cmake error for 4.x by @HIllya51 in JuliaMath/openlibm#333
* Bump actions/checkout from 4 to 5 by @dependabot[bot] in JuliaMath/openlibm#335
* Bump actions/upload-artifact from 4 to 5 by @dependabot[bot] in JuliaMath/openlibm#336
* Bump actions/checkout from 5 to 6 by @dependabot[bot] in JuliaMath/openlibm#338
* Bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in JuliaMath/openlibm#339
* Bump actions/upload-artifact from 6 to 7 by @dependabot[bot] in JuliaMath/openlibm#341
* Bump codecov/codecov-action from 5 to 6 by @dependabot[bot] in JuliaMath/openlibm#342
* ci: add native ARM (Linux + Windows) and Intel macOS runners by @ViralBShah in JuliaMath/openlibm#345
* ci: workflow hygiene (concurrency, timeouts, loongarch fold, mips64, fork-safe codecov) by @ViralBShah in JuliaMath/openlibm#346
* riscv: Fix feholdexcept() by @AlekseyZhmulin in JuliaMath/openlibm#324
* CI: add -Werror strict lane and an auto-discovered regression-test harness by @ViralBShah in JuliaMath/openlibm#350
* ci: speed up Windows jobs by trimming the msys2 install by @ViralBShah in JuliaMath/openlibm#354
* ci: make codecov coverage status informational by @ViralBShah in JuliaMath/openlibm#358
* riscv: allow single-precision float ABI (lp64f / ilp32f) by @ViralBShah in JuliaMath/openlibm#349
* Fix powl() returning NaN instead of +0 on extreme underflow (#334) by @ViralBShah in JuliaMath/openlibm#351
* Make powl() thread-safe (#222) by @ViralBShah in JuliaMath/openlibm#355
* Bump codecov/codecov-action from 6 to 7 by @dependabot[bot] in JuliaMath/openlibm#359
* riscv64: Keep hard-float fenv functions private by @maleadt in JuliaMath/openlibm#360

## New Contributors
* @sertonix made their first contribution in JuliaMath/openlibm#331
* @HIllya51 made their first contribution in JuliaMath/openlibm#333
* @AlekseyZhmulin made their first contribution in JuliaMath/openlibm#324

**Full Changelog**: https://github.com/JuliaMath/openlibm/compare/v0.8.7...v0.8.8</pre>
  <p>View the full release notes at <a href="https://github.com/JuliaMath/openlibm/releases/tag/v0.8.8">https://github.com/JuliaMath/openlibm/releases/tag/v0.8.8</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!18388
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