From patchwork Sun Nov 6 20:53:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 691703 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tBnq41jZNz9t1C for ; Mon, 7 Nov 2016 07:53:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="k0uQrzgb"; dkim-atps=neutral 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:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; q=dns; s=default; b=pS62gH34dAb5XNrn9N/Vcza nzvyoyUq6Alw9UFi8OVfMN0NNFJDKSN5zchaOEd8e12yQwW9gyCqyYcHiPeWq+qN lKENiHqPW2tkGtNQXiNulSoIQU2iM5TzLYLtlbpwWAGHUrmMS8wI6XkTf2kizJaA oysUC32ViqkL5bNgrV1o= 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:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; s=default; bh=hex6d2fZkHbLL74gSTb9wMhurSk=; b= k0uQrzgbUlJh6+3XZaei74NfKb4IoYTsciCQYKg1sYDZQwmu5NdLFT+vHygu+m2s ZwA58URAvr60T4BJnyKeYrhAspt/6iGSRSaCLzGOWrlfJb8YDc6kq0K8heM0NBSV l0b57q5u3CQCpDdO51HK/5cxZAc9axHgMMbFrWFJtf8= Received: (qmail 46115 invoked by alias); 6 Nov 2016 20:53:26 -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 46102 invoked by uid 89); 6 Nov 2016 20:53:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=srcdir, Else, 1030, punt X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 06 Nov 2016 20:53:15 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1c3URC-0002h1-Be from Iain_Sandoe@mentor.com ; Sun, 06 Nov 2016 12:53:10 -0800 Received: from [127.0.0.1] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sun, 6 Nov 2016 20:53:06 +0000 From: Iain Sandoe Subject: [PATCH, Darwin] fix for PR67710 : Update 'as' specs and inputs to handle newer assembler versions. Date: Sun, 6 Nov 2016 12:53:03 -0800 Message-ID: CC: Rainer Orth , Mike Stump To: GCC Patches MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) Hi Folks, This is an updated solution, but on a patch from Rainer Orth (attached to pr67710). A/ Newer versions of ld64 check the min_version command, and newer versions of the system assembler inserts this in response to "-mmacosx-version-min=" on the assembler line. Unless one makes sensible versions, some object is bound to conflict. B/ Additionally, there's a difference in behaviour between "as" and "ld" when presented with xx.yy.zz (ld truncates to xx.yy, as doesn't); net result is that one needs to pass a truncated version to "as". So (if the assembler supports minversion commands) (a) provide a truncated minversion (as asm_macosx_version_min, which is a driver-only var). (b) pass this to "as" (c) Update tests to determine 'HAVE_AS_MMACOSX_VERSION_MIN_OPTION' (Rainer's patch) (d) For some reason the testcases are "run" (it's not obvious they need to be, they are checking compile-time issues) - anyway, to preserve the status quo, I've left them as exec. However, the minimum version that can be code-gened for is target-dependent (there are no x86 versions before 10.4, for example). To avoid conflicts where the "as" is assuming some minimum, I've set the testversion to 10.5 (which is supported by all the archs we have) (e) We need to ensure that libgcc and crts are generated with a sufficiently old minversion not to conflict. OK for trunk? OK for open branches? Iain gcc/ 2016-11-06 Iain Sandoe Rainer Orth target/PR67710 * config.in: Regenerate * config/darwin-driver.c (darwin_driver_init): Emit a version string for the assembler. * config/darwin.h(ASM_MMACOSX_VERSION_MIN_SPEC): New, new tests. * config/darwin.opt(asm_macosx_version_min): New. * config/i386/darwin.h: Handle ASM_MMACOSX_VERSION_MIN_SPEC. * configure: Regenerate * configure.ac: Check for mmacosx-version-min handling. gcc/testsuite/ 2016-11-06 Iain Sandoe Rainer Orth target/PR67710 * gcc.dg/darwin-minversion-1.c: Update min version check. * gcc.dg/darwin-minversion-2.c: Likewise. * gcc.dg/darwin-minversion-3.c: Likewise. libgcc/ 2016-11-06 Iain Sandoe Rainer Orth target/PR67710 * libgcc/config/t-darwin: Default builds to 10.5 codegen. --- gcc/config.in | 7 ++++++ gcc/config/darwin-driver.c | 28 ++++++++++++++++++++- gcc/config/darwin.h | 21 ++++++++++++++-- gcc/config/darwin.opt | 3 +++ gcc/config/i386/darwin.h | 5 ++-- gcc/configure | 39 ++++++++++++++++++++++++++++++ gcc/configure.ac | 14 +++++++++++ gcc/testsuite/gcc.dg/darwin-minversion-1.c | 4 +-- gcc/testsuite/gcc.dg/darwin-minversion-2.c | 4 +-- gcc/testsuite/gcc.dg/darwin-minversion-3.c | 4 +-- libgcc/config/t-darwin | 4 +++ 11 files changed, 122 insertions(+), 11 deletions(-) diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index db8d72c..f80c9ed 100644 --- a/gcc/config/darwin-driver.c +++ b/gcc/config/darwin-driver.c @@ -73,7 +73,8 @@ darwin_find_version_from_kernel (void) component. */ if (major_vers - 4 <= 4) /* On 10.4 and earlier, the old linker is used which does not - support three-component system versions. */ + support three-component system versions. + FIXME: we should not assume this - a newer linker could be used. */ asprintf (&new_flag, "10.%d", major_vers - 4); else asprintf (&new_flag, "10.%d.%s", major_vers - 4, minor_vers); @@ -294,4 +295,29 @@ darwin_driver_init (unsigned int *decoded_options_count, &(*decoded_options)[*decoded_options_count - 1]); } } + /* Create and push the major version for assemblers that need it. */ + if (vers_string != NULL) + { + char *asm_major = NULL; + char *first_period = strchr(vers_string, '.'); + if (first_period != NULL) + { + char *second_period = strchr(first_period+1, '.'); + if (second_period != NULL) + asm_major = xstrndup (vers_string, second_period-vers_string); + else + asm_major = xstrdup (vers_string); + } + /* Else we appear to have a weird macosx version with no major number. + Punt on this for now. */ + if (asm_major != NULL) + { + ++*decoded_options_count; + *decoded_options = XRESIZEVEC (struct cl_decoded_option, + *decoded_options, + *decoded_options_count); + generate_option (OPT_asm_macosx_version_min_, asm_major, 1, CL_DRIVER, + &(*decoded_options)[*decoded_options_count - 1]); + } + } } diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 79fc506..374034e 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -399,10 +399,27 @@ extern GTY(()) int darwin_ms_struct; %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o) \ %{fgnu-tm: -lcrttms.o}" -/* Default Darwin ASM_SPEC, very simple. */ +#ifdef HAVE_AS_MMACOSX_VERSION_MIN_OPTION +/* Emit macosx version (but only major). */ +#define ASM_MMACOSX_VERSION_MIN_SPEC \ + " %{asm_macosx_version_min=*: -mmacosx-version-min=%*} %