public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Martin Liška" <mliska@suse.cz>,
	gcc-patches@gcc.gnu.org, soeren@soeren-tempel.net
Subject: Re: [PATCH] Disable -fsplit-stack support on non-glibc targets
Date: Sat, 22 Jan 2022 19:03:48 +0100	[thread overview]
Message-ID: <20220122180348.GZ2646553@tucnak> (raw)
In-Reply-To: <20220122121638.GX2646553@tucnak>

On Sat, Jan 22, 2022 at 01:16:38PM +0100, Jakub Jelinek via Gcc-patches wrote:
> Actually, I suspect we either need something like following patch,
> or need to change gcc/config/{linux,rs6000/linux{,64},alpha/linux}.h
> so that next to those OPTION_GLIBC etc. macros it also defines versions
> of those macros with opts argument.

And here is a larger but perhaps cleaner patch that matches how e.g.
options.h defines TARGET_WHATEVER_P(opts) options and then TARGET_WHATEVER
too.

Only compile tested on x86_64-linux so far.

2022-01-22  Jakub Jelinek  <jakub@redhat.com>

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

--- gcc/config/linux.h.jj	2022-01-18 11:58:59.160988086 +0100
+++ gcc/config/linux.h	2022-01-22 18:42:25.476235564 +0100
@@ -29,18 +29,23 @@ see the files COPYING3 and COPYING.RUNTI
 
 /* 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 {							\
--- gcc/config/alpha/linux.h.jj	2022-01-11 23:11:21.692299963 +0100
+++ gcc/config/alpha/linux.h	2022-01-22 18:43:59.739923743 +0100
@@ -58,18 +58,23 @@ along with GCC; see the file COPYING3.
 #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.  */
--- gcc/config/rs6000/linux.h.jj	2022-01-11 23:11:21.939296492 +0100
+++ gcc/config/rs6000/linux.h	2022-01-22 18:42:59.834757410 +0100
@@ -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.  */
--- gcc/config/rs6000/linux64.h.jj	2022-01-11 23:11:21.939296492 +0100
+++ gcc/config/rs6000/linux64.h	2022-01-22 18:43:37.830228647 +0100
@@ -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.  */
--- gcc/config/fuchsia.h.jj	2022-01-11 23:11:21.750299147 +0100
+++ gcc/config/fuchsia.h	2022-01-22 18:49:53.927996890 +0100
@@ -52,6 +52,8 @@ along with GCC; see the file COPYING3.
 /* 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()
--- gcc/config/glibc-stdint.h.jj	2022-01-11 23:11:21.753299105 +0100
+++ gcc/config/glibc-stdint.h	2022-01-22 18:49:53.928996876 +0100
@@ -27,6 +27,9 @@ see the files COPYING3 and COPYING.RUNTI
 #ifndef OPTION_MUSL
 #define OPTION_MUSL 0
 #endif
+#ifndef OPTION_MUSL_P
+#define OPTION_MUSL_P(opts) 0
+#endif
 
 #define SIG_ATOMIC_TYPE "int"
 
--- gcc/common/config/s390/s390-common.cc.jj	2022-01-22 18:37:18.701504795 +0100
+++ gcc/common/config/s390/s390-common.cc	2022-01-22 18:39:09.820958400 +0100
@@ -121,10 +121,12 @@ s390_handle_option (struct gcc_options *
 
 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");
--- gcc/common/config/i386/i386-common.cc.jj	2022-01-22 18:37:18.700504809 +0100
+++ gcc/common/config/i386/i386-common.cc	2022-01-22 18:39:09.821958386 +0100
@@ -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)


	Jakub


  reply	other threads:[~2022-01-22 18:04 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18 10:43 soeren
2021-12-18 10:54 ` Andrew Pinski
2021-12-18 11:13   ` Sören Tempel
2021-12-18 11:22     ` Andrew Pinski
2021-12-18 12:19       ` [PATCH v2] " soeren
2022-01-20 20:45         ` Sören Tempel
2022-01-20 22:52         ` Richard Sandiford
2022-01-21  7:32           ` Andreas Krebbel
2022-01-21  8:17           ` Uros Bizjak
2022-01-21 19:16           ` [PATCH v3] " soeren
2022-01-21 19:23             ` Richard Sandiford
2022-01-21 19:47               ` H.J. Lu
2022-01-21 20:09                 ` H.J. Lu
2022-01-21 20:18             ` Jakub Jelinek
2022-01-21 21:31               ` [PATCH] x86: Properly disable " H.J. Lu
2022-01-21 21:42                 ` Jakub Jelinek
2022-01-21 21:57                   ` [PATCH v2] " H.J. Lu
2022-01-21 22:14                     ` Jakub Jelinek
2022-01-21 19:53         ` [PATCH v2] Disable " H.J. Lu
2022-01-21 20:43           ` Sören Tempel
2022-01-22  9:32 ` [PATCH] " Martin Liška
2022-01-22  9:35   ` Jakub Jelinek
2022-01-22 12:16   ` Jakub Jelinek
2022-01-22 18:03     ` Jakub Jelinek [this message]
2022-01-23  9:06       ` Uros Bizjak
2022-01-23 10:06         ` Jakub Jelinek
2022-01-24  9:33       ` Jakub Jelinek
2022-01-24 10:09         ` Richard Biener
2022-01-25 15:27 David Edelsohn
2022-01-28 19:25 ` Iain Sandoe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220122180348.GZ2646553@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    --cc=soeren@soeren-tempel.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).