From patchwork Sun Nov 3 20:58:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 288081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 13C8D2C0369 for ; Mon, 4 Nov 2013 07:59:08 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:subject:date:message-id:cc:to:mime-version; q=dns; s=default; b=BCpymSZ8pNO6s7nGBeaYhaQhOSoatoOqMYFED1M+3u0eUJ/2o6 VAP1wz82o5ICAmIjFTL4PZCb/TLtr4dTPLJwNvnKFIeuXHF0VK+NiSEw/LAg48XM PjXITMOrodL4F1Hadfx3KNDeRWsMS/TmlfSmse2+0MosVH6I2hUY5efTI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:subject:date:message-id:cc:to:mime-version; s= default; bh=4kNnaNfSc+0uo5vi8Sac2l+DxrM=; b=PB8vVWRlIESsxO3auP+k abcC5M44mpdHmC9yBdZUFyV01t+mKVQLY5Q61hf1aLXz20wLanRPESi2E1PozC2d 9iuPhc2AS8YIS5LCAhI2nGzr+UOyh+gRXeTToXsBILQVot9XCpaC9qi6LmjqKlSF oCX6NmbdR4od60yX+owK+YE= Received: (qmail 12108 invoked by alias); 3 Nov 2013 20:58:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12098 invoked by uid 89); 3 Nov 2013 20:58:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, RDNS_NONE autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Nov 2013 20:58:55 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Vd4kp-0005Wy-8y from Iain_Sandoe@mentor.com ; Sun, 03 Nov 2013 12:58:39 -0800 Received: from SVR-IES-FEM-02.mgc.mentorg.com ([137.202.0.106]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 3 Nov 2013 12:58:39 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.2.247.3; Sun, 3 Nov 2013 20:58:36 +0000 From: Iain Sandoe Subject: [Patch, ObjC, ObjC++, Darwin] Remove "-fobjc-sjlj-exceptions" Date: Sun, 3 Nov 2013 20:58:32 +0000 Message-ID: <3F3F586F-6A1E-42DB-9A5D-CB9AF39217A7@codesourcery.com> CC: "Joseph S. Myers" , Mike Stump , Nicola Pero To: gcc patches MIME-Version: 1.0 (Apple Message framework v1283) The Objective C/C++ exceptions model is, currently, completely determined by the combination of runtime {gnu, next} and ABI {m32/V1, m64/V2}. Thus, the "-fobjc-sjlj-exceptions" command line option is redundant and may be removed. (note that trunk clang doesn't even accept the option, although xcode 4.6.3 still does). The patch below removes the action of the flag, and produces a warning if the User puts it on a c/l. This has been in use for some time on my *-darwin* systems and has been tested also on x86_64-linux. The option is apparently undocumented in the current User's manual, hence, there are no adjustments to documentation. OK for trunk? Iain gcc/c-family: * c-opts.c (c_common_post_options): Remove handling of flag_objc_sjlj_exceptions. * c.opt (fobjc-sjlj-exceptions): Issue a warning if this option is given. gcc: * config/darwin.c (darwin_override_options): Remove handling of flag_objc_sjlj_exceptions. gcc/objc: * objc-act.c (objc_begin_try_stmt): Find the exceptions model in force from the runtime structure rather than a command line flag. * objc-gnu-runtime-abi-01.c (objc_gnu_runtime_abi_01_init): Set up the exceptions model and handle conflicting User selections. * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Likewise. * objc-next-runtime-abi-01.c (OBJC_SJLJ_EXCEPTIONS): Define true. (objc_next_runtime_abi_01_init): Set up the exceptions model and handle conflicting User selections. (next_runtime_01_initialize, objc_build_exc_ptr, finish_try_stmt): Use OBJC_SJLJ_EXCEPTIONS rather than a flag. * objc-runtime-hooks.h (objc_exceptions_model_t): New enum. (objc_runtime_hooks): Add exceptions model. gcc/c-family/c-opts.c | 6 ------ gcc/c-family/c.opt | 4 ++-- gcc/config/darwin.c | 12 ------------ gcc/objc/objc-act.c | 2 +- gcc/objc/objc-gnu-runtime-abi-01.c | 18 +++++++++++++----- gcc/objc/objc-next-runtime-abi-01.c | 20 ++++++++++---------- gcc/objc/objc-next-runtime-abi-02.c | 20 +++++++++++++++----- gcc/objc/objc-runtime-hooks.h | 12 ++++++++++++ 8 files changed, 53 insertions(+), 41 deletions(-) diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 702fe1a..9d0b972 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -834,12 +834,6 @@ 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. */ - if (flag_objc_sjlj_exceptions < 0) - flag_objc_sjlj_exceptions = flag_next_runtime; - if (flag_objc_exceptions && !flag_objc_sjlj_exceptions) - flag_exceptions = 1; - /* -Woverlength-strings is off by default, but is enabled by -Wpedantic. It is never enabled in C++, as the minimum limit is not normative in that standard. */ diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index b862eb9..23646f3 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1058,8 +1058,8 @@ Enable inline checks for nil receivers with the NeXT runtime and ABI version 2. ; Nonzero means that we generate NeXT setjmp based exceptions. fobjc-sjlj-exceptions -ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1) -Enable Objective-C setjmp exception handling runtime +ObjC ObjC++ Ignore Warn(switch %qs has been removed and is set automatically where required) +Option removed fobjc-std=objc1 ObjC ObjC++ Var(flag_objc1_only) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index fc7a9a8..3bf30db 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -3126,18 +3126,6 @@ darwin_override_options (void) flag_reorder_blocks = 1; } - /* FIXME: flag_objc_sjlj_exceptions is no longer needed since there is only - one valid choice of exception scheme for each runtime. */ - if (!global_options_set.x_flag_objc_sjlj_exceptions) - global_options.x_flag_objc_sjlj_exceptions = - flag_next_runtime && !TARGET_64BIT; - - /* FIXME: and this could be eliminated then too. */ - if (!global_options_set.x_flag_exceptions - && flag_objc_exceptions - && TARGET_64BIT) - flag_exceptions = 1; - if (flag_mkernel || flag_apple_kext) { /* -mkernel implies -fapple-kext for C++ */ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 95ec4ec..6103b3b 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -4126,7 +4126,7 @@ objc_begin_try_stmt (location_t try_locus, tree body) /* Collect the list of local variables. We'll mark them as volatile at the end of compilation of this function to prevent them being clobbered by setjmp/longjmp. */ - if (flag_objc_sjlj_exceptions) + if (runtime.exceptions_model == objc_exceptions_sjlj) objc_mark_locals_volatile (NULL); } diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c index f011683..fdcd409 100644 --- a/gcc/objc/objc-gnu-runtime-abi-01.c +++ b/gcc/objc/objc-gnu-runtime-abi-01.c @@ -132,12 +132,20 @@ objc_gnu_runtime_abi_01_init (objc_runtime_hooks *rthooks) flag_objc_gc = 0; } - /* Although I guess we could, we don't currently support SJLJ exceptions for the - GNU runtime. */ - if (flag_objc_sjlj_exceptions) + /* Objective C exceptions implies -fexceptions for the GNU Runtime. */ + if (flag_objc_exceptions) { - inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for %<-fgnu-runtime%>"); - flag_objc_sjlj_exceptions = 0; + /* GNU runtime uses dwarf unwinding. */ + rthooks->exceptions_model = objc_exceptions_dwarf; + + /* If the User has not specified fexceptions, set it silently. */ + if (!global_options_set.x_flag_exceptions) + flag_exceptions = 1; + else if (!flag_exceptions) + /* If the User has explicitly specified -fno-exceptions together + with -fobjc-exceptions, this is an error. */ + error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires" + "%<-fexceptions%> for the GNU runtime"); } /* TODO: Complain if -fobjc-abi-version=N was used. */ diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 000256d..dcaa0d7 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -97,6 +97,9 @@ along with GCC; see the file COPYING3. If not see #define CLS_HAS_CXX_STRUCTORS 0x2000L +/* For this ABI, there is no choice but to use sjlj, presently. */ +#define OBJC_SJLJ_EXCEPTIONS true + /* rt_trees identifiers - shared between NeXT implementations. These allow the FE to tag meta-data in a manner that survives LTO and can be used when the runtime requires that certain meta-data items @@ -144,13 +147,9 @@ static tree finish_try_stmt (struct objc_try_context **); bool objc_next_runtime_abi_01_init (objc_runtime_hooks *rthooks) { - if (flag_objc_exceptions - && !flag_objc_sjlj_exceptions) - { - warning_at (UNKNOWN_LOCATION, OPT_Wall, - "%<-fobjc-sjlj-exceptions%> is the only supported exceptions " - "system for %<-fnext-runtime%> with %<-fobjc-abi-version%> < 2"); - } + /* NeXT V0/1 Objective-C and Objective-C++ exceptions (i.e. @throw) are + SjLj exceptions. */ + rthooks->exceptions_model = objc_exceptions_sjlj; rthooks->initialize = next_runtime_01_initialize; rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME; @@ -383,7 +382,7 @@ static void next_runtime_01_initialize (void) objc_setPropertyStruct_decl = NULL_TREE; build_next_objc_exception_stuff (); - if (flag_objc_exceptions && !flag_objc_sjlj_exceptions) + if (flag_objc_exceptions && !OBJC_SJLJ_EXCEPTIONS) using_eh_for_cleanups (); lang_hooks.eh_runtime_type = objc_eh_runtime_type; lang_hooks.eh_personality = objc_eh_personality; @@ -2847,6 +2846,7 @@ objc_eh_personality (void) { if (!objc_eh_personality_decl) #ifndef OBJCPLUS + /* The personality for ABI=0,1 is just the gcc one. */ objc_eh_personality_decl = build_personality_function ("gcc"); #else objc_eh_personality_decl = build_personality_function ("gxx"); @@ -2877,7 +2877,7 @@ build_throw_stmt (location_t loc, tree throw_expr, bool rethrown ATTRIBUTE_UNUSE static tree objc_build_exc_ptr (struct objc_try_context **cur_try_context) { - if (flag_objc_sjlj_exceptions) + if (OBJC_SJLJ_EXCEPTIONS) { tree var = (*cur_try_context)->caught_decl; if (!var) @@ -2925,7 +2925,7 @@ finish_try_stmt (struct objc_try_context **cur_try_context) tree stmt; struct objc_try_context *c = *cur_try_context; /* If we're doing Darwin setjmp exceptions, build the big nasty. */ - if (flag_objc_sjlj_exceptions) + if (OBJC_SJLJ_EXCEPTIONS) { bool save = in_late_binary_op; in_late_binary_op = true; diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 0960006..8762a6f 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -239,11 +239,20 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks) { extern_names = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE); - if (flag_objc_exceptions && flag_objc_sjlj_exceptions) + if (flag_objc_exceptions) { - inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for " - "%<-fnext-runtime%> when %<-fobjc-abi-version%> >= 2"); - flag_objc_sjlj_exceptions = 0; + /* NeXT ABI v2 runtime uses dwarf unwinding. */ + rthooks->exceptions_model = objc_exceptions_dwarf; + + /* If the User has not specified fexceptions, set it silently. */ + if (!global_options_set.x_flag_exceptions) + flag_exceptions = 1; + else if (!flag_exceptions) + /* If the User has explicitly specified -fno-exceptions together + with -fobjc-exceptions, this is an error. */ + error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires" + "%<-fexceptions%> for the 64 bit NeXT" + " runtime"); } rthooks->initialize = next_runtime_02_initialize; @@ -478,7 +487,8 @@ static void next_runtime_02_initialize (void) objc_getPropertyStruct_decl = NULL_TREE; objc_setPropertyStruct_decl = NULL_TREE; - gcc_assert (!flag_objc_sjlj_exceptions); + gcc_checking_assert (!flag_objc_exceptions + || (runtime.exceptions_model == objc_exceptions_dwarf)); /* Although we warn that fobjc-exceptions is required for exceptions code, we carry on and create it anyway. */ diff --git a/gcc/objc/objc-runtime-hooks.h b/gcc/objc/objc-runtime-hooks.h index c6de986..badf899 100644 --- a/gcc/objc/objc-runtime-hooks.h +++ b/gcc/objc/objc-runtime-hooks.h @@ -33,6 +33,15 @@ along with GCC; see the file COPYING3. If not see and so on, and the purpose of this interface is to abstract such differences from the parser's perspective. */ +/* Currently, two different exceptions models are used (depends on which + runtime and ABI is selected). */ + +typedef enum { + objc_exceptions_unk = 0, + objc_exceptions_sjlj, + objc_exceptions_dwarf +} objc_exceptions_model_t; + /* TODO: Do we want the initial underscore ? */ typedef struct _objc_runtime_hooks_r { @@ -97,6 +106,9 @@ typedef struct _objc_runtime_hooks_r during parsing. */ void (*generate_metadata) (void); + /* What kind of exceptions code to generate. */ + objc_exceptions_model_t exceptions_model; + } objc_runtime_hooks; /* For shared support that needs to access these. */