diff mbox series

[v2,04/10] powerpc64le: Enforce -mabi=ibmlongdouble when -mfloat128 used

Message ID 20200327211801.31234-5-murphyp@linux.vnet.ibm.com
State Committed
Delegated to: Tulio Magno Quites Machado Filho
Headers show
Series IEEE binary128 long double on powerpc64le | expand

Commit Message

Paul E. Murphy March 27, 2020, 9:17 p.m. UTC
I have observed a bug on 7.4.0 whereby __mulkc3 calls are
swapped with __multc3 depending on ABI selection.  For the
sake of being overly cautious, build all _Float128 files
with ibm128 to workaround these compilers.  This has been
noted in GCC BZ 84914, and will not be fixed for GCC 7.

Likewise, non-math files built with _Float128 are assumed
to have ibm long double.  Explicilty preserve this
assumption.

Finally, add some bootstrapping code to avoid applying
these options until IEEE long double is enabled as they
require GCC 7 and above.
---
 sysdeps/powerpc/powerpc64/le/Makefile         | 88 +++++++++++--------
 .../powerpc64/le/fpu/multiarch/Makefile       |  4 +-
 2 files changed, 51 insertions(+), 41 deletions(-)

Comments

Tulio Magno Quites Machado Filho April 3, 2020, 7:29 p.m. UTC | #1
"Paul E. Murphy via Libc-alpha" <libc-alpha@sourceware.org> writes:

> I have observed a bug on 7.4.0 whereby __mulkc3 calls are
> swapped with __multc3 depending on ABI selection.  For the
> sake of being overly cautious, build all _Float128 files
> with ibm128 to workaround these compilers.  This has been
> noted in GCC BZ 84914, and will not be fixed for GCC 7.
>
> Likewise, non-math files built with _Float128 are assumed
> to have ibm long double.  Explicilty preserve this
> assumption.
>
> Finally, add some bootstrapping code to avoid applying
> these options until IEEE long double is enabled as they
> require GCC 7 and above.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Paul E Murphy April 6, 2020, 4:49 p.m. UTC | #2
Pushed with patch 5, 8 and all requested changes.  Thanks!

On 4/3/20 2:29 PM, Tulio Magno Quites Machado Filho wrote:
> "Paul E. Murphy via Libc-alpha" <libc-alpha@sourceware.org> writes:
> 
>> I have observed a bug on 7.4.0 whereby __mulkc3 calls are
>> swapped with __multc3 depending on ABI selection.  For the
>> sake of being overly cautious, build all _Float128 files
>> with ibm128 to workaround these compilers.  This has been
>> noted in GCC BZ 84914, and will not be fixed for GCC 7.
>>
>> Likewise, non-math files built with _Float128 are assumed
>> to have ibm long double.  Explicilty preserve this
>> assumption.
>>
>> Finally, add some bootstrapping code to avoid applying
>> these options until IEEE long double is enabled as they
>> require GCC 7 and above.
> 
> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>
diff mbox series

Patch

diff --git a/sysdeps/powerpc/powerpc64/le/Makefile b/sysdeps/powerpc/powerpc64/le/Makefile
index d79ad222fc..441a8a14e5 100644
--- a/sysdeps/powerpc/powerpc64/le/Makefile
+++ b/sysdeps/powerpc/powerpc64/le/Makefile
@@ -1,5 +1,6 @@ 
 # When building float128 we need to ensure -mfloat128 is
 # passed to all such object files.
+type-float128-CFLAGS := -mfloat128
 
 # Bootstrapping code for enabling IEEE 128.  This can be removed and
 # any indirections simplified once IEEE 128 long double is enabled.
@@ -11,28 +12,33 @@  type-ldouble-CFLAGS += $(ibm128-abi-CFLAGS)
 no-gnu-attribute-CFLAGS = -mno-gnu-attribute
 endif
 
+# All _Float128 files should be built assuming an ibm128 long double.
+# Likewise, this avoids some old GCC 7 compiler bugs whereby calls
+# to __mulkc3 are swapped with __multc3, or worse.  This is noted in
+# GCC BZ 84914, and marked as will-not-fix.
+type-float128-CFLAGS += $(type-ldouble-CFLAGS)
+
 ifeq ($(subdir),math)
 # sqrtf128 requires emulation before POWER9.
 CPPFLAGS += -I../soft-fp
 
 # float128 requires adding a handful of extra flags.
 # Similarly, disable
-$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128
-$(foreach suf,$(all-object-suffixes),$(objpfx)test-float64x%$(suf)): CFLAGS += -mfloat128
+$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += $(type-float128-CFLAGS)
+$(foreach suf,$(all-object-suffixes),$(objpfx)test-float64x%$(suf)): CFLAGS += $(type-float128-CFLAGS)
 # Pairs of types with _Float128 / _Float64x as the wider type but not
 # the narrower one.
 f128-pairs = float32-float64x float32-float128 float64-float64x \
 	     float64-float128 float32x-float64x float32x-float128
-$(foreach suf,$(all-object-suffixes),$(foreach pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf))): CFLAGS += -mfloat128
-
-CFLAGS-libm-test-support-float128.c += -mfloat128
-CFLAGS-libm-test-support-float64x.c += -mfloat128
-CFLAGS-test-math-iscanonical.cc += -mfloat128
-CFLAGS-test-math-iseqsig.cc += -mfloat128
-CFLAGS-test-math-issignaling.cc += -mfloat128
-CFLAGS-test-math-iszero.cc += -mfloat128
+$(foreach suf,$(all-object-suffixes),$(foreach pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf))): CFLAGS += $(type-float128-CFLAGS)
+CFLAGS-libm-test-support-float128.c += $(type-float128-CFLAGS)
+CFLAGS-libm-test-support-float64x.c += $(type-float128-CFLAGS)
+CFLAGS-test-math-iscanonical.cc += $(type-float128-CFLAGS)
+CFLAGS-test-math-iseqsig.cc += $(type-float128-CFLAGS)
+CFLAGS-test-math-issignaling.cc += $(type-float128-CFLAGS)
+CFLAGS-test-math-iszero.cc += $(type-float128-CFLAGS)
 
 CFLAGS-s_logbl-power7.c += $(type-ldouble-CFLAGS)
 CFLAGS-s_logbl-ppc64.c += $(type-ldouble-CFLAGS)
@@ -71,45 +77,49 @@  $(foreach suf,$(all-object-suffixes),\
          ): sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble,$(sysdep-CFLAGS))
 endif
 
+
 # Append flags to string <-> _Float128 routines.
 ifneq ($(filter $(subdir),wcsmbs stdlib),)
-$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),%f128_l$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),%f128_nan$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),%float1282mpn$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-$(foreach suf,$(all-object-suffixes),%mpn2float128$(suf)): CFLAGS += -mfloat128 $(no-gnu-attribute-CFLAGS)
-CFLAGS-bug-strtod.c += -mfloat128
-CFLAGS-bug-strtod2.c += -mfloat128
-CFLAGS-tst-strtod-round.c += -mfloat128
-CFLAGS-tst-wcstod-round.c += -mfloat128
-CFLAGS-tst-strtod-nan-locale.c += -mfloat128
-CFLAGS-tst-wcstod-nan-locale.c += -mfloat128
-CFLAGS-tst-strtod6.c += -mfloat128
-CFLAGS-tst-strfrom.c += -mfloat128
-CFLAGS-tst-strfrom-locale.c += -mfloat128
-CFLAGS-strfrom-skeleton.c += -mfloat128
-CFLAGS-tst-strtod-nan-sign.c += -mfloat128
-CFLAGS-tst-wcstod-nan-sign.c += -mfloat128
+$(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),%f128_l$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),%f128_nan$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),%float1282mpn$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+$(foreach suf,$(all-object-suffixes),%mpn2float128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+CFLAGS-bug-strtod.c += $(type-float128-CFLAGS)
+CFLAGS-bug-strtod2.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strtod-round.c += $(type-float128-CFLAGS)
+CFLAGS-tst-wcstod-round.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strtod-nan-locale.c += $(type-float128-CFLAGS)
+CFLAGS-tst-wcstod-nan-locale.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strtod6.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strfrom.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strfrom-locale.c += $(type-float128-CFLAGS)
+CFLAGS-strfrom-skeleton.c += $(type-float128-CFLAGS)
+CFLAGS-tst-strtod-nan-sign.c += $(type-float128-CFLAGS)
+CFLAGS-tst-wcstod-nan-sign.c += $(type-float128-CFLAGS)
 
 # When building glibc with support for _Float128, the powers of ten tables in
 # fpioconst.c and in the string conversion functions must be extended.  Some
 # Makefiles (e.g.: wcsmbs/Makefile) override CFLAGS defined by the Makefiles in
 # sysdeps.  This is avoided with the use sysdep-CFLAGS instead of CFLAGS.
 sysdep-CFLAGS += $(sysdep-CFLAGS-$(<F))
-sysdep-CFLAGS-fpioconst.c += -mfloat128
-sysdep-CFLAGS-strtod_l.c += -mfloat128
-sysdep-CFLAGS-strtof_l.c += -mfloat128
-sysdep-CFLAGS-strtold_l.c += -mfloat128
-sysdep-CFLAGS-wcstod_l.c += -mfloat128
-sysdep-CFLAGS-wcstof_l.c += -mfloat128
-sysdep-CFLAGS-wcstold_l.c += -mfloat128
+sysdep-CFLAGS-fpioconst.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-strtod_l.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-strtof_l.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-strtold_l.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-wcstod_l.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-wcstof_l.c += $(type-float128-CFLAGS)
+sysdep-CFLAGS-wcstold_l.c += $(type-float128-CFLAGS)
+
+# Build any ibm128 specific stdlib tests with ibm128 ABI.
+$(foreach suf,$(all-object-suffixes),%128ibm$(suf)): CFLAGS += $(type-ldouble-CFLAGS)
 endif
 
 # Append flags to printf routines.
 ifeq ($(subdir),stdio-common)
-CFLAGS-printf_fp.c = -mfloat128
-CFLAGS-printf_fphex.c = -mfloat128
-CFLAGS-printf_size.c = -mfloat128
+CFLAGS-printf_fp.c = $(type-float128-CFLAGS)
+CFLAGS-printf_fphex.c = $(type-float128-CFLAGS)
+CFLAGS-printf_size.c = $(type-float128-CFLAGS)
 endif
 
 # Disable linker noise on files using ieee128 long double internally
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
index c6ca872a4b..24dd679ea4 100644
--- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile
@@ -1,6 +1,6 @@ 
 ifeq ($(subdir),math)
 libm-sysdep_routines += w_sqrtf128-power9 w_sqrtf128-ppc64le
 
-CFLAGS-w_sqrtf128-ppc64le.c += -mfloat128 $(no-gnu-attribute-CFLAGS)
-CFLAGS-w_sqrtf128-power9.c += -mfloat128 -mcpu=power9 $(no-gnu-attribute-CFLAGS)
+CFLAGS-w_sqrtf128-ppc64le.c += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
+CFLAGS-w_sqrtf128-power9.c += $(type-float128-CFLAGS) -mcpu=power9 $(no-gnu-attribute-CFLAGS)
 endif