public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Arsen Arsenović" <arsen@aarsen.me>
To: gdb-patches@sourceware.org, binutils@sourceware.org
Cc: Iain Sandoe <iain@sandoe.co.uk>
Subject: [PATCH 20/45] Darwin, config: Revise host config fragment.
Date: Mon,  7 Aug 2023 13:07:23 +0200	[thread overview]
Message-ID: <20230807111029.2320238-21-arsen@aarsen.me> (raw)
In-Reply-To: <20230807111029.2320238-1-arsen@aarsen.me>

From: Iain Sandoe <iain@sandoe.co.uk>

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 <iain@sandoe.co.uk>

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
-- 
2.41.0


  parent reply	other threads:[~2023-08-07 11:19 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 11:07 [PATCH 00/45] Synchronize shared build infrastructure with GCC tree Arsen Arsenović
2023-08-07 11:07 ` [PATCH 01/45] *: Regenerate autoconf and aclocal files Arsen Arsenović
2023-08-09 13:43   ` Alan Modra
2023-08-10  9:13     ` Arsen Arsenović
2023-08-07 11:07 ` [PATCH 02/45] Libvtv: Add loongarch support Arsen Arsenović
2023-08-07 11:07 ` [PATCH 03/45] c++: source position of lambda captures [PR84471] Arsen Arsenović
2023-08-10 21:48   ` Jason Merrill
2023-08-07 11:07 ` [PATCH 04/45] Updated constants from <https://dwarfstd.org/Languages.php> Arsen Arsenović
2023-08-07 11:07 ` [PATCH 05/45] LoongArch: implement count_{leading,trailing}_zeros Arsen Arsenović
2023-08-07 11:07 ` [PATCH 06/45] Darwin : Update libtool and dependencies for Darwin20 [PR97865] Arsen Arsenović
2023-08-07 11:07 ` [PATCH 07/45] configure: Do not build the ununsed libffi shared library Arsen Arsenović
2023-08-09 13:44   ` Alan Modra
2023-08-10  9:21     ` Arsen Arsenović
2023-08-10 11:39       ` Alan Modra
2023-08-10 11:25     ` Arsen Arsenović
2023-08-07 11:07 ` [PATCH 08/45] configure: When host-shared, pass --with-pic to in-tree lib configs Arsen Arsenović
2023-08-07 11:07 ` [PATCH 09/45] configure: Implement --enable-host-pie Arsen Arsenović
2023-08-07 11:07 ` [PATCH 10/45] configure: Only create serdep.tmp if needed Arsen Arsenović
2023-08-07 11:07 ` [PATCH 11/45] configure, Darwin: Ensure overrides to host-pie are passed to gcc configure Arsen Arsenović
2023-08-07 11:07 ` [PATCH 12/45] Remove support for Intel MIC offloading Arsen Arsenović
2023-08-07 11:07 ` [PATCH 13/45] configure: use OBJDUMP determined by libtool [PR95648] Arsen Arsenović
2023-08-07 11:07 ` [PATCH 14/45] configure: Account CXXFLAGS in gcc-plugin.m4 Arsen Arsenović
2023-08-07 11:07 ` [PATCH 15/45] Add TFLAGS to gcc's GCC_FOR_TARGET Arsen Arsenović
2023-08-07 11:07 ` [PATCH 16/45] Merge modula-2 front end onto gcc Arsen Arsenović
2023-08-07 11:07 ` [PATCH 17/45] sync toplevel with GCC: drop 32b PA-RISC on HPUX in GCC Arsen Arsenović
2023-08-07 11:07 ` [PATCH 18/45] Fix PR bootstrap/102389: --with-build-config=bootstrap-lto is broken Arsen Arsenović
2023-08-07 11:07 ` [PATCH 19/45] gcc: Add 'mcf' thread model support from mcfgthread Arsen Arsenović
2023-08-07 11:07 ` Arsen Arsenović [this message]
2023-08-07 11:07 ` [PATCH 21/45] configure: Allow host fragments to react to --enable-host-shared Arsen Arsenović
2023-08-07 11:07 ` [PATCH 22/45] mh-mingw: Set __USE_MINGW_ACCESS in missed C++ flags variables Arsen Arsenović
2023-08-07 11:07 ` [PATCH 23/45] mh-mingw: drop unused BOOT_CXXFLAGS variable Arsen Arsenović
2023-08-07 11:07 ` [PATCH 24/45] config-ml.in: Suppress output from multi-do recipes Arsen Arsenović
2023-08-07 11:07 ` [PATCH 25/45] Add D front-end, libphobos library, and D2 testsuite Arsen Arsenović
2023-08-07 11:07 ` [PATCH 26/45] MSP430: Add -fno-exceptions multilib Arsen Arsenović
2023-08-07 11:07 ` [PATCH 27/45] gcc: xtensa: add XCHAL_HAVE_{CLAMPS,DEPBITS,EXCLUSIVE,XEA3} to dynconfig Arsen Arsenović
2023-08-07 11:07 ` [PATCH 28/45] gcc: xtensa: add data alignment properties " Arsen Arsenović
2023-08-07 11:07 ` [PATCH 29/45] toplevel: reconcile few divergences with GCC Arsen Arsenović
2023-08-07 11:07 ` [PATCH 30/45] Generic configury support for shared libs on VxWorks Arsen Arsenović
2023-08-07 11:07 ` [PATCH 31/45] Fix hppa64-hpux11 build to remove source paths from embedded path Arsen Arsenović
2023-08-07 11:07 ` [PATCH 32/45] libtool.m4: Sort output of 'find' to enable deterministic builds Arsen Arsenović
2023-08-07 11:07 ` [PATCH 33/45] [ARM/FDPIC v6 02/24] [ARM] FDPIC: Handle arm*-*-uclinuxfdpiceabi in configure scripts Arsen Arsenović
2023-08-07 11:07 ` [PATCH 34/45] Do not use HAVE_DOS_BASED_FILE_SYSTEM for Cygwin Arsen Arsenović
2023-08-07 11:07 ` [PATCH 35/45] Makefile.def: drop remnants of unused libelf Arsen Arsenović
2023-08-07 11:07 ` [PATCH 36/45] d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1) Arsen Arsenović
2023-08-07 11:07 ` [PATCH 37/45] Collect both user and kernel events for autofdo tests and autoprofiledbootstrap Arsen Arsenović
2023-08-07 11:07 ` [PATCH 38/45] Fix collection and processing of autoprofile data for target libs Arsen Arsenović
2023-08-07 11:07 ` [PATCH 39/45] Fix autoprofiledbootstrap build Arsen Arsenović
2023-08-07 11:07 ` [PATCH 40/45] Disable warnings as errors for STAGEautofeedback Arsen Arsenović
2023-08-07 11:07 ` [PATCH 41/45] Revert "Fix PR 67102: Add libstdc++ dependancy to libffi" [PR67102] Arsen Arsenović
2023-08-07 11:07 ` [PATCH 42/45] PR bootstrap/106472: Add libgo depends on libbacktrace to Makefile.def Arsen Arsenović
2023-08-07 11:07 ` [PATCH 43/45] gccrs: Add gcc-check-target check-rust Arsen Arsenović
2023-08-07 11:07 ` [PATCH 44/45] Use substituted GDCFLAGS Arsen Arsenović
2023-08-07 11:07 ` [PATCH 45/45] toplevel: Substitute GDCFLAGS instead of using CFLAGS Arsen Arsenović
2023-08-12  1:18 ` [PATCH 00/45] Synchronize shared build infrastructure with GCC tree Alan Modra
2023-08-12  9:55   ` Arsen Arsenović

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230807111029.2320238-21-arsen@aarsen.me \
    --to=arsen@aarsen.me \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=iain@sandoe.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).