gcc: do build ibm128 support code on musl but do not emit fp abi attr

This allows the __ibm128 type to work on musl without failing on
missing symbols, while still supporting musl's 64-bit ldbl env.
This commit is contained in:
q66 2019-12-10 22:53:29 +01:00 committed by Daniel Kolesa
parent fa5138cc28
commit e1f7e131c0
2 changed files with 38 additions and 138 deletions

View file

@ -0,0 +1,38 @@
From 236634eed58fa6e00cc50f19e7202903a9d8fae6 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Thu, 12 Dec 2019 04:03:56 +0100
Subject: [PATCH] libgcc: use -mno-gnu-attribute for 128-bit IBM ldouble
support code
Doing this will allow libgcc to emit the appropriate symbols without actually
emitting the FP ABI tag for them, which allows 64-bit long double environments
to function and even link statically while still allowing usage of
explicit __ibm128.
---
libgcc/config/rs6000/t-ibm-ldouble | 2 +-
libgcc/config/rs6000/t-linux | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libgcc/config/rs6000/t-ibm-ldouble b/libgcc/config/rs6000/t-ibm-ldouble
index b132784..fb5eca8 100644
--- libgcc/config/rs6000/t-ibm-ldouble
+++ libgcc/config/rs6000/t-ibm-ldouble
@@ -1,6 +1,6 @@
# GCC 128-bit long double support routines.
LIB2ADD += $(srcdir)/config/rs6000/ibm-ldouble.c
-HOST_LIBGCC2_CFLAGS += -mlong-double-128
+HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute
SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-ibm-ldouble.ver
diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
index 4f6d4c4..fa93bb6 100644
--- libgcc/config/rs6000/t-linux
+++ libgcc/config/rs6000/t-linux
@@ -1,3 +1,3 @@
SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
-HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc
+HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-gnu-attribute -mno-minimal-toc
--
2.24.0

View file

@ -1,138 +0,0 @@
From 330788a7acde436c1ee8fcb0c1fd657e6ffab8fd Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Thu, 2 May 2019 18:58:29 +0200
Subject: [PATCH] libgcc: do not build 128-bit long double runtime support for
musl
Another patch was already disabling 128-bit long doubles for the
compiler itself, this one additionally avoids building the runtime
support for that.
Musl does not support 128-bit long doubles, and building libgcc
with 128-bit long double ABI was breaking things like ld.gold
which refuses to link two objects with different FP ABI tags.
---
libgcc/config.host | 10 +++++++++-
libgcc/config/rs6000/ppc64-fp.c | 14 ++++++++++++++
libgcc/config/rs6000/t-musl | 8 ++++++++
3 files changed, 31 insertions(+), 1 deletion(-)
create mode 100644 libgcc/config/rs6000/t-musl
diff --git a/libgcc/config.host b/libgcc/config.host
index 11b4aca..51ceef5 100644
--- libgcc/config.host
+++ libgcc/config.host
@@ -1071,8 +1071,16 @@ powerpc-*-rtems*)
extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
;;
powerpc*-*-linux*)
- tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-linux t-dfprules rs6000/t-ppc64-fp t-slibgcc-libgcc"
+ tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-dfprules rs6000/t-ppc64-fp t-slibgcc-libgcc"
tmake_file="${tmake_file} t-stack rs6000/t-stack-rs6000"
+ case ${host} in
+ powerpc*-*-linux-musl*)
+ tmake_file="${tmake_file} rs6000/t-musl"
+ ;;
+ *)
+ tmake_file="${tmake_file} rs6000/t-linux"
+ ;;
+ esac
case $ppc_fp_type in
64)
;;
diff --git a/libgcc/config/rs6000/ppc64-fp.c b/libgcc/config/rs6000/ppc64-fp.c
index faffc82..9f479ee 100644
--- libgcc/config/rs6000/ppc64-fp.c
+++ libgcc/config/rs6000/ppc64-fp.c
@@ -25,25 +25,34 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
#if defined(__powerpc64__) || defined (__64BIT__) || defined(__ppc64__)
+#if __LDBL_MANT_DIG__ > __DBL_MANT_DIG__
#define TMODES
+#endif
#include "fp-bit.h"
+#ifdef TMODES
extern DItype __fixtfdi (TFtype);
+#endif
extern DItype __fixdfdi (DFtype);
extern DItype __fixsfdi (SFtype);
extern USItype __fixunsdfsi (DFtype);
extern USItype __fixunssfsi (SFtype);
+#ifdef TMODES
extern TFtype __floatditf (DItype);
extern TFtype __floatunditf (UDItype);
+#endif
extern DFtype __floatdidf (DItype);
extern DFtype __floatundidf (UDItype);
extern SFtype __floatdisf (DItype);
extern SFtype __floatundisf (UDItype);
+#ifdef TMODES
extern DItype __fixunstfdi (TFtype);
+#endif
static DItype local_fixunssfdi (SFtype);
static DItype local_fixunsdfdi (DFtype);
+#ifdef TMODES
DItype
__fixtfdi (TFtype a)
{
@@ -51,6 +60,7 @@ __fixtfdi (TFtype a)
return - __fixunstfdi (-a);
return __fixunstfdi (a);
}
+#endif
DItype
__fixdfdi (DFtype a)
@@ -86,6 +96,7 @@ __fixunssfsi (SFtype a)
return (SItype) a;
}
+#ifdef TMODES
TFtype
__floatditf (DItype u)
{
@@ -109,6 +120,7 @@ __floatunditf (UDItype u)
return (TFtype) dh + (TFtype) dl;
}
+#endif
DFtype
__floatdidf (DItype u)
@@ -183,6 +195,7 @@ __floatundisf (UDItype u)
return (SFtype) f;
}
+#ifdef TMODES
DItype
__fixunstfdi (TFtype a)
{
@@ -206,6 +219,7 @@ __fixunstfdi (TFtype a)
v += (USItype) a;
return v;
}
+#endif
/* This version is needed to prevent recursion; fixunsdfdi in libgcc
calls fixdfdi, which in turn calls calls fixunsdfdi. */
diff --git a/libgcc/config/rs6000/t-musl b/libgcc/config/rs6000/t-musl
new file mode 100644
index 0000000..f261d8a
--- /dev/null
+++ libgcc/config/rs6000/t-musl
@@ -0,0 +1,8 @@
+# Overrides for musl; we want to avoid building all these implementations
+# required for quad-precision float handling as musl does not support that,
+# ibm-ldouble.c is added into the build by t-ppccomm
+
+HOST_LIBGCC2_CFLAGS += -mlong-double-64 -mno-minimal-toc
+
+# We do not want to build ibm-ldouble.c.
+LIB2ADD := $(filter-out %ibm-ldouble.c, $(LIB2ADD))
--
2.21.0