From faf35e26740461fe1a1da5433d5a0169a663e3b5 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 34/39] 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 dd8cee99fd3..b5f478af382 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -48,6 +48,7 @@ unwind_header = @unwind_header@
 md_unwind_header = @md_unwind_header@
 sfp_machine_header = @sfp_machine_header@
 thread_header = @thread_header@
+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 4f6d4c4a4d2..c50dd94a2da 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 b2f3f870844..ed806587c17
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -619,6 +619,7 @@ build_vendor
 build_cpu
 build
 with_aix_soname
+with_ldbl128
 enable_vtable_verify
 enable_shared
 libgcc_topdir
@@ -668,6 +669,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
@@ -1329,6 +1331,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
@@ -2213,6 +2216,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 b59aa746afc..42220a263c5 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -78,6 +78,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.17.0

