Commit 6b772fe
math: restrict __builtin_roundeven to glibc >= 2.25 on GCC 10+
roundeven() / roundevenf() are C23 functions added to glibc 2.25 (2017).
On GCC 10+, HEDLEY_HAS_BUILTIN(__builtin_roundeven) returns true (both
__has_builtin and __builtin_roundeven were introduced in GCC 10), so the
builtin path is taken. GCC lowers this to a roundeven() libm call when
the target has no native instruction (ROUNDSD/FRINTN). On non-glibc
platforms (musl, OpenBSD, MinGW, etc.) this symbol is absent, causing a
link error:
undefined reference to 'roundevenf'
Note: the previous HEDLEY_GCC_VERSION_CHECK(10,0,0) branch in the ||
condition was dead code — on GCC 10+ HEDLEY_HAS_BUILTIN already fires.
Fix: guard the HEDLEY_HAS_BUILTIN path so GCC 10+ only uses the builtin
when glibc >= 2.25 is confirmed. Non-glibc platforms and older glibc fall
through to the portable inline fallback (roundf + fabsf), which requires
no libm symbols beyond what every C platform provides.
Clang is unaffected: it lowers __builtin_roundeven to llvm.roundeven.*
intrinsics which are always emitted inline (no libm dependency), so the
GCC guard does not apply there.
Both simde_math_roundeven (double) and simde_math_roundevenf (float) are
fixed identically.
Fixes link failure observed on OpenBSD/GCC building VVenC with bundled
SIMDE: fraunhoferhhi/vvenc#6801 parent 856df51 commit 6b772fe
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1266 | 1266 | | |
1267 | 1267 | | |
1268 | 1268 | | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
1269 | 1275 | | |
1270 | | - | |
1271 | | - | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
1272 | 1280 | | |
1273 | 1281 | | |
1274 | 1282 | | |
| |||
1286 | 1294 | | |
1287 | 1295 | | |
1288 | 1296 | | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1289 | 1300 | | |
1290 | | - | |
1291 | | - | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
1292 | 1305 | | |
1293 | 1306 | | |
1294 | 1307 | | |
| |||
0 commit comments