]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Fix x86_64 build failure with -Os (BZ 33367)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 23 Dec 2025 17:30:45 +0000 (14:30 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 12 Jan 2026 13:34:40 +0000 (10:34 -0300)
The 13cfd77bf5 change broke the b5d88fa6c3 fix by removing the symbol
to __symbol redirections.  Although it works for -O2 with both gcc
and clang, with -Os without the redirection, the libcall might still
be issued.

This patch reinstates the b5d88fa6c3 fix, with a modification that
allows each ifunc variant to control which trunc to issue.  This is
required for clang, which defines HAVE_X86_INLINE_TRUNC to 1 (meaning
that trunc will always be lowered to the instruction on -Os).

Checked on x86_64-linux-gnu with -O2 and -Os with gcc-15 and clang-18.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
sysdeps/ieee754/dbl-64/s_modf.c
sysdeps/ieee754/flt-32/s_modff.c
sysdeps/x86_64/fpu/multiarch/s_modf-avx.c
sysdeps/x86_64/fpu/multiarch/s_modf-sse4_1.c
sysdeps/x86_64/fpu/multiarch/s_modff-avx.c
sysdeps/x86_64/fpu/multiarch/s_modff-sse4_1.c

index 7c7e2de6b2d72fbe739566f127591566ce2bbb20..90205670855c527cb36b237626f34d00488e2b85 100644 (file)
@@ -25,12 +25,15 @@ __modf (double x, double *iptr)
 {
   uint64_t t = asuint64 (x);
 #if USE_TRUNC_BUILTIN
+# ifndef TRUNC
+#  define TRUNC trunc
+# endif
   if (is_inf (t))
     {
       *iptr = x;
       return copysign (0.0, x);
     }
-  *iptr = trunc (x);
+  *iptr = TRUNC (x);
   return copysign (x - *iptr, x);
 #else
   int e = get_exponent (t);
index 2addebc425aac1c42db642fb56793ec95589acef..cc42098045accea9a15874b16867eb05bf6d8e47 100644 (file)
@@ -25,12 +25,15 @@ __modff (float x, float *iptr)
 {
   uint32_t t = asuint (x);
 #if USE_TRUNCF_BUILTIN
+# ifndef TRUNCF
+#  define TRUNCF truncf
+# endif
   if (is_inf (t))
     {
       *iptr = x;
       return copysignf (0.0, x);
     }
-  *iptr = truncf (x);
+  *iptr = TRUNCF (x);
   return copysignf (x - *iptr, x);
 #else
   int e = get_exponent (t);
index 9b8b951a97cb41b3dd39c4cf0d7723d9f4034e50..76e7896277727510f8b606cd74719506eb254f19 100644 (file)
@@ -1,2 +1,3 @@
 #define __modf __modf_avx
+#define TRUNC __trunc
 #include <sysdeps/ieee754/dbl-64/s_modf.c>
index 1f773863364045e48d6c256a0f3c81a5c1665fd8..49fa4f0b97136466d3ad88dffb28ac03950473d7 100644 (file)
@@ -1,2 +1,3 @@
 #define __modf __modf_sse41
+#define TRUNC __trunc
 #include <sysdeps/ieee754/dbl-64/s_modf.c>
index 488f93700c0af22dc04c9d89d1546a8461e19282..3b00c364b1af226c41ef2b5886a33fe8b4892d79 100644 (file)
@@ -1,2 +1,3 @@
 #define __modff __modff_avx
+#define TRUNCF __truncf
 #include <sysdeps/ieee754/flt-32/s_modff.c>
index 8e49970ffc7a25218aff44f2ac982eab9c618599..58d46582bdfc5c1f56c103558989b167ad9253aa 100644 (file)
@@ -1,2 +1,3 @@
 #define __modff __modff_sse41
+#define TRUNCF __truncf
 #include <sysdeps/ieee754/flt-32/s_modff.c>