public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work024)] PowerPC: PR libgcc/97543, fix 64-bit long double issues
@ 2020-11-04 18:22 Michael Meissner
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2020-11-04 18:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:26e7a8a966afe2463bd22b0f45f25be64937547f

commit 26e7a8a966afe2463bd22b0f45f25be64937547f
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Wed Nov 4 13:21:50 2020 -0500

    PowerPC: PR libgcc/97543, fix 64-bit long double issues
    
    There are two issues in PR libgcc/97543 which shows up if you build a GCC
    compiler with long double defaulting to 64-bit instead of 128-bit with IBM
    extended double:
    
        1)  The first issue was the t-linux file forced the entire libgcc library
            to be compiled with the -mlong-double-128 option.
    
        2)  The second issue is that the GNU attribute #4 is set to reflect using
            128-bit long doubles, and you get linker warnings when you use use the
            compiler, since libgcc_s.so indicates 128-bit IBM long doubles were
            used.  I ran into a similar issue with my patches to extend libgcc to
            work if long doubles were configured to use the 128-bit IEEE format
            instead of the 128-bit IBM format.
    
    One feature of the current GNU attribute implementation is if you have a shared
    library (such as libgcc_s.so), the GNU attributes for the shared library is an
    inclusive OR of all of the modules within the library.  This means if any
    module uses the -mlong-double-128 option and uses long double, the GNU
    attributes for the library will indicate that it uses 128-bit IBM long
    doubles.  If you have a static library, you will get the warning only if you
    actually reference a module with the attribute set.
    
    This patch does two things:
    
        1)  Instead of compiling the whole library with -mlong-double-128, it only
            compiles the modules that process the IBM extended double format with
            this switch.  It also specifies that these files must be compiled using
            the IBM format for long double.
    
        2)  I turned off GNU attributes for the whole library.  Originally, I just
            turned off GNU attributes for just the modules that process IBM
            extended format values.  But this doesn't work if the compiler defaults
            long double to 64-bits.  What happens is the logic in rs6000.c that
            sets the GNU attribute bits, will set the bits for 64-bit long double
            if a normal double (DFmode) is used.  So I just turned off the
            attributes for the whole library.
    
    This patch replaces the patch I previously did for IEEE 128-bit to turn off
    GNU attributes for just the ibm-ldouble.o module.
            https://gcc.gnu.org/pipermail/gcc-patches/2020-October/556863.html
    
    I have tested this by building a compiler on a little endian power9 system
    running Linux with long double defaulting to 64-bits using the configure
    option: --without-long-double-128, and I verified that the warning no longer is
    generated by the linker.
    
    I then built a bootstrap compiler, by first building a non-bootstrap version.
    With that non-bootstrap compiler, I built versions of the MPC and MPFR.  Using
    those libraries, and the non-bootstrap compiler as the host compiler, I was
    able to do a full bootstrap compiler.
    
    There are differences in the regression test suite where the test implicitly
    assumed long double was 128-bits or was a float128 test.
    
    Can I install this patch into the master branch?  I would also like to install
    it in the GCC 10 branch after an appropriate period.
    
    libgcc/
    2020-11-04  Michael Meissner  <meissner@linux.ibm.com>
    
            PR libgcc/97543
            * config/rs6000/t-linux (HOST_LIBGCC2_CFLAGS): Don't set
            -mlong-double-128 for all modules.  Instead set
            -mno-gnu-attributes.
            (IBM128_OBJS): New make variable for long double support.
            (IBM128_S_OBJS): New make variable for long double support.
            (IBM128_ALL_OBJS): New make variable for long double support.
            (IBM128_CFLAGS): New make variable for long double support.

Diff:
---
 libgcc/config/rs6000/t-linux | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
index ed821947b66..b2a079c6b54 100644
--- a/libgcc/config/rs6000/t-linux
+++ b/libgcc/config/rs6000/t-linux
@@ -1,6 +1,22 @@
 SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
 
-HOST_LIBGCC2_CFLAGS += -mlong-double-128
+# On the modules that deal with IBM 128-bit values, we need to make sure that
+# TFmode uses the IBM extended double format.
+IBM128_OBJS	= ibm-ldouble$(objext) _powitf2$(objext) ppc64-fp$(objext) \
+		  _divtc3$(object) _multc3$(object) \
+		  _fixtfdi$(object) _fixunstfdi$(object) \
+		  _floatditf$(objext) _floatunsditf$(objext)
+
+IBM128_S_OBJS	= $(patsubst %$(objext),%_s$(objext),$(IBM128_OBJS))
+IBM128_ALL_OBJS	= $(IBM128_OBJS) $(IBM128_S_OBJS)
+
+IBM128_CFLAGS	= -mlong-double-128 -Wno-psabi -mabi=ibmlongdouble
+
+$(IBM128_ALL_OBJS) : INTERNAL_CFLAGS += $(IBM128_CFLAGS)
+
+# Turn off gnu attributes for the whole library.  This allows us to build
+# libgcc that supports the different long double formats.
+HOST_LIBGCC2_CFLAGS += -mno-gnu-attribute
 
 # This is a way of selecting -mcmodel=small for ppc64, which gives
 # smaller and faster libgcc code.  Directly specifying -mcmodel=small


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/meissner/heads/work024)] PowerPC: PR libgcc/97543, fix 64-bit long double issues
@ 2020-11-05  2:24 Michael Meissner
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2020-11-05  2:24 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1f24cf0c79d203e123d9d35861abffc9ed54a899

