[PATCH 43/59] Build glibc with -ftrapping-math

H.J. Lu hjl.tools@gmail.com
Fri Oct 17 22:24:48 GMT 2025


On Sat, Oct 18, 2025 at 4:07 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> GCC enables it by default, clang in the other hand sets -fno-trapping-math.
> This is required to fix some math and stdlib tests that explicit raises
> floating point exceptions:
>
> math/test-double-canonicalize.out
> testing double (without inline functions)
> Failure: canonicalize (max_value): Exception "Overflow" set
> Failure: canonicalize (max_value): Exception "Inexact" set
> Failure: canonicalize (-max_value): Exception "Overflow" set
> Failure: canonicalize (-max_value): Exception "Inexact" set
> Failure: canonicalize_downward (max_value): Exception "Overflow" set
> Failure: canonicalize_downward (max_value): Exception "Inexact" set
> Failure: canonicalize_downward (-max_value): Exception "Overflow" set
> Failure: canonicalize_downward (-max_value): Exception "Inexact" set
> Failure: canonicalize_towardzero (max_value): Exception "Overflow" set
> Failure: canonicalize_towardzero (max_value): Exception "Inexact" set
> Failure: canonicalize_towardzero (-max_value): Exception "Overflow" set
> Failure: canonicalize_towardzero (-max_value): Exception "Inexact" set
> Failure: canonicalize_upward (max_value): Exception "Overflow" set
> Failure: canonicalize_upward (max_value): Exception "Inexact" set
> Failure: canonicalize_upward (-max_value): Exception "Overflow" set
> Failure: canonicalize_upward (-max_value): Exception "Inexact" set
>
> test-float-catanh.out
> testing float (without inline functions)
> Failure: Real part of: catanh (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_downward (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_towardzero (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (-0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0x1.000002p+0 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0x1.000002p+0 - 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0x1.000002p+0 + 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0x1.000002p+0 + 0x8p-152 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0xf.fffffp-4 - 0x4p-128 i): Exception "Underflow" set
> Failure: Real part of: catanh_upward (0xf.fffffp-4 + 0x4p-128 i): Exception "Underflow" set
> ---
>  Makeconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makeconfig b/Makeconfig
> index 9eda4fa528..eb44bbd113 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -916,6 +916,9 @@ endif
>  # disable any optimization that assume default rounding mode.
>  +math-flags = -frounding-math
>
> +# We have to assume that glibc functions might generate user-visible traps.
> ++math-flags += -ftrapping-math
> +
>  # Logically only "libnldbl", "nonlib" and "testsuite" should be using
>  # -fno-math-errno. However due to GCC bug #88576, only "libm" and
>  # "libmvec" can use -fno-math-errno.
> --
> 2.43.0
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.


More information about the Libc-alpha mailing list