From patchwork Sun Apr 8 11:38:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 151356 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 254A8B7016 for ; Sun, 8 Apr 2012 21:38:35 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1334489916; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Cc:Message-Id:From:To:In-Reply-To:Content-Type: Mime-Version:Subject:Date:References:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=4oWcpZvojGpbyKiMhEcKoYY7+7I=; b=CmeBRmeFvNwsvFe ZHKemuApu8UOyD0QLO0m6/3qtwVjWBvZdTldebeyJ6eimhOneXj2q0Ps777HMqfY YqGyyhgUF6NQyr1Sqz0cT2w6AtVO+w+6BOOv7IpGG4/HmCdARvdMuDerm1fOz/e+ RGHl9JEikBfidaU59xjnEyPzqDm4= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Cc:Message-Id:From:To:In-Reply-To:Content-Type:Mime-Version:Subject:Date:References:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mrNXgmg8HVyWJ93h2XevqXul9MdqvAN5WryOx1h0lQ2ICNm/96RIA+jm0mBx4k +guBSvaxbbJLeh1pErU8VttvWLbFzUgcafX04FztSqczMMg1gDBlDH4VHb8LcaRB AEcjJ9YgH/jQKzaEc0Xvy8Uw0LZZG1xLGvN38wMHkXG84=; Received: (qmail 25310 invoked by alias); 8 Apr 2012 11:38:32 -0000 Received: (qmail 25302 invoked by uid 22791); 8 Apr 2012 11:38:31 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_BJ X-Spam-Check-By: sourceware.org Received: from mail-we0-f175.google.com (HELO mail-we0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 08 Apr 2012 11:38:17 +0000 Received: by wera1 with SMTP id a1so2419815wer.20 for ; Sun, 08 Apr 2012 04:38:16 -0700 (PDT) Received: by 10.180.95.34 with SMTP id dh2mr8644000wib.15.1333885096378; Sun, 08 Apr 2012 04:38:16 -0700 (PDT) Received: from thor.office (host86-180-184-90.range86-180.btcentralplus.com. [86.180.184.90]) by mx.google.com with ESMTPS id ff2sm35372396wib.9.2012.04.08.04.38.14 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 Apr 2012 04:38:15 -0700 (PDT) Cc: "Joseph S. Myers" , Mike Stump , GCC Patches Message-Id: <9959DE37-E2EC-4361-B555-3B7192C742CF@googlemail.com> From: Iain Sandoe To: "H.J. Lu" In-Reply-To: <20120331192444.GA15969@bromo.med.uc.edu> Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2 Date: Sun, 8 Apr 2012 12:38:13 +0100 References: <28756905-85A0-4319-93CB-CC35D0601F96@comcast.net> <20120330180556.GA9392@bromo.med.uc.edu> <20120330202328.GA9998@bromo.med.uc.edu> <20120331192444.GA15969@bromo.med.uc.edu> 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 Hi H.J. On 31 Mar 2012, at 20:24, Jack Howarth wrote: > > The latest gcc-pr52784-2.patch patch also allows current gcc trunk > to > bootstrap on i386-apple-darwin10. Despite the fact that bootstrap is restored, there remain problems with this patch and some more work is needed. (a) [trivial] the option 'mx32' is in i386.opt, which means it is exposed to all sub-targets, even if they don't support it. $ ./gcc/xgcc -Bgcc ../tests/hello.c -mx32 -o hc /var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:10:bad register name `%rbp' /var/folders/OW/OW-PGOtgHbKakssxFpJpkU++-0E/-Tmp-//ccIP9e4Z.s:14:bad register name `%rsi' etc. etc. (b) [serious] the m64 ObjC multi-lib is broken on i?86-darwin* (and likely there are other more subtle effects). This is because the code in config/darwin.c that Joseph pointed out (earlier in this thread) is called for SUBSUBTARGET_OVERRIDE_OPTIONS. That code sets defaults for, and checks errors for, flags that apply to *-*-darwin* (and are needed for LTO as well as c-family). In the case of the ObjC ABI (fobjc-abi-version=) we need to default it to "2" @ m64 (and default it to 0 or 1 depending on the darwin version @ m32). I accept that some of this could possibly be done in driver-self- specs; however, we allow m32/m64 to be unspecified on the c/l and to default for the target. I'm also not yet sure whether %:version- compare() would be applicable to fobjc-abi-version. Thus, the current trunk implementation is broken by your patch and we need to address that pending other solutions (I'm also very short of free time for Darwin right now - to experiment with the specs solution). =--= It is possible that there is an options handling issue, (although I might also have misunderstood) viz: ========= (current) i386.opt: ;; ISA support m32 Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) Var(ix86_isa_flags) Save Generate 32bit i386 code m64 Target RejectNegative Negative(mx32) Report Mask(ABI_64) Var(ix86_isa_flags) Save Generate 64bit x86-64 code mx32 Target RejectNegative Negative(m32) Report Mask(ABI_X32) Var(ix86_isa_flags) Save Generate 32bit x86-64 code ======= from gccint.pdf (section 8.2): Negative(othername ) The option will turn off another option othername, which is the option name with the leading “-” removed. This chain action will propagate through the Negative property of the option to be turned off. As a consequence, if you have a group of mutually-exclusive options, their Negative properties should form a circular chain. For example, if options ‘-a ’, ‘-b ’ and ‘-c ’ are mutually exclusive, their respective Negative properties should be ‘Negative(b )’, ‘Negative(c )’ and ‘Negative(a )’. ====== I read this as "if the User specifies -a on the command line the inverse of -b *and* the inverse of -c will be applied". so that when -m64 is issued, the *inverse* of Mask(ABI_X32) should be applied and then the *inverse* of InverseMask(ISA_64BIT) - which would (correctly, for the case we're considering) set MASK_ISA_64BIT. However, in the example above this does NOT happen - if I set a breakpoint at the entry of x86_internal_override_options - ISA_64BIT ends up as 0 when -m64 is specified on the c/l for i?86-darwin*. The x86_isa_explicit stuff doesn't appear to get set either, although global_options_set.x_x86_isa... does, which I've used in the attached patch. so is this an options bug or misunderstanding on my part? ===== An interim solution to the current scenario (tested by the chaps across the darwin range) is attached. Is that OK for trunk? NOTE: I can't apply any patch at present, unless it's considered to be trivial, since my personal FSF (c) assignment is in the process of being transferred to my new employer. cheers Iain Index: gcc/config/i386/darwin.h =================================================================== --- gcc/config/i386/darwin.h (revision 186156) +++ gcc/config/i386/darwin.h (working copy) @@ -231,11 +231,26 @@ extern int darwin_emit_branch_islands; SUBTARGET_C_COMMON_OVERRIDE_OPTIONS; \ } while (0) +/* This macros gets the first opportunity to check/modify flags. + In this case we need to sort out the ABI/ISA mask flags here because + we want to act on them in SUBSUBTARGET_OVERRIDE_OPTIONS. */ + #undef SUBTARGET_OVERRIDE_OPTIONS #define SUBTARGET_OVERRIDE_OPTIONS \ do { \ + /* As of darwin 11/OSX 10.7, mx32 has no implementation for darwin. */\ + if (TARGET_X32) \ + error_at (UNKNOWN_LOCATION, \ + "%<-mx32%> is not valid for Darwin/Mac OS X"); \ + /* Furthermore, explicit LP64 implies ISA_64BIT. */ \ + if (TARGET_LP64 \ + && (global_options_set.x_ix86_isa_flags & OPTION_MASK_ABI_64)) \ + ix86_isa_flags |= OPTION_MASK_ISA_64BIT; \ + /* No non-PIC code for m64, so far. */ \ if (TARGET_64BIT && MACHO_DYNAMIC_NO_PIC_P) \ target_flags &= ~MASK_MACHO_DYNAMIC_NO_PIC; \ + if (TARGET_64BIT) \ + flag_pic = 2; \ } while (0) /* Darwin on x86_64 uses dwarf-2 by default. Pre-darwin9 32-bit Index: gcc/config/darwin.c =================================================================== --- gcc/config/darwin.c (revision 186156) +++ gcc/config/darwin.c (working copy) @@ -3005,6 +3005,18 @@ 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; + + /* ... 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++ */ Index: gcc/config/darwin.h =================================================================== --- gcc/config/darwin.h (revision 186156) +++ gcc/config/darwin.h (working copy) @@ -140,9 +140,6 @@ extern GTY(()) int darwin_ms_struct; } while (0) #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do { \ - if (!global_options_set.x_flag_objc_sjlj_exceptions) \ - global_options.x_flag_objc_sjlj_exceptions = \ - flag_next_runtime && !TARGET_64BIT; \ if (flag_mkernel || flag_apple_kext) \ { \ if (flag_use_cxa_atexit == 2) \