[PATCH v2 6/6] math: Disable exception check for soft-fp routine with compiler-rt

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Mar 13 16:54:52 GMT 2026



On 13/03/26 13:46, H.J. Lu wrote:
> On Fri, Mar 13, 2026 at 7:21 AM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>
>>
>>
>> On 25/02/26 22:03, H.J. Lu wrote:
>>> On Thu, Feb 26, 2026 at 2:32 AM Adhemerval Zanella
>>> <adhemerval.zanella@linaro.org> wrote:
>>>>
>>>> The compiler-rt does not support throwing floating-point exceptions
>>>> for math builtin (__addtf3, __multf3, __divtf3, etc.) [1][2][3].
>>>> So disable the check when compiler-rt is used instead of libgcc.
>>>
>>> I think we check capability instead of HAVE_COMPILER_RT_RUNTIME.
>>
>> I think we can not easily check capability for a runtime only behavior,
>> there is no indication in compiler pre-defined flags or similar to
>> indicate this behavior.
> 
> Since this issue is specific to soft-fp exception, I think we should add
> a macro for soft-fp exception capability and xfail these tests when
> compiler-rt is used.

The macro HAVE_COMPILER_RT_RUNTIME already specify this, and the xfail
is not simple because the math tests check not only floating-point
exception but also errno and precision.  

So xfail them solely on EXCEPTION_TESTS_* will hide a lot of potential 
unrelated issues, we will need to a *quite* large refactor of math tests 
to split the tests in multiple ones, which also has some other implications 
(more build and check time).

