public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6838] properly disable -fsplit-stack on non-glibc targets [PR104170]
@ 2022-01-24 10:18 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-01-24 10:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2c31a8be4a5db11a0a0e97c366dded6362421086

commit r12-6838-g2c31a8be4a5db11a0a0e97c366dded6362421086
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Jan 24 11:13:39 2022 +0100

    properly disable -fsplit-stack on non-glibc targets [PR104170]
    
    On Sat, Jan 22, 2022 at 10:32:21AM +0100, Martin Liška wrote:
    > I've just noticed the patch broke a few cross compilers:
    >
    > s390x-ibm-tpf:
    >
    > /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/s390/s390-common.cc: In function ‘bool s390_supports_split_stack(bool, gcc_options*)’:
    > /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/s390/s390-common.cc:126:13: error: ‘struct gcc_options’ has no member named ‘x_linux_libc’
    >   126 |   if (opts->x_linux_libc == LIBC_GLIBC)
    >       |             ^~~~~~~~~~~~
    >
    > i686-kopensolaris-gnu, i686-symbolics-gnu
    >
    > /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/i386/i386-common.cc: In function ‘bool ix86_supports_split_stack(bool, gcc_options*)’:
    > /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/i386/i386-common.cc:1721:13: error: ‘struct gcc_options’ has no member named ‘x_linux_libc’
    >  1721 |   if (opts->x_linux_libc != LIBC_GLIBC)
    >       |             ^~~~~~~~~~~~
    > make[1]: *** [Makefile:2418: i386-common.o] Error 1
    >
    > Can you please take a look? Btw. do you have a bugzilla account?
    
    I bet instead of opts->x_linux_libc != LIBC_GLIBC it needs to use
     #ifdef OPTION_GLIBC
       if (!OPTION_GLIBC)
     #endif
    or so.  I think the first committed patch actually used that
    but used it in #if directive, which is wrong because it is something
    that needs to be evaluated at runtime.
    
    That doesn't work well either, because the *supports_split_stack
    hooks have opts argument and OPTION_GLIBC doesn't take that.
    
    So, here is a patch that introduces OPTION_*_P macros that take opts
    as an argument and redefines OPTION_* using those (similarly to how
    the option scripts create TARGET_*_P and TARGET_* macros).
    
    2022-01-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR bootstrap/104170
            * config/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P,
            OPTION_BIONIC_P, OPTION_MUSL_P): Define.
            (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine
            using OPTION_*_P macros.
            * config/alpha/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P,
            OPTION_BIONIC_P, OPTION_MUSL_P): Define.
            (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine
            using OPTION_*_P macros.
            * config/rs6000/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P,
            OPTION_BIONIC_P, OPTION_MUSL_P): Define.
            (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine
            using OPTION_*_P macros.
            * config/rs6000/linux64.h (OPTION_GLIBC_P, OPTION_UCLIBC_P,
            OPTION_BIONIC_P, OPTION_MUSL_P): Define.
            (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine
            using OPTION_*_P macros.
            * config/fuchsia.h (OPTION_MUSL_P): Redefine.
            * config/glibc-stdint.h (OPTION_MUSL_P): Define if not defined.
            * common/config/s390/s390-common.cc (s390_supports_split_stack): Re-add
            ATTRIBUTE_UNUSED to opts parameter.  If OPTION_GLIBC_P is defined, use
            OPTION_GLIBC_P (opts) as condition, otherwise assume if (false).
            * common/config/i386/i386-common.cc (ix86_supports_split_stack): If
            OPTION_GLIBC_P is defined use !OPTION_GLIBC_P (opts) as condition,
            otherwise assume if (true).

Diff:
---
 gcc/common/config/i386/i386-common.cc |  4 ++--
 gcc/common/config/s390/s390-common.cc |  6 ++++--
 gcc/config/alpha/linux.h              | 25 +++++++++++++++----------
 gcc/config/fuchsia.h                  |  2 ++
 gcc/config/glibc-stdint.h             |  3 +++
 gcc/config/linux.h                    | 25 +++++++++++++++----------
 gcc/config/rs6000/linux.h             | 25 +++++++++++++++----------
 gcc/config/rs6000/linux64.h           | 25 +++++++++++++++----------
 8 files changed, 71 insertions(+), 44 deletions(-)

diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc
index 7496d179892..607e9f20e85 100644
--- a/gcc/common/config/i386/i386-common.cc
+++ b/gcc/common/config/i386/i386-common.cc
@@ -1717,8 +1717,8 @@ static bool
 ix86_supports_split_stack (bool report,
 			   struct gcc_options *opts ATTRIBUTE_UNUSED)
 {
-#ifdef TARGET_THREAD_SPLIT_STACK_OFFSET
-  if (opts->x_linux_libc != LIBC_GLIBC)
+#if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC_P)
+  if (!OPTION_GLIBC_P (opts))
 #endif
     {
       if (report)
diff --git a/gcc/common/config/s390/s390-common.cc b/gcc/common/config/s390/s390-common.cc
index 547b0826f93..caec2f14c6c 100644
--- a/gcc/common/config/s390/s390-common.cc
+++ b/gcc/common/config/s390/s390-common.cc
@@ -121,10 +121,12 @@ s390_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED,
 
 static bool
 s390_supports_split_stack (bool report,
-			   struct gcc_options *opts)
+			   struct gcc_options *opts ATTRIBUTE_UNUSED)
 {
-  if (opts->x_linux_libc == LIBC_GLIBC)
+#ifdef OPTION_GLIBC_P
+  if (OPTION_GLIBC_P (opts))
     return true;
+#endif
 
   if (report)
     error ("%<-fsplit-stack%> currently only supported on GNU/Linux");
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 9ab501c2616..14ced5f8be6 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -58,18 +58,23 @@ along with GCC; see the file COPYING3.  If not see
 #define WCHAR_TYPE "int"
 
 #ifdef SINGLE_LIBC
-#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (DEFAULT_LIBC == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	(DEFAULT_LIBC == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	(DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	(DEFAULT_LIBC == LIBC_MUSL)
 #else
-#define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	((opts)->x_linux_libc == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	((opts)->x_linux_libc == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	((opts)->x_linux_libc == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	((opts)->x_linux_libc == LIBC_MUSL)
 #endif
+#define OPTION_GLIBC		OPTION_GLIBC_P (&global_options)
+#define OPTION_UCLIBC		OPTION_UCLIBC_P (&global_options)
+#define OPTION_BIONIC		OPTION_BIONIC_P (&global_options)
+#undef OPTION_MUSL
+#define OPTION_MUSL		OPTION_MUSL_P (&global_options)
 
 /* Determine what functions are present at the runtime;
    this includes full c99 runtime and sincos.  */
diff --git a/gcc/config/fuchsia.h b/gcc/config/fuchsia.h
index e013265a210..0baf6f1f385 100644
--- a/gcc/config/fuchsia.h
+++ b/gcc/config/fuchsia.h
@@ -52,6 +52,8 @@ along with GCC; see the file COPYING3.  If not see
 /* We are using MUSL as our libc.  */
 #undef  OPTION_MUSL
 #define OPTION_MUSL 1
+#undef  OPTION_MUSL_P
+#define OPTION_MUSL_P(opts) 1
 
 #ifndef TARGET_SUB_OS_CPP_BUILTINS
 #define TARGET_SUB_OS_CPP_BUILTINS()
diff --git a/gcc/config/glibc-stdint.h b/gcc/config/glibc-stdint.h
index 116161690c8..a3652d0112d 100644
--- a/gcc/config/glibc-stdint.h
+++ b/gcc/config/glibc-stdint.h
@@ -27,6 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #ifndef OPTION_MUSL
 #define OPTION_MUSL 0
 #endif
+#ifndef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts) 0
+#endif
 
 #define SIG_ATOMIC_TYPE "int"
 
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index 2e888e3b176..74f70793d90 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -29,18 +29,23 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 /* C libraries supported on Linux.  */
 #ifdef SINGLE_LIBC
-#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (DEFAULT_LIBC == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	(DEFAULT_LIBC == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	(DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	(DEFAULT_LIBC == LIBC_MUSL)
 #else
-#define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	((opts)->x_linux_libc == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	((opts)->x_linux_libc == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	((opts)->x_linux_libc == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	((opts)->x_linux_libc == LIBC_MUSL)
 #endif
+#define OPTION_GLIBC		OPTION_GLIBC_P (&global_options)
+#define OPTION_UCLIBC		OPTION_UCLIBC_P (&global_options)
+#define OPTION_BIONIC		OPTION_BIONIC_P (&global_options)
+#undef OPTION_MUSL
+#define OPTION_MUSL		OPTION_MUSL_P (&global_options)
 
 #define GNU_USER_TARGET_OS_CPP_BUILTINS()			\
     do {							\
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index e6a3223b244..8c9039ac1e5 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -27,18 +27,23 @@
 #define NO_PROFILE_COUNTERS 1
 
 #ifdef SINGLE_LIBC
-#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (DEFAULT_LIBC == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	(DEFAULT_LIBC == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	(DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	(DEFAULT_LIBC == LIBC_MUSL)
 #else
-#define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	((opts)->x_linux_libc == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	((opts)->x_linux_libc == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	((opts)->x_linux_libc == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	((opts)->x_linux_libc == LIBC_MUSL)
 #endif
+#define OPTION_GLIBC		OPTION_GLIBC_P (&global_options)
+#define OPTION_UCLIBC		OPTION_UCLIBC_P (&global_options)
+#define OPTION_BIONIC		OPTION_BIONIC_P (&global_options)
+#undef OPTION_MUSL
+#define OPTION_MUSL		OPTION_MUSL_P (&global_options)
 
 /* Determine what functions are present at the runtime;
    this includes full c99 runtime and sincos.  */
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index d617f346f81..b2a7afabc73 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -265,18 +265,23 @@ extern int dot_symbols;
 #define OS_MISSING_POWERPC64 !TARGET_64BIT
 
 #ifdef SINGLE_LIBC
-#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (DEFAULT_LIBC == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	(DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	(DEFAULT_LIBC == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	(DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	(DEFAULT_LIBC == LIBC_MUSL)
 #else
-#define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
-#undef OPTION_MUSL
-#define OPTION_MUSL   (linux_libc == LIBC_MUSL)
+#define OPTION_GLIBC_P(opts)	((opts)->x_linux_libc == LIBC_GLIBC)
+#define OPTION_UCLIBC_P(opts)	((opts)->x_linux_libc == LIBC_UCLIBC)
+#define OPTION_BIONIC_P(opts)	((opts)->x_linux_libc == LIBC_BIONIC)
+#undef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts)	((opts)->x_linux_libc == LIBC_MUSL)
 #endif
+#define OPTION_GLIBC		OPTION_GLIBC_P (&global_options)
+#define OPTION_UCLIBC		OPTION_UCLIBC_P (&global_options)
+#define OPTION_BIONIC		OPTION_BIONIC_P (&global_options)
+#undef OPTION_MUSL
+#define OPTION_MUSL		OPTION_MUSL_P (&global_options)
 
 /* Determine what functions are present at the runtime;
    this includes full c99 runtime and sincos.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-24 10:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 10:18 [gcc r12-6838] properly disable -fsplit-stack on non-glibc targets [PR104170] Jakub Jelinek

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).