public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI
@ 2021-07-29  3:35 Matt Jacobson
  2021-08-02 21:09 ` Eric Gallager
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Jacobson @ 2021-07-29  3:35 UTC (permalink / raw)
  To: gcc-patches

As is, an invocation of GCC with -fnext-runtime -fobjc-abi-version=2 crashes, 
unless target-specific code adds an implicit -fno-objc-sjlj-exceptions (which 
Darwin does).

This patch makes the general case not crash.

I don't have commit access, so if this patch is suitable, I'd need someone else
to commit it for me.  Thanks.

gcc/objc/ChangeLog:

2021-07-28  Matt Jacobson  <mhjacobson@me.com>

	* objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Warn
	about and reset	flag_objc_sjlj_exceptions regardless of
	flag_objc_exceptions.


gcc/c-family/ChangeLog:

2021-07-28  Matt Jacobson  <mhjacobson@me.com>

	* c-opts.c (c_common_post_options): Default to
	flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2.

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index c51d6d34726..2568df67972 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -840,9 +840,9 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
 
-  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
+  /* Default to ObjC sjlj exception handling if NeXT <v2 runtime.  */
   if (flag_objc_sjlj_exceptions < 0)
-    flag_objc_sjlj_exceptions = flag_next_runtime;
+    flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
   if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
     flag_exceptions = 1;
 
diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c
index 66c13ad0db2..9a0868410a8 100644
--- a/gcc/objc/objc-next-runtime-abi-02.c
+++ b/gcc/objc/objc-next-runtime-abi-02.c
@@ -245,7 +245,7 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
 {
   extern_names = ggc_cleared_vec_alloc<hash> (SIZEHASHTABLE);
 
-  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
+  if (flag_objc_sjlj_exceptions)
     {
       inform (UNKNOWN_LOCATION,
              "%<-fobjc-sjlj-exceptions%> is ignored for "


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI
  2021-07-29  3:35 [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI Matt Jacobson
@ 2021-08-02 21:09 ` Eric Gallager
  2021-08-02 21:37   ` Matt Jacobson
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Gallager @ 2021-08-02 21:09 UTC (permalink / raw)
  To: Matt Jacobson; +Cc: gcc-patches

On Wed, Jul 28, 2021 at 11:36 PM Matt Jacobson via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> As is, an invocation of GCC with -fnext-runtime -fobjc-abi-version=2 crashes,
> unless target-specific code adds an implicit -fno-objc-sjlj-exceptions (which
> Darwin does).
>
> This patch makes the general case not crash.
>
> I don't have commit access, so if this patch is suitable, I'd need someone else
> to commit it for me.  Thanks.

Is there a bug open for the issue that this fixes? Just wondering for
cross-referencing purposes...

>
> gcc/objc/ChangeLog:
>
> 2021-07-28  Matt Jacobson  <mhjacobson@me.com>
>
>         * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Warn
>         about and reset flag_objc_sjlj_exceptions regardless of
>         flag_objc_exceptions.
>
>
> gcc/c-family/ChangeLog:
>
> 2021-07-28  Matt Jacobson  <mhjacobson@me.com>
>
>         * c-opts.c (c_common_post_options): Default to
>         flag_objc_sjlj_exceptions = 1 only when flag_objc_abi < 2.
>
> diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
> index c51d6d34726..2568df67972 100644
> --- a/gcc/c-family/c-opts.c
> +++ b/gcc/c-family/c-opts.c
> @@ -840,9 +840,9 @@ c_common_post_options (const char **pfilename)
>    else if (!flag_gnu89_inline && !flag_isoc99)
>      error ("%<-fno-gnu89-inline%> is only supported in GNU99 or C99 mode");
>
> -  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
> +  /* Default to ObjC sjlj exception handling if NeXT <v2 runtime.  */
>    if (flag_objc_sjlj_exceptions < 0)
> -    flag_objc_sjlj_exceptions = flag_next_runtime;
> +    flag_objc_sjlj_exceptions = (flag_next_runtime && flag_objc_abi < 2);
>    if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
>      flag_exceptions = 1;
>
> diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c
> index 66c13ad0db2..9a0868410a8 100644
> --- a/gcc/objc/objc-next-runtime-abi-02.c
> +++ b/gcc/objc/objc-next-runtime-abi-02.c
> @@ -245,7 +245,7 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
>  {
>    extern_names = ggc_cleared_vec_alloc<hash> (SIZEHASHTABLE);
>
> -  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
> +  if (flag_objc_sjlj_exceptions)
>      {
>        inform (UNKNOWN_LOCATION,
>               "%<-fobjc-sjlj-exceptions%> is ignored for "
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI
  2021-08-02 21:09 ` Eric Gallager
@ 2021-08-02 21:37   ` Matt Jacobson
  2021-08-03 18:39     ` Iain Sandoe
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Jacobson @ 2021-08-02 21:37 UTC (permalink / raw)
  To: Eric Gallager; +Cc: gcc-patches