> 
>> Even compiler-rt documentation is not explicit clear about floating
>> point exceptions for soft-fp implementations.
>>
>>
>>>
>>>> Checked on x86_64-linux-gnu and aarch64-linux-gnu with clang.
>>>>
>>>> [1] https://github.com/llvm/llvm-project/issues/59924
>>>> [2] https://github.com/llvm/llvm-project/issues/60141
>>>> [3] https://github.com/llvm/llvm-project/issues/172499
>>>> ---
>>>>  config.h.in                             |  3 +++
>>>>  configure                               |  4 +++
>>>>  configure.ac                            |  3 +++
>>>>  sysdeps/aarch64/math-tests-exceptions.h | 34 +++++++++++++++++++++++++
>>>>  sysdeps/x86_64/math-tests-exceptions.h  | 33 ++++++++++++++++++++++++
>>>>  5 files changed, 77 insertions(+)
>>>>  create mode 100644 sysdeps/aarch64/math-tests-exceptions.h
>>>>  create mode 100644 sysdeps/x86_64/math-tests-exceptions.h
>>>>
>>>> diff --git a/config.h.in b/config.h.in
>>>> index 125532ec6b..215b223e12 100644
>>>> --- a/config.h.in
>>>> +++ b/config.h.in
>>>> @@ -231,6 +231,9 @@
>>>>  /* Define to 1 if compiler runtime provides __sfp_handle_exceptions */
>>>>  #undef HAVE_SFP_HANDLE_EXCEPTIONS
>>>>
>>>> +/* Define to 1 if compiler uses compiler-rt instead of libgcc.  */
>>>> +#undef HAVE_COMPILER_RT_RUNTIME
>>>> +
>>>>  /*
>>>>   */
>>>>
>>>> diff --git a/configure b/configure
>>>> index d156912063..4ccf5600d7 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -9398,6 +9398,10 @@ esac
>>>>  fi
>>>>  { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_runtime_library" >&5
>>>>  printf "%s\n" "$libc_cv_runtime_library" >&6; }
>>>> +if test $libc_cv_runtime_library = compiler-rt; then
>>>> +  printf "%s\n" "#define HAVE_COMPILER_RT_RUNTIME 1" >>confdefs.h
>>>> +
>>>> +fi
>>>>  config_vars="$config_vars
>>>>  libgcc-name = $libc_cv_libgcc"
>>>>  config_vars="$config_vars
>>>> diff --git a/configure.ac b/configure.ac
>>>> index 776695486a..9ced9ec0f5 100644
>>>> --- a/configure.ac
>>>> +++ b/configure.ac
>>>> @@ -2152,6 +2152,9 @@ AC_CACHE_CHECK([for the usable compiler runtime library], [libc_cv_runtime_libra
>>>>        ;;
>>>>      *) AC_MSG_FAILURE([non supported compiler runtime library]) ;;
>>>>    esac])
>>>> +if test $libc_cv_runtime_library = compiler-rt; then
>>>> +  AC_DEFINE([HAVE_COMPILER_RT_RUNTIME])
>>>> +fi
>>>>  LIBC_CONFIG_VAR([libgcc-name], [$libc_cv_libgcc])
>>>>  LIBC_CONFIG_VAR([libgcc_eh-name], [$libc_cv_libgcc_eh])
>>>>
>>>> diff --git a/sysdeps/aarch64/math-tests-exceptions.h b/sysdeps/aarch64/math-tests-exceptions.h
>>>> new file mode 100644
>>>> index 0000000000..dc824c25a5
>>>> --- /dev/null
>>>> +++ b/sysdeps/aarch64/math-tests-exceptions.h
>>>> @@ -0,0 +1,34 @@
>>>> +/* Configuration for math tests: support for exceptions.  AArch64 version.
>>>> +   Copyright (C) 2026 Free Software Foundation, Inc.
>>>> +   This file is part of the GNU C Library.
>>>> +
>>>> +   The GNU C Library is free software; you can redistribute it and/or
>>>> +   modify it under the terms of the GNU Lesser General Public
>>>> +   License as published by the Free Software Foundation; either
>>>> +   version 2.1 of the License, or (at your option) any later version.
>>>> +
>>>> +   The GNU C Library is distributed in the hope that it will be useful,
>>>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>>> +   Lesser General Public License for more details.
>>>> +
>>>> +   You should have received a copy of the GNU Lesser General Public
>>>> +   License along with the GNU C Library; if not, see
>>>> +   <https://www.gnu.org/licenses/>.  */
>>>> +
>>>> +#ifndef _MATH_TESTS_EXCEPTIONS_H
>>>> +#define _MATH_TESTS_EXCEPTIONS_H 1
>>>> +
>>>> +#define EXCEPTION_TESTS_float  1
>>>> +#define EXCEPTION_TESTS_double 1
>>>> +/* compiler-rt does not support floating-point exceptions for the
>>>> +   long double / __float128 math builtins.  */
>>>> +#ifdef HAVE_COMPILER_RT_RUNTIME
>>>> +# define EXCEPTION_TESTS_long_double   0
>>>> +# define EXCEPTION_TESTS_float128      0
>>>> +#else
>>>> +# define EXCEPTION_TESTS_long_double   1
>>>> +# define EXCEPTION_TESTS_float128      1
>>>> +#endif
>>>> +
>>>> +#endif /* math-tests-exceptions.h.  */
>>>> diff --git a/sysdeps/x86_64/math-tests-exceptions.h b/sysdeps/x86_64/math-tests-exceptions.h
>>>> new file mode 100644
>>>> index 0000000000..fa60397b79
>>>> --- /dev/null
>>>> +++ b/sysdeps/x86_64/math-tests-exceptions.h
>>>> @@ -0,0 +1,33 @@
>>>> +/* Configuration for math tests: support for exceptions.  x86_64 version.
>>>> +   Copyright (C) 2026 Free Software Foundation, Inc.
>>>> +   This file is part of the GNU C Library.
>>>> +
>>>> +   The GNU C Library is free software; you can redistribute it and/or
>>>> +   modify it under the terms of the GNU Lesser General Public
>>>> +   License as published by the Free Software Foundation; either
>>>> +   version 2.1 of the License, or (at your option) any later version.
>>>> +
>>>> +   The GNU C Library is distributed in the hope that it will be useful,
>>>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>>>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>>> +   Lesser General Public License for more details.
>>>> +
>>>> +   You should have received a copy of the GNU Lesser General Public
>>>> +   License along with the GNU C Library; if not, see
>>>> +   <https://www.gnu.org/licenses/>.  */
>>>> +
>>>> +#ifndef _MATH_TESTS_EXCEPTIONS_H
>>>> +#define _MATH_TESTS_EXCEPTIONS_H 1
>>>> +
>>>> +#define EXCEPTION_TESTS_float  1
>>>> +#define EXCEPTION_TESTS_double 1
>>>> +#define EXCEPTION_TESTS_long_double    1
>>>> +/* compiler-rt does not support floating-point exceptions for the
>>>> +   _float128 math builtins.  */
>>>> +#ifdef HAVE_COMPILER_RT_RUNTIME
>>>> +# define EXCEPTION_TESTS_float128      0
>>>> +#else
>>>> +# define EXCEPTION_TESTS_float128      1
>>>> +#endif
>>>> +
>>>> +#endif /* math-tests-exceptions.h.  */
>>>> --
>>>> 2.43.0
>>>>
>>>
>>>
>>
> 
> 



More information about the Libc-alpha mailing list