[libc-commits] [libc] [libc][math] Avoid system fenv.h in FEnvImpl.h when LIBC_MATH_HAS_NO_EXCEPT is set (PR #224384)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 17 12:04:22 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Marcos Ramirez Joos (maarcosrmz)
<details>
<summary>Changes</summary>
The warning being added under #<!-- -->199009 triggers errors in subprojects (e.g., flang) using libc headers that gate the use of `#pragma STDC FENV_ACCESS ON` on the internal libc `LIBC_COMPILER_HAS_STDC_FENV_ACCESS` flag, when building under `-Wfenv-access -Werror`. As the idea is for these subprojects to not access the libc FP environment (see https://github.com/llvm/llvm-project/pull/199009#issuecomment-5299119396), gating the use of system fenv.h functions on the `LIBC_MATH_HAS_NO_EXCEPT` flag avoids having to specify the `LIBC_COMPILER_HAS_STDC_FENV_ACCESS` flag when building them.
---
Full diff: https://github.com/llvm/llvm-project/pull/224384.diff
1 Files Affected:
- (modified) libc/src/__support/FPUtil/FEnvImpl.h (+1-4)
``````````diff
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 46572260cbc9e0..b188511d1f6bf8 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -31,7 +31,7 @@
#undef LIBC_MATH_USE_SYSTEM_FENV
#endif // LIBC_FULL_BUILD
-#if defined(LIBC_MATH_USE_SYSTEM_FENV)
+#if defined(LIBC_MATH_USE_SYSTEM_FENV) && !defined(LIBC_MATH_HAS_NO_EXCEPT)
// Simply call the system libc fenv.h functions, only for those that are used in
// math function implementations.
@@ -164,7 +164,6 @@ clear_except_if_required([[maybe_unused]] int excepts) {
return 0;
} else {
#ifndef LIBC_MATH_HAS_NO_EXCEPT
- LIBC_FENV_ACCESS_ON
if (math_errhandling & MATH_ERREXCEPT)
return clear_except(excepts);
#endif // LIBC_MATH_HAS_NO_EXCEPT
@@ -178,7 +177,6 @@ set_except_if_required([[maybe_unused]] int excepts) {
return 0;
} else {
#ifndef LIBC_MATH_HAS_NO_EXCEPT
- LIBC_FENV_ACCESS_ON
if (math_errhandling & MATH_ERREXCEPT)
return set_except(excepts);
#endif // LIBC_MATH_HAS_NO_EXCEPT
@@ -192,7 +190,6 @@ raise_except_if_required([[maybe_unused]] int excepts) {
return 0;
} else {
#ifndef LIBC_MATH_HAS_NO_EXCEPT
- LIBC_FENV_ACCESS_ON
if (math_errhandling & MATH_ERREXCEPT)
return raise_except(excepts);
#endif // LIBC_MATH_HAS_NO_EXCEPT
``````````
</details>
https://github.com/llvm/llvm-project/pull/224384
More information about the libc-commits
mailing list