diff --git Makefile.in Makefile.in
index b824e0a0c..30e037e0f 100644
--- Makefile.in
+++ Makefile.in
@@ -597,6 +597,20 @@ all:
 @host_makefile_frag@
 ###
 
+# Allow host makefile fragment to override PIE settings.
+ifneq ($(STAGE1_NO_PIE_CFLAGS),)
+	HOST_EXPORTS += export NO_PIE_CFLAGS="$(STAGE1_NO_PIE_CFLAGS)";
+endif
+ifneq ($(STAGE1_NO_PIE_FLAG),)
+	HOST_EXPORTS += export NO_PIE_FLAG="$(STAGE1_NO_PIE_FLAG)";
+endif
+ifneq ($(BOOT_NO_PIE_CFLAGS),)
+	POSTSTAGE1_HOST_EXPORTS += export NO_PIE_CFLAGS="$(BOOT_NO_PIE_CFLAGS)";
+endif
+ifneq ($(BOOT_NO_PIE_FLAG),)
+	POSTSTAGE1_HOST_EXPORTS += export NO_PIE_FLAG="$(BOOT_NO_PIE_FLAG)";
+endif
+
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that programs built for the target machine work.
 TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libsanitizer)$(TARGET_LIB_PATH_libmpx)$(TARGET_LIB_PATH_libvtv)$(TARGET_LIB_PATH_libcilkrts)$(TARGET_LIB_PATH_liboffloadmic)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
diff --git config/mh-darwin config/mh-darwin
index 148b73038..08ce540b5 100644
--- config/mh-darwin
+++ config/mh-darwin
@@ -1,29 +1,33 @@
 # 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).  Do not add it if the buulding
+# compiler doesn't also support -mno-dynamic-no-pic to undo it, since libiberty,
+# at least, needs this facility
 
-# 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;`
+# In addition, all versions of clang released to date treat -fno-PIE in -m32
+# compilations  as switching PIC code off too, which means that -fno-PIE, without
+# -mdynamic-no-pic produces broken relocations (and we cannot enable mdynamic-no-pic
+# because the inverse setting doesn't work).
 
-BOOT_CFLAGS += $(DARWIN_MDYNAMIC_NO_PIC)
-BOOT_LDFLAGS += $(DARWIN_NO_PIE)
+CAN_MDYNAMIC_NO_PIC := \
+`$(CC) -S -xc /dev/null -o /dev/null -mno-dynamic-no-pic 2>/dev/null \
+ && ($(CC) -E -dM -xc /dev/null | grep -q __clang__ || echo true)`
 
-# Similarly, for cross-compilation.
-STAGE1_CFLAGS += $(DARWIN_MDYNAMIC_NO_PIC)
-STAGE1_LDFLAGS += $(DARWIN_NO_PIE)
+# Here we use STAGE1 to mean both bootstrap and for the no-bootstrap single compile.
+ifeq ($(CAN_MDYNAMIC_NO_PIC),true)
+STAGE1_NO_PIE_CFLAGS = -fno-PIE
+else
+STAGE1_NO_PIE_CFLAGS = -fno-PIE -fPIC
+endif
 
-# 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
+# Add -mdynamic-no-pic to later stages when we know it is built with GCC.
+STAGE2_CFLAGS += -mdynamic-no-pic
+STAGE3_CFLAGS += -mdynamic-no-pic
+STAGE4_CFLAGS += -mdynamic-no-pic
+# For GCC, this is compatible with mdynamic-no-pic.
+BOOT_NO_PIE_CFLAGS = -fno-PIE
+@endif gcc-bootstrap
+
+STAGE1_NO_PIE_FLAG = -Wl,-no_pie
+BOOT_NO_PIE_FLAG = -Wl,-no_pie
diff --git gcc/configure gcc/configure
index 5dab9142e..f16834499 100755
--- gcc/configure
+++ gcc/configure
@@ -29831,7 +29831,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_c_no_fpie" >&5
 $as_echo "$gcc_cv_c_no_fpie" >&6; }
 if test "$gcc_cv_c_no_fpie" = "yes"; then
-  NO_PIE_CFLAGS="-fno-PIE"
+   NO_PIE_CFLAGS=${NO_PIE_CFLAGS-"-fno-PIE"}
 fi
 
 
@@ -29859,7 +29859,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_no_pie" >&5
 $as_echo "$gcc_cv_no_pie" >&6; }
 if test "$gcc_cv_no_pie" = "yes"; then
-  NO_PIE_FLAG="-no-pie"
+  NO_PIE_FLAG=${NO_PIE_FLAG-"-no-pie"}
 fi
 
 
diff --git gcc/configure.ac gcc/configure.ac
index e1fa8af5e..3ad0c505a 100644
--- gcc/configure.ac
+++ gcc/configure.ac
@@ -6328,7 +6328,7 @@ AC_CACHE_CHECK([for -fno-PIE option],
      [gcc_cv_c_no_fpie=no])
    CXXFLAGS="$saved_CXXFLAGS"])
 if test "$gcc_cv_c_no_fpie" = "yes"; then
-  NO_PIE_CFLAGS="-fno-PIE"
+  NO_PIE_CFLAGS=${NO_PIE_CFLAGS-"-fno-PIE"}
 fi
 AC_SUBST([NO_PIE_CFLAGS])
 
@@ -6342,7 +6342,7 @@ AC_CACHE_CHECK([for -no-pie option],
      [gcc_cv_no_pie=no])
    LDFLAGS="$saved_LDFLAGS"])
 if test "$gcc_cv_no_pie" = "yes"; then
-  NO_PIE_FLAG="-no-pie"
+  NO_PIE_FLAG=${NO_PIE_FLAG-"-no-pie"}
 fi
 AC_SUBST([NO_PIE_FLAG])
 