> On Aug 2, 2021, at 5:09 PM, Eric Gallager <egall@gwmail.gwu.edu> wrote:
> 
> On Wed, Jul 28, 2021 at 11:36 PM Matt Jacobson via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> 
>> As is, an invocation of GCC with -fnext-runtime -fobjc-abi-version=2 crashes,
>> unless target-specific code adds an implicit -fno-objc-sjlj-exceptions (which
>> Darwin does).
>> 
>> This patch makes the general case not crash.
>> 
>> I don't have commit access, so if this patch is suitable, I'd need someone else
>> to commit it for me.  Thanks.
> 
> Is there a bug open for the issue that this fixes? Just wondering for
> cross-referencing purposes...

No, I didn’t file a bug for this one, just sent the patch directly.  Hope 
that’s OK.  If not, happy to file one.

Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI
  2021-08-02 21:37   ` Matt Jacobson
@ 2021-08-03 18:39     ` Iain Sandoe
  2021-08-11  2:06       ` Matt Jacobson
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Sandoe @ 2021-08-03 18:39 UTC (permalink / raw)
  To: Matt Jacobson; +Cc: Eric Gallager, gcc-patches



> On 2 Aug 2021, at 22:37, Matt Jacobson via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> 
>> On Aug 2, 2021, at 5:09 PM, Eric Gallager <egall@gwmail.gwu.edu> wrote:
>> 
>> On Wed, Jul 28, 2021 at 11:36 PM Matt Jacobson via Gcc-patches
>> <gcc-patches@gcc.gnu.org> wrote:
>>> 
>>> As is, an invocation of GCC with -fnext-runtime -fobjc-abi-version=2 crashes,
>>> unless target-specific code adds an implicit -fno-objc-sjlj-exceptions (which
>>> Darwin does).
>>> 
>>> This patch makes the general case not crash.
>>> 
>>> I don't have commit access, so if this patch is suitable, I'd need someone else
>>> to commit it for me.  Thanks.
>> 
>> Is there a bug open for the issue that this fixes? Just wondering for
>> cross-referencing purposes...
> 
> No, I didn’t file a bug for this one, just sent the patch directly.  Hope 
> that’s OK.  If not, happy to file one.

I have this on my TODO (and in my “to apply” patch queue - IMO it’s OK as an interim
solution - but I think in the longer term it would be better to make fobjc-sjlj-exceptions
into a NOP, since the exception models are fixed for NeXT runtime (unless you have
some intent to update the 32bit one to use DWARF unwinding ;-) ).

thanks
Iain


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI
  2021-08-03 18:39     ` Iain Sandoe
@ 2021-08-11  2:06       ` Matt Jacobson
  0 siblings, 0 replies; 5+ messages in thread
From: Matt Jacobson @ 2021-08-11  2:06 UTC (permalink / raw)
  To: Iain Sandoe; +Cc: Eric Gallager, gcc-patches



> On Aug 3, 2021, at 2:39 PM, Iain Sandoe <idsandoe@googlemail.com> wrote:
> 
> 
> 
>> On 2 Aug 2021, at 22:37, Matt Jacobson via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> 
>>> On Aug 2, 2021, at 5:09 PM, Eric Gallager <egall@gwmail.gwu.edu> wrote:
>>> 
>>> On Wed, Jul 28, 2021 at 11:36 PM Matt Jacobson via Gcc-patches
>>> <gcc-patches@gcc.gnu.org> wrote:
>>>> 
>>>> As is, an invocation of GCC with -fnext-runtime -fobjc-abi-version=2 crashes,
>>>> unless target-specific code adds an implicit -fno-objc-sjlj-exceptions (which
>>>> Darwin does).
>>>> 
>>>> This patch makes the general case not crash.
>>>> 
>>>> I don't have commit access, so if this patch is suitable, I'd need someone else
>>>> to commit it for me.  Thanks.
>>> 
>>> Is there a bug open for the issue that this fixes? Just wondering for
>>> cross-referencing purposes...
>> 
>> No, I didn’t file a bug for this one, just sent the patch directly.  Hope 
>> that’s OK.  If not, happy to file one.
> 
> I have this on my TODO (and in my “to apply” patch queue - IMO it’s OK as an interim
> solution - but I think in the longer term it would be better to make fobjc-sjlj-exceptions
> into a NOP, since the exception models are fixed for NeXT runtime (unless you have
> some intent to update the 32bit one to use DWARF unwinding ;-) ).

Thanks.

It certainly isn’t crystal clear just from the diff in the mail, but with this 
patch, -fobjc-sjlj-exceptions *is* essentially a no-op (modulo a small warning) 
under NeXT v2.

Prior to this patch, it’s also a no-op, but (a) it’s initially on by default 
for NeXT v2, which (b) causes a crash unless `-fobjc-exceptions` is also 
specified.

Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-11  2:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  3:35 [PATCH] Objective-C: don't require redundant -fno-objc-sjlj-exceptions for the NeXT v2 ABI Matt Jacobson
2021-08-02 21:09 ` Eric Gallager
2021-08-02 21:37   ` Matt Jacobson
2021-08-03 18:39     ` Iain Sandoe
2021-08-11  2:06       ` Matt Jacobson

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