[08/45] configure: When host-shared, pass --with-pic to in-tree lib configs.

Message ID 20230807111029.2320238-9-arsen@aarsen.me
State New
Headers
Series Synchronize shared build infrastructure with GCC tree |

Commit Message

Arsen Arsenović Aug. 7, 2023, 11:07 a.m. UTC
  From: Iain Sandoe <iain@sandoe.co.uk>

If we are building PIC/PIE host executables, and we are building dependent
libs (e.g. GMP) in-tree those libs need to be configured to generate PIC code.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

ChangeLog:

	* Makefile.def: Pass host_libs_picflag to host dependent library
	configures.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac (host_libs_picflag): New configure variable set to
	'--with-pic' when building 'host_shared'.
---
 Makefile.def |  13 +++---
 Makefile.in  | 120 +++++++++++++++++++++++++--------------------------
 configure    |  11 +++++
 configure.ac |  10 +++++
 4 files changed, 88 insertions(+), 66 deletions(-)
  

Patch

diff --git a/Makefile.def b/Makefile.def
index 8f5a5bb1c9e..1ed80c4f651 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -50,7 +50,7 @@  host_modules= { module= gcc; bootstrap=true;
 		extra_make_flags="$(EXTRA_GCC_FLAGS)"; };
 host_modules= { module= gmp; lib_path=.libs; bootstrap=true;
 		// Work around in-tree gmp configure bug with missing flex.
-		extra_configure_flags='--disable-shared LEX="touch lex.yy.c"';
+		extra_configure_flags='--disable-shared LEX="touch lex.yy.c" @host_libs_picflag@';
 		extra_make_flags='AM_CFLAGS="-DNO_ASM"';
 		no_install= true;
 		// none-*-* disables asm optimizations, bootstrap-testing
@@ -60,14 +60,14 @@  host_modules= { module= gmp; lib_path=.libs; bootstrap=true;
 		// different from host for target.
 	        target="none-${host_vendor}-${host_os}"; };
 host_modules= { module= mpfr; lib_path=src/.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@';
+		extra_configure_flags='--disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@';
 		extra_make_flags='AM_CFLAGS="-DNO_ASM"';
 		no_install= true; };
 host_modules= { module= mpc; lib_path=src/.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode';
+		extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode';
 		no_install= true; };
 host_modules= { module= isl; lib_path=.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@';
+		extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@';
 		extra_make_flags='V=1';
 		no_install= true; };
 host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
@@ -76,6 +76,7 @@  host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
 host_modules= { module= gold; bootstrap=true; };
 host_modules= { module= gprof; };
 host_modules= { module= gprofng; };
+// intl acts on 'host_shared' directly, and does not support --with-pic.
 host_modules= { module= intl; bootstrap=true; };
 host_modules= { module= tcl;
                 missing=mostlyclean; };
@@ -111,7 +112,7 @@  host_modules= { module= libiberty-linker-plugin; bootstrap=true;
 // We abuse missing to avoid installing anything for libiconv.
 host_modules= { module= libiconv;
 		bootstrap=true;
-		extra_configure_flags='--disable-shared';
+		extra_configure_flags='--disable-shared  @host_libs_picflag@';
 		no_install= true;
 		missing= pdf;
 		missing= html;
@@ -126,7 +127,7 @@  host_modules= { module= sim; };
 host_modules= { module= texinfo; no_install= true; };
 host_modules= { module= zlib; no_install=true; no_check=true;
 		bootstrap=true;
-	        extra_configure_flags='@extra_host_zlib_configure_flags@';};
+	        extra_configure_flags='@extra_host_zlib_configure_flags@ @host_libs_picflag@';};
 host_modules= { module= gnulib; };
 host_modules= { module= gdbsupport; };
 host_modules= { module= gdbserver; };
diff --git a/Makefile.in b/Makefile.in
index eb973eea024..599e6061cff 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -13162,7 +13162,7 @@  configure-gmp:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=none-${host_vendor}-${host_os} \
-	  --target=none-${host_vendor}-${host_os} --disable-shared LEX="touch lex.yy.c" \
+	  --target=none-${host_vendor}-${host_os} --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@ \
 	  || exit 1
 @endif gmp
 
@@ -13198,7 +13198,7 @@  configure-stage1-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stage2-gmp maybe-configure-stage2-gmp
@@ -13232,7 +13232,7 @@  configure-stage2-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stage3-gmp maybe-configure-stage3-gmp
@@ -13266,7 +13266,7 @@  configure-stage3-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stage4-gmp maybe-configure-stage4-gmp
@@ -13300,7 +13300,7 @@  configure-stage4-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stageprofile-gmp maybe-configure-stageprofile-gmp
@@ -13334,7 +13334,7 @@  configure-stageprofile-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stagetrain-gmp maybe-configure-stagetrain-gmp
@@ -13368,7 +13368,7 @@  configure-stagetrain-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stagefeedback-gmp maybe-configure-stagefeedback-gmp
@@ -13402,7 +13402,7 @@  configure-stagefeedback-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stageautoprofile-gmp maybe-configure-stageautoprofile-gmp
@@ -13436,7 +13436,7 @@  configure-stageautoprofile-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 .PHONY: configure-stageautofeedback-gmp maybe-configure-stageautofeedback-gmp
@@ -13470,7 +13470,7 @@  configure-stageautofeedback-gmp:
 	  --target=none-${host_vendor}-${host_os} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared LEX="touch lex.yy.c"
+	  --disable-shared LEX="touch lex.yy.c" @host_libs_picflag@
 @endif gmp-bootstrap
 
 
@@ -14299,7 +14299,7 @@  configure-mpfr:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} --disable-shared @extra_mpfr_configure_flags@ \
+	  --target=${target_alias} --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@ \
 	  || exit 1
 @endif mpfr
 
@@ -14335,7 +14335,7 @@  configure-stage1-mpfr:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stage2-mpfr maybe-configure-stage2-mpfr
@@ -14369,7 +14369,7 @@  configure-stage2-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stage3-mpfr maybe-configure-stage3-mpfr
@@ -14403,7 +14403,7 @@  configure-stage3-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stage4-mpfr maybe-configure-stage4-mpfr
@@ -14437,7 +14437,7 @@  configure-stage4-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stageprofile-mpfr maybe-configure-stageprofile-mpfr
@@ -14471,7 +14471,7 @@  configure-stageprofile-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stagetrain-mpfr maybe-configure-stagetrain-mpfr
@@ -14505,7 +14505,7 @@  configure-stagetrain-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stagefeedback-mpfr maybe-configure-stagefeedback-mpfr
@@ -14539,7 +14539,7 @@  configure-stagefeedback-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stageautoprofile-mpfr maybe-configure-stageautoprofile-mpfr
@@ -14573,7 +14573,7 @@  configure-stageautoprofile-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 .PHONY: configure-stageautofeedback-mpfr maybe-configure-stageautofeedback-mpfr
@@ -14607,7 +14607,7 @@  configure-stageautofeedback-mpfr:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpfr_configure_flags@
+	  --disable-shared @extra_mpfr_configure_flags@ @host_libs_picflag@
 @endif mpfr-bootstrap
 
 
@@ -15436,7 +15436,7 @@  configure-mpc:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode \
+	  --target=${target_alias} --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode \
 	  || exit 1
 @endif mpc
 
@@ -15472,7 +15472,7 @@  configure-stage1-mpc:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stage2-mpc maybe-configure-stage2-mpc
@@ -15506,7 +15506,7 @@  configure-stage2-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stage3-mpc maybe-configure-stage3-mpc
@@ -15540,7 +15540,7 @@  configure-stage3-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stage4-mpc maybe-configure-stage4-mpc
@@ -15574,7 +15574,7 @@  configure-stage4-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stageprofile-mpc maybe-configure-stageprofile-mpc
@@ -15608,7 +15608,7 @@  configure-stageprofile-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stagetrain-mpc maybe-configure-stagetrain-mpc
@@ -15642,7 +15642,7 @@  configure-stagetrain-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stagefeedback-mpc maybe-configure-stagefeedback-mpc
@@ -15676,7 +15676,7 @@  configure-stagefeedback-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stageautoprofile-mpc maybe-configure-stageautoprofile-mpc
@@ -15710,7 +15710,7 @@  configure-stageautoprofile-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 .PHONY: configure-stageautofeedback-mpc maybe-configure-stageautofeedback-mpc
@@ -15744,7 +15744,7 @@  configure-stageautofeedback-mpc:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@ --disable-maintainer-mode
+	  --disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@  @host_libs_picflag@ --disable-maintainer-mode
 @endif mpc-bootstrap
 
 
@@ -16573,7 +16573,7 @@  configure-isl:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} --disable-shared @extra_isl_gmp_configure_flags@ \
+	  --target=${target_alias} --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@ \
 	  || exit 1
 @endif isl
 
@@ -16609,7 +16609,7 @@  configure-stage1-isl:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stage2-isl maybe-configure-stage2-isl
@@ -16643,7 +16643,7 @@  configure-stage2-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stage3-isl maybe-configure-stage3-isl
@@ -16677,7 +16677,7 @@  configure-stage3-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stage4-isl maybe-configure-stage4-isl
@@ -16711,7 +16711,7 @@  configure-stage4-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stageprofile-isl maybe-configure-stageprofile-isl
@@ -16745,7 +16745,7 @@  configure-stageprofile-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stagetrain-isl maybe-configure-stagetrain-isl
@@ -16779,7 +16779,7 @@  configure-stagetrain-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stagefeedback-isl maybe-configure-stagefeedback-isl
@@ -16813,7 +16813,7 @@  configure-stagefeedback-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stageautoprofile-isl maybe-configure-stageautoprofile-isl
@@ -16847,7 +16847,7 @@  configure-stageautoprofile-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 .PHONY: configure-stageautofeedback-isl maybe-configure-stageautofeedback-isl
@@ -16881,7 +16881,7 @@  configure-stageautofeedback-isl:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared @extra_isl_gmp_configure_flags@
+	  --disable-shared @extra_isl_gmp_configure_flags@  @host_libs_picflag@
 @endif isl-bootstrap
 
 
@@ -31284,7 +31284,7 @@  configure-libiconv:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} --disable-shared \
+	  --target=${target_alias} --disable-shared  @host_libs_picflag@ \
 	  || exit 1
 @endif libiconv
 
@@ -31320,7 +31320,7 @@  configure-stage1-libiconv:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stage2-libiconv maybe-configure-stage2-libiconv
@@ -31354,7 +31354,7 @@  configure-stage2-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stage3-libiconv maybe-configure-stage3-libiconv
@@ -31388,7 +31388,7 @@  configure-stage3-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stage4-libiconv maybe-configure-stage4-libiconv
@@ -31422,7 +31422,7 @@  configure-stage4-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stageprofile-libiconv maybe-configure-stageprofile-libiconv
@@ -31456,7 +31456,7 @@  configure-stageprofile-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stagetrain-libiconv maybe-configure-stagetrain-libiconv
@@ -31490,7 +31490,7 @@  configure-stagetrain-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stagefeedback-libiconv maybe-configure-stagefeedback-libiconv
@@ -31524,7 +31524,7 @@  configure-stagefeedback-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stageautoprofile-libiconv maybe-configure-stageautoprofile-libiconv
@@ -31558,7 +31558,7 @@  configure-stageautoprofile-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 .PHONY: configure-stageautofeedback-libiconv maybe-configure-stageautofeedback-libiconv
@@ -31592,7 +31592,7 @@  configure-stageautofeedback-libiconv:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  --disable-shared
+	  --disable-shared  @host_libs_picflag@
 @endif libiconv-bootstrap
 
 
@@ -34656,7 +34656,7 @@  configure-zlib:
 	  $$s/$$module_srcdir/configure \
 	  --srcdir=$${topdir}/$$module_srcdir \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} @extra_host_zlib_configure_flags@ \
+	  --target=${target_alias} @extra_host_zlib_configure_flags@ @host_libs_picflag@ \
 	  || exit 1
 @endif zlib
 
@@ -34692,7 +34692,7 @@  configure-stage1-zlib:
 	  --target=${target_alias} \
 	   \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stage2-zlib maybe-configure-stage2-zlib
@@ -34726,7 +34726,7 @@  configure-stage2-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stage3-zlib maybe-configure-stage3-zlib
@@ -34760,7 +34760,7 @@  configure-stage3-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stage4-zlib maybe-configure-stage4-zlib
@@ -34794,7 +34794,7 @@  configure-stage4-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stageprofile-zlib maybe-configure-stageprofile-zlib
@@ -34828,7 +34828,7 @@  configure-stageprofile-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stagetrain-zlib maybe-configure-stagetrain-zlib
@@ -34862,7 +34862,7 @@  configure-stagetrain-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEtrain_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stagefeedback-zlib maybe-configure-stagefeedback-zlib
@@ -34896,7 +34896,7 @@  configure-stagefeedback-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stageautoprofile-zlib maybe-configure-stageautoprofile-zlib
@@ -34930,7 +34930,7 @@  configure-stageautoprofile-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautoprofile_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 .PHONY: configure-stageautofeedback-zlib maybe-configure-stageautofeedback-zlib
@@ -34964,7 +34964,7 @@  configure-stageautofeedback-zlib:
 	  --target=${target_alias} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEautofeedback_CONFIGURE_FLAGS) \
-	  @extra_host_zlib_configure_flags@
+	  @extra_host_zlib_configure_flags@ @host_libs_picflag@
 @endif zlib-bootstrap
 
 
diff --git a/configure b/configure
index 9cb953a197e..4b3d8ed02c5 100755
--- a/configure
+++ b/configure
@@ -688,6 +688,7 @@  get_gcc_base_ver
 extra_host_zlib_configure_flags
 extra_host_libiberty_configure_flags
 stage1_languages
+host_libs_picflag
 host_shared
 extra_linker_plugin_flags
 extra_linker_plugin_configure_flags
@@ -8787,6 +8788,16 @@  fi
 
 
 
+
+# If we are building PIC/PIE host executables, and we are building dependent
+# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+# code.
+host_libs_picflag=
+if test "$host_shared" = "yes";then
+host_libs_picflag='--with-pic'
+fi
+
+
 # By default, C and C++ are the only stage 1 languages.
 stage1_languages=,c,
 
diff --git a/configure.ac b/configure.ac
index e95a9ed116e..86d10a6af8e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2006,8 +2006,18 @@  AC_ARG_ENABLE(host-shared,
   x86_64-*-darwin* | aarch64-*-darwin*) host_shared=yes ;;
   *) host_shared=no ;;
  esac])
+
 AC_SUBST(host_shared)
 
+# If we are building PIC/PIE host executables, and we are building dependent
+# libs (e.g. GMP) in-tree those libs need to be configured to generate PIC
+# code.
+host_libs_picflag=
+if test "$host_shared" = "yes";then
+host_libs_picflag='--with-pic'
+fi
+AC_SUBST(host_libs_picflag)
+
 # By default, C and C++ are the only stage 1 languages.
 stage1_languages=,c,