From patchwork Fri Jul 9 18:10:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1503309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GM1Rk3CrDz9sXV for ; Sat, 10 Jul 2021 04:10:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F0C4C398E825 for ; Fri, 9 Jul 2021 18:10:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp001-out.apm-internet.net (smtp001-out.apm-internet.net [85.119.248.222]) by sourceware.org (Postfix) with ESMTPS id 10D22385802A for ; Fri, 9 Jul 2021 18:10:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10D22385802A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=sandoe.co.uk Received: (qmail 69725 invoked from network); 9 Jul 2021 18:10:20 -0000 X-APM-Out-ID: 16258542206972 X-APM-Authkey: 257869/1(257869/1) 7 Received: from unknown (HELO ?192.168.1.214?) (81.138.1.83) by smtp001.apm-internet.net with SMTP; 9 Jul 2021 18:10:20 -0000 From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: [pushed] Darwin, config: Revise host config fragment. Message-Id: <985D6AE2-C838-40CC-8EB1-BE3E875A284B@sandoe.co.uk> Date: Fri, 9 Jul 2021 19:10:20 +0100 To: GCC Patches X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-16.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_COUK, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, There were two uses for the Darwin host config fragment: The first is to arrange for targets that support mdynamic-no-pic to be built with that enabled (since it makes a significant difference to the compiler performance). We can be more specific in the application of this, since it only applies to 32b hosts plus powerpc64-darwin9. The second was to work around a tool bug where -fno-PIE was not propagated to the link stage. This second use is redundant, since the buggy toolchain cannot bootstrap current GCC sources anyway. This makes the host fragment more specific and reduces the number of toolchains for which it is included which reduces clutter in configure lines. tested across the Darwin range and on x86_64-linux, pushed to master, thanks Iain Signed-off-by: Iain Sandoe config/ChangeLog: * mh-darwin: Make this specific to handling the mdynamic-no-pic case. ChangeLog: * configure: Regenerate. * configure.ac: Adjust cases for which it is necessary to include the Darwin host config fragment. --- config/mh-darwin | 57 ++++++++++++++++++++++++++++-------------------- configure | 2 +- configure.ac | 2 +- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/config/mh-darwin b/config/mh-darwin index 148b73038c3..fb2bb5ad1d9 100644 --- a/config/mh-darwin +++ b/config/mh-darwin @@ -1,29 +1,38 @@ # The -mdynamic-no-pic ensures that the compiler executable is built without -# position-independent-code -- the usual default on Darwin. This fix speeds -# compiles by 3-5%. Don't add it if the compiler doesn't also support -# -mno-dynamic-no-pic to undo it. -DARWIN_MDYNAMIC_NO_PIC := \ -`case ${host} in i?86-*-darwin* | powerpc-*-darwin*) \ - $(CC) -S -xc /dev/null -o /dev/null -mno-dynamic-no-pic 2>/dev/null \ - && echo -mdynamic-no-pic ;; esac` -DARWIN_GCC_MDYNAMIC_NO_PIC := \ -`case ${host} in i?86-*-darwin* | powerpc-*-darwin*) \ - $(CC) -S -xc /dev/null -o /dev/null -mno-dynamic-no-pic 2>/dev/null \ - || echo -mdynamic-no-pic ;; esac` +# position-independent-code -- the usual default on Darwin. This speeds compiles +# by 8-20% (measurements made against GCC-11). +# However, we cannot add it unless the bootstrap compiler supports +# -mno-dynamic-no-pic to undo it, since libiberty, at least, needs this. -# ld on Darwin versions >= 10.7 defaults to PIE executables. Disable this for -# gcc components, since it is incompatible with our pch implementation. -DARWIN_NO_PIE := `case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;` +# We use Werror, since some versions of clang report unknown command line flags +# as a warning only. -BOOT_CFLAGS += $(DARWIN_MDYNAMIC_NO_PIC) -BOOT_LDFLAGS += $(DARWIN_NO_PIE) +# We only need to determine this for the host tool used to build stage1 (or a +# non-bootstrapped compiler), later stages will be built by GCC which supports +# the required flags. -# Similarly, for cross-compilation. -STAGE1_CFLAGS += $(DARWIN_MDYNAMIC_NO_PIC) -STAGE1_LDFLAGS += $(DARWIN_NO_PIE) +BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := $(shell \ + $(CC) -S -xc /dev/null -o /dev/null -Werror -mno-dynamic-no-pic 2>/dev/null \ + && echo true) -# Without -mno-dynamic-no-pic support, add -mdynamic-no-pic just to later -# stages when we know it is built with gcc. -STAGE2_CFLAGS += $(DARWIN_GCC_MDYNAMIC_NO_PIC) -STAGE3_CFLAGS += $(DARWIN_GCC_MDYNAMIC_NO_PIC) -STAGE4_CFLAGS += $(DARWIN_GCC_MDYNAMIC_NO_PIC) +@if gcc-bootstrap +ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true) +STAGE1_CFLAGS += -mdynamic-no-pic +else +STAGE1_CFLAGS += -fPIC +endif +# Add -mdynamic-no-pic to later stages when we know it is built with GCC. +BOOT_CFLAGS += -mdynamic-no-pic +@endif gcc-bootstrap + +@unless gcc-bootstrap +ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true) +# FIXME: we should also enable this for cross and non-bootstrap builds but +# that needs amendment to libcc1. +# CFLAGS += -mdynamic-no-pic +# CXXFLAGS += -mdynamic-no-pic +else +CFLAGS += -fPIC +CXXFLAGS += -fPIC +endif +@endunless gcc-bootstrap diff --git a/configure b/configure index 732d1870b3d..85ab9915402 100755 --- a/configure +++ b/configure @@ -4074,7 +4074,7 @@ fi hppa*-*) host_makefile_frag="config/mh-pa" ;; - *-*-darwin*) + i?86-*-darwin[89]* | i?86-*-darwin1[0-7]* | powerpc*-*-darwin*) host_makefile_frag="config/mh-darwin" ;; powerpc-*-aix*) diff --git a/configure.ac b/configure.ac index 041ee249bac..1df038b04f3 100644 --- a/configure.ac +++ b/configure.ac @@ -1318,7 +1318,7 @@ case "${host}" in hppa*-*) host_makefile_frag="config/mh-pa" ;; - *-*-darwin*) + i?86-*-darwin[[89]]* | i?86-*-darwin1[[0-7]]* | powerpc*-*-darwin*) host_makefile_frag="config/mh-darwin" ;; powerpc-*-aix*)