math: extend non-glibc guard to Clang and add exp10 guard#1400
Merged
mr-c merged 1 commit intosimd-everywhere:masterfrom Mar 30, 2026
Merged
Conversation
This was referenced Mar 30, 2026
The previous fix (simd-everywhere#1398) guarded __builtin_roundeven only for GCC 10+, assuming Clang always lowers it to an inline llvm.roundeven.* intrinsic. That assumption is wrong: Clang emits a roundeven()/roundevenf() libm call on targets without a native rounding instruction (x86 without SSE4.1, powerpc, sparc, i386, etc.). On non-glibc systems (musl, OpenBSD, FreeBSD, MinGW) the symbol is absent, causing: undefined reference to 'roundevenf' Fix: drop the GCC-only restriction and apply the glibc >= 2.25 guard to all compilers. Non-glibc platforms fall through to the existing portable inline fallback. Also guard __builtin_exp10 / __builtin_exp10f: exp10() is a GNU extension present only in glibc, so the builtin produces the same class of link error on musl and other non-glibc libcs. The fallback simde_math_pow(10.0, v) / simde_math_powf(10.0f, v) is already present and correct. Reported by brad0 in issue simd-everywhere#1396.
7a291da to
e6f8243
Compare
|
|
Thanks. I'll take this for a spin and test on the various archs OpenBSD / FreeBSD. |
|
Build tested and tests run on OpenBSD/ FreeBSD amd64 with GCC and Clang. Build tests and tests run on OpenBSD aarch64 with Clang. This also closes #1014 |
mr-c
approved these changes
Mar 30, 2026
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1398, addressing two remaining issues reported in #1396.
1. Clang on non-AArch64 targets
The previous fix guarded
__builtin_roundevenfor GCC 10+ only, basedon the assumption that Clang always lowers it to an inline
llvm.roundeven.*intrinsic. That is only true on AArch64 (FRINTN).On x86 without SSE4.1, powerpc, sparc, i386, and others, Clang emits
a
roundeven()/roundevenf()libm call — same failure mode as GCC.Fix: drop the compiler-specific check and apply the glibc >= 2.25 guard
to all compilers. Non-glibc platforms fall through to the existing
portable inline fallback.
2.
__builtin_exp10/__builtin_exp10fexp10()is a GNU extension present only in glibc. On musl and othernon-glibc libcs the symbol is absent, producing the same class of link
error. The existing fallback (
simde_math_pow(10.0, v)) is correct;it just needs to be activated on non-glibc platforms.
Closes #1396.