PowerPC: Don't assume all targets have GLIBC.

David reminded me that not all targets support GLIBC.  This patch should fix my
previous committed patch not to use TARGET_GLIBC_MAJOR or TARGET_GLIBC_MINOR
unless they are defined.

I have done a bootstrap on a little endian power9 system and it was fine.  Can
I check this patch into the master branch?

gcc/
2020-10-30  Michael Meissner  <meiss...@linux.ibm.com>

        * config/rs6000/rs6000.c (glibc_supports_ieee_128bit): New helper
        function.
        (rs6000_option_override_internal): Call it.
---
 gcc/config/rs6000/rs6000.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1d7e8878c45..a59dc919baa 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -3539,6 +3539,25 @@ rs6000_linux64_override_options ()
 }
 #endif
 
+/* Return true if we are using GLIBC, and it supports IEEE 128-bit long double.
+   This support is only in little endian GLIBC 2.32 or newer.  */
+static bool
+glibc_supports_ieee_128bit (void)
+{
+#if defined (OPTION_GLIBC) \
+  && defined (TARGET_GLIBC_MAJOR) \
+  && defined (TARGET_GLIBC_MINOR)
+
+  if (OPTION_GLIBC
+      && !BYTES_BIG_ENDIAN
+      && DEFAULT_ABI == ABI_ELFv2
+      && ((TARGET_GLIBC_MAJOR * 1000) + TARGET_GLIBC_MINOR) >= 2032)
+    return true;
+#endif /* GLIBC provided.  */
+
+  return false;
+}
+
 /* Override command line options.
 
    Combine build-specific configuration information with options
@@ -4173,9 +4192,8 @@ rs6000_option_override_internal (bool global_init_p)
          static bool warned_change_long_double;
 
          if (!warned_change_long_double
-             && (!OPTION_GLIBC
-                 || (!lang_GNU_C () && !lang_GNU_CXX ())
-                 || ((TARGET_GLIBC_MAJOR * 1000) + TARGET_GLIBC_MINOR) < 2032))
+             && (!glibc_supports_ieee_128bit ()
+                 || (!lang_GNU_C () && !lang_GNU_CXX ())))
            {
              if (TARGET_IEEEQUAD)
                warning (OPT_Wpsabi, "Using IEEE extended precision "
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797

Reply via email to