From patchwork Fri Dec 17 14:34:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 75902 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]) by ozlabs.org (Postfix) with SMTP id 9D584B6ED0 for ; Sat, 18 Dec 2010 01:34:36 +1100 (EST) Received: (qmail 10926 invoked by alias); 17 Dec 2010 14:34:33 -0000 Received: (qmail 10771 invoked by uid 22791); 17 Dec 2010 14:34:32 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_BJ, TW_JL X-Spam-Check-By: sourceware.org Received: from c2beaomr06.btconnect.com (HELO mail.btconnect.com) (213.123.26.184) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Dec 2010 14:34:24 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2beaomr06.btconnect.com with ESMTP id BHV33976; Fri, 17 Dec 2010 14:34:17 +0000 (GMT) Message-Id: From: IainS To: GCC Patches Mime-Version: 1.0 (Apple Message framework v936) Subject: [Patch ObjC] fix objc.dg/exceptions2.m linkage error. Date: Fri, 17 Dec 2010 14:34:16 +0000 Cc: Mike Stump , Nicola Pero X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0302.4D0B74E8.0154, actions=TAG X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0209.4D0B74EE.006D, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine X-IsSubscribed: yes 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 The NeXT runtime library names its m64 personality routine "___objc_personality_v0" So, in addition to the change to switch off sjlj exceptions (which causes linkage errors for the absent sjlj routines), we also need to generate the right name for the eh personality... OK? Iain objc: * objc/objc-act.c (objc_eh_personality): Select personality name on runtime. (objc_init_exceptions): New. (objc_begin_try_stmt): Use objc_init_exceptions. (objc_build_throw_stmt): Likewise. Index: gcc/objc/objc-act.c =================================================================== --- gcc/objc/objc-act.c (revision 167976) +++ gcc/objc/objc-act.c (working copy) @@ -5028,11 +5028,41 @@ tree objc_eh_personality (void) { if (!flag_objc_sjlj_exceptions && !objc_eh_personality_decl) - objc_eh_personality_decl = build_personality_function ("gnu_objc"); + objc_eh_personality_decl = build_personality_function + (flag_next_runtime + ? "objc" + : "gnu_objc"); return objc_eh_personality_decl; } #endif +static void +objc_init_exceptions (location_t loc) +{ + static bool done = false; + + /* -fobjc-exceptions is required to enable Objective-C exceptions. + For example, on Darwin, ObjC exceptions require a sufficiently + recent version of the runtime, so the user must ask for them + explicitly. On other platforms, at the moment -fobjc-exceptions + triggers -fexceptions which again is required for exceptions to + work. + */ + if (!flag_objc_exceptions) + { + error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); + } + + /* We could arrange for only one warning - by moving this before the check. */ + if (done) + return; + done = true; + +#ifndef OBJCPLUS + using_eh_for_cleanups (); +#endif +} + /* Build __builtin_eh_pointer, or the moral equivalent. In the case of Darwin, we'll arrange for it to be initialized (and associated with a binding) later. */ @@ -5334,17 +5364,7 @@ objc_begin_try_stmt (location_t try_locus, tree bo c->end_try_locus = input_location; cur_try_context = c; - /* -fobjc-exceptions is required to enable Objective-C exceptions. - For example, on Darwin, ObjC exceptions require a sufficiently - recent version of the runtime, so the user must ask for them - explicitly. On other platforms, at the moment -fobjc-exceptions - triggers -fexceptions which again is required for exceptions to - work. - */ - if (!flag_objc_exceptions) - { - error_at (try_locus, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); - } + objc_init_exceptions (try_locus); /* Collect the list of local variables. We'll mark them as volatile at the end of compilation of this function to prevent them being @@ -5552,10 +5572,7 @@ objc_build_throw_stmt (location_t loc, tree throw_ { tree args; - if (!flag_objc_exceptions) - { - error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); - } + objc_init_exceptions (loc); if (throw_expr == NULL) {