commit 1f24cf0c79d203e123d9d35861abffc9ed54a899
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Wed Nov 4 21:19:13 2020 -0500

    PowerPC: PR libgcc/97543, fix 64-bit long double issues
    
    There are two issues in PR libgcc/97543 which shows up if you build a GCC
    compiler with long double defaulting to 64-bit instead of 128-bit with IBM
    extended double:
    
        1)  The first issue was the t-linux file forced the entire libgcc library
            to be compiled with the -mlong-double-128 option.
    
        2)  The second issue is that the GNU attribute #4 is set to reflect using
            128-bit long doubles, and you get linker warnings when you use use the
            compiler, since libgcc_s.so indicates 128-bit IBM long doubles were
            used.  I ran into a similar issue with my patches to extend libgcc to
            work if long doubles were configured to use the 128-bit IEEE format
            instead of the 128-bit IBM format.
    
    One feature of the current GNU attribute implementation is if you have a shared
    library (such as libgcc_s.so), the GNU attributes for the shared library is an
    inclusive OR of all of the modules within the library.  This means if any
    module uses the -mlong-double-128 option and uses long double, the GNU
    attributes for the library will indicate that it uses 128-bit IBM long
    doubles.  If you have a static library, you will get the warning only if you
    actually reference a module with the attribute set.
    
    This patch does two things:
    
        1)  Instead of compiling the whole library with -mlong-double-128, it only
            compiles the modules that process the IBM extended double format with
            this switch.  It also specifies that these files must be compiled using
            the IBM format for long double.
    
        2) I turned off GNU attributes for building the shared library.
    
    This patch replaces the patch I previously did for IEEE 128-bit to turn off
    GNU attributes for just the ibm-ldouble.o module.
            https://gcc.gnu.org/pipermail/gcc-patches/2020-October/556863.html
    
    I have tested this by building a compiler on a little endian power9 system
    running Linux with long double defaulting to 64-bits using the configure
    option: --without-long-double-128, and I verified that the warning no longer is
    generated by the linker.
    
    I then built a bootstrap compiler, by first building a non-bootstrap version.
    With that non-bootstrap compiler, I built versions of the MPC and MPFR.  Using
    those libraries, and the non-bootstrap compiler as the host compiler, I was
    able to do a full bootstrap compiler.
    
    There are differences in the regression test suite where the test implicitly
    assumed long double was 128-bits or was a float128 test.
    
    Can I install this patch into the master branch?  I would also like to install
    it in the GCC 10 branch after an appropriate period.
    
    libgcc/
    2020-11-04  Michael Meissner  <meissner@linux.ibm.com>
    
            PR libgcc/97543
            PR libgcc/97643
            * config/rs6000/t-linux (IBM128_OBJS): New make variable for long
            double support.
            (IBM128_CFLAGS): New make variable for long double support.
            Explicitly set the long double type to IBM extended for the
            modules that deal with IBM extended values.
            (gcc_s_compile): Add -mno-gnu-attribute to all shared library
            modules.

Diff:
---
 libgcc/config/rs6000/t-linux | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
index ed821947b66..d06394d22f2 100644
--- a/libgcc/config/rs6000/t-linux
+++ b/libgcc/config/rs6000/t-linux
@@ -6,3 +6,22 @@ HOST_LIBGCC2_CFLAGS += -mlong-double-128
 # smaller and faster libgcc code.  Directly specifying -mcmodel=small
 # would need to take into account targets for which -mcmodel is invalid.
 HOST_LIBGCC2_CFLAGS += -mno-minimal-toc
+
+# On the modules that deal with IBM 128-bit values, we need to make sure that
+# TFmode uses the IBM extended double format.
+IBM128_OBJS    = ibm-ldouble$(objext) _powitf2$(objext) ppc64-fp$(objext) \
+                 _divtc3$(object) _multc3$(object) \
+                 _fixtfdi$(object) _fixunstfdi$(object) \
+                 _floatditf$(objext) _floatunsditf$(objext)
+
+IBM128_CFLAGS  = -Wno-psabi -mabi=ibmlongdouble -mno-gnu-attribute
+
+$(IBM128_OBJS) : INTERNAL_CFLAGS += $(IBM128_CFLAGS)
+
+# Turn off gnu attributes for long double size on all of the shared library
+# modules, but leave it on for the static modules, except for the functions
+# that explicitly process IBM 128-bit floating point.  Shared libraries only
+# have one gnu attribute for the whole library, and it can lead to warnings if
+# somebody changes the long double format.  We leave it on for the static
+# modules to catch mis-compilation errors.
+gcc_s_compile += -mno-gnu-attribute


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-05  2:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04 18:22 [gcc(refs/users/meissner/heads/work024)] PowerPC: PR libgcc/97543, fix 64-bit long double issues Michael Meissner
2020-11-05  2:24 Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).