From 23b2f96c9d043806a30df86258238ae001241057 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Fri, 24 May 2024 09:17:08 +0200 Subject: [PATCH] libm/libm: disable optimization for sincos Disable sincos optimization for all functions in this file, otherwise gcc would generate infinite calls. Refer to gcc bug 46926. -fno-builtin-sin or -fno-builtin-cos can disable sincos optimization, but these two options do not work inside optimize pragma in-file. Thus we just enforce -O0 when compiling this file. Signed-off-by: p-szafonimateusz --- libs/libm/libm/lib_sincos.c | 9 +++++++++ libs/libm/libm/lib_sincosf.c | 9 +++++++++ libs/libm/libm/lib_sincosl.c | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/libs/libm/libm/lib_sincos.c b/libs/libm/libm/lib_sincos.c index fd00547edd..a3c3fc82ae 100644 --- a/libs/libm/libm/lib_sincos.c +++ b/libs/libm/libm/lib_sincos.c @@ -27,12 +27,21 @@ #include +/* Disable sincos optimization for all functions in this file, + * otherwise gcc would generate infinite calls. + * Refer to gcc PR46926. + * -fno-builtin-sin or -fno-builtin-cos can disable sincos optimization, + * but these two options do not work inside optimize pragma in-file. + * Thus we just enforce -O0 when compiling this file. + */ + /**************************************************************************** * Public Functions ****************************************************************************/ #ifdef CONFIG_HAVE_DOUBLE +nooptimiziation_function void sincos(double x, double *s, double *c) { *s = sin(x); diff --git a/libs/libm/libm/lib_sincosf.c b/libs/libm/libm/lib_sincosf.c index 311c36f6fb..064cb0e757 100644 --- a/libs/libm/libm/lib_sincosf.c +++ b/libs/libm/libm/lib_sincosf.c @@ -27,10 +27,19 @@ #include +/* Disable sincos optimization for all functions in this file, + * otherwise gcc would generate infinite calls. + * Refer to gcc PR46926. + * -fno-builtin-sin or -fno-builtin-cos can disable sincos optimization, + * but these two options do not work inside optimize pragma in-file. + * Thus we just enforce -O0 when compiling this file. + */ + /**************************************************************************** * Public Functions ****************************************************************************/ +nooptimiziation_function void sincosf(float x, float *s, float *c) { *s = sinf(x); diff --git a/libs/libm/libm/lib_sincosl.c b/libs/libm/libm/lib_sincosl.c index 864e1fd67b..1512765c70 100644 --- a/libs/libm/libm/lib_sincosl.c +++ b/libs/libm/libm/lib_sincosl.c @@ -27,12 +27,21 @@ #include +/* Disable sincos optimization for all functions in this file, + * otherwise gcc would generate infinite calls. + * Refer to gcc PR46926. + * -fno-builtin-sin or -fno-builtin-cos can disable sincos optimization, + * but these two options do not work inside optimize pragma in-file. + * Thus we just enforce -O0 when compiling this file. + */ + /**************************************************************************** * Public Functions ****************************************************************************/ #ifdef CONFIG_HAVE_LONG_DOUBLE +nooptimiziation_function void sincosl(long double x, long double *s, long double *c) { *s = sinl(x);