From 5a47d404ea29e2547269e3ddf38754462d93f903 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 29 Apr 2016 20:03:28 +0000
Subject: [PATCH 45/46] libgcc: Add knob to use ldbl-128 on ppc

musl does not support ldbl 128 so we can not assume
that linux as a whole supports ldbl-128 bits, instead
act upon configure option passed to gcc and assume no
on musl and yes otherwise if no option is passed since
default behaviour is to assume ldbl128 it does not
change the defaults

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending

 libgcc/Makefile.in           |  1 +
 libgcc/config/rs6000/t-linux |  5 ++++-
 libgcc/configure             | 18 ++++++++++++++++++
 libgcc/configure.ac          | 12 ++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 libgcc/configure

diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index f09b39b..296cf0f 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -43,6 +43,7 @@ enable_vtable_verify = @enable_vtable_verify@
 enable_decimal_float = @enable_decimal_float@
 fixed_point = @fixed_point@
 with_aix_soname = @with_aix_soname@
+with_ldbl128 = @with_ldbl128@
 
 host_noncanonical = @host_noncanonical@
 real_host_noncanonical = @real_host_noncanonical@
diff --git a/libgcc/config/rs6000/t-linux b/libgcc/config/rs6000/t-linux
index 4f6d4c4..c50dd94 100644
--- a/libgcc/config/rs6000/t-linux
+++ b/libgcc/config/rs6000/t-linux
@@ -1,3 +1,6 @@
 SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
 
-HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc
+ifeq ($(with_ldbl128),yes)
+HOST_LIBGCC2_CFLAGS += -mlong-double-128
+endif
+HOST_LIBGCC2_CFLAGS += -mno-minimal-toc
diff --git a/libgcc/configure b/libgcc/configure
old mode 100644
new mode 100755
index e7d6c75..e9a9019
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -614,6 +614,7 @@ build_vendor
 build_cpu
 build
 with_aix_soname
+with_ldbl128
 enable_vtable_verify
 enable_shared
 libgcc_topdir
@@ -663,6 +664,7 @@ with_cross_host
 with_ld
 enable_shared
 enable_vtable_verify
+with_long_double_128
 with_aix_soname
 enable_version_specific_runtime_libs
 with_slibdir
@@ -1319,6 +1321,7 @@ Optional Packages:
   --with-target-subdir=SUBDIR      Configuring in a subdirectory for target
   --with-cross-host=HOST           Configuring with a cross compiler
   --with-ld               arrange to use the specified ld (full pathname)
+  --with-long-double-128  use 128-bit long double by default
   --with-aix-soname=aix|svr4|both
                           shared library versioning (aka "SONAME") variant to
                           provide on AIX
@@ -2201,6 +2204,21 @@ fi
 
 
 
+# Check whether --with-long-double-128 was given.
+if test "${with_long_double_128+set}" = set; then :
+  withval=$with_long_double_128; with_ldbl128="$with_long_double_128"
+else
+  case "${host}" in
+ power*-*-musl*)
+   with_ldbl128="no";;
+ *) with_ldbl128="yes";;
+ esac
+
+fi
+
+
+
+
 # Check whether --with-aix-soname was given.
 if test "${with_aix_soname+set}" = set; then :
   withval=$with_aix_soname; case "${host}:${enable_shared}" in
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 269997f..81dc3ba 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -77,6 +77,18 @@ AC_ARG_ENABLE(vtable-verify,
 [enable_vtable_verify=no])
 AC_SUBST(enable_vtable_verify)
 
+AC_ARG_WITH(long-double-128,
+[AS_HELP_STRING([--with-long-double-128],
+    [use 128-bit long double by default])],
+      with_ldbl128="$with_long_double_128",
+[case "${host}" in
+ power*-*-musl*)
+   with_ldbl128="no";;
+ *) with_ldbl128="yes";;
+ esac
+])
+AC_SUBST(with_ldbl128)
+
 AC_ARG_WITH(aix-soname,
 [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
     [shared library versioning (aka "SONAME") variant to provide on AIX])],
-- 
2.8.2

