From patchwork Mon Aug 7 11:07:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Arsen_Arsenovi=C4=87?= X-Patchwork-Id: 131829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1384838vqr; Mon, 7 Aug 2023 04:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFG5L4LZrg786EJPy5xm01zeMo6VW/YQAzKaQALJFHj4Um5tVF+d76Av5Ujmyd+/zd5UBxM X-Received: by 2002:aa7:d358:0:b0:51d:f5bd:5a88 with SMTP id m24-20020aa7d358000000b0051df5bd5a88mr7701358edr.38.1691408357322; Mon, 07 Aug 2023 04:39:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691408357; cv=none; d=google.com; s=arc-20160816; b=xsS+SJXVrXIyOWHFmN0Mp3EPQCip2Y8JqrvgJAlYnjMpHv1WJIlW0mpmBOZdIC3nI2 h7FMupKH0j9hgwOjjffDA4rjRTFNOfxAQtMmVnwL5J6npYKRzZfd1qpm2XBw50F8Uvvt HaOeIDT5ieBRK2ZG19eRFjeJZjDNHq4t2p6jn7r8pjBcU7JD44Kmg/6PVLWDZbEJHNrk Rogf0kyZrl1g302Oh6QyIZU52n274dYJKSuLIjl1K/hJ8PMiksqHn7ZC1+w7QeUaEITD gtZsFRNyW25YuV1E55Dfb2DlKAUuenGBwO9suJMKjMaqy/FZwhsJYFPdTiyXcXqXVByq SI1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=Lk2U3DqVbCodm5o9LuS9JVZh/KH21DTvzeWyBdIAqdE=; fh=5m/Ou5nb9mSX4jgWjeSrLy5XL/K/fwRPXiU1Ypr6h+w=; b=UpQl3iB96rPLAvhPEDZOMf1ALVGBmuPkkFBY04qX7xS/PxeYwB1zmLui+kmvitlTfq Qv0X93mbUfzCcvFZKhYHiEPzSCWk5x9Zlz4tMZoIFr98qOPHY4ojPgPZy50dLNGmnl6Q 0uKDULLHnS3SMgBRNo5eIbbJzXKLLKGTNhJc/ZK5+QUUb2VFgPgV0Z9CvvRI2G4rZX6p SzQxZj+auifo3MwF1hjImfHdcwx1cAhHnyaotQgatl37Q/lkheD1UtJpPBh/spzm/eyK xs7A3jjTkP/mEVXZPQcVGOHvtpesI3KKi2HVrWrP/udqazHpcpUZ+GdgIj+i+VliVnqn +2Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JHtpDwhI; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c16-20020aa7df10000000b005224c64e814si5356833edy.302.2023.08.07.04.39.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JHtpDwhI; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 691623AA8CB4 for ; Mon, 7 Aug 2023 11:27:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 691623AA8CB4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691407679; bh=Lk2U3DqVbCodm5o9LuS9JVZh/KH21DTvzeWyBdIAqdE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=JHtpDwhIMEZWnTdCY14Z8WOwZsiuJ5rZvA8UL92QNePCfS6YGdpXgTsspgLTT3Y7J RUgFMX0EcUnXPVVQ/AtGSrjlKCj82oQeNLtWmVe+TneN2jkyrPDSIAGMyJRr8TxtsD 8wUKbNHDvEyfPPJVBbRUFPx/HuXFunGFgiepjC0o= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) by sourceware.org (Postfix) with ESMTPS id C52ED3858025; Mon, 7 Aug 2023 11:19:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C52ED3858025 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4RKDP01ZXvz9sS2; Mon, 7 Aug 2023 13:19:32 +0200 (CEST) To: gdb-patches@sourceware.org, binutils@sourceware.org Cc: Iain Sandoe Subject: [PATCH 20/45] Darwin, config: Revise host config fragment. Date: Mon, 7 Aug 2023 13:07:23 +0200 Message-ID: <20230807111029.2320238-21-arsen@aarsen.me> In-Reply-To: <20230807111029.2320238-1-arsen@aarsen.me> References: <20230807111029.2320238-1-arsen@aarsen.me> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Arsen_Arsenovi=C4=87_via_Binutils?= From: =?utf-8?q?Arsen_Arsenovi=C4=87?= Reply-To: =?utf-8?q?Arsen_Arsenovi=C4=87?= Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773570209523133487 X-GMAIL-MSGID: 1773570209523133487 From: Iain Sandoe 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. 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 ++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 24 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