* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets @ 2022-01-25 15:27 David Edelsohn 2022-01-28 19:25 ` Iain Sandoe 0 siblings, 1 reply; 14+ messages in thread From: David Edelsohn @ 2022-01-25 15:27 UTC (permalink / raw) To: Martin Liska, Jakub Jelinek, Iain Sandoe; +Cc: GCC Patches This patch broke bootstrap on AIX. It may have broken Darwin. I have applied the following patch. AIX doesn't need to distinguish between different Linux libc implementations. Bootstrapped on powerpc-ibm-aix7.2.3.0 Thanks, David aix: AIX is not GLIBC. A recent patch added tests for OPTION_GLIBC that is defined in linux.h and linux64.h. This broke bootstrap for non-Linux rs6000 configurations. This patch defines OPTION_GLIBC as 0. * config/rs6000/aix.h (OPTION_GLIBC): Define as 0. diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index ad3238bf09a..eb7a0c09f72 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -23,6 +23,7 @@ #define DEFAULT_ABI ABI_AIX #undef TARGET_AIX #define TARGET_AIX 1 +#define OPTION_GLIBC 0 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-25 15:27 [PATCH] Disable -fsplit-stack support on non-glibc targets David Edelsohn @ 2022-01-28 19:25 ` Iain Sandoe 0 siblings, 0 replies; 14+ messages in thread From: Iain Sandoe @ 2022-01-28 19:25 UTC (permalink / raw) To: GCC Patches; +Cc: David Edelsohn > On 25 Jan 2022, at 15:27, David Edelsohn <dje.gcc@gmail.com> wrote: > > This patch broke bootstrap on AIX. It may have broken Darwin. As you anticipated, it did : fixed as below (tested on powerpc-darwin9, pushed to master). thanks Iain [pushed] Darwin, PPC: Fix bootstrap after GLIBC version changes. A recent patch added tests for OPTION_GLIBC that is defined in linux.h and linux64.h. This broke bootstrap for powerpc Darwin. Fixed by adding a definition to 0 for OPTION_GLIBC. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> gcc/ChangeLog: * config/rs6000/darwin.h (OPTION_GLIBC): Define to 0. --- gcc/config/rs6000/darwin.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/config/rs6000/darwin.h b/gcc/config/rs6000/darwin.h index b5cef42610f..210c60694cd 100644 --- a/gcc/config/rs6000/darwin.h +++ b/gcc/config/rs6000/darwin.h @@ -34,6 +34,8 @@ #endif #endif +#define OPTION_GLIBC 0 + /* The object file format is Mach-O. */ #define TARGET_OBJECT_FORMAT OBJECT_MACHO -- 2.24.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] Disable -fsplit-stack support on non-glibc targets @ 2021-12-18 10:43 soeren 2021-12-18 10:54 ` Andrew Pinski 2022-01-22 9:32 ` Martin Liška 0 siblings, 2 replies; 14+ messages in thread From: soeren @ 2021-12-18 10:43 UTC (permalink / raw) To: gcc-patches From: Sören Tempel <soeren+git@soeren-tempel.net> The -fsplit-stack option requires the pthread_t TCB definition in the libc to provide certain struct fields at specific hardcoded offsets. As far as I know, only glibc provides these fields at the required offsets. Most notably, musl libc does not have these fields. However, since gcc accesses the fields using a fixed offset, this does not cause a compile-time error, but instead results in a silent memory corruption at run-time with musl libc. For example, on s390x libgcc's __stack_split_initialize CTOR will overwrite the cancel field in the pthread_t TCB on musl. The -fsplit-stack option is used within the gcc code base itself by gcc-go (if available). On musl-based systems with split-stack support (i.e. s390x or x86) this causes Go programs compiled with gcc-go to misbehave at run-time. This patch fixes gcc-go on musl by disabling -fsplit-stack in gcc itself since it is not supported on non-glibc targets anyhow. This is achieved by checking if TARGET_GLIBC_MAJOR is defined to a non-zero value (it defaults to zero on non-glibc systems). The check has been added for x86 and s390x, the rs6000 config already checks for TARGET_GLIBC_MAJOR. Other architectures do not have split-stack support. With this patch applied, the gcc-go configure script will detect that -fsplit-stack support is not available and will not use it. See https://www.openwall.com/lists/musl/2012/10/16/12 This patch has been tested on Alpine Linux Edge on the s390x and x86 architectures by bootstrapping Google's Go implementation with gcc-go. Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> gcc/ChangeLog: * common/config/s390/s390-common.c (s390_supports_split_stack): Only support split-stack on glibc targets. * config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN): Ditto. * config/i386/gnu.h (defined): Ditto. --- gcc/common/config/s390/s390-common.c | 9 ++++++++- gcc/config/i386/gnu-user-common.h | 5 +++-- gcc/config/i386/gnu.h | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/common/config/s390/s390-common.c b/gcc/common/config/s390/s390-common.c index b6bc8501742..afbd8d3fe66 100644 --- a/gcc/common/config/s390/s390-common.c +++ b/gcc/common/config/s390/s390-common.c @@ -116,13 +116,20 @@ s390_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED, /* -fsplit-stack uses a field in the TCB, available with glibc-2.23. We don't verify it, since earlier versions just have padding at - its place, which works just as well. */ + its place, which works just as well. For other libc implementations + we disable the feature entirely to avoid corrupting the TCB. */ static bool s390_supports_split_stack (bool report ATTRIBUTE_UNUSED, struct gcc_options *opts ATTRIBUTE_UNUSED) { +#if TARGET_GLIBC_MAJOR return true; +#else + if (report) + error("%<-fsplit-stack%> currently only supported on GNU/Linux"); + return false; +#endif } #undef TARGET_DEFAULT_TARGET_FLAGS diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h index 00226f5a455..69f2d7415ad 100644 --- a/gcc/config/i386/gnu-user-common.h +++ b/gcc/config/i386/gnu-user-common.h @@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see #define STACK_CHECK_STATIC_BUILTIN 1 /* We only build the -fsplit-stack support in libgcc if the - assembler has full support for the CFI directives. */ -#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + assembler has full support for the CFI directives and + targets glibc. */ +#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && TARGET_GLIBC_MAJOR #define TARGET_CAN_SPLIT_STACK #endif diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h index 25fbc07f58c..895a7369816 100644 --- a/gcc/config/i386/gnu.h +++ b/gcc/config/i386/gnu.h @@ -35,7 +35,11 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>. crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" #endif -#ifdef TARGET_LIBC_PROVIDES_SSP +/* -fsplit-stack uses a field in the TCB at a fixed offset. This + field is only available for glibc. Disable -fsplit-stack for + other libc implementation to avoid silent TCB corruptions. */ + +#if defined (TARGET_LIBC_PROVIDES_SSP) && TARGET_GLIBC_MAJOR /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ #define TARGET_THREAD_SSP_OFFSET 0x14 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2021-12-18 10:43 soeren @ 2021-12-18 10:54 ` Andrew Pinski 2021-12-18 11:13 ` Sören Tempel 2022-01-22 9:32 ` Martin Liška 1 sibling, 1 reply; 14+ messages in thread From: Andrew Pinski @ 2021-12-18 10:54 UTC (permalink / raw) To: soeren; +Cc: GCC Patches On Sat, Dec 18, 2021 at 2:44 AM soeren--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Sören Tempel <soeren+git@soeren-tempel.net> > > The -fsplit-stack option requires the pthread_t TCB definition in the > libc to provide certain struct fields at specific hardcoded offsets. As > far as I know, only glibc provides these fields at the required offsets. > Most notably, musl libc does not have these fields. However, since gcc > accesses the fields using a fixed offset, this does not cause a > compile-time error, but instead results in a silent memory corruption at > run-time with musl libc. For example, on s390x libgcc's > __stack_split_initialize CTOR will overwrite the cancel field in the > pthread_t TCB on musl. > > The -fsplit-stack option is used within the gcc code base itself by > gcc-go (if available). On musl-based systems with split-stack support > (i.e. s390x or x86) this causes Go programs compiled with gcc-go to > misbehave at run-time. > > This patch fixes gcc-go on musl by disabling -fsplit-stack in gcc itself > since it is not supported on non-glibc targets anyhow. This is achieved > by checking if TARGET_GLIBC_MAJOR is defined to a non-zero value (it > defaults to zero on non-glibc systems). The check has been added for x86 > and s390x, the rs6000 config already checks for TARGET_GLIBC_MAJOR. > Other architectures do not have split-stack support. With this patch > applied, the gcc-go configure script will detect that -fsplit-stack > support is not available and will not use it. > > See https://www.openwall.com/lists/musl/2012/10/16/12 > > This patch has been tested on Alpine Linux Edge on the s390x and x86 > architectures by bootstrapping Google's Go implementation with gcc-go. > > Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net> > > gcc/ChangeLog: > > * common/config/s390/s390-common.c (s390_supports_split_stack): > Only support split-stack on glibc targets. > * config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN): Ditto. > * config/i386/gnu.h (defined): Ditto. > --- > gcc/common/config/s390/s390-common.c | 9 ++++++++- > gcc/config/i386/gnu-user-common.h | 5 +++-- > gcc/config/i386/gnu.h | 6 +++++- > 3 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/gcc/common/config/s390/s390-common.c b/gcc/common/config/s390/s390-common.c > index b6bc8501742..afbd8d3fe66 100644 > --- a/gcc/common/config/s390/s390-common.c > +++ b/gcc/common/config/s390/s390-common.c > @@ -116,13 +116,20 @@ s390_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED, > > /* -fsplit-stack uses a field in the TCB, available with glibc-2.23. > We don't verify it, since earlier versions just have padding at > - its place, which works just as well. */ > + its place, which works just as well. For other libc implementations > + we disable the feature entirely to avoid corrupting the TCB. */ > > static bool > s390_supports_split_stack (bool report ATTRIBUTE_UNUSED, > struct gcc_options *opts ATTRIBUTE_UNUSED) > { > +#if TARGET_GLIBC_MAJOR > return true; > +#else > + if (report) > + error("%<-fsplit-stack%> currently only supported on GNU/Linux"); > + return false; > +#endif > } I think it should check OPTION_MUSL at runtime instead of TARGET_GLIBC_MAJOR at compile time. or rather opts->x_linux_libc == LIBC_MUSL The others should be done similarly too. Thanks, Andrew > > #undef TARGET_DEFAULT_TARGET_FLAGS > diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h > index 00226f5a455..69f2d7415ad 100644 > --- a/gcc/config/i386/gnu-user-common.h > +++ b/gcc/config/i386/gnu-user-common.h > @@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see > #define STACK_CHECK_STATIC_BUILTIN 1 > > /* We only build the -fsplit-stack support in libgcc if the > - assembler has full support for the CFI directives. */ > -#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE > + assembler has full support for the CFI directives and > + targets glibc. */ > +#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && TARGET_GLIBC_MAJOR > #define TARGET_CAN_SPLIT_STACK > #endif > diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h > index 25fbc07f58c..895a7369816 100644 > --- a/gcc/config/i386/gnu.h > +++ b/gcc/config/i386/gnu.h > @@ -35,7 +35,11 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>. > crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" > #endif > > -#ifdef TARGET_LIBC_PROVIDES_SSP > +/* -fsplit-stack uses a field in the TCB at a fixed offset. This > + field is only available for glibc. Disable -fsplit-stack for > + other libc implementation to avoid silent TCB corruptions. */ > + > +#if defined (TARGET_LIBC_PROVIDES_SSP) && TARGET_GLIBC_MAJOR > > /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ > #define TARGET_THREAD_SSP_OFFSET 0x14 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2021-12-18 10:54 ` Andrew Pinski @ 2021-12-18 11:13 ` Sören Tempel 2021-12-18 11:22 ` Andrew Pinski 0 siblings, 1 reply; 14+ messages in thread From: Sören Tempel @ 2021-12-18 11:13 UTC (permalink / raw) To: Andrew Pinski; +Cc: GCC Patches Andrew Pinski <pinskia@gmail.com> wrote: > I think it should check OPTION_MUSL at runtime instead of > TARGET_GLIBC_MAJOR at compile time. > or rather opts->x_linux_libc == LIBC_MUSL > The others should be done similarly too. Thanks for pointing this out, I wasn't aware of OPTION_MUSL and OPTION_GLIBC. However, I am wondering if isn't more useful to whitelist this feature on glibc instead of blacklisting it on musl? I was operating on the assumption that other libc implementations (uclibc, bionic, dietlibc, …) do also not support the required pthread_t fields, i.e. that glibc is the only libc where this feature actually works. Greetings, Sören ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2021-12-18 11:13 ` Sören Tempel @ 2021-12-18 11:22 ` Andrew Pinski 0 siblings, 0 replies; 14+ messages in thread From: Andrew Pinski @ 2021-12-18 11:22 UTC (permalink / raw) To: Sören Tempel; +Cc: GCC Patches On Sat, Dec 18, 2021 at 3:13 AM Sören Tempel <soeren@soeren-tempel.net> wrote: > > Andrew Pinski <pinskia@gmail.com> wrote: > > I think it should check OPTION_MUSL at runtime instead of > > TARGET_GLIBC_MAJOR at compile time. > > or rather opts->x_linux_libc == LIBC_MUSL > > The others should be done similarly too. > > Thanks for pointing this out, I wasn't aware of OPTION_MUSL and > OPTION_GLIBC. However, I am wondering if isn't more useful to whitelist > this feature on glibc instead of blacklisting it on musl? I was > operating on the assumption that other libc implementations (uclibc, > bionic, dietlibc, …) do also not support the required pthread_t fields, > i.e. that glibc is the only libc where this feature actually works. yes checking OPTION_GLIBC is better really. Saying glibc only is better than saying it does not work on musl in this case. Though I think opts->x_linux_libc == LIBC_GLIBC is the more correct fix for this function as we are passed down the opts struction and all. Thanks, Andrew Pinski > > Greetings, > Sören ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2021-12-18 10:43 soeren 2021-12-18 10:54 ` Andrew Pinski @ 2022-01-22 9:32 ` Martin Liška 2022-01-22 9:35 ` Jakub Jelinek 2022-01-22 12:16 ` Jakub Jelinek 1 sibling, 2 replies; 14+ messages in thread From: Martin Liška @ 2022-01-22 9:32 UTC (permalink / raw) To: soeren, gcc-patches Hello. 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? Cheers, Martin ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-22 9:32 ` Martin Liška @ 2022-01-22 9:35 ` Jakub Jelinek 2022-01-22 12:16 ` Jakub Jelinek 1 sibling, 0 replies; 14+ messages in thread From: Jakub Jelinek @ 2022-01-22 9:35 UTC (permalink / raw) To: Martin Liška; +Cc: soeren, gcc-patches On Sat, Jan 22, 2022 at 10:32:21AM +0100, Martin Liška wrote: > Hello. > > 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. Jakub ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-22 9:32 ` Martin Liška 2022-01-22 9:35 ` Jakub Jelinek @ 2022-01-22 12:16 ` Jakub Jelinek 2022-01-22 18:03 ` Jakub Jelinek 1 sibling, 1 reply; 14+ messages in thread From: Jakub Jelinek @ 2022-01-22 12:16 UTC (permalink / raw) To: Martin Liška; +Cc: soeren, gcc-patches 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? 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. Untested and I don't have cycles to test this right now. 2022-01-22 Jakub Jelinek <jakub@redhat.com> * common/config/s390/s390-common.cc (s390_supports_split_stack): Re-add ATTRIBUTE_UNUSED to opts parameter. If OPTION_GLIBC is defined and SINGLE_LIBC is defined too, use OPTION_GLIBC as condition, otherwise if OPTION_GLIBC is defined, use opts->x_linux_libc == LIBC_GLIBC as condition, otherwise assume if (false). * common/config/i386/i386-common.cc (ix86_supports_split_stack): If OPTION_GLIBC is defined and SINGLE_LIBC is defined too, use !OPTION_GLIBC as condition, otherwise if OPTION_GLIBC is defined, use opts->x_linux_libc != LIBC_GLIBC as condition, otherwise assume if (true). --- gcc/common/config/s390/s390-common.cc.jj 2022-01-21 22:43:22.847719836 +0100 +++ gcc/common/config/s390/s390-common.cc 2022-01-22 13:05:31.205118265 +0100 @@ -121,10 +121,16 @@ s390_handle_option (struct gcc_options * static bool s390_supports_split_stack (bool report, - struct gcc_options *opts) + struct gcc_options *opts ATTRIBUTE_UNUSED) { +#ifdef OPTION_GLIBC +#ifdef SINGLE_LIBC + if (OPTION_GLIBC) +#else if (opts->x_linux_libc == LIBC_GLIBC) +#endif 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 12:02:24.572563780 +0100 +++ gcc/common/config/i386/i386-common.cc 2022-01-22 13:07:12.223700957 +0100 @@ -1717,9 +1717,13 @@ static bool ix86_supports_split_stack (bool report, struct gcc_options *opts ATTRIBUTE_UNUSED) { -#ifdef TARGET_THREAD_SPLIT_STACK_OFFSET +#if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC) +#ifdef SINGLE_LIBC + if (!OPTION_GLIBC) +#else if (opts->x_linux_libc != LIBC_GLIBC) #endif +#endif { if (report) error ("%<-fsplit-stack%> currently only supported on GNU/Linux"); > > Cheers, > Martin Jakub ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-22 12:16 ` Jakub Jelinek @ 2022-01-22 18:03 ` Jakub Jelinek 2022-01-23 9:06 ` Uros Bizjak 2022-01-24 9:33 ` Jakub Jelinek 0 siblings, 2 replies; 14+ messages in thread From: Jakub Jelinek @ 2022-01-22 18:03 UTC (permalink / raw) To: Martin Liška, gcc-patches, soeren 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-22 18:03 ` Jakub Jelinek @ 2022-01-23 9:06 ` Uros Bizjak 2022-01-23 10:06 ` Jakub Jelinek 2022-01-24 9:33 ` Jakub Jelinek 1 sibling, 1 reply; 14+ messages in thread From: Uros Bizjak @ 2022-01-23 9:06 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Martin Liška, gcc-patches, soeren On Sat, Jan 22, 2022 at 7:04 PM Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > 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). I wonder why every target defines its own set of #defines. I'd expect that they include toplevel gcc/config/linux.h and inherit these defines from it. Uros. > > --- 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 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-23 9:06 ` Uros Bizjak @ 2022-01-23 10:06 ` Jakub Jelinek 0 siblings, 0 replies; 14+ messages in thread From: Jakub Jelinek @ 2022-01-23 10:06 UTC (permalink / raw) To: Uros Bizjak; +Cc: Martin Liška, gcc-patches, soeren On Sun, Jan 23, 2022 at 10:06:24AM +0100, Uros Bizjak wrote: > > 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). > > I wonder why every target defines its own set of #defines. I'd expect > that they include toplevel gcc/config/linux.h and inherit these > defines from it. Not every target, most of the Linux targets do use config/linux.h, just ppc* and alpha haven't been converted to do so. It would be nice to have that done at some point, but to me that looks like stage1 task rather than stage4. Jakub ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-22 18:03 ` Jakub Jelinek 2022-01-23 9:06 ` Uros Bizjak @ 2022-01-24 9:33 ` Jakub Jelinek 2022-01-24 10:09 ` Richard Biener 1 sibling, 1 reply; 14+ messages in thread From: Jakub Jelinek @ 2022-01-24 9:33 UTC (permalink / raw) To: Richard Biener, Jeff Law; +Cc: Martin Liška, gcc-patches, soeren On Sat, Jan 22, 2022 at 07:03:48PM +0100, Jakub Jelinek via Gcc-patches wrote: > 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. Bootstrapped/regtested on x86_64-linux and i686-linux now, ok for trunk? > 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). Jakub ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Disable -fsplit-stack support on non-glibc targets 2022-01-24 9:33 ` Jakub Jelinek @ 2022-01-24 10:09 ` Richard Biener 0 siblings, 0 replies; 14+ messages in thread From: Richard Biener @ 2022-01-24 10:09 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Jeff Law, Martin Liška, gcc-patches, soeren On Mon, 24 Jan 2022, Jakub Jelinek wrote: > On Sat, Jan 22, 2022 at 07:03:48PM +0100, Jakub Jelinek via Gcc-patches wrote: > > 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. > > Bootstrapped/regtested on x86_64-linux and i686-linux now, ok for trunk? OK. Thanks, Richard. > > 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). > > Jakub > > -- Richard Biener <rguenther@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg) ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-01-28 19:25 UTC | newest] Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-25 15:27 [PATCH] Disable -fsplit-stack support on non-glibc targets David Edelsohn 2022-01-28 19:25 ` Iain Sandoe -- strict thread matches above, loose matches on Subject: below -- 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 2022-01-22 9:32 ` Martin Liška 2022-01-22 9:35 ` Jakub Jelinek 2022-01-22 12:16 ` Jakub Jelinek 2022-01-22 18:03 ` Jakub Jelinek 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
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).