* [PATCH] configure: Implement --enable-host-pie
@ 2022-11-11 2:52 Marek Polacek
2022-11-20 15:06 ` Jeff Law
0 siblings, 1 reply; 8+ messages in thread
From: Marek Polacek @ 2022-11-11 2:52 UTC (permalink / raw)
To: GCC Patches; +Cc: oliva, Joseph Myers
This is a rebased version of the patch I posted in March:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591239.html>
which Alex sort of approved here:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592360.html>
but it was too late to commit the patch in GCC 12.
There are no changes except that I've converted the documentation
part into the ReST format, and of course regenerated configure.
With --enable-host-pie enabled:
$ file ./gcc/cc1 ./gcc/cc1plus
./gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
./gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
Bootstrapped/regtested on x86_64-pc-linux-gnu w/ and w/o --enable-host-pie,
ok for trunk?
-- >8 --
This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE. This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.
It is similar to the option --enable-host-shared, except that --e-h-s
won't add -shared to the linker flags whereas --e-h-p will add -pie.
It is different from --enable-default-pie because that option just
adds an implicit -fPIE/-pie when the compiler is invoked, but the
compiler itself isn't PIE.
Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
regressions.
When building the compiler, the build process may use various in-tree
libraries; these need to be built with -fPIE so that it's possible to
use them when building a PIE. For instance, when --with-included-gettext
is in effect, intl object files must be compiled with -fPIE. Similarly,
when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
-fPIE.
I plan to add an option to link with -Wl,-z,now.
ChangeLog:
* Makefile.def: Pass $(PICFLAG) to AM_CFLAGS for gmp, mpfr, mpc, and
isl.
* Makefile.in: Regenerate.
* Makefile.tpl: Set PICFLAG.
* configure.ac (--enable-host-pie): New check. Set PICFLAG after this
check.
* configure: Regenerate.
c++tools/ChangeLog:
* Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
Use pic/libiberty.a if PICFLAG is set.
* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
(--enable-host-pie): New check.
* configure: Regenerate.
fixincludes/ChangeLog:
* Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
build of libiberty if PICFLAG is set.
* configure.ac:
* configure: Regenerate.
gcc/ChangeLog:
* Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
* doc/install/configuration.rst: Document --enable-host-pie.
gcc/d/ChangeLog:
* Make-lang.in: Remove NO_PIE_CFLAGS.
intl/ChangeLog:
* Makefile.in: Use @PICFLAG@ in COMPILE as well.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libcody/ChangeLog:
* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
libcpp/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libdecnumber/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libiberty/ChangeLog:
* configure.ac: Also set shared when enable_host_pie.
* configure: Regenerate.
zlib/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
---
Makefile.def | 7 +-
Makefile.in | 273 +++++++++++++++---------------
Makefile.tpl | 1 +
c++tools/Makefile.in | 11 +-
c++tools/configure | 17 +-
c++tools/configure.ac | 11 +-
configure | 22 +++
configure.ac | 16 ++
fixincludes/Makefile.in | 14 +-
fixincludes/configure | 13 ++
fixincludes/configure.ac | 8 +
gcc/Makefile.in | 29 ++--
gcc/configure | 47 +++--
gcc/configure.ac | 36 ++--
gcc/d/Make-lang.in | 2 +-
gcc/doc/install/configuration.rst | 17 +-
intl/Makefile.in | 2 +-
intl/configure | 24 ++-
intl/configure.ac | 19 ++-
libcody/Makefile.in | 2 +-
libcody/configure | 30 +++-
libcody/configure.ac | 26 ++-
libcpp/configure | 22 ++-
libcpp/configure.ac | 19 ++-
libdecnumber/configure | 22 ++-
libdecnumber/configure.ac | 19 ++-
libiberty/configure | 4 +-
libiberty/configure.ac | 4 +-
zlib/configure | 28 ++-
zlib/configure.ac | 21 ++-
30 files changed, 550 insertions(+), 216 deletions(-)
diff --git a/Makefile.def b/Makefile.def
index 02e63c57177..ba2903d4b30 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -51,7 +51,7 @@ host_modules= { module= gcc; bootstrap=true;
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_make_flags='AM_CFLAGS="-DNO_ASM"';
+ extra_make_flags='AM_CFLAGS="-DNO_ASM $(PICFLAG)"';
no_install= true;
// none-*-* disables asm optimizations, bootstrap-testing
// the compiler more thoroughly.
@@ -61,14 +61,15 @@ host_modules= { module= gmp; lib_path=.libs; bootstrap=true;
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_make_flags='AM_CFLAGS="-DNO_ASM"';
+ extra_make_flags='AM_CFLAGS="-DNO_ASM $(PICFLAG)"';
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_make_flags='AM_CFLAGS="$(PICFLAG)"';
no_install= true; };
host_modules= { module= isl; lib_path=.libs; bootstrap=true;
extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@';
- extra_make_flags='V=1';
+ extra_make_flags='V=1 AM_CFLAGS="$(PICFLAG)"';
no_install= true; };
host_modules= { module= gold; bootstrap=true; };
host_modules= { module= gprof; };
diff --git a/Makefile.in b/Makefile.in
index 6ffa9660c25..9bc00b2dda0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -428,6 +428,7 @@ READELF = @READELF@
STRIP = @STRIP@
WINDRES = @WINDRES@
WINDMC = @WINDMC@
+PICFLAG = @PICFLAG@
GDC = @GDC@
GNATBIND = @GNATBIND@
@@ -13424,7 +13425,7 @@ all-gmp: configure-gmp
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
$(TARGET-gmp))
@endif gmp
@@ -13455,7 +13456,7 @@ all-stage1-gmp: configure-stage1-gmp
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
$(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE1_TFLAGS)" \
$(TARGET-stage1-gmp)
@@ -13470,7 +13471,7 @@ clean-stage1-gmp:
fi; \
cd $(HOST_SUBDIR)/gmp && \
$(MAKE) $(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13499,7 +13500,7 @@ all-stage2-gmp: configure-stage2-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE2_TFLAGS)" \
$(TARGET-stage2-gmp)
@@ -13513,7 +13514,7 @@ clean-stage2-gmp:
$(MAKE) stage2-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13542,7 +13543,7 @@ all-stage3-gmp: configure-stage3-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE3_TFLAGS)" \
$(TARGET-stage3-gmp)
@@ -13556,7 +13557,7 @@ clean-stage3-gmp:
$(MAKE) stage3-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13585,7 +13586,7 @@ all-stage4-gmp: configure-stage4-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE4_TFLAGS)" \
$(TARGET-stage4-gmp)
@@ -13599,7 +13600,7 @@ clean-stage4-gmp:
$(MAKE) stage4-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13628,7 +13629,7 @@ all-stageprofile-gmp: configure-stageprofile-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEprofile_TFLAGS)" \
$(TARGET-stageprofile-gmp)
@@ -13642,7 +13643,7 @@ clean-stageprofile-gmp:
$(MAKE) stageprofile-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13671,7 +13672,7 @@ all-stagetrain-gmp: configure-stagetrain-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEtrain_TFLAGS)" \
$(TARGET-stagetrain-gmp)
@@ -13685,7 +13686,7 @@ clean-stagetrain-gmp:
$(MAKE) stagetrain-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13714,7 +13715,7 @@ all-stagefeedback-gmp: configure-stagefeedback-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEfeedback_TFLAGS)" \
$(TARGET-stagefeedback-gmp)
@@ -13728,7 +13729,7 @@ clean-stagefeedback-gmp:
$(MAKE) stagefeedback-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13757,7 +13758,7 @@ all-stageautoprofile-gmp: configure-stageautoprofile-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEautoprofile_TFLAGS)" \
$(TARGET-stageautoprofile-gmp)
@@ -13771,7 +13772,7 @@ clean-stageautoprofile-gmp:
$(MAKE) stageautoprofile-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13800,7 +13801,7 @@ all-stageautofeedback-gmp: configure-stageautofeedback-gmp
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEautofeedback_TFLAGS)" PERF_DATA=perf.data \
$(TARGET-stageautofeedback-gmp)
@@ -13814,7 +13815,7 @@ clean-stageautofeedback-gmp:
$(MAKE) stageautofeedback-start; \
fi; \
cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif gmp-bootstrap
@@ -13832,7 +13833,7 @@ check-gmp:
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/gmp && \
- $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" $(EXTRA_BOOTSTRAP_FLAGS) check)
+ $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" $(EXTRA_BOOTSTRAP_FLAGS) check)
@endif gmp
@@ -13867,7 +13868,7 @@ info-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing info in gmp"; \
@@ -13892,7 +13893,7 @@ dvi-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing dvi in gmp"; \
@@ -13917,7 +13918,7 @@ pdf-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing pdf in gmp"; \
@@ -13942,7 +13943,7 @@ html-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing html in gmp"; \
@@ -13967,7 +13968,7 @@ TAGS-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing TAGS in gmp"; \
@@ -13993,7 +13994,7 @@ install-info-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-info in gmp"; \
@@ -14019,7 +14020,7 @@ install-dvi-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-dvi in gmp"; \
@@ -14045,7 +14046,7 @@ install-pdf-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-pdf in gmp"; \
@@ -14071,7 +14072,7 @@ install-html-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-html in gmp"; \
@@ -14096,7 +14097,7 @@ installcheck-gmp: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing installcheck in gmp"; \
@@ -14120,7 +14121,7 @@ mostlyclean-gmp:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing mostlyclean in gmp"; \
@@ -14144,7 +14145,7 @@ clean-gmp:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing clean in gmp"; \
@@ -14168,7 +14169,7 @@ distclean-gmp:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing distclean in gmp"; \
@@ -14192,7 +14193,7 @@ maintainer-clean-gmp:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing maintainer-clean in gmp"; \
@@ -14561,7 +14562,7 @@ all-mpfr: configure-mpfr
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
$(TARGET-mpfr))
@endif mpfr
@@ -14592,7 +14593,7 @@ all-stage1-mpfr: configure-stage1-mpfr
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
$(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE1_TFLAGS)" \
$(TARGET-stage1-mpfr)
@@ -14607,7 +14608,7 @@ clean-stage1-mpfr:
fi; \
cd $(HOST_SUBDIR)/mpfr && \
$(MAKE) $(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14636,7 +14637,7 @@ all-stage2-mpfr: configure-stage2-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE2_TFLAGS)" \
$(TARGET-stage2-mpfr)
@@ -14650,7 +14651,7 @@ clean-stage2-mpfr:
$(MAKE) stage2-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14679,7 +14680,7 @@ all-stage3-mpfr: configure-stage3-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE3_TFLAGS)" \
$(TARGET-stage3-mpfr)
@@ -14693,7 +14694,7 @@ clean-stage3-mpfr:
$(MAKE) stage3-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14722,7 +14723,7 @@ all-stage4-mpfr: configure-stage4-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGE4_TFLAGS)" \
$(TARGET-stage4-mpfr)
@@ -14736,7 +14737,7 @@ clean-stage4-mpfr:
$(MAKE) stage4-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14765,7 +14766,7 @@ all-stageprofile-mpfr: configure-stageprofile-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEprofile_TFLAGS)" \
$(TARGET-stageprofile-mpfr)
@@ -14779,7 +14780,7 @@ clean-stageprofile-mpfr:
$(MAKE) stageprofile-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14808,7 +14809,7 @@ all-stagetrain-mpfr: configure-stagetrain-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEtrain_TFLAGS)" \
$(TARGET-stagetrain-mpfr)
@@ -14822,7 +14823,7 @@ clean-stagetrain-mpfr:
$(MAKE) stagetrain-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14851,7 +14852,7 @@ all-stagefeedback-mpfr: configure-stagefeedback-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEfeedback_TFLAGS)" \
$(TARGET-stagefeedback-mpfr)
@@ -14865,7 +14866,7 @@ clean-stagefeedback-mpfr:
$(MAKE) stagefeedback-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14894,7 +14895,7 @@ all-stageautoprofile-mpfr: configure-stageautoprofile-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEautoprofile_TFLAGS)" \
$(TARGET-stageautoprofile-mpfr)
@@ -14908,7 +14909,7 @@ clean-stageautoprofile-mpfr:
$(MAKE) stageautoprofile-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14937,7 +14938,7 @@ all-stageautofeedback-mpfr: configure-stageautofeedback-mpfr
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" \
TFLAGS="$(STAGEautofeedback_TFLAGS)" PERF_DATA=perf.data \
$(TARGET-stageautofeedback-mpfr)
@@ -14951,7 +14952,7 @@ clean-stageautofeedback-mpfr:
$(MAKE) stageautofeedback-start; \
fi; \
cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" clean
@endif mpfr-bootstrap
@@ -14969,7 +14970,7 @@ check-mpfr:
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/mpfr && \
- $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM" $(EXTRA_BOOTSTRAP_FLAGS) check)
+ $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="-DNO_ASM $(PICFLAG)" $(EXTRA_BOOTSTRAP_FLAGS) check)
@endif mpfr
@@ -15004,7 +15005,7 @@ info-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing info in mpfr"; \
@@ -15029,7 +15030,7 @@ dvi-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing dvi in mpfr"; \
@@ -15054,7 +15055,7 @@ pdf-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing pdf in mpfr"; \
@@ -15079,7 +15080,7 @@ html-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing html in mpfr"; \
@@ -15104,7 +15105,7 @@ TAGS-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing TAGS in mpfr"; \
@@ -15130,7 +15131,7 @@ install-info-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-info in mpfr"; \
@@ -15156,7 +15157,7 @@ install-dvi-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-dvi in mpfr"; \
@@ -15182,7 +15183,7 @@ install-pdf-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-pdf in mpfr"; \
@@ -15208,7 +15209,7 @@ install-html-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-html in mpfr"; \
@@ -15233,7 +15234,7 @@ installcheck-mpfr: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing installcheck in mpfr"; \
@@ -15257,7 +15258,7 @@ mostlyclean-mpfr:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing mostlyclean in mpfr"; \
@@ -15281,7 +15282,7 @@ clean-mpfr:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing clean in mpfr"; \
@@ -15305,7 +15306,7 @@ distclean-mpfr:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing distclean in mpfr"; \
@@ -15329,7 +15330,7 @@ maintainer-clean-mpfr:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM"; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="-DNO_ASM $(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing maintainer-clean in mpfr"; \
@@ -15698,7 +15699,7 @@ all-mpc: configure-mpc
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
$(TARGET-mpc))
@endif mpc
@@ -15729,7 +15730,7 @@ all-stage1-mpc: configure-stage1-mpc
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
$(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) \
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE1_TFLAGS)" \
$(TARGET-stage1-mpc)
@@ -15744,7 +15745,7 @@ clean-stage1-mpc:
fi; \
cd $(HOST_SUBDIR)/mpc && \
$(MAKE) $(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) clean
+ $(STAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15773,7 +15774,7 @@ all-stage2-mpc: configure-stage2-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE2_TFLAGS)" \
$(TARGET-stage2-mpc)
@@ -15787,7 +15788,7 @@ clean-stage2-mpc:
$(MAKE) stage2-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15816,7 +15817,7 @@ all-stage3-mpc: configure-stage3-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE3_TFLAGS)" \
$(TARGET-stage3-mpc)
@@ -15830,7 +15831,7 @@ clean-stage3-mpc:
$(MAKE) stage3-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15859,7 +15860,7 @@ all-stage4-mpc: configure-stage4-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE4_TFLAGS)" \
$(TARGET-stage4-mpc)
@@ -15873,7 +15874,7 @@ clean-stage4-mpc:
$(MAKE) stage4-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15902,7 +15903,7 @@ all-stageprofile-mpc: configure-stageprofile-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEprofile_TFLAGS)" \
$(TARGET-stageprofile-mpc)
@@ -15916,7 +15917,7 @@ clean-stageprofile-mpc:
$(MAKE) stageprofile-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15945,7 +15946,7 @@ all-stagetrain-mpc: configure-stagetrain-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEtrain_TFLAGS)" \
$(TARGET-stagetrain-mpc)
@@ -15959,7 +15960,7 @@ clean-stagetrain-mpc:
$(MAKE) stagetrain-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -15988,7 +15989,7 @@ all-stagefeedback-mpc: configure-stagefeedback-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEfeedback_TFLAGS)" \
$(TARGET-stagefeedback-mpc)
@@ -16002,7 +16003,7 @@ clean-stagefeedback-mpc:
$(MAKE) stagefeedback-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -16031,7 +16032,7 @@ all-stageautoprofile-mpc: configure-stageautoprofile-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEautoprofile_TFLAGS)" \
$(TARGET-stageautoprofile-mpc)
@@ -16045,7 +16046,7 @@ clean-stageautoprofile-mpc:
$(MAKE) stageautoprofile-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -16074,7 +16075,7 @@ all-stageautofeedback-mpc: configure-stageautofeedback-mpc
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEautofeedback_TFLAGS)" PERF_DATA=perf.data \
$(TARGET-stageautofeedback-mpc)
@@ -16088,7 +16089,7 @@ clean-stageautofeedback-mpc:
$(MAKE) stageautofeedback-start; \
fi; \
cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" clean
@endif mpc-bootstrap
@@ -16106,7 +16107,7 @@ check-mpc:
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/mpc && \
- $(MAKE) $(FLAGS_TO_PASS) $(EXTRA_BOOTSTRAP_FLAGS) check)
+ $(MAKE) $(FLAGS_TO_PASS) AM_CFLAGS="$(PICFLAG)" $(EXTRA_BOOTSTRAP_FLAGS) check)
@endif mpc
@@ -16141,7 +16142,7 @@ info-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing info in mpc"; \
@@ -16166,7 +16167,7 @@ dvi-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing dvi in mpc"; \
@@ -16191,7 +16192,7 @@ pdf-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing pdf in mpc"; \
@@ -16216,7 +16217,7 @@ html-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing html in mpc"; \
@@ -16241,7 +16242,7 @@ TAGS-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing TAGS in mpc"; \
@@ -16267,7 +16268,7 @@ install-info-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-info in mpc"; \
@@ -16293,7 +16294,7 @@ install-dvi-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-dvi in mpc"; \
@@ -16319,7 +16320,7 @@ install-pdf-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-pdf in mpc"; \
@@ -16345,7 +16346,7 @@ install-html-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-html in mpc"; \
@@ -16370,7 +16371,7 @@ installcheck-mpc: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing installcheck in mpc"; \
@@ -16394,7 +16395,7 @@ mostlyclean-mpc:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing mostlyclean in mpc"; \
@@ -16418,7 +16419,7 @@ clean-mpc:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing clean in mpc"; \
@@ -16442,7 +16443,7 @@ distclean-mpc:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing distclean in mpc"; \
@@ -16466,7 +16467,7 @@ maintainer-clean-mpc:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) ; do \
+ for flag in $(EXTRA_HOST_FLAGS) AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing maintainer-clean in mpc"; \
@@ -16835,7 +16836,7 @@ all-isl: configure-isl
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) V=1 \
+ $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
$(TARGET-isl))
@endif isl
@@ -16866,7 +16867,7 @@ all-stage1-isl: configure-stage1-isl
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
$(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) V=1 \
+ $(STAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE1_TFLAGS)" \
$(TARGET-stage1-isl)
@@ -16881,7 +16882,7 @@ clean-stage1-isl:
fi; \
cd $(HOST_SUBDIR)/isl && \
$(MAKE) $(EXTRA_HOST_FLAGS) \
- $(STAGE1_FLAGS_TO_PASS) V=1 clean
+ $(STAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -16910,7 +16911,7 @@ all-stage2-isl: configure-stage2-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE2_TFLAGS)" \
$(TARGET-stage2-isl)
@@ -16924,7 +16925,7 @@ clean-stage2-isl:
$(MAKE) stage2-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -16953,7 +16954,7 @@ all-stage3-isl: configure-stage3-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE3_TFLAGS)" \
$(TARGET-stage3-isl)
@@ -16967,7 +16968,7 @@ clean-stage3-isl:
$(MAKE) stage3-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -16996,7 +16997,7 @@ all-stage4-isl: configure-stage4-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGE4_TFLAGS)" \
$(TARGET-stage4-isl)
@@ -17010,7 +17011,7 @@ clean-stage4-isl:
$(MAKE) stage4-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17039,7 +17040,7 @@ all-stageprofile-isl: configure-stageprofile-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEprofile_TFLAGS)" \
$(TARGET-stageprofile-isl)
@@ -17053,7 +17054,7 @@ clean-stageprofile-isl:
$(MAKE) stageprofile-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17082,7 +17083,7 @@ all-stagetrain-isl: configure-stagetrain-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEtrain_TFLAGS)" \
$(TARGET-stagetrain-isl)
@@ -17096,7 +17097,7 @@ clean-stagetrain-isl:
$(MAKE) stagetrain-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17125,7 +17126,7 @@ all-stagefeedback-isl: configure-stagefeedback-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEfeedback_TFLAGS)" \
$(TARGET-stagefeedback-isl)
@@ -17139,7 +17140,7 @@ clean-stagefeedback-isl:
$(MAKE) stagefeedback-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17168,7 +17169,7 @@ all-stageautoprofile-isl: configure-stageautoprofile-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEautoprofile_TFLAGS)" \
$(TARGET-stageautoprofile-isl)
@@ -17182,7 +17183,7 @@ clean-stageautoprofile-isl:
$(MAKE) stageautoprofile-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17211,7 +17212,7 @@ all-stageautofeedback-isl: configure-stageautofeedback-isl
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
- $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
+ $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" \
TFLAGS="$(STAGEautofeedback_TFLAGS)" PERF_DATA=perf.data \
$(TARGET-stageautofeedback-isl)
@@ -17225,7 +17226,7 @@ clean-stageautofeedback-isl:
$(MAKE) stageautofeedback-start; \
fi; \
cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+ $(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" clean
@endif isl-bootstrap
@@ -17243,7 +17244,7 @@ check-isl:
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/isl && \
- $(MAKE) $(FLAGS_TO_PASS) V=1 $(EXTRA_BOOTSTRAP_FLAGS) check)
+ $(MAKE) $(FLAGS_TO_PASS) V=1 AM_CFLAGS="$(PICFLAG)" $(EXTRA_BOOTSTRAP_FLAGS) check)
@endif isl
@@ -17278,7 +17279,7 @@ info-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing info in isl"; \
@@ -17303,7 +17304,7 @@ dvi-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing dvi in isl"; \
@@ -17328,7 +17329,7 @@ pdf-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing pdf in isl"; \
@@ -17353,7 +17354,7 @@ html-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing html in isl"; \
@@ -17378,7 +17379,7 @@ TAGS-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing TAGS in isl"; \
@@ -17404,7 +17405,7 @@ install-info-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-info in isl"; \
@@ -17430,7 +17431,7 @@ install-dvi-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-dvi in isl"; \
@@ -17456,7 +17457,7 @@ install-pdf-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-pdf in isl"; \
@@ -17482,7 +17483,7 @@ install-html-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing install-html in isl"; \
@@ -17507,7 +17508,7 @@ installcheck-isl: \
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing installcheck in isl"; \
@@ -17531,7 +17532,7 @@ mostlyclean-isl:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing mostlyclean in isl"; \
@@ -17555,7 +17556,7 @@ clean-isl:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing clean in isl"; \
@@ -17579,7 +17580,7 @@ distclean-isl:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing distclean in isl"; \
@@ -17603,7 +17604,7 @@ maintainer-clean-isl:
r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
- for flag in $(EXTRA_HOST_FLAGS) V=1; do \
+ for flag in $(EXTRA_HOST_FLAGS) V=1 AM_CFLAGS="$(PICFLAG)"; do \
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
done; \
echo "Doing maintainer-clean in isl"; \
diff --git a/Makefile.tpl b/Makefile.tpl
index c7344558429..b73dd6f4b19 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -431,6 +431,7 @@ READELF = @READELF@
STRIP = @STRIP@
WINDRES = @WINDRES@
WINDMC = @WINDMC@
+PICFLAG = @PICFLAG@
GDC = @GDC@
GNATBIND = @GNATBIND@
diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
index d6a33613732..4d5a5b0522b 100644
--- a/c++tools/Makefile.in
+++ b/c++tools/Makefile.in
@@ -28,8 +28,9 @@ AUTOCONF := @AUTOCONF@
AUTOHEADER := @AUTOHEADER@
CXX := @CXX@
CXXFLAGS := @CXXFLAGS@
-PIEFLAG := @PIEFLAG@
-CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
+PICFLAG := @PICFLAG@
+LD_PICFLAG := @LD_PICFLAG@
+CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
LDFLAGS := @LDFLAGS@
exeext := @EXEEXT@
LIBIBERTY := ../libiberty/libiberty.a
@@ -88,11 +89,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
all::g++-mapper-server$(exeext)
+ifneq ($(PICFLAG),)
+override LIBIBERTY := ../libiberty/pic/libiberty.a
+endif
+
MAPPER.O := server.o resolver.o
CODYLIB = ../libcody/libcody.a
CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
- +$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
+ +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
# copy to gcc dir so tests there can run
all::../gcc/g++-mapper-server$(exeext)
diff --git a/c++tools/configure b/c++tools/configure
index 742816e4253..88087009383 100755
--- a/c++tools/configure
+++ b/c++tools/configure
@@ -627,7 +627,8 @@ get_gcc_base_ver
EGREP
GREP
CXXCPP
-PIEFLAG
+LD_PICFLAG
+PICFLAG
MAINTAINER
CXX_AUX_TOOLS
AUTOHEADER
@@ -700,6 +701,7 @@ enable_c___tools
enable_maintainer_mode
enable_checking
enable_default_pie
+enable_host_pie
with_gcc_major_version_only
'
ac_precious_vars='build_alias
@@ -1333,6 +1335,7 @@ Optional Features:
only specific categories of checks. Categories are:
yes,no,all,none,release.
--enable-default-pie enable Position Independent Executable as default
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -2990,12 +2993,20 @@ fi
# Check whether --enable-default-pie was given.
# Check whether --enable-default-pie was given.
if test "${enable_default_pie+set}" = set; then :
- enableval=$enable_default_pie; PIEFLAG=-fPIE
+ enableval=$enable_default_pie; PICFLAG=-fPIE
else
- PIEFLAG=
+ PICFLAG=
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
+fi
+
+
+
# Check if O_CLOEXEC is defined by fcntl
diff --git a/c++tools/configure.ac b/c++tools/configure.ac
index 6662b5ad7c9..1e42689f2eb 100644
--- a/c++tools/configure.ac
+++ b/c++tools/configure.ac
@@ -102,8 +102,15 @@ fi
AC_ARG_ENABLE(default-pie,
[AS_HELP_STRING([--enable-default-pie],
[enable Position Independent Executable as default])],
-[PIEFLAG=-fPIE], [PIEFLAG=])
-AC_SUBST([PIEFLAG])
+[PICFLAG=-fPIE], [PICFLAG=])
+
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])],
+[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
# Check if O_CLOEXEC is defined by fcntl
AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
diff --git a/configure b/configure
index c13b24055b3..426b624a097 100755
--- a/configure
+++ b/configure
@@ -685,6 +685,8 @@ get_gcc_base_ver
extra_host_zlib_configure_flags
extra_host_libiberty_configure_flags
stage1_languages
+PICFLAG
+enable_host_pie
host_shared
extra_linker_plugin_flags
extra_linker_plugin_configure_flags
@@ -828,6 +830,7 @@ enable_lto
enable_linker_plugin_configure_flags
enable_linker_plugin_flags
enable_host_shared
+enable_host_pie
enable_stage1_languages
enable_objc_gc
with_target_bdw_gc
@@ -1554,6 +1557,7 @@ Optional Features:
additional flags for configuring and building linker
plugins [none]
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-stage1-languages[=all]
choose additional languages to build during stage1.
Mostly useful for compiler development
@@ -8596,6 +8600,24 @@ fi
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+
+
# By default, C and C++ are the only stage 1 languages.
stage1_languages=,c,
diff --git a/configure.ac b/configure.ac
index 8f3a4f38e30..fb70a9d01ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1870,6 +1870,22 @@ AC_ARG_ENABLE(host-shared,
esac])
AC_SUBST(host_shared)
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+AC_SUBST(PICFLAG)
+
# By default, C and C++ are the only stage 1 languages.
stage1_languages=,c,
diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
index 1937dcaa32d..990c08e5699 100644
--- a/fixincludes/Makefile.in
+++ b/fixincludes/Makefile.in
@@ -30,6 +30,8 @@ CC = @CC@
CFLAGS = @CFLAGS@
WARN_CFLAGS = @WARN_CFLAGS@ @WARN_PEDANTIC@ @WERROR@
LDFLAGS = @LDFLAGS@
+PICFLAG = @PICFLAG@
+LD_PICFLAG = @LD_PICFLAG@
INCLUDES = -I. -I$(srcdir) -I../include -I$(srcdir)/../include
FIXINC_CFLAGS = -DHAVE_CONFIG_H $(INCLUDES)
@@ -73,7 +75,7 @@ default : all
# Now figure out from those variables how to compile and link.
.c.o:
- $(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
+ $(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
# The only suffixes we want for implicit rules are .c and .o.
.SUFFIXES:
@@ -87,7 +89,11 @@ default : all
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+ifeq ($(PICFLAG),)
LIBIBERTY=../libiberty/libiberty.a
+else
+LIBIBERTY=../libiberty/pic/libiberty.a
+endif
ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
fixlib.o fixopts.o
@@ -107,15 +113,15 @@ oneprocess : full-stamp
twoprocess : test-stamp $(AF)
full-stamp : $(ALLOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
$(STAMP) $@
test-stamp : $(TESTOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
$(STAMP) $@
$(AF): $(FIXOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
$(ALLOBJ) : $(HDR)
fixincl.o : fixincl.c $(srcdir)/fixincl.x
diff --git a/fixincludes/configure b/fixincludes/configure
index b3bca666a4d..67a7597a30b 100755
--- a/fixincludes/configure
+++ b/fixincludes/configure
@@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
get_gcc_base_ver
MAINT
+LD_PICFLAG
+PICFLAG
TARGET
target_noncanonical
WERROR
@@ -695,6 +697,7 @@ enable_option_checking
enable_werror_always
with_local_prefix
enable_twoprocess
+enable_host_pie
enable_maintainer_mode
with_gcc_major_version_only
'
@@ -1323,6 +1326,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-werror-always enable -Werror despite compiler version
--enable-twoprocess Use a separate process to apply the fixes
+ --enable-host-pie build host code as PIE
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
@@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
fi
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
+fi
+
+
+
+
case $host in
vax-dec-bsd* )
diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
index 14813b910f1..ec8534f769f 100644
--- a/fixincludes/configure.ac
+++ b/fixincludes/configure.ac
@@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
[Define if testing and fixing are done by separate process])
fi
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])],
+[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
+
case $host in
vax-dec-bsd* )
AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 4982012f5b2..e27ebef426d 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -157,6 +157,9 @@ LDFLAGS = @LDFLAGS@
# Should we build position-independent host code?
PICFLAG = @PICFLAG@
+# The linker flag for the above.
+LD_PICFLAG = @LD_PICFLAG@
+
# Flags to determine code coverage. When coverage is disabled, this will
# contain the optimization flags, as you normally want code coverage
# without optimization.
@@ -265,18 +268,17 @@ LINKER = $(CC)
LINKER_FLAGS = $(CFLAGS)
endif
+enable_host_pie = @enable_host_pie@
+
# Enable Intel CET on Intel CET enabled host if needed.
CET_HOST_FLAGS = @CET_HOST_FLAGS@
COMPILER += $(CET_HOST_FLAGS)
-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
-NO_PIE_FLAG = @NO_PIE_FLAG@
-
-# We don't want to compile the compilers with -fPIE, it make PCH fail.
-COMPILER += $(NO_PIE_CFLAGS)
+# Maybe compile the compilers with -fPIE or -fPIC.
+COMPILER += $(PICFLAG)
-# Link with -no-pie since we compile the compiler with -fno-PIE.
-LINKER += $(NO_PIE_FLAG)
+# Link with -pie, or -no-pie, depending on the above.
+LINKER += $(LD_PICFLAG)
# Like LINKER, but use a mutex for serializing front end links.
ifeq (@DO_LINK_MUTEX@,true)
@@ -1049,18 +1051,21 @@ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
# This is the variable to use when using $(LINKER).
-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
+ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
# Build and host support libraries.
-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
-# building for mingw.
+# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
+# unless we are building for mingw.
LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
-ifeq ($(enable_host_shared),yes)
+ifneq ($(enable_host_shared)$(enable_host_pie),)
LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
else
LIBIBERTY = ../libiberty/libiberty.a
+endif
+ifeq ($(enable_host_shared),yes)
+BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+else
BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
endif
diff --git a/gcc/configure b/gcc/configure
index 1a32f894394..3e303f7e5bd 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -632,10 +632,10 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
-NO_PIE_FLAG
-NO_PIE_CFLAGS
-enable_default_pie
+LD_PICFLAG
PICFLAG
+enable_default_pie
+enable_host_pie
enable_host_shared
enable_plugin
pluginlibs
@@ -1029,6 +1029,7 @@ enable_link_serialization
enable_version_specific_runtime_libs
enable_plugin
enable_host_shared
+enable_host_pie
enable_libquadmath_support
with_linker_hash_style
with_diagnostics_color
@@ -1791,6 +1792,7 @@ Optional Features:
in a compiler-specific directory
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--disable-libquadmath-support
disable libquadmath support for Fortran
--enable-default-pie enable Position Independent Executable as default
@@ -19762,7 +19764,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19765 "configure"
+#line 19779 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19868,7 +19870,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19871 "configure"
+#line 19885 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -31997,13 +31999,17 @@ fi
# Enable --enable-host-shared
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
-else
- PICFLAG=
+ enableval=$enable_host_shared;
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
# Check whether --enable-libquadmath-support was given.
@@ -32157,10 +32163,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
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"
-fi
-
# Check if -no-pie works.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
@@ -32185,11 +32187,28 @@ rm -f core conftest.err conftest.$ac_objext \
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"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
fi
+
+
# Enable Intel CET on Intel CET enabled host if jit is enabled.
# Check whether --enable-cet was given.
if test "${enable_cet+set}" = set; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index f87fab97edd..29eeed7e569 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7402,11 +7402,14 @@ fi
# Enable --enable-host-shared
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
AC_SUBST(enable_host_shared)
-AC_SUBST(PICFLAG)
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
AC_ARG_ENABLE(libquadmath-support,
[AS_HELP_STRING([--disable-libquadmath-support],
@@ -7528,10 +7531,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
[gcc_cv_c_no_fpie=yes],
[gcc_cv_c_no_fpie=no])
CXXFLAGS="$saved_CXXFLAGS"])
-if test "$gcc_cv_c_no_fpie" = "yes"; then
- NO_PIE_CFLAGS="-fno-PIE"
-fi
-AC_SUBST([NO_PIE_CFLAGS])
# Check if -no-pie works.
AC_CACHE_CHECK([for -no-pie option],
@@ -7542,10 +7541,27 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
-if test "$gcc_cv_no_pie" = "yes"; then
- NO_PIE_FLAG="-no-pie"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
fi
-AC_SUBST([NO_PIE_FLAG])
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
+fi
+
+AC_SUBST([PICFLAG])
+AC_SUBST([LD_PICFLAG])
# Enable Intel CET on Intel CET enabled host if jit is enabled.
GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index b7a4ef3af15..2898f37d030 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
$(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
$(WARN_DFLAGS)
-DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
+DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
diff --git a/gcc/doc/install/configuration.rst b/gcc/doc/install/configuration.rst
index c090d7a86a1..c2a9680e1e5 100644
--- a/gcc/doc/install/configuration.rst
+++ b/gcc/doc/install/configuration.rst
@@ -425,14 +425,27 @@ corresponding :option:`--without` option.
.. option:: --enable-host-shared
Specify that the *host* code should be built into position-independent
- machine code (with -fPIC), allowing it to be used within shared libraries,
- but yielding a slightly slower compiler.
+ machine code (with :option:`-fPIC`), allowing it to be used within shared
+ libraries, but yielding a slightly slower compiler.
This option is required when building the libgccjit.so library.
Contrast with :option:`--enable-shared`, which affects *target*
libraries.
+.. option:: --enable-host-pie
+
+ Specify that the *host* executables should be built into position-independent
+ executables (with :option:`-fPIE` and :option:`-pie`), yielding a slightly
+ slower compiler (but faster than :option:`--enable-host-shared`).
+ Position-independent executables are loaded at random addresses each time
+ they are executed, therefore provide additional protection against Return
+ Oriented Programming (ROP) attacks.
+
+ :option:`--enable-host-pie` may be used with :option:`--enable-host-shared`,
+ in which case :option:`-fPIC` is used when compiling, and :option:`-pie`
+ when linking.
+
.. option:: --with-gnu-as
.. _with-gnu-as:
diff --git a/intl/Makefile.in b/intl/Makefile.in
index 409d693c48e..5beebdc152c 100644
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -54,7 +54,7 @@ CTAGS = @CTAGS@
ETAGS = @ETAGS@
MKID = @MKID@
-COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
+COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
HEADERS = \
gmo.h \
diff --git a/intl/configure b/intl/configure
index 03f40487a92..79bb5831a47 100755
--- a/intl/configure
+++ b/intl/configure
@@ -623,6 +623,8 @@ ac_header_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
PICFLAG
+enable_host_pie
+enable_host_shared
BISON3_NO
BISON3_YES
INCINTL
@@ -731,6 +733,7 @@ with_libintl_prefix
with_libintl_type
enable_maintainer_mode
enable_host_shared
+enable_host_pie
'
ac_precious_vars='build_alias
host_alias
@@ -1356,6 +1359,7 @@ Optional Features:
--disable-rpath do not hardcode runtime library paths
--enable-maintainer-mode enable rules only needed by maintainers
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -6852,15 +6856,31 @@ fi
+# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
-
ac_config_files="$ac_config_files Makefile config.intl"
cat >confcache <<\_ACEOF
diff --git a/intl/configure.ac b/intl/configure.ac
index 16a740aa230..81aa831f59f 100644
--- a/intl/configure.ac
+++ b/intl/configure.ac
@@ -83,10 +83,25 @@ fi
AC_SUBST(BISON3_YES)
AC_SUBST(BISON3_NO)
+# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
AC_SUBST(PICFLAG)
AC_CONFIG_FILES(Makefile config.intl)
diff --git a/libcody/Makefile.in b/libcody/Makefile.in
index bb87468cb9a..cb01b0092d8 100644
--- a/libcody/Makefile.in
+++ b/libcody/Makefile.in
@@ -31,7 +31,7 @@ endif
CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
# Linker options
-LDFLAGS := @LDFLAGS@
+LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
LIBS := @LIBS@
# Per-source & per-directory compile flags (warning: recursive)
diff --git a/libcody/configure b/libcody/configure
index da52a5cfca5..0e536c0ccb0 100755
--- a/libcody/configure
+++ b/libcody/configure
@@ -591,7 +591,10 @@ configure_args
AR
RANLIB
EXCEPTIONS
+LD_PICFLAG
PICFLAG
+enable_host_pie
+enable_host_shared
OBJEXT
EXEEXT
ac_ct_CXX
@@ -653,6 +656,7 @@ enable_maintainer_mode
with_compiler
enable_checking
enable_host_shared
+enable_host_pie
enable_exceptions
'
ac_precious_vars='build_alias
@@ -1286,6 +1290,7 @@ Optional Features:
yes,no,all,none,release. Flags are: misc,valgrind or
other strings
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-exceptions enable exceptions & rtti
Optional Packages:
@@ -2635,11 +2640,34 @@ fi
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
+
# Check whether --enable-exceptions was given.
diff --git a/libcody/configure.ac b/libcody/configure.ac
index 960191ecb72..14e8dd4a226 100644
--- a/libcody/configure.ac
+++ b/libcody/configure.ac
@@ -63,9 +63,31 @@ fi
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
NMS_ENABLE_EXCEPTIONS
diff --git a/libcpp/configure b/libcpp/configure
index 75145390215..85168273cd1 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -625,6 +625,8 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
MAINT
USED_CATALOGS
PACKAGE
@@ -738,6 +740,7 @@ enable_maintainer_mode
enable_checking
enable_canonical_system_headers
enable_host_shared
+enable_host_pie
enable_cet
enable_valgrind_annotations
'
@@ -1379,6 +1382,7 @@ Optional Features:
--enable-canonical-system-headers
enable or disable system headers canonicalization
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
--enable-valgrind-annotations
enable valgrind runtime interaction
@@ -7605,7 +7609,23 @@ esac
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 9b6042518e5..d25bf5f414f 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -211,8 +211,23 @@ esac
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/libdecnumber/configure b/libdecnumber/configure
index fb6db05565a..84bc4ffc767 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
ADDITIONAL_OBJS
enable_decimal_float
target_os
@@ -706,6 +708,7 @@ enable_werror_always
enable_maintainer_mode
enable_decimal_float
enable_host_shared
+enable_host_pie
enable_cet
'
ac_precious_vars='build_alias
@@ -1338,6 +1341,7 @@ Optional Features:
or 'dpd' choses which decimal floating point format
to use
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
Some influential environment variables:
@@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
index 0794031ec83..14f67f926d1 100644
--- a/libdecnumber/configure.ac
+++ b/libdecnumber/configure.ac
@@ -100,8 +100,23 @@ AC_C_BIGENDIAN
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/libiberty/configure b/libiberty/configure
index 7ee5d6002f7..e8b5b52ca96 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5310,8 +5310,8 @@ case "${enable_shared}" in
*) shared=yes ;;
esac
-# ...unless --enable-host-shared was passed from top-level config:
-if [ "${enable_host_shared}" = "yes" ]; then
+# ...unless --enable-host-{shared,pie} was passed from top-level config:
+if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
shared=yes
fi
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index b2cfef90489..d65617663ce 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -271,8 +271,8 @@ case "${enable_shared}" in
*) shared=yes ;;
esac
-# ...unless --enable-host-shared was passed from top-level config:
-if [[ "${enable_host_shared}" = "yes" ]]; then
+# ...unless --enable-host-{shared,pie} was passed from top-level config:
+if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
shared=yes
fi
diff --git a/zlib/configure b/zlib/configure
index e35ac6e7e17..77be6c284e3 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -635,6 +635,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
PICFLAG
+enable_host_pie
+enable_host_shared
TARGET_LIBRARY_FALSE
TARGET_LIBRARY_TRUE
toolexeclibdir
@@ -778,6 +780,7 @@ with_gnu_ld
enable_libtool_lock
with_toolexeclibdir
enable_host_shared
+enable_host_pie
'
ac_precious_vars='build_alias
host_alias
@@ -1420,6 +1423,7 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -10759,7 +10763,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10762 "configure"
+#line 10778 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10865,7 +10869,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10868 "configure"
+#line 10884 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11548,15 +11552,31 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
-
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
diff --git a/zlib/configure.ac b/zlib/configure.ac
index be1cfe29651..adf7aad4e51 100644
--- a/zlib/configure.ac
+++ b/zlib/configure.ac
@@ -122,11 +122,26 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
-AC_SUBST(PICFLAG)
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+AC_SUBST(PICFLAG)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
base-commit: 5c6546ca7d8cab1f1c129f5b55f709e2ceee0f94
--
2.38.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] configure: Implement --enable-host-pie
2022-11-11 2:52 [PATCH] configure: Implement --enable-host-pie Marek Polacek
@ 2022-11-20 15:06 ` Jeff Law
2022-11-23 2:18 ` Marek Polacek
0 siblings, 1 reply; 8+ messages in thread
From: Jeff Law @ 2022-11-20 15:06 UTC (permalink / raw)
To: Marek Polacek, GCC Patches; +Cc: oliva, Joseph Myers
On 11/10/22 19:52, Marek Polacek via Gcc-patches wrote:
> This is a rebased version of the patch I posted in March:
> <https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591239.html>
> which Alex sort of approved here:
> <https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592360.html>
> but it was too late to commit the patch in GCC 12.
>
> There are no changes except that I've converted the documentation
> part into the ReST format, and of course regenerated configure.
>
> With --enable-host-pie enabled:
> $ file ./gcc/cc1 ./gcc/cc1plus
> ./gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> ./gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu w/ and w/o --enable-host-pie,
> ok for trunk?
>
> -- >8 --
>
> This patch implements the --enable-host-pie configure option which
> makes the compiler executables PIE. This can be used to enhance
> protection against ROP attacks, and can be viewed as part of a wider
> trend to harden binaries.
>
> It is similar to the option --enable-host-shared, except that --e-h-s
> won't add -shared to the linker flags whereas --e-h-p will add -pie.
> It is different from --enable-default-pie because that option just
> adds an implicit -fPIE/-pie when the compiler is invoked, but the
> compiler itself isn't PIE.
>
> Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
> regressions.
>
> When building the compiler, the build process may use various in-tree
> libraries; these need to be built with -fPIE so that it's possible to
> use them when building a PIE. For instance, when --with-included-gettext
> is in effect, intl object files must be compiled with -fPIE. Similarly,
> when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
> -fPIE.
>
> I plan to add an option to link with -Wl,-z,now.
>
> ChangeLog:
>
> * Makefile.def: Pass $(PICFLAG) to AM_CFLAGS for gmp, mpfr, mpc, and
> isl.
> * Makefile.in: Regenerate.
> * Makefile.tpl: Set PICFLAG.
> * configure.ac (--enable-host-pie): New check. Set PICFLAG after this
> check.
> * configure: Regenerate.
>
> c++tools/ChangeLog:
>
> * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
> Use pic/libiberty.a if PICFLAG is set.
> * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
> (--enable-host-pie): New check.
> * configure: Regenerate.
>
> fixincludes/ChangeLog:
>
> * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
> build of libiberty if PICFLAG is set.
> * configure.ac:
> * configure: Regenerate.
>
> gcc/ChangeLog:
>
> * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
> Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
> ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> check.
> * configure: Regenerate.
> * doc/install/configuration.rst: Document --enable-host-pie.
>
> gcc/d/ChangeLog:
>
> * Make-lang.in: Remove NO_PIE_CFLAGS.
>
> intl/ChangeLog:
>
> * Makefile.in: Use @PICFLAG@ in COMPILE as well.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libcody/ChangeLog:
>
> * Makefile.in: Pass LD_PICFLAG to LDFLAGS.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> check.
> * configure: Regenerate.
>
> libcpp/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libdecnumber/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libiberty/ChangeLog:
>
> * configure.ac: Also set shared when enable_host_pie.
> * configure: Regenerate.
>
> zlib/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
OK.
Jeff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] configure: Implement --enable-host-pie
2022-11-20 15:06 ` Jeff Law
@ 2022-11-23 2:18 ` Marek Polacek
0 siblings, 0 replies; 8+ messages in thread
From: Marek Polacek @ 2022-11-23 2:18 UTC (permalink / raw)
To: Jeff Law; +Cc: GCC Patches, oliva, Joseph Myers
On Sun, Nov 20, 2022 at 08:06:55AM -0700, Jeff Law wrote:
>
> On 11/10/22 19:52, Marek Polacek via Gcc-patches wrote:
> > This is a rebased version of the patch I posted in March:
> > <https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591239.html>
> > which Alex sort of approved here:
> > <https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592360.html>
> > but it was too late to commit the patch in GCC 12.
> >
> > There are no changes except that I've converted the documentation
> > part into the ReST format, and of course regenerated configure.
> >
> > With --enable-host-pie enabled:
> > $ file ./gcc/cc1 ./gcc/cc1plus
> > ./gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> > ./gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> >
> > Bootstrapped/regtested on x86_64-pc-linux-gnu w/ and w/o --enable-host-pie,
> > ok for trunk?
> >
> > -- >8 --
> >
> > This patch implements the --enable-host-pie configure option which
> > makes the compiler executables PIE. This can be used to enhance
> > protection against ROP attacks, and can be viewed as part of a wider
> > trend to harden binaries.
> >
> > It is similar to the option --enable-host-shared, except that --e-h-s
> > won't add -shared to the linker flags whereas --e-h-p will add -pie.
> > It is different from --enable-default-pie because that option just
> > adds an implicit -fPIE/-pie when the compiler is invoked, but the
> > compiler itself isn't PIE.
> >
> > Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
> > regressions.
> >
> > When building the compiler, the build process may use various in-tree
> > libraries; these need to be built with -fPIE so that it's possible to
> > use them when building a PIE. For instance, when --with-included-gettext
> > is in effect, intl object files must be compiled with -fPIE. Similarly,
> > when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
> > -fPIE.
> >
> > I plan to add an option to link with -Wl,-z,now.
> >
> > ChangeLog:
> >
> > * Makefile.def: Pass $(PICFLAG) to AM_CFLAGS for gmp, mpfr, mpc, and
> > isl.
> > * Makefile.in: Regenerate.
> > * Makefile.tpl: Set PICFLAG.
> > * configure.ac (--enable-host-pie): New check. Set PICFLAG after this
> > check.
> > * configure: Regenerate.
> >
> > c++tools/ChangeLog:
> >
> > * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
> > Use pic/libiberty.a if PICFLAG is set.
> > * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
> > (--enable-host-pie): New check.
> > * configure: Regenerate.
> >
> > fixincludes/ChangeLog:
> >
> > * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
> > build of libiberty if PICFLAG is set.
> > * configure.ac:
> > * configure: Regenerate.
> >
> > gcc/ChangeLog:
> >
> > * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
> > Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
> > ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> > check.
> > * configure: Regenerate.
> > * doc/install/configuration.rst: Document --enable-host-pie.
> >
> > gcc/d/ChangeLog:
> >
> > * Make-lang.in: Remove NO_PIE_CFLAGS.
> >
> > intl/ChangeLog:
> >
> > * Makefile.in: Use @PICFLAG@ in COMPILE as well.
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG after this check.
> > * configure: Regenerate.
> >
> > libcody/ChangeLog:
> >
> > * Makefile.in: Pass LD_PICFLAG to LDFLAGS.
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> > check.
> > * configure: Regenerate.
> >
> > libcpp/ChangeLog:
> >
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG after this check.
> > * configure: Regenerate.
> >
> > libdecnumber/ChangeLog:
> >
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG after this check.
> > * configure: Regenerate.
> >
> > libiberty/ChangeLog:
> >
> > * configure.ac: Also set shared when enable_host_pie.
> > * configure: Regenerate.
> >
> > zlib/ChangeLog:
> >
> > * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> > (--enable-host-pie): New check. Set PICFLAG after this check.
> > * configure: Regenerate.
>
> OK.
Thanks! Unfortunately, even though I'd retested the patch before pushing,
it seemed to break the build on gcc-debian-amd64:
https://builder.sourceware.org/buildbot/#/builders/154/builds/2160/steps/4/logs/stdio
so I've reverted both patches. Sigh.
Marek
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] configure: Implement --enable-host-pie
2023-05-16 15:29 ` Marek Polacek
@ 2023-05-16 20:11 ` Iain Sandoe
0 siblings, 0 replies; 8+ messages in thread
From: Iain Sandoe @ 2023-05-16 20:11 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
Hi Marek,
> On 16 May 2023, at 16:29, Marek Polacek via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> Ping.
I’m trying this on Darwin (since I have a local patch to do this for modern [darwin20+]
versions, which do not allow non-PIE)
I think you are missing a hunk to deal with Ada.
thanks for the patch
Iain
>
> On Tue, May 09, 2023 at 03:41:58PM -0400, Marek Polacek via Gcc-patches wrote:
>> [ This is my third attempt to add this configure option. The first
>> version was approved but it came too late in the development cycle.
>> The second version was also approved, but I had to revert it:
>> <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
>> I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
>> ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer
>> need to touch Makefile.def, so this patch is simplified. ]
>>
>> This patch implements the --enable-host-pie configure option which
>> makes the compiler executables PIE. This can be used to enhance
>> protection against ROP attacks, and can be viewed as part of a wider
>> trend to harden binaries.
>>
>> It is similar to the option --enable-host-shared, except that --e-h-s
>> won't add -shared to the linker flags whereas --e-h-p will add -pie.
>> It is different from --enable-default-pie because that option just
>> adds an implicit -fPIE/-pie when the compiler is invoked, but the
>> compiler itself isn't PIE.
>>
>> Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
>> regressions.
>>
>> When building the compiler, the build process may use various in-tree
>> libraries; these need to be built with -fPIE so that it's possible to
>> use them when building a PIE. For instance, when --with-included-gettext
>> is in effect, intl object files must be compiled with -fPIE. Similarly,
>> when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
>> -fPIE.
>>
>> With this patch and --enable-host-pie used to configure gcc:
>>
>> $ file gcc/cc1{,plus,obj} gcc/f951 gcc/lto1 gcc/cpp
>> gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>> gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>> gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>> gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>> gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>> gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>>
>> I plan to add an option to link with -Wl,-z,now.
>>
>> Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
>> --enable-host-pie as well as without --enable-host-pie. Also tested
>> on a Debian system where the system gcc was configured with
>> --enable-default-pie.
>>
>> ChangeLog:
>>
>> * configure.ac (--enable-host-pie): New check. Set PICFLAG after this
>> check.
>> * configure: Regenerate.
>>
>> c++tools/ChangeLog:
>>
>> * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
>> Use pic/libiberty.a if PICFLAG is set.
>> * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
>> (--enable-host-pie): New check.
>> * configure: Regenerate.
>>
>> fixincludes/ChangeLog:
>>
>> * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
>> build of libiberty if PICFLAG is set.
>> * configure.ac:
>> * configure: Regenerate.
>>
>> gcc/ChangeLog:
>>
>> * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
>> Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
>> ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
>> check.
>> * configure: Regenerate.
>> * doc/install.texi: Document --enable-host-pie.
>>
>> gcc/d/ChangeLog:
>>
>> * Make-lang.in: Remove NO_PIE_CFLAGS.
>>
>> intl/ChangeLog:
>>
>> * Makefile.in: Use @PICFLAG@ in COMPILE as well.
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG after this check.
>> * configure: Regenerate.
>>
>> libcody/ChangeLog:
>>
>> * Makefile.in: Pass LD_PICFLAG to LDFLAGS.
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
>> check.
>> * configure: Regenerate.
>>
>> libcpp/ChangeLog:
>>
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG after this check.
>> * configure: Regenerate.
>>
>> libdecnumber/ChangeLog:
>>
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG after this check.
>> * configure: Regenerate.
>>
>> libiberty/ChangeLog:
>>
>> * configure.ac: Also set shared when enable_host_pie.
>> * configure: Regenerate.
>>
>> zlib/ChangeLog:
>>
>> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
>> (--enable-host-pie): New check. Set PICFLAG after this check.
>> * configure: Regenerate.
>> ---
>> c++tools/Makefile.in | 11 ++++++---
>> c++tools/configure | 17 +++++++++++---
>> c++tools/configure.ac | 11 +++++++--
>> configure | 24 +++++++++++++++++++-
>> configure.ac | 18 ++++++++++++++-
>> fixincludes/Makefile.in | 12 ++++++----
>> fixincludes/configure | 13 +++++++++++
>> fixincludes/configure.ac | 8 +++++++
>> gcc/Makefile.in | 32 +++++++++++++++-----------
>> gcc/configure | 47 +++++++++++++++++++++++++++------------
>> gcc/configure.ac | 36 +++++++++++++++++++++---------
>> gcc/d/Make-lang.in | 2 +-
>> gcc/doc/install.texi | 16 +++++++++++--
>> intl/Makefile.in | 2 +-
>> intl/configure | 24 ++++++++++++++++++--
>> intl/configure.ac | 19 ++++++++++++++--
>> libcody/Makefile.in | 2 +-
>> libcody/configure | 30 ++++++++++++++++++++++++-
>> libcody/configure.ac | 26 ++++++++++++++++++++--
>> libcpp/configure | 22 +++++++++++++++++-
>> libcpp/configure.ac | 19 ++++++++++++++--
>> libdecnumber/configure | 22 +++++++++++++++++-
>> libdecnumber/configure.ac | 19 ++++++++++++++--
>> libiberty/configure | 4 ++--
>> libiberty/configure.ac | 4 ++--
>> zlib/configure | 28 +++++++++++++++++++----
>> zlib/configure.ac | 21 ++++++++++++++---
>> 27 files changed, 409 insertions(+), 80 deletions(-)
>>
>> diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
>> index 77bda3d56dc..dcb1029e064 100644
>> --- a/c++tools/Makefile.in
>> +++ b/c++tools/Makefile.in
>> @@ -29,8 +29,9 @@ AUTOCONF := @AUTOCONF@
>> AUTOHEADER := @AUTOHEADER@
>> CXX := @CXX@
>> CXXFLAGS := @CXXFLAGS@
>> -PIEFLAG := @PIEFLAG@
>> -CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
>> +PICFLAG := @PICFLAG@
>> +LD_PICFLAG := @LD_PICFLAG@
>> +CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
>> LDFLAGS := @LDFLAGS@
>> exeext := @EXEEXT@
>> LIBIBERTY := ../libiberty/libiberty.a
>> @@ -90,11 +91,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
>>
>> all::g++-mapper-server$(exeext)
>>
>> +ifneq ($(PICFLAG),)
>> +override LIBIBERTY := ../libiberty/pic/libiberty.a
>> +endif
>> +
>> MAPPER.O := server.o resolver.o
>> CODYLIB = ../libcody/libcody.a
>> CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
>> g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
>> - +$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
>> + +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
>>
>> # copy to gcc dir so tests there can run
>> all::../gcc/g++-mapper-server$(exeext)
>> diff --git a/c++tools/configure b/c++tools/configure
>> index 742816e4253..88087009383 100755
>> --- a/c++tools/configure
>> +++ b/c++tools/configure
>> @@ -627,7 +627,8 @@ get_gcc_base_ver
>> EGREP
>> GREP
>> CXXCPP
>> -PIEFLAG
>> +LD_PICFLAG
>> +PICFLAG
>> MAINTAINER
>> CXX_AUX_TOOLS
>> AUTOHEADER
>> @@ -700,6 +701,7 @@ enable_c___tools
>> enable_maintainer_mode
>> enable_checking
>> enable_default_pie
>> +enable_host_pie
>> with_gcc_major_version_only
>> '
>> ac_precious_vars='build_alias
>> @@ -1333,6 +1335,7 @@ Optional Features:
>> only specific categories of checks. Categories are:
>> yes,no,all,none,release.
>> --enable-default-pie enable Position Independent Executable as default
>> + --enable-host-pie build host code as PIE
>>
>> Optional Packages:
>> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
>> @@ -2990,12 +2993,20 @@ fi
>> # Check whether --enable-default-pie was given.
>> # Check whether --enable-default-pie was given.
>> if test "${enable_default_pie+set}" = set; then :
>> - enableval=$enable_default_pie; PIEFLAG=-fPIE
>> + enableval=$enable_default_pie; PICFLAG=-fPIE
>> else
>> - PIEFLAG=
>> + PICFLAG=
>> fi
>>
>>
>> +# Enable --enable-host-pie
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
>> +fi
>> +
>> +
>> +
>>
>> # Check if O_CLOEXEC is defined by fcntl
>>
>> diff --git a/c++tools/configure.ac b/c++tools/configure.ac
>> index 23e98c8e721..44dfaccbbfa 100644
>> --- a/c++tools/configure.ac
>> +++ b/c++tools/configure.ac
>> @@ -102,8 +102,15 @@ fi
>> AC_ARG_ENABLE(default-pie,
>> [AS_HELP_STRING([--enable-default-pie],
>> [enable Position Independent Executable as default])],
>> -[PIEFLAG=-fPIE], [PIEFLAG=])
>> -AC_SUBST([PIEFLAG])
>> +[PICFLAG=-fPIE], [PICFLAG=])
>> +
>> +# Enable --enable-host-pie
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])],
>> +[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
>> +AC_SUBST(PICFLAG)
>> +AC_SUBST(LD_PICFLAG)
>>
>> # Check if O_CLOEXEC is defined by fcntl
>> AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
>> diff --git a/configure b/configure
>> index 0494e2fa2bf..f5cf9b84c06 100755
>> --- a/configure
>> +++ b/configure
>> @@ -687,6 +687,8 @@ extra_host_zlib_configure_flags
>> extra_host_libiberty_configure_flags
>> stage1_languages
>> host_libs_picflag
>> +PICFLAG
>> +enable_host_pie
>> host_shared
>> extra_linker_plugin_flags
>> extra_linker_plugin_configure_flags
>> @@ -831,6 +833,7 @@ enable_lto
>> enable_linker_plugin_configure_flags
>> enable_linker_plugin_flags
>> enable_host_shared
>> +enable_host_pie
>> enable_stage1_languages
>> enable_objc_gc
>> with_target_bdw_gc
>> @@ -1559,6 +1562,7 @@ Optional Features:
>> additional flags for configuring and building linker
>> plugins [none]
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>> --enable-stage1-languages[=all]
>> choose additional languages to build during stage1.
>> Mostly useful for compiler development
>> @@ -8669,11 +8673,29 @@ fi
>>
>>
>>
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +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
>> +if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
>> host_libs_picflag='--with-pic'
>> fi
>>
>> diff --git a/configure.ac b/configure.ac
>> index f5cce5830bc..2a85834f2b6 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1913,11 +1913,27 @@ AC_ARG_ENABLE(host-shared,
>>
>> AC_SUBST(host_shared)
>>
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>> +
>> +AC_SUBST(PICFLAG)
>> +
>> # 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
>> +if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
>> host_libs_picflag='--with-pic'
>> fi
>> AC_SUBST(host_libs_picflag)
>> diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
>> index 1937dcaa32d..e6ce41dba39 100644
>> --- a/fixincludes/Makefile.in
>> +++ b/fixincludes/Makefile.in
>> @@ -73,7 +73,7 @@ default : all
>> # Now figure out from those variables how to compile and link.
>>
>> .c.o:
>> - $(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
>> + $(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
>>
>> # The only suffixes we want for implicit rules are .c and .o.
>> .SUFFIXES:
>> @@ -87,7 +87,11 @@ default : all
>> ##
>> ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
>>
>> +ifeq ($(PICFLAG),)
>> LIBIBERTY=../libiberty/libiberty.a
>> +else
>> +LIBIBERTY=../libiberty/pic/libiberty.a
>> +endif
>>
>> ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
>> fixlib.o fixopts.o
>> @@ -107,15 +111,15 @@ oneprocess : full-stamp
>> twoprocess : test-stamp $(AF)
>>
>> full-stamp : $(ALLOBJ) $(LIBIBERTY)
>> - $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
>> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
>> $(STAMP) $@
>>
>> test-stamp : $(TESTOBJ) $(LIBIBERTY)
>> - $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
>> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
>> $(STAMP) $@
>>
>> $(AF): $(FIXOBJ) $(LIBIBERTY)
>> - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
>> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
>>
>> $(ALLOBJ) : $(HDR)
>> fixincl.o : fixincl.c $(srcdir)/fixincl.x
>> diff --git a/fixincludes/configure b/fixincludes/configure
>> index bdcc41f6ddc..f1748ebef74 100755
>> --- a/fixincludes/configure
>> +++ b/fixincludes/configure
>> @@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
>> LIBOBJS
>> get_gcc_base_ver
>> MAINT
>> +LD_PICFLAG
>> +PICFLAG
>> TARGET
>> target_noncanonical
>> WERROR
>> @@ -695,6 +697,7 @@ enable_option_checking
>> enable_werror_always
>> with_local_prefix
>> enable_twoprocess
>> +enable_host_pie
>> enable_maintainer_mode
>> with_gcc_major_version_only
>> '
>> @@ -1323,6 +1326,7 @@ Optional Features:
>> --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
>> --enable-werror-always enable -Werror despite compiler version
>> --enable-twoprocess Use a separate process to apply the fixes
>> + --enable-host-pie build host code as PIE
>> --enable-maintainer-mode enable make rules and dependencies not useful
>> (and sometimes confusing) to the casual installer
>>
>> @@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
>>
>> fi
>>
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
>> +fi
>> +
>> +
>> +
>> +
>> case $host in
>> vax-dec-bsd* )
>>
>> diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
>> index ef2227e3c93..4e78511d20f 100644
>> --- a/fixincludes/configure.ac
>> +++ b/fixincludes/configure.ac
>> @@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
>> [Define if testing and fixing are done by separate process])
>> fi
>>
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])],
>> +[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
>> +AC_SUBST(PICFLAG)
>> +AC_SUBST(LD_PICFLAG)
>> +
>> case $host in
>> vax-dec-bsd* )
>> AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
>> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
>> index bb63b5c501d..860fd9af81a 100644
>> --- a/gcc/Makefile.in
>> +++ b/gcc/Makefile.in
>> @@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@
>> # Should we build position-independent host code?
>> PICFLAG = @PICFLAG@
>>
>> +# The linker flag for the above.
>> +LD_PICFLAG = @LD_PICFLAG@
>> +
>> # Flags to determine code coverage. When coverage is disabled, this will
>> # contain the optimization flags, as you normally want code coverage
>> # without optimization.
>> @@ -283,19 +286,19 @@ LINKER = $(CC)
>> LINKER_FLAGS = $(CFLAGS)
>> endif
>>
>> +enable_host_pie = @enable_host_pie@
>> +
>> # Enable Intel CET on Intel CET enabled host if needed.
>> CET_HOST_FLAGS = @CET_HOST_FLAGS@
>> COMPILER += $(CET_HOST_FLAGS)
>>
>> -NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
>> -NO_PIE_FLAG = @NO_PIE_FLAG@
>> DO_LINK_MUTEX = @DO_LINK_MUTEX@
>>
>> -# We don't want to compile the compilers with -fPIE, it make PCH fail.
>> -COMPILER += $(NO_PIE_CFLAGS)
>> +# Maybe compile the compilers with -fPIE or -fPIC.
>> +COMPILER += $(PICFLAG)
>>
>> -# Link with -no-pie since we compile the compiler with -fno-PIE.
>> -LINKER += $(NO_PIE_FLAG)
>> +# Link with -pie, or -no-pie, depending on the above.
>> +LINKER += $(LD_PICFLAG)
>>
>> # Like LINKER, but use a mutex for serializing front end links.
>> ifeq (@DO_LINK_MUTEX@,true)
>> @@ -1067,7 +1070,7 @@ RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
>> # programs built during a bootstrap.
>> # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
>> # cross compiler which does not use the native headers and libraries.
>> -INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@
>> +INTERNAL_CFLAGS = -DIN_GCC @CROSS@
>>
>> # This is the variable actually used when we compile. If you change this,
>> # you probably want to update BUILD_CFLAGS in configure.ac
>> @@ -1085,21 +1088,24 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
>> ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
>>
>> # This is the variable to use when using $(COMPILER).
>> -ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
>> +ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) $(PICFLAG)
>>
>> # This is the variable to use when using $(LINKER).
>> -ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
>> +ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
>>
>> # Build and host support libraries.
>>
>> -# Use the "pic" build of libiberty if --enable-host-shared, unless we are
>> -# building for mingw.
>> +# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
>> +# unless we are building for mingw.
>> LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
>> -ifeq ($(enable_host_shared),yes)
>> +ifneq ($(enable_host_shared)$(enable_host_pie),)
>> LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
>> -BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
>> else
>> LIBIBERTY = ../libiberty/libiberty.a
>> +endif
>> +ifeq ($(enable_host_shared),yes)
>> +BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
>> +else
>> BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
>> endif
>>
>> diff --git a/gcc/configure b/gcc/configure
>> index 191f68581b3..629446ecf3b 100755
>> --- a/gcc/configure
>> +++ b/gcc/configure
>> @@ -632,10 +632,10 @@ ac_includes_default="\
>> ac_subst_vars='LTLIBOBJS
>> LIBOBJS
>> CET_HOST_FLAGS
>> -NO_PIE_FLAG
>> -NO_PIE_CFLAGS
>> -enable_default_pie
>> +LD_PICFLAG
>> PICFLAG
>> +enable_default_pie
>> +enable_host_pie
>> enable_host_shared
>> enable_plugin
>> pluginlibs
>> @@ -1030,6 +1030,7 @@ enable_link_serialization
>> enable_version_specific_runtime_libs
>> enable_plugin
>> enable_host_shared
>> +enable_host_pie
>> enable_libquadmath_support
>> with_linker_hash_style
>> with_diagnostics_color
>> @@ -1792,6 +1793,7 @@ Optional Features:
>> in a compiler-specific directory
>> --enable-plugin enable plugin support
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>> --disable-libquadmath-support
>> disable libquadmath support for Fortran
>> --enable-default-pie enable Position Independent Executable as default
>> @@ -19850,7 +19852,7 @@ else
>> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> lt_status=$lt_dlunknown
>> cat > conftest.$ac_ext <<_LT_EOF
>> -#line 19853 "configure"
>> +#line 19867 "configure"
>> #include "confdefs.h"
>>
>> #if HAVE_DLFCN_H
>> @@ -19956,7 +19958,7 @@ else
>> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> lt_status=$lt_dlunknown
>> cat > conftest.$ac_ext <<_LT_EOF
>> -#line 19959 "configure"
>> +#line 19973 "configure"
>> #include "confdefs.h"
>>
>> #if HAVE_DLFCN_H
>> @@ -32090,13 +32092,17 @@ fi
>> # Enable --enable-host-shared
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> -else
>> - PICFLAG=
>> + enableval=$enable_host_shared;
>> fi
>>
>>
>>
>> +# Enable --enable-host-pie
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>>
>>
>> # Check whether --enable-libquadmath-support was given.
>> @@ -32250,10 +32256,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
>> 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"
>> -fi
>> -
>>
>> # Check if -no-pie works.
>> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
>> @@ -32278,11 +32280,28 @@ rm -f core conftest.err conftest.$ac_objext \
>> 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"
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +elif test x$gcc_cv_c_no_fpie = xyes; then
>> + PICFLAG=-fno-PIE
>> +else
>> + PICFLAG=
>> +fi
>> +
>> +if test x$enable_host_pie = xyes; then
>> + LD_PICFLAG=-pie
>> +elif test x$gcc_cv_no_pie = xyes; then
>> + LD_PICFLAG=-no-pie
>> +else
>> + LD_PICFLAG=
>> fi
>>
>>
>> +
>> +
>> # Enable Intel CET on Intel CET enabled host if jit is enabled.
>> # Check whether --enable-cet was given.
>> if test "${enable_cet+set}" = set; then :
>> diff --git a/gcc/configure.ac b/gcc/configure.ac
>> index 075424669c9..9c69a55668e 100644
>> --- a/gcc/configure.ac
>> +++ b/gcc/configure.ac
>> @@ -7418,11 +7418,14 @@ fi
>> # Enable --enable-host-shared
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> + [build host code as shared libraries])])
>> AC_SUBST(enable_host_shared)
>> -AC_SUBST(PICFLAG)
>>
>> +# Enable --enable-host-pie
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>>
>> AC_ARG_ENABLE(libquadmath-support,
>> [AS_HELP_STRING([--disable-libquadmath-support],
>> @@ -7544,10 +7547,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
>> [gcc_cv_c_no_fpie=yes],
>> [gcc_cv_c_no_fpie=no])
>> CXXFLAGS="$saved_CXXFLAGS"])
>> -if test "$gcc_cv_c_no_fpie" = "yes"; then
>> - NO_PIE_CFLAGS="-fno-PIE"
>> -fi
>> -AC_SUBST([NO_PIE_CFLAGS])
>>
>> # Check if -no-pie works.
>> AC_CACHE_CHECK([for -no-pie option],
>> @@ -7558,10 +7557,27 @@ AC_CACHE_CHECK([for -no-pie option],
>> [gcc_cv_no_pie=yes],
>> [gcc_cv_no_pie=no])
>> LDFLAGS="$saved_LDFLAGS"])
>> -if test "$gcc_cv_no_pie" = "yes"; then
>> - NO_PIE_FLAG="-no-pie"
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +elif test x$gcc_cv_c_no_fpie = xyes; then
>> + PICFLAG=-fno-PIE
>> +else
>> + PICFLAG=
>> fi
>> -AC_SUBST([NO_PIE_FLAG])
>> +
>> +if test x$enable_host_pie = xyes; then
>> + LD_PICFLAG=-pie
>> +elif test x$gcc_cv_no_pie = xyes; then
>> + LD_PICFLAG=-no-pie
>> +else
>> + LD_PICFLAG=
>> +fi
>> +
>> +AC_SUBST([PICFLAG])
>> +AC_SUBST([LD_PICFLAG])
>>
>> # Enable Intel CET on Intel CET enabled host if jit is enabled.
>> GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
>> diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
>> index 1679fb81097..4fbf2096416 100644
>> --- a/gcc/d/Make-lang.in
>> +++ b/gcc/d/Make-lang.in
>> @@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
>> $(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
>> $(WARN_DFLAGS)
>>
>> -DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
>> +DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
>> DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
>> DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
>> DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
>> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
>> index fa91ce1953d..2248308dbdf 100644
>> --- a/gcc/doc/install.texi
>> +++ b/gcc/doc/install.texi
>> @@ -1072,14 +1072,26 @@ code.
>>
>> @item --enable-host-shared
>> Specify that the @emph{host} code should be built into position-independent
>> -machine code (with -fPIC), allowing it to be used within shared libraries,
>> -but yielding a slightly slower compiler.
>> +machine code (with @option{-fPIC}), allowing it to be used within shared
>> +libraries, but yielding a slightly slower compiler.
>>
>> This option is required when building the libgccjit.so library.
>>
>> Contrast with @option{--enable-shared}, which affects @emph{target}
>> libraries.
>>
>> +@item --enable-host-pie
>> +Specify that the @emph{host} executables should be built into
>> +position-independent executables (with @option{-fPIE} and @option{-pie}),
>> +yielding a slightly slower compiler (but faster than
>> +@option{--enable-host-shared}). Position-independent executables are loaded
>> +at random addresses each time they are executed, therefore provide additional
>> +protection against Return Oriented Programming (ROP) attacks.
>> +
>> +@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
>> +in which case @option{-fPIC} is used when compiling, and @option{-pie} when
>> +linking.
>> +
>> @item @anchor{with-gnu-as}--with-gnu-as
>> Specify that the compiler should assume that the
>> assembler it finds is the GNU assembler. However, this does not modify
>> diff --git a/intl/Makefile.in b/intl/Makefile.in
>> index 409d693c48e..5beebdc152c 100644
>> --- a/intl/Makefile.in
>> +++ b/intl/Makefile.in
>> @@ -54,7 +54,7 @@ CTAGS = @CTAGS@
>> ETAGS = @ETAGS@
>> MKID = @MKID@
>>
>> -COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
>> +COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
>>
>> HEADERS = \
>> gmo.h \
>> diff --git a/intl/configure b/intl/configure
>> index 03f40487a92..79bb5831a47 100755
>> --- a/intl/configure
>> +++ b/intl/configure
>> @@ -623,6 +623,8 @@ ac_header_list=
>> ac_subst_vars='LTLIBOBJS
>> LIBOBJS
>> PICFLAG
>> +enable_host_pie
>> +enable_host_shared
>> BISON3_NO
>> BISON3_YES
>> INCINTL
>> @@ -731,6 +733,7 @@ with_libintl_prefix
>> with_libintl_type
>> enable_maintainer_mode
>> enable_host_shared
>> +enable_host_pie
>> '
>> ac_precious_vars='build_alias
>> host_alias
>> @@ -1356,6 +1359,7 @@ Optional Features:
>> --disable-rpath do not hardcode runtime library paths
>> --enable-maintainer-mode enable rules only needed by maintainers
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>>
>> Optional Packages:
>> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
>> @@ -6852,15 +6856,31 @@ fi
>>
>>
>>
>> +# Enable --enable-host-shared.
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> + enableval=$enable_host_shared;
>> +fi
>> +
>> +
>> +
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> else
>> PICFLAG=
>> fi
>>
>>
>> -
>> ac_config_files="$ac_config_files Makefile config.intl"
>>
>> cat >confcache <<\_ACEOF
>> diff --git a/intl/configure.ac b/intl/configure.ac
>> index 16a740aa230..81aa831f59f 100644
>> --- a/intl/configure.ac
>> +++ b/intl/configure.ac
>> @@ -83,10 +83,25 @@ fi
>> AC_SUBST(BISON3_YES)
>> AC_SUBST(BISON3_NO)
>>
>> +# Enable --enable-host-shared.
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> + [build host code as shared libraries])])
>> +AC_SUBST(enable_host_shared)
>> +
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>> AC_SUBST(PICFLAG)
>>
>> AC_CONFIG_FILES(Makefile config.intl)
>> diff --git a/libcody/Makefile.in b/libcody/Makefile.in
>> index bb87468cb9a..cb01b0092d8 100644
>> --- a/libcody/Makefile.in
>> +++ b/libcody/Makefile.in
>> @@ -31,7 +31,7 @@ endif
>> CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
>>
>> # Linker options
>> -LDFLAGS := @LDFLAGS@
>> +LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
>> LIBS := @LIBS@
>>
>> # Per-source & per-directory compile flags (warning: recursive)
>> diff --git a/libcody/configure b/libcody/configure
>> index da52a5cfca5..0e536c0ccb0 100755
>> --- a/libcody/configure
>> +++ b/libcody/configure
>> @@ -591,7 +591,10 @@ configure_args
>> AR
>> RANLIB
>> EXCEPTIONS
>> +LD_PICFLAG
>> PICFLAG
>> +enable_host_pie
>> +enable_host_shared
>> OBJEXT
>> EXEEXT
>> ac_ct_CXX
>> @@ -653,6 +656,7 @@ enable_maintainer_mode
>> with_compiler
>> enable_checking
>> enable_host_shared
>> +enable_host_pie
>> enable_exceptions
>> '
>> ac_precious_vars='build_alias
>> @@ -1286,6 +1290,7 @@ Optional Features:
>> yes,no,all,none,release. Flags are: misc,valgrind or
>> other strings
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>> --enable-exceptions enable exceptions & rtti
>>
>> Optional Packages:
>> @@ -2635,11 +2640,34 @@ fi
>> # Enable --enable-host-shared.
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> + enableval=$enable_host_shared;
>> +fi
>> +
>> +
>> +
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> else
>> PICFLAG=
>> fi
>>
>> +if test x$enable_host_pie = xyes; then
>> + LD_PICFLAG=-pie
>> +else
>> + LD_PICFLAG=
>> +fi
>> +
>> +
>>
>>
>> # Check whether --enable-exceptions was given.
>> diff --git a/libcody/configure.ac b/libcody/configure.ac
>> index 960191ecb72..14e8dd4a226 100644
>> --- a/libcody/configure.ac
>> +++ b/libcody/configure.ac
>> @@ -63,9 +63,31 @@ fi
>> # Enable --enable-host-shared.
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> + [build host code as shared libraries])])
>> +AC_SUBST(enable_host_shared)
>> +
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>> +
>> +if test x$enable_host_pie = xyes; then
>> + LD_PICFLAG=-pie
>> +else
>> + LD_PICFLAG=
>> +fi
>> +
>> AC_SUBST(PICFLAG)
>> +AC_SUBST(LD_PICFLAG)
>>
>> NMS_ENABLE_EXCEPTIONS
>>
>> diff --git a/libcpp/configure b/libcpp/configure
>> index e9937cde330..1389ddab544 100755
>> --- a/libcpp/configure
>> +++ b/libcpp/configure
>> @@ -625,6 +625,8 @@ ac_includes_default="\
>> ac_subst_vars='LTLIBOBJS
>> CET_HOST_FLAGS
>> PICFLAG
>> +enable_host_pie
>> +enable_host_shared
>> MAINT
>> USED_CATALOGS
>> PACKAGE
>> @@ -738,6 +740,7 @@ enable_maintainer_mode
>> enable_checking
>> enable_canonical_system_headers
>> enable_host_shared
>> +enable_host_pie
>> enable_cet
>> enable_valgrind_annotations
>> '
>> @@ -1379,6 +1382,7 @@ Optional Features:
>> --enable-canonical-system-headers
>> enable or disable system headers canonicalization
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>> --enable-cet enable Intel CET in host libraries [default=auto]
>> --enable-valgrind-annotations
>> enable valgrind runtime interaction
>> @@ -7605,7 +7609,23 @@ esac
>> # Enable --enable-host-shared.
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> + enableval=$enable_host_shared;
>> +fi
>> +
>> +
>> +
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> else
>> PICFLAG=
>> fi
>> diff --git a/libcpp/configure.ac b/libcpp/configure.ac
>> index 89ac99b04bd..b29b4d6acf1 100644
>> --- a/libcpp/configure.ac
>> +++ b/libcpp/configure.ac
>> @@ -211,8 +211,23 @@ esac
>> # Enable --enable-host-shared.
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> + [build host code as shared libraries])])
>> +AC_SUBST(enable_host_shared)
>> +
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>> +
>> AC_SUBST(PICFLAG)
>>
>> # Enable Intel CET on Intel CET enabled host if jit is enabled.
>> diff --git a/libdecnumber/configure b/libdecnumber/configure
>> index fb6db05565a..84bc4ffc767 100755
>> --- a/libdecnumber/configure
>> +++ b/libdecnumber/configure
>> @@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
>> LIBOBJS
>> CET_HOST_FLAGS
>> PICFLAG
>> +enable_host_pie
>> +enable_host_shared
>> ADDITIONAL_OBJS
>> enable_decimal_float
>> target_os
>> @@ -706,6 +708,7 @@ enable_werror_always
>> enable_maintainer_mode
>> enable_decimal_float
>> enable_host_shared
>> +enable_host_pie
>> enable_cet
>> '
>> ac_precious_vars='build_alias
>> @@ -1338,6 +1341,7 @@ Optional Features:
>> or 'dpd' choses which decimal floating point format
>> to use
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>> --enable-cet enable Intel CET in host libraries [default=auto]
>>
>> Some influential environment variables:
>> @@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
>> # Enable --enable-host-shared.
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> + enableval=$enable_host_shared;
>> +fi
>> +
>> +
>> +
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> else
>> PICFLAG=
>> fi
>> diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
>> index aafd06f8a64..30a51ca410b 100644
>> --- a/libdecnumber/configure.ac
>> +++ b/libdecnumber/configure.ac
>> @@ -100,8 +100,23 @@ AC_C_BIGENDIAN
>> # Enable --enable-host-shared.
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> + [build host code as shared libraries])])
>> +AC_SUBST(enable_host_shared)
>> +
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>> +
>> AC_SUBST(PICFLAG)
>>
>> # Enable Intel CET on Intel CET enabled host if jit is enabled.
>> diff --git a/libiberty/configure b/libiberty/configure
>> index 860f981fa18..b8a19c42110 100755
>> --- a/libiberty/configure
>> +++ b/libiberty/configure
>> @@ -5258,8 +5258,8 @@ case "${enable_shared}" in
>> *) shared=yes ;;
>> esac
>>
>> -# ...unless --enable-host-shared was passed from top-level config:
>> -if [ "${enable_host_shared}" = "yes" ]; then
>> +# ...unless --enable-host-{shared,pie} was passed from top-level config:
>> +if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
>> shared=yes
>> fi
>>
>> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
>> index 28d996f9cf7..6747a7b5cff 100644
>> --- a/libiberty/configure.ac
>> +++ b/libiberty/configure.ac
>> @@ -233,8 +233,8 @@ case "${enable_shared}" in
>> *) shared=yes ;;
>> esac
>>
>> -# ...unless --enable-host-shared was passed from top-level config:
>> -if [[ "${enable_host_shared}" = "yes" ]]; then
>> +# ...unless --enable-host-{shared,pie} was passed from top-level config:
>> +if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
>> shared=yes
>> fi
>>
>> diff --git a/zlib/configure b/zlib/configure
>> index e35ac6e7e17..77be6c284e3 100755
>> --- a/zlib/configure
>> +++ b/zlib/configure
>> @@ -635,6 +635,8 @@ am__EXEEXT_TRUE
>> LTLIBOBJS
>> LIBOBJS
>> PICFLAG
>> +enable_host_pie
>> +enable_host_shared
>> TARGET_LIBRARY_FALSE
>> TARGET_LIBRARY_TRUE
>> toolexeclibdir
>> @@ -778,6 +780,7 @@ with_gnu_ld
>> enable_libtool_lock
>> with_toolexeclibdir
>> enable_host_shared
>> +enable_host_pie
>> '
>> ac_precious_vars='build_alias
>> host_alias
>> @@ -1420,6 +1423,7 @@ Optional Features:
>> optimize for fast installation [default=yes]
>> --disable-libtool-lock avoid locking (might break parallel builds)
>> --enable-host-shared build host code as shared libraries
>> + --enable-host-pie build host code as PIE
>>
>> Optional Packages:
>> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
>> @@ -10759,7 +10763,7 @@ else
>> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> lt_status=$lt_dlunknown
>> cat > conftest.$ac_ext <<_LT_EOF
>> -#line 10762 "configure"
>> +#line 10778 "configure"
>> #include "confdefs.h"
>>
>> #if HAVE_DLFCN_H
>> @@ -10865,7 +10869,7 @@ else
>> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>> lt_status=$lt_dlunknown
>> cat > conftest.$ac_ext <<_LT_EOF
>> -#line 10868 "configure"
>> +#line 10884 "configure"
>> #include "confdefs.h"
>>
>> #if HAVE_DLFCN_H
>> @@ -11548,15 +11552,31 @@ else
>> multilib_arg=
>> fi
>>
>> +# Enable --enable-host-shared.
>> # Check whether --enable-host-shared was given.
>> if test "${enable_host_shared+set}" = set; then :
>> - enableval=$enable_host_shared; PICFLAG=-fPIC
>> + enableval=$enable_host_shared;
>> +fi
>> +
>> +
>> +
>> +# Enable --enable-host-pie.
>> +# Check whether --enable-host-pie was given.
>> +if test "${enable_host_pie+set}" = set; then :
>> + enableval=$enable_host_pie;
>> +fi
>> +
>> +
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> else
>> PICFLAG=
>> fi
>>
>>
>> -
>> ac_config_files="$ac_config_files Makefile"
>>
>> cat >confcache <<\_ACEOF
>> diff --git a/zlib/configure.ac b/zlib/configure.ac
>> index be1cfe29651..adf7aad4e51 100644
>> --- a/zlib/configure.ac
>> +++ b/zlib/configure.ac
>> @@ -122,11 +122,26 @@ else
>> multilib_arg=
>> fi
>>
>> +# Enable --enable-host-shared.
>> AC_ARG_ENABLE(host-shared,
>> [AS_HELP_STRING([--enable-host-shared],
>> - [build host code as shared libraries])],
>> -[PICFLAG=-fPIC], [PICFLAG=])
>> -AC_SUBST(PICFLAG)
>> + [build host code as shared libraries])])
>> +AC_SUBST(enable_host_shared)
>> +
>> +# Enable --enable-host-pie.
>> +AC_ARG_ENABLE(host-pie,
>> +[AS_HELP_STRING([--enable-host-pie],
>> + [build host code as PIE])])
>> +AC_SUBST(enable_host_pie)
>> +
>> +if test x$enable_host_shared = xyes; then
>> + PICFLAG=-fPIC
>> +elif test x$enable_host_pie = xyes; then
>> + PICFLAG=-fPIE
>> +else
>> + PICFLAG=
>> +fi
>>
>> +AC_SUBST(PICFLAG)
>> AC_CONFIG_FILES([Makefile])
>> AC_OUTPUT
>>
>> base-commit: bbb6cf926f1732559b3a8aaf2796d34e8651c066
>> --
>> 2.40.1
>>
>
> Marek
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] configure: Implement --enable-host-pie
2023-05-09 19:41 Marek Polacek
@ 2023-05-16 15:29 ` Marek Polacek
2023-05-16 20:11 ` Iain Sandoe
0 siblings, 1 reply; 8+ messages in thread
From: Marek Polacek @ 2023-05-16 15:29 UTC (permalink / raw)
To: GCC Patches
Ping.
On Tue, May 09, 2023 at 03:41:58PM -0400, Marek Polacek via Gcc-patches wrote:
> [ This is my third attempt to add this configure option. The first
> version was approved but it came too late in the development cycle.
> The second version was also approved, but I had to revert it:
> <https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
> I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
> ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer
> need to touch Makefile.def, so this patch is simplified. ]
>
> This patch implements the --enable-host-pie configure option which
> makes the compiler executables PIE. This can be used to enhance
> protection against ROP attacks, and can be viewed as part of a wider
> trend to harden binaries.
>
> It is similar to the option --enable-host-shared, except that --e-h-s
> won't add -shared to the linker flags whereas --e-h-p will add -pie.
> It is different from --enable-default-pie because that option just
> adds an implicit -fPIE/-pie when the compiler is invoked, but the
> compiler itself isn't PIE.
>
> Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
> regressions.
>
> When building the compiler, the build process may use various in-tree
> libraries; these need to be built with -fPIE so that it's possible to
> use them when building a PIE. For instance, when --with-included-gettext
> is in effect, intl object files must be compiled with -fPIE. Similarly,
> when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
> -fPIE.
>
> With this patch and --enable-host-pie used to configure gcc:
>
> $ file gcc/cc1{,plus,obj} gcc/f951 gcc/lto1 gcc/cpp
> gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
> gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
>
> I plan to add an option to link with -Wl,-z,now.
>
> Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
> --enable-host-pie as well as without --enable-host-pie. Also tested
> on a Debian system where the system gcc was configured with
> --enable-default-pie.
>
> ChangeLog:
>
> * configure.ac (--enable-host-pie): New check. Set PICFLAG after this
> check.
> * configure: Regenerate.
>
> c++tools/ChangeLog:
>
> * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
> Use pic/libiberty.a if PICFLAG is set.
> * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
> (--enable-host-pie): New check.
> * configure: Regenerate.
>
> fixincludes/ChangeLog:
>
> * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
> build of libiberty if PICFLAG is set.
> * configure.ac:
> * configure: Regenerate.
>
> gcc/ChangeLog:
>
> * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
> Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
> ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> check.
> * configure: Regenerate.
> * doc/install.texi: Document --enable-host-pie.
>
> gcc/d/ChangeLog:
>
> * Make-lang.in: Remove NO_PIE_CFLAGS.
>
> intl/ChangeLog:
>
> * Makefile.in: Use @PICFLAG@ in COMPILE as well.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libcody/ChangeLog:
>
> * Makefile.in: Pass LD_PICFLAG to LDFLAGS.
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
> check.
> * configure: Regenerate.
>
> libcpp/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libdecnumber/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
>
> libiberty/ChangeLog:
>
> * configure.ac: Also set shared when enable_host_pie.
> * configure: Regenerate.
>
> zlib/ChangeLog:
>
> * configure.ac (--enable-host-shared): Don't set PICFLAG here.
> (--enable-host-pie): New check. Set PICFLAG after this check.
> * configure: Regenerate.
> ---
> c++tools/Makefile.in | 11 ++++++---
> c++tools/configure | 17 +++++++++++---
> c++tools/configure.ac | 11 +++++++--
> configure | 24 +++++++++++++++++++-
> configure.ac | 18 ++++++++++++++-
> fixincludes/Makefile.in | 12 ++++++----
> fixincludes/configure | 13 +++++++++++
> fixincludes/configure.ac | 8 +++++++
> gcc/Makefile.in | 32 +++++++++++++++-----------
> gcc/configure | 47 +++++++++++++++++++++++++++------------
> gcc/configure.ac | 36 +++++++++++++++++++++---------
> gcc/d/Make-lang.in | 2 +-
> gcc/doc/install.texi | 16 +++++++++++--
> intl/Makefile.in | 2 +-
> intl/configure | 24 ++++++++++++++++++--
> intl/configure.ac | 19 ++++++++++++++--
> libcody/Makefile.in | 2 +-
> libcody/configure | 30 ++++++++++++++++++++++++-
> libcody/configure.ac | 26 ++++++++++++++++++++--
> libcpp/configure | 22 +++++++++++++++++-
> libcpp/configure.ac | 19 ++++++++++++++--
> libdecnumber/configure | 22 +++++++++++++++++-
> libdecnumber/configure.ac | 19 ++++++++++++++--
> libiberty/configure | 4 ++--
> libiberty/configure.ac | 4 ++--
> zlib/configure | 28 +++++++++++++++++++----
> zlib/configure.ac | 21 ++++++++++++++---
> 27 files changed, 409 insertions(+), 80 deletions(-)
>
> diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
> index 77bda3d56dc..dcb1029e064 100644
> --- a/c++tools/Makefile.in
> +++ b/c++tools/Makefile.in
> @@ -29,8 +29,9 @@ AUTOCONF := @AUTOCONF@
> AUTOHEADER := @AUTOHEADER@
> CXX := @CXX@
> CXXFLAGS := @CXXFLAGS@
> -PIEFLAG := @PIEFLAG@
> -CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
> +PICFLAG := @PICFLAG@
> +LD_PICFLAG := @LD_PICFLAG@
> +CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
> LDFLAGS := @LDFLAGS@
> exeext := @EXEEXT@
> LIBIBERTY := ../libiberty/libiberty.a
> @@ -90,11 +91,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
>
> all::g++-mapper-server$(exeext)
>
> +ifneq ($(PICFLAG),)
> +override LIBIBERTY := ../libiberty/pic/libiberty.a
> +endif
> +
> MAPPER.O := server.o resolver.o
> CODYLIB = ../libcody/libcody.a
> CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
> g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
> - +$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
> + +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
>
> # copy to gcc dir so tests there can run
> all::../gcc/g++-mapper-server$(exeext)
> diff --git a/c++tools/configure b/c++tools/configure
> index 742816e4253..88087009383 100755
> --- a/c++tools/configure
> +++ b/c++tools/configure
> @@ -627,7 +627,8 @@ get_gcc_base_ver
> EGREP
> GREP
> CXXCPP
> -PIEFLAG
> +LD_PICFLAG
> +PICFLAG
> MAINTAINER
> CXX_AUX_TOOLS
> AUTOHEADER
> @@ -700,6 +701,7 @@ enable_c___tools
> enable_maintainer_mode
> enable_checking
> enable_default_pie
> +enable_host_pie
> with_gcc_major_version_only
> '
> ac_precious_vars='build_alias
> @@ -1333,6 +1335,7 @@ Optional Features:
> only specific categories of checks. Categories are:
> yes,no,all,none,release.
> --enable-default-pie enable Position Independent Executable as default
> + --enable-host-pie build host code as PIE
>
> Optional Packages:
> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
> @@ -2990,12 +2993,20 @@ fi
> # Check whether --enable-default-pie was given.
> # Check whether --enable-default-pie was given.
> if test "${enable_default_pie+set}" = set; then :
> - enableval=$enable_default_pie; PIEFLAG=-fPIE
> + enableval=$enable_default_pie; PICFLAG=-fPIE
> else
> - PIEFLAG=
> + PICFLAG=
> fi
>
>
> +# Enable --enable-host-pie
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
> +fi
> +
> +
> +
>
> # Check if O_CLOEXEC is defined by fcntl
>
> diff --git a/c++tools/configure.ac b/c++tools/configure.ac
> index 23e98c8e721..44dfaccbbfa 100644
> --- a/c++tools/configure.ac
> +++ b/c++tools/configure.ac
> @@ -102,8 +102,15 @@ fi
> AC_ARG_ENABLE(default-pie,
> [AS_HELP_STRING([--enable-default-pie],
> [enable Position Independent Executable as default])],
> -[PIEFLAG=-fPIE], [PIEFLAG=])
> -AC_SUBST([PIEFLAG])
> +[PICFLAG=-fPIE], [PICFLAG=])
> +
> +# Enable --enable-host-pie
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])],
> +[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
> +AC_SUBST(PICFLAG)
> +AC_SUBST(LD_PICFLAG)
>
> # Check if O_CLOEXEC is defined by fcntl
> AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
> diff --git a/configure b/configure
> index 0494e2fa2bf..f5cf9b84c06 100755
> --- a/configure
> +++ b/configure
> @@ -687,6 +687,8 @@ extra_host_zlib_configure_flags
> extra_host_libiberty_configure_flags
> stage1_languages
> host_libs_picflag
> +PICFLAG
> +enable_host_pie
> host_shared
> extra_linker_plugin_flags
> extra_linker_plugin_configure_flags
> @@ -831,6 +833,7 @@ enable_lto
> enable_linker_plugin_configure_flags
> enable_linker_plugin_flags
> enable_host_shared
> +enable_host_pie
> enable_stage1_languages
> enable_objc_gc
> with_target_bdw_gc
> @@ -1559,6 +1562,7 @@ Optional Features:
> additional flags for configuring and building linker
> plugins [none]
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
> --enable-stage1-languages[=all]
> choose additional languages to build during stage1.
> Mostly useful for compiler development
> @@ -8669,11 +8673,29 @@ fi
>
>
>
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +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
> +if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
> host_libs_picflag='--with-pic'
> fi
>
> diff --git a/configure.ac b/configure.ac
> index f5cce5830bc..2a85834f2b6 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1913,11 +1913,27 @@ AC_ARG_ENABLE(host-shared,
>
> AC_SUBST(host_shared)
>
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
> +
> +AC_SUBST(PICFLAG)
> +
> # 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
> +if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
> host_libs_picflag='--with-pic'
> fi
> AC_SUBST(host_libs_picflag)
> diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
> index 1937dcaa32d..e6ce41dba39 100644
> --- a/fixincludes/Makefile.in
> +++ b/fixincludes/Makefile.in
> @@ -73,7 +73,7 @@ default : all
> # Now figure out from those variables how to compile and link.
>
> .c.o:
> - $(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
> + $(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
>
> # The only suffixes we want for implicit rules are .c and .o.
> .SUFFIXES:
> @@ -87,7 +87,11 @@ default : all
> ##
> ## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
>
> +ifeq ($(PICFLAG),)
> LIBIBERTY=../libiberty/libiberty.a
> +else
> +LIBIBERTY=../libiberty/pic/libiberty.a
> +endif
>
> ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
> fixlib.o fixopts.o
> @@ -107,15 +111,15 @@ oneprocess : full-stamp
> twoprocess : test-stamp $(AF)
>
> full-stamp : $(ALLOBJ) $(LIBIBERTY)
> - $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
> $(STAMP) $@
>
> test-stamp : $(TESTOBJ) $(LIBIBERTY)
> - $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
> $(STAMP) $@
>
> $(AF): $(FIXOBJ) $(LIBIBERTY)
> - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
> + $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
>
> $(ALLOBJ) : $(HDR)
> fixincl.o : fixincl.c $(srcdir)/fixincl.x
> diff --git a/fixincludes/configure b/fixincludes/configure
> index bdcc41f6ddc..f1748ebef74 100755
> --- a/fixincludes/configure
> +++ b/fixincludes/configure
> @@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
> LIBOBJS
> get_gcc_base_ver
> MAINT
> +LD_PICFLAG
> +PICFLAG
> TARGET
> target_noncanonical
> WERROR
> @@ -695,6 +697,7 @@ enable_option_checking
> enable_werror_always
> with_local_prefix
> enable_twoprocess
> +enable_host_pie
> enable_maintainer_mode
> with_gcc_major_version_only
> '
> @@ -1323,6 +1326,7 @@ Optional Features:
> --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
> --enable-werror-always enable -Werror despite compiler version
> --enable-twoprocess Use a separate process to apply the fixes
> + --enable-host-pie build host code as PIE
> --enable-maintainer-mode enable make rules and dependencies not useful
> (and sometimes confusing) to the casual installer
>
> @@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
>
> fi
>
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
> +fi
> +
> +
> +
> +
> case $host in
> vax-dec-bsd* )
>
> diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
> index ef2227e3c93..4e78511d20f 100644
> --- a/fixincludes/configure.ac
> +++ b/fixincludes/configure.ac
> @@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
> [Define if testing and fixing are done by separate process])
> fi
>
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])],
> +[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
> +AC_SUBST(PICFLAG)
> +AC_SUBST(LD_PICFLAG)
> +
> case $host in
> vax-dec-bsd* )
> AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index bb63b5c501d..860fd9af81a 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@
> # Should we build position-independent host code?
> PICFLAG = @PICFLAG@
>
> +# The linker flag for the above.
> +LD_PICFLAG = @LD_PICFLAG@
> +
> # Flags to determine code coverage. When coverage is disabled, this will
> # contain the optimization flags, as you normally want code coverage
> # without optimization.
> @@ -283,19 +286,19 @@ LINKER = $(CC)
> LINKER_FLAGS = $(CFLAGS)
> endif
>
> +enable_host_pie = @enable_host_pie@
> +
> # Enable Intel CET on Intel CET enabled host if needed.
> CET_HOST_FLAGS = @CET_HOST_FLAGS@
> COMPILER += $(CET_HOST_FLAGS)
>
> -NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
> -NO_PIE_FLAG = @NO_PIE_FLAG@
> DO_LINK_MUTEX = @DO_LINK_MUTEX@
>
> -# We don't want to compile the compilers with -fPIE, it make PCH fail.
> -COMPILER += $(NO_PIE_CFLAGS)
> +# Maybe compile the compilers with -fPIE or -fPIC.
> +COMPILER += $(PICFLAG)
>
> -# Link with -no-pie since we compile the compiler with -fno-PIE.
> -LINKER += $(NO_PIE_FLAG)
> +# Link with -pie, or -no-pie, depending on the above.
> +LINKER += $(LD_PICFLAG)
>
> # Like LINKER, but use a mutex for serializing front end links.
> ifeq (@DO_LINK_MUTEX@,true)
> @@ -1067,7 +1070,7 @@ RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
> # programs built during a bootstrap.
> # autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
> # cross compiler which does not use the native headers and libraries.
> -INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@
> +INTERNAL_CFLAGS = -DIN_GCC @CROSS@
>
> # This is the variable actually used when we compile. If you change this,
> # you probably want to update BUILD_CFLAGS in configure.ac
> @@ -1085,21 +1088,24 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
> ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
>
> # This is the variable to use when using $(COMPILER).
> -ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
> +ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) $(PICFLAG)
>
> # This is the variable to use when using $(LINKER).
> -ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
> +ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
>
> # Build and host support libraries.
>
> -# Use the "pic" build of libiberty if --enable-host-shared, unless we are
> -# building for mingw.
> +# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
> +# unless we are building for mingw.
> LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
> -ifeq ($(enable_host_shared),yes)
> +ifneq ($(enable_host_shared)$(enable_host_pie),)
> LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
> -BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
> else
> LIBIBERTY = ../libiberty/libiberty.a
> +endif
> +ifeq ($(enable_host_shared),yes)
> +BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
> +else
> BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
> endif
>
> diff --git a/gcc/configure b/gcc/configure
> index 191f68581b3..629446ecf3b 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -632,10 +632,10 @@ ac_includes_default="\
> ac_subst_vars='LTLIBOBJS
> LIBOBJS
> CET_HOST_FLAGS
> -NO_PIE_FLAG
> -NO_PIE_CFLAGS
> -enable_default_pie
> +LD_PICFLAG
> PICFLAG
> +enable_default_pie
> +enable_host_pie
> enable_host_shared
> enable_plugin
> pluginlibs
> @@ -1030,6 +1030,7 @@ enable_link_serialization
> enable_version_specific_runtime_libs
> enable_plugin
> enable_host_shared
> +enable_host_pie
> enable_libquadmath_support
> with_linker_hash_style
> with_diagnostics_color
> @@ -1792,6 +1793,7 @@ Optional Features:
> in a compiler-specific directory
> --enable-plugin enable plugin support
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
> --disable-libquadmath-support
> disable libquadmath support for Fortran
> --enable-default-pie enable Position Independent Executable as default
> @@ -19850,7 +19852,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 19853 "configure"
> +#line 19867 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -19956,7 +19958,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 19959 "configure"
> +#line 19973 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -32090,13 +32092,17 @@ fi
> # Enable --enable-host-shared
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> -else
> - PICFLAG=
> + enableval=$enable_host_shared;
> fi
>
>
>
> +# Enable --enable-host-pie
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
>
>
> # Check whether --enable-libquadmath-support was given.
> @@ -32250,10 +32256,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
> 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"
> -fi
> -
>
> # Check if -no-pie works.
> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
> @@ -32278,11 +32280,28 @@ rm -f core conftest.err conftest.$ac_objext \
> 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"
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +elif test x$gcc_cv_c_no_fpie = xyes; then
> + PICFLAG=-fno-PIE
> +else
> + PICFLAG=
> +fi
> +
> +if test x$enable_host_pie = xyes; then
> + LD_PICFLAG=-pie
> +elif test x$gcc_cv_no_pie = xyes; then
> + LD_PICFLAG=-no-pie
> +else
> + LD_PICFLAG=
> fi
>
>
> +
> +
> # Enable Intel CET on Intel CET enabled host if jit is enabled.
> # Check whether --enable-cet was given.
> if test "${enable_cet+set}" = set; then :
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 075424669c9..9c69a55668e 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -7418,11 +7418,14 @@ fi
> # Enable --enable-host-shared
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> + [build host code as shared libraries])])
> AC_SUBST(enable_host_shared)
> -AC_SUBST(PICFLAG)
>
> +# Enable --enable-host-pie
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
>
> AC_ARG_ENABLE(libquadmath-support,
> [AS_HELP_STRING([--disable-libquadmath-support],
> @@ -7544,10 +7547,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
> [gcc_cv_c_no_fpie=yes],
> [gcc_cv_c_no_fpie=no])
> CXXFLAGS="$saved_CXXFLAGS"])
> -if test "$gcc_cv_c_no_fpie" = "yes"; then
> - NO_PIE_CFLAGS="-fno-PIE"
> -fi
> -AC_SUBST([NO_PIE_CFLAGS])
>
> # Check if -no-pie works.
> AC_CACHE_CHECK([for -no-pie option],
> @@ -7558,10 +7557,27 @@ AC_CACHE_CHECK([for -no-pie option],
> [gcc_cv_no_pie=yes],
> [gcc_cv_no_pie=no])
> LDFLAGS="$saved_LDFLAGS"])
> -if test "$gcc_cv_no_pie" = "yes"; then
> - NO_PIE_FLAG="-no-pie"
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +elif test x$gcc_cv_c_no_fpie = xyes; then
> + PICFLAG=-fno-PIE
> +else
> + PICFLAG=
> fi
> -AC_SUBST([NO_PIE_FLAG])
> +
> +if test x$enable_host_pie = xyes; then
> + LD_PICFLAG=-pie
> +elif test x$gcc_cv_no_pie = xyes; then
> + LD_PICFLAG=-no-pie
> +else
> + LD_PICFLAG=
> +fi
> +
> +AC_SUBST([PICFLAG])
> +AC_SUBST([LD_PICFLAG])
>
> # Enable Intel CET on Intel CET enabled host if jit is enabled.
> GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
> diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
> index 1679fb81097..4fbf2096416 100644
> --- a/gcc/d/Make-lang.in
> +++ b/gcc/d/Make-lang.in
> @@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
> $(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
> $(WARN_DFLAGS)
>
> -DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
> +DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
> DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
> DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
> DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
> diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
> index fa91ce1953d..2248308dbdf 100644
> --- a/gcc/doc/install.texi
> +++ b/gcc/doc/install.texi
> @@ -1072,14 +1072,26 @@ code.
>
> @item --enable-host-shared
> Specify that the @emph{host} code should be built into position-independent
> -machine code (with -fPIC), allowing it to be used within shared libraries,
> -but yielding a slightly slower compiler.
> +machine code (with @option{-fPIC}), allowing it to be used within shared
> +libraries, but yielding a slightly slower compiler.
>
> This option is required when building the libgccjit.so library.
>
> Contrast with @option{--enable-shared}, which affects @emph{target}
> libraries.
>
> +@item --enable-host-pie
> +Specify that the @emph{host} executables should be built into
> +position-independent executables (with @option{-fPIE} and @option{-pie}),
> +yielding a slightly slower compiler (but faster than
> +@option{--enable-host-shared}). Position-independent executables are loaded
> +at random addresses each time they are executed, therefore provide additional
> +protection against Return Oriented Programming (ROP) attacks.
> +
> +@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
> +in which case @option{-fPIC} is used when compiling, and @option{-pie} when
> +linking.
> +
> @item @anchor{with-gnu-as}--with-gnu-as
> Specify that the compiler should assume that the
> assembler it finds is the GNU assembler. However, this does not modify
> diff --git a/intl/Makefile.in b/intl/Makefile.in
> index 409d693c48e..5beebdc152c 100644
> --- a/intl/Makefile.in
> +++ b/intl/Makefile.in
> @@ -54,7 +54,7 @@ CTAGS = @CTAGS@
> ETAGS = @ETAGS@
> MKID = @MKID@
>
> -COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
> +COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
>
> HEADERS = \
> gmo.h \
> diff --git a/intl/configure b/intl/configure
> index 03f40487a92..79bb5831a47 100755
> --- a/intl/configure
> +++ b/intl/configure
> @@ -623,6 +623,8 @@ ac_header_list=
> ac_subst_vars='LTLIBOBJS
> LIBOBJS
> PICFLAG
> +enable_host_pie
> +enable_host_shared
> BISON3_NO
> BISON3_YES
> INCINTL
> @@ -731,6 +733,7 @@ with_libintl_prefix
> with_libintl_type
> enable_maintainer_mode
> enable_host_shared
> +enable_host_pie
> '
> ac_precious_vars='build_alias
> host_alias
> @@ -1356,6 +1359,7 @@ Optional Features:
> --disable-rpath do not hardcode runtime library paths
> --enable-maintainer-mode enable rules only needed by maintainers
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
>
> Optional Packages:
> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
> @@ -6852,15 +6856,31 @@ fi
>
>
>
> +# Enable --enable-host-shared.
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> + enableval=$enable_host_shared;
> +fi
> +
> +
> +
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> else
> PICFLAG=
> fi
>
>
> -
> ac_config_files="$ac_config_files Makefile config.intl"
>
> cat >confcache <<\_ACEOF
> diff --git a/intl/configure.ac b/intl/configure.ac
> index 16a740aa230..81aa831f59f 100644
> --- a/intl/configure.ac
> +++ b/intl/configure.ac
> @@ -83,10 +83,25 @@ fi
> AC_SUBST(BISON3_YES)
> AC_SUBST(BISON3_NO)
>
> +# Enable --enable-host-shared.
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> + [build host code as shared libraries])])
> +AC_SUBST(enable_host_shared)
> +
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
> AC_SUBST(PICFLAG)
>
> AC_CONFIG_FILES(Makefile config.intl)
> diff --git a/libcody/Makefile.in b/libcody/Makefile.in
> index bb87468cb9a..cb01b0092d8 100644
> --- a/libcody/Makefile.in
> +++ b/libcody/Makefile.in
> @@ -31,7 +31,7 @@ endif
> CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
>
> # Linker options
> -LDFLAGS := @LDFLAGS@
> +LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
> LIBS := @LIBS@
>
> # Per-source & per-directory compile flags (warning: recursive)
> diff --git a/libcody/configure b/libcody/configure
> index da52a5cfca5..0e536c0ccb0 100755
> --- a/libcody/configure
> +++ b/libcody/configure
> @@ -591,7 +591,10 @@ configure_args
> AR
> RANLIB
> EXCEPTIONS
> +LD_PICFLAG
> PICFLAG
> +enable_host_pie
> +enable_host_shared
> OBJEXT
> EXEEXT
> ac_ct_CXX
> @@ -653,6 +656,7 @@ enable_maintainer_mode
> with_compiler
> enable_checking
> enable_host_shared
> +enable_host_pie
> enable_exceptions
> '
> ac_precious_vars='build_alias
> @@ -1286,6 +1290,7 @@ Optional Features:
> yes,no,all,none,release. Flags are: misc,valgrind or
> other strings
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
> --enable-exceptions enable exceptions & rtti
>
> Optional Packages:
> @@ -2635,11 +2640,34 @@ fi
> # Enable --enable-host-shared.
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> + enableval=$enable_host_shared;
> +fi
> +
> +
> +
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> else
> PICFLAG=
> fi
>
> +if test x$enable_host_pie = xyes; then
> + LD_PICFLAG=-pie
> +else
> + LD_PICFLAG=
> +fi
> +
> +
>
>
> # Check whether --enable-exceptions was given.
> diff --git a/libcody/configure.ac b/libcody/configure.ac
> index 960191ecb72..14e8dd4a226 100644
> --- a/libcody/configure.ac
> +++ b/libcody/configure.ac
> @@ -63,9 +63,31 @@ fi
> # Enable --enable-host-shared.
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> + [build host code as shared libraries])])
> +AC_SUBST(enable_host_shared)
> +
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
> +
> +if test x$enable_host_pie = xyes; then
> + LD_PICFLAG=-pie
> +else
> + LD_PICFLAG=
> +fi
> +
> AC_SUBST(PICFLAG)
> +AC_SUBST(LD_PICFLAG)
>
> NMS_ENABLE_EXCEPTIONS
>
> diff --git a/libcpp/configure b/libcpp/configure
> index e9937cde330..1389ddab544 100755
> --- a/libcpp/configure
> +++ b/libcpp/configure
> @@ -625,6 +625,8 @@ ac_includes_default="\
> ac_subst_vars='LTLIBOBJS
> CET_HOST_FLAGS
> PICFLAG
> +enable_host_pie
> +enable_host_shared
> MAINT
> USED_CATALOGS
> PACKAGE
> @@ -738,6 +740,7 @@ enable_maintainer_mode
> enable_checking
> enable_canonical_system_headers
> enable_host_shared
> +enable_host_pie
> enable_cet
> enable_valgrind_annotations
> '
> @@ -1379,6 +1382,7 @@ Optional Features:
> --enable-canonical-system-headers
> enable or disable system headers canonicalization
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
> --enable-cet enable Intel CET in host libraries [default=auto]
> --enable-valgrind-annotations
> enable valgrind runtime interaction
> @@ -7605,7 +7609,23 @@ esac
> # Enable --enable-host-shared.
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> + enableval=$enable_host_shared;
> +fi
> +
> +
> +
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> else
> PICFLAG=
> fi
> diff --git a/libcpp/configure.ac b/libcpp/configure.ac
> index 89ac99b04bd..b29b4d6acf1 100644
> --- a/libcpp/configure.ac
> +++ b/libcpp/configure.ac
> @@ -211,8 +211,23 @@ esac
> # Enable --enable-host-shared.
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> + [build host code as shared libraries])])
> +AC_SUBST(enable_host_shared)
> +
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
> +
> AC_SUBST(PICFLAG)
>
> # Enable Intel CET on Intel CET enabled host if jit is enabled.
> diff --git a/libdecnumber/configure b/libdecnumber/configure
> index fb6db05565a..84bc4ffc767 100755
> --- a/libdecnumber/configure
> +++ b/libdecnumber/configure
> @@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
> LIBOBJS
> CET_HOST_FLAGS
> PICFLAG
> +enable_host_pie
> +enable_host_shared
> ADDITIONAL_OBJS
> enable_decimal_float
> target_os
> @@ -706,6 +708,7 @@ enable_werror_always
> enable_maintainer_mode
> enable_decimal_float
> enable_host_shared
> +enable_host_pie
> enable_cet
> '
> ac_precious_vars='build_alias
> @@ -1338,6 +1341,7 @@ Optional Features:
> or 'dpd' choses which decimal floating point format
> to use
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
> --enable-cet enable Intel CET in host libraries [default=auto]
>
> Some influential environment variables:
> @@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
> # Enable --enable-host-shared.
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> + enableval=$enable_host_shared;
> +fi
> +
> +
> +
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> else
> PICFLAG=
> fi
> diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
> index aafd06f8a64..30a51ca410b 100644
> --- a/libdecnumber/configure.ac
> +++ b/libdecnumber/configure.ac
> @@ -100,8 +100,23 @@ AC_C_BIGENDIAN
> # Enable --enable-host-shared.
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> + [build host code as shared libraries])])
> +AC_SUBST(enable_host_shared)
> +
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
> +
> AC_SUBST(PICFLAG)
>
> # Enable Intel CET on Intel CET enabled host if jit is enabled.
> diff --git a/libiberty/configure b/libiberty/configure
> index 860f981fa18..b8a19c42110 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -5258,8 +5258,8 @@ case "${enable_shared}" in
> *) shared=yes ;;
> esac
>
> -# ...unless --enable-host-shared was passed from top-level config:
> -if [ "${enable_host_shared}" = "yes" ]; then
> +# ...unless --enable-host-{shared,pie} was passed from top-level config:
> +if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
> shared=yes
> fi
>
> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
> index 28d996f9cf7..6747a7b5cff 100644
> --- a/libiberty/configure.ac
> +++ b/libiberty/configure.ac
> @@ -233,8 +233,8 @@ case "${enable_shared}" in
> *) shared=yes ;;
> esac
>
> -# ...unless --enable-host-shared was passed from top-level config:
> -if [[ "${enable_host_shared}" = "yes" ]]; then
> +# ...unless --enable-host-{shared,pie} was passed from top-level config:
> +if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
> shared=yes
> fi
>
> diff --git a/zlib/configure b/zlib/configure
> index e35ac6e7e17..77be6c284e3 100755
> --- a/zlib/configure
> +++ b/zlib/configure
> @@ -635,6 +635,8 @@ am__EXEEXT_TRUE
> LTLIBOBJS
> LIBOBJS
> PICFLAG
> +enable_host_pie
> +enable_host_shared
> TARGET_LIBRARY_FALSE
> TARGET_LIBRARY_TRUE
> toolexeclibdir
> @@ -778,6 +780,7 @@ with_gnu_ld
> enable_libtool_lock
> with_toolexeclibdir
> enable_host_shared
> +enable_host_pie
> '
> ac_precious_vars='build_alias
> host_alias
> @@ -1420,6 +1423,7 @@ Optional Features:
> optimize for fast installation [default=yes]
> --disable-libtool-lock avoid locking (might break parallel builds)
> --enable-host-shared build host code as shared libraries
> + --enable-host-pie build host code as PIE
>
> Optional Packages:
> --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
> @@ -10759,7 +10763,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 10762 "configure"
> +#line 10778 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -10865,7 +10869,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 10868 "configure"
> +#line 10884 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -11548,15 +11552,31 @@ else
> multilib_arg=
> fi
>
> +# Enable --enable-host-shared.
> # Check whether --enable-host-shared was given.
> if test "${enable_host_shared+set}" = set; then :
> - enableval=$enable_host_shared; PICFLAG=-fPIC
> + enableval=$enable_host_shared;
> +fi
> +
> +
> +
> +# Enable --enable-host-pie.
> +# Check whether --enable-host-pie was given.
> +if test "${enable_host_pie+set}" = set; then :
> + enableval=$enable_host_pie;
> +fi
> +
> +
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> else
> PICFLAG=
> fi
>
>
> -
> ac_config_files="$ac_config_files Makefile"
>
> cat >confcache <<\_ACEOF
> diff --git a/zlib/configure.ac b/zlib/configure.ac
> index be1cfe29651..adf7aad4e51 100644
> --- a/zlib/configure.ac
> +++ b/zlib/configure.ac
> @@ -122,11 +122,26 @@ else
> multilib_arg=
> fi
>
> +# Enable --enable-host-shared.
> AC_ARG_ENABLE(host-shared,
> [AS_HELP_STRING([--enable-host-shared],
> - [build host code as shared libraries])],
> -[PICFLAG=-fPIC], [PICFLAG=])
> -AC_SUBST(PICFLAG)
> + [build host code as shared libraries])])
> +AC_SUBST(enable_host_shared)
> +
> +# Enable --enable-host-pie.
> +AC_ARG_ENABLE(host-pie,
> +[AS_HELP_STRING([--enable-host-pie],
> + [build host code as PIE])])
> +AC_SUBST(enable_host_pie)
> +
> +if test x$enable_host_shared = xyes; then
> + PICFLAG=-fPIC
> +elif test x$enable_host_pie = xyes; then
> + PICFLAG=-fPIE
> +else
> + PICFLAG=
> +fi
>
> +AC_SUBST(PICFLAG)
> AC_CONFIG_FILES([Makefile])
> AC_OUTPUT
>
> base-commit: bbb6cf926f1732559b3a8aaf2796d34e8651c066
> --
> 2.40.1
>
Marek
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] configure: Implement --enable-host-pie
@ 2023-05-09 19:41 Marek Polacek
2023-05-16 15:29 ` Marek Polacek
0 siblings, 1 reply; 8+ messages in thread
From: Marek Polacek @ 2023-05-09 19:41 UTC (permalink / raw)
To: GCC Patches
[ This is my third attempt to add this configure option. The first
version was approved but it came too late in the development cycle.
The second version was also approved, but I had to revert it:
<https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607082.html>.
I've fixed the problem (by moving $(PICFLAG) from INTERNAL_CFLAGS to
ALL_COMPILERFLAGS). Another change is that since r13-4536 I no longer
need to touch Makefile.def, so this patch is simplified. ]
This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE. This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.
It is similar to the option --enable-host-shared, except that --e-h-s
won't add -shared to the linker flags whereas --e-h-p will add -pie.
It is different from --enable-default-pie because that option just
adds an implicit -fPIE/-pie when the compiler is invoked, but the
compiler itself isn't PIE.
Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
regressions.
When building the compiler, the build process may use various in-tree
libraries; these need to be built with -fPIE so that it's possible to
use them when building a PIE. For instance, when --with-included-gettext
is in effect, intl object files must be compiled with -fPIE. Similarly,
when building in-tree gmp, isl, mpfr and mpc, they must be compiled with
-fPIE.
With this patch and --enable-host-pie used to configure gcc:
$ file gcc/cc1{,plus,obj} gcc/f951 gcc/lto1 gcc/cpp
gcc/cc1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1plus: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/f951: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cc1obj: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/lto1: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
gcc/cpp: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
I plan to add an option to link with -Wl,-z,now.
Bootstrapped on x86_64-pc-linux-gnu with --with-included-gettext
--enable-host-pie as well as without --enable-host-pie. Also tested
on a Debian system where the system gcc was configured with
--enable-default-pie.
ChangeLog:
* configure.ac (--enable-host-pie): New check. Set PICFLAG after this
check.
* configure: Regenerate.
c++tools/ChangeLog:
* Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
Use pic/libiberty.a if PICFLAG is set.
* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
(--enable-host-pie): New check.
* configure: Regenerate.
fixincludes/ChangeLog:
* Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic"
build of libiberty if PICFLAG is set.
* configure.ac:
* configure: Regenerate.
gcc/ChangeLog:
* Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
* doc/install.texi: Document --enable-host-pie.
gcc/d/ChangeLog:
* Make-lang.in: Remove NO_PIE_CFLAGS.
intl/ChangeLog:
* Makefile.in: Use @PICFLAG@ in COMPILE as well.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libcody/ChangeLog:
* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
libcpp/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libdecnumber/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libiberty/ChangeLog:
* configure.ac: Also set shared when enable_host_pie.
* configure: Regenerate.
zlib/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
---
c++tools/Makefile.in | 11 ++++++---
c++tools/configure | 17 +++++++++++---
c++tools/configure.ac | 11 +++++++--
configure | 24 +++++++++++++++++++-
configure.ac | 18 ++++++++++++++-
fixincludes/Makefile.in | 12 ++++++----
fixincludes/configure | 13 +++++++++++
fixincludes/configure.ac | 8 +++++++
gcc/Makefile.in | 32 +++++++++++++++-----------
gcc/configure | 47 +++++++++++++++++++++++++++------------
gcc/configure.ac | 36 +++++++++++++++++++++---------
gcc/d/Make-lang.in | 2 +-
gcc/doc/install.texi | 16 +++++++++++--
intl/Makefile.in | 2 +-
intl/configure | 24 ++++++++++++++++++--
intl/configure.ac | 19 ++++++++++++++--
libcody/Makefile.in | 2 +-
libcody/configure | 30 ++++++++++++++++++++++++-
libcody/configure.ac | 26 ++++++++++++++++++++--
libcpp/configure | 22 +++++++++++++++++-
libcpp/configure.ac | 19 ++++++++++++++--
libdecnumber/configure | 22 +++++++++++++++++-
libdecnumber/configure.ac | 19 ++++++++++++++--
libiberty/configure | 4 ++--
libiberty/configure.ac | 4 ++--
zlib/configure | 28 +++++++++++++++++++----
zlib/configure.ac | 21 ++++++++++++++---
27 files changed, 409 insertions(+), 80 deletions(-)
diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
index 77bda3d56dc..dcb1029e064 100644
--- a/c++tools/Makefile.in
+++ b/c++tools/Makefile.in
@@ -29,8 +29,9 @@ AUTOCONF := @AUTOCONF@
AUTOHEADER := @AUTOHEADER@
CXX := @CXX@
CXXFLAGS := @CXXFLAGS@
-PIEFLAG := @PIEFLAG@
-CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
+PICFLAG := @PICFLAG@
+LD_PICFLAG := @LD_PICFLAG@
+CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
LDFLAGS := @LDFLAGS@
exeext := @EXEEXT@
LIBIBERTY := ../libiberty/libiberty.a
@@ -90,11 +91,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
all::g++-mapper-server$(exeext)
+ifneq ($(PICFLAG),)
+override LIBIBERTY := ../libiberty/pic/libiberty.a
+endif
+
MAPPER.O := server.o resolver.o
CODYLIB = ../libcody/libcody.a
CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
- +$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
+ +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
# copy to gcc dir so tests there can run
all::../gcc/g++-mapper-server$(exeext)
diff --git a/c++tools/configure b/c++tools/configure
index 742816e4253..88087009383 100755
--- a/c++tools/configure
+++ b/c++tools/configure
@@ -627,7 +627,8 @@ get_gcc_base_ver
EGREP
GREP
CXXCPP
-PIEFLAG
+LD_PICFLAG
+PICFLAG
MAINTAINER
CXX_AUX_TOOLS
AUTOHEADER
@@ -700,6 +701,7 @@ enable_c___tools
enable_maintainer_mode
enable_checking
enable_default_pie
+enable_host_pie
with_gcc_major_version_only
'
ac_precious_vars='build_alias
@@ -1333,6 +1335,7 @@ Optional Features:
only specific categories of checks. Categories are:
yes,no,all,none,release.
--enable-default-pie enable Position Independent Executable as default
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -2990,12 +2993,20 @@ fi
# Check whether --enable-default-pie was given.
# Check whether --enable-default-pie was given.
if test "${enable_default_pie+set}" = set; then :
- enableval=$enable_default_pie; PIEFLAG=-fPIE
+ enableval=$enable_default_pie; PICFLAG=-fPIE
else
- PIEFLAG=
+ PICFLAG=
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
+fi
+
+
+
# Check if O_CLOEXEC is defined by fcntl
diff --git a/c++tools/configure.ac b/c++tools/configure.ac
index 23e98c8e721..44dfaccbbfa 100644
--- a/c++tools/configure.ac
+++ b/c++tools/configure.ac
@@ -102,8 +102,15 @@ fi
AC_ARG_ENABLE(default-pie,
[AS_HELP_STRING([--enable-default-pie],
[enable Position Independent Executable as default])],
-[PIEFLAG=-fPIE], [PIEFLAG=])
-AC_SUBST([PIEFLAG])
+[PICFLAG=-fPIE], [PICFLAG=])
+
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])],
+[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
# Check if O_CLOEXEC is defined by fcntl
AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
diff --git a/configure b/configure
index 0494e2fa2bf..f5cf9b84c06 100755
--- a/configure
+++ b/configure
@@ -687,6 +687,8 @@ extra_host_zlib_configure_flags
extra_host_libiberty_configure_flags
stage1_languages
host_libs_picflag
+PICFLAG
+enable_host_pie
host_shared
extra_linker_plugin_flags
extra_linker_plugin_configure_flags
@@ -831,6 +833,7 @@ enable_lto
enable_linker_plugin_configure_flags
enable_linker_plugin_flags
enable_host_shared
+enable_host_pie
enable_stage1_languages
enable_objc_gc
with_target_bdw_gc
@@ -1559,6 +1562,7 @@ Optional Features:
additional flags for configuring and building linker
plugins [none]
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-stage1-languages[=all]
choose additional languages to build during stage1.
Mostly useful for compiler development
@@ -8669,11 +8673,29 @@ fi
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+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
+if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
host_libs_picflag='--with-pic'
fi
diff --git a/configure.ac b/configure.ac
index f5cce5830bc..2a85834f2b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1913,11 +1913,27 @@ AC_ARG_ENABLE(host-shared,
AC_SUBST(host_shared)
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+AC_SUBST(PICFLAG)
+
# 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
+if test "$host_shared" = "yes" -o "$enable_host_pie" = "yes"; then
host_libs_picflag='--with-pic'
fi
AC_SUBST(host_libs_picflag)
diff --git a/fixincludes/Makefile.in b/fixincludes/Makefile.in
index 1937dcaa32d..e6ce41dba39 100644
--- a/fixincludes/Makefile.in
+++ b/fixincludes/Makefile.in
@@ -73,7 +73,7 @@ default : all
# Now figure out from those variables how to compile and link.
.c.o:
- $(CC) -c $(CFLAGS) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
+ $(CC) -c $(CFLAGS) $(PICFLAG) $(WARN_CFLAGS) $(CPPFLAGS) $(FIXINC_CFLAGS) $<
# The only suffixes we want for implicit rules are .c and .o.
.SUFFIXES:
@@ -87,7 +87,11 @@ default : all
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+ifeq ($(PICFLAG),)
LIBIBERTY=../libiberty/libiberty.a
+else
+LIBIBERTY=../libiberty/pic/libiberty.a
+endif
ALLOBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
fixlib.o fixopts.o
@@ -107,15 +111,15 @@ oneprocess : full-stamp
twoprocess : test-stamp $(AF)
full-stamp : $(ALLOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(ALLOBJ) $(LIBIBERTY)
$(STAMP) $@
test-stamp : $(TESTOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $(FI) $(TESTOBJ) $(LIBIBERTY)
$(STAMP) $@
$(AF): $(FIXOBJ) $(LIBIBERTY)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(FIXOBJ) $(LIBIBERTY)
+ $(CC) $(CFLAGS) $(PICFLAG) $(LDFLAGS) $(LD_PICFLAG) -o $@ $(FIXOBJ) $(LIBIBERTY)
$(ALLOBJ) : $(HDR)
fixincl.o : fixincl.c $(srcdir)/fixincl.x
diff --git a/fixincludes/configure b/fixincludes/configure
index bdcc41f6ddc..f1748ebef74 100755
--- a/fixincludes/configure
+++ b/fixincludes/configure
@@ -623,6 +623,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
get_gcc_base_ver
MAINT
+LD_PICFLAG
+PICFLAG
TARGET
target_noncanonical
WERROR
@@ -695,6 +697,7 @@ enable_option_checking
enable_werror_always
with_local_prefix
enable_twoprocess
+enable_host_pie
enable_maintainer_mode
with_gcc_major_version_only
'
@@ -1323,6 +1326,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-werror-always enable -Werror despite compiler version
--enable-twoprocess Use a separate process to apply the fixes
+ --enable-host-pie build host code as PIE
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
@@ -4835,6 +4839,15 @@ $as_echo "#define SEPARATE_FIX_PROC 1" >>confdefs.h
fi
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
+fi
+
+
+
+
case $host in
vax-dec-bsd* )
diff --git a/fixincludes/configure.ac b/fixincludes/configure.ac
index ef2227e3c93..4e78511d20f 100644
--- a/fixincludes/configure.ac
+++ b/fixincludes/configure.ac
@@ -68,6 +68,14 @@ if test $TARGET = twoprocess; then
[Define if testing and fixing are done by separate process])
fi
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])],
+[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
+
case $host in
vax-dec-bsd* )
AC_DEFINE(exit, xexit, [Define to xexit if the host system does not support atexit])
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index bb63b5c501d..860fd9af81a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -158,6 +158,9 @@ LDFLAGS = @LDFLAGS@
# Should we build position-independent host code?
PICFLAG = @PICFLAG@
+# The linker flag for the above.
+LD_PICFLAG = @LD_PICFLAG@
+
# Flags to determine code coverage. When coverage is disabled, this will
# contain the optimization flags, as you normally want code coverage
# without optimization.
@@ -283,19 +286,19 @@ LINKER = $(CC)
LINKER_FLAGS = $(CFLAGS)
endif
+enable_host_pie = @enable_host_pie@
+
# Enable Intel CET on Intel CET enabled host if needed.
CET_HOST_FLAGS = @CET_HOST_FLAGS@
COMPILER += $(CET_HOST_FLAGS)
-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
-NO_PIE_FLAG = @NO_PIE_FLAG@
DO_LINK_MUTEX = @DO_LINK_MUTEX@
-# We don't want to compile the compilers with -fPIE, it make PCH fail.
-COMPILER += $(NO_PIE_CFLAGS)
+# Maybe compile the compilers with -fPIE or -fPIC.
+COMPILER += $(PICFLAG)
-# Link with -no-pie since we compile the compiler with -fno-PIE.
-LINKER += $(NO_PIE_FLAG)
+# Link with -pie, or -no-pie, depending on the above.
+LINKER += $(LD_PICFLAG)
# Like LINKER, but use a mutex for serializing front end links.
ifeq (@DO_LINK_MUTEX@,true)
@@ -1067,7 +1070,7 @@ RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
# programs built during a bootstrap.
# autoconf inserts -DCROSS_DIRECTORY_STRUCTURE if we are building a
# cross compiler which does not use the native headers and libraries.
-INTERNAL_CFLAGS = -DIN_GCC $(PICFLAG) @CROSS@
+INTERNAL_CFLAGS = -DIN_GCC @CROSS@
# This is the variable actually used when we compile. If you change this,
# you probably want to update BUILD_CFLAGS in configure.ac
@@ -1085,21 +1088,24 @@ ALL_CXXFLAGS = $(T_CFLAGS) $(CFLAGS-$@) $(CXXFLAGS) $(INTERNAL_CFLAGS) \
ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
# This is the variable to use when using $(COMPILER).
-ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
+ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) $(PICFLAG)
# This is the variable to use when using $(LINKER).
-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
+ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
# Build and host support libraries.
-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
-# building for mingw.
+# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
+# unless we are building for mingw.
LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
-ifeq ($(enable_host_shared),yes)
+ifneq ($(enable_host_shared)$(enable_host_pie),)
LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
else
LIBIBERTY = ../libiberty/libiberty.a
+endif
+ifeq ($(enable_host_shared),yes)
+BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+else
BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
endif
diff --git a/gcc/configure b/gcc/configure
index 191f68581b3..629446ecf3b 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -632,10 +632,10 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
-NO_PIE_FLAG
-NO_PIE_CFLAGS
-enable_default_pie
+LD_PICFLAG
PICFLAG
+enable_default_pie
+enable_host_pie
enable_host_shared
enable_plugin
pluginlibs
@@ -1030,6 +1030,7 @@ enable_link_serialization
enable_version_specific_runtime_libs
enable_plugin
enable_host_shared
+enable_host_pie
enable_libquadmath_support
with_linker_hash_style
with_diagnostics_color
@@ -1792,6 +1793,7 @@ Optional Features:
in a compiler-specific directory
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--disable-libquadmath-support
disable libquadmath support for Fortran
--enable-default-pie enable Position Independent Executable as default
@@ -19850,7 +19852,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19853 "configure"
+#line 19867 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19956,7 +19958,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19959 "configure"
+#line 19973 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -32090,13 +32092,17 @@ fi
# Enable --enable-host-shared
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
-else
- PICFLAG=
+ enableval=$enable_host_shared;
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
# Check whether --enable-libquadmath-support was given.
@@ -32250,10 +32256,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
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"
-fi
-
# Check if -no-pie works.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
@@ -32278,11 +32280,28 @@ rm -f core conftest.err conftest.$ac_objext \
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"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
fi
+
+
# Enable Intel CET on Intel CET enabled host if jit is enabled.
# Check whether --enable-cet was given.
if test "${enable_cet+set}" = set; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 075424669c9..9c69a55668e 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7418,11 +7418,14 @@ fi
# Enable --enable-host-shared
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
AC_SUBST(enable_host_shared)
-AC_SUBST(PICFLAG)
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
AC_ARG_ENABLE(libquadmath-support,
[AS_HELP_STRING([--disable-libquadmath-support],
@@ -7544,10 +7547,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
[gcc_cv_c_no_fpie=yes],
[gcc_cv_c_no_fpie=no])
CXXFLAGS="$saved_CXXFLAGS"])
-if test "$gcc_cv_c_no_fpie" = "yes"; then
- NO_PIE_CFLAGS="-fno-PIE"
-fi
-AC_SUBST([NO_PIE_CFLAGS])
# Check if -no-pie works.
AC_CACHE_CHECK([for -no-pie option],
@@ -7558,10 +7557,27 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
-if test "$gcc_cv_no_pie" = "yes"; then
- NO_PIE_FLAG="-no-pie"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
fi
-AC_SUBST([NO_PIE_FLAG])
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
+fi
+
+AC_SUBST([PICFLAG])
+AC_SUBST([LD_PICFLAG])
# Enable Intel CET on Intel CET enabled host if jit is enabled.
GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index 1679fb81097..4fbf2096416 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -64,7 +64,7 @@ ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
$(PICFLAG) $(ALIASING_FLAGS) $(NOEXCEPTION_DFLAGS) $(COVERAGE_FLAGS) \
$(WARN_DFLAGS)
-DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
+DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index fa91ce1953d..2248308dbdf 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1072,14 +1072,26 @@ code.
@item --enable-host-shared
Specify that the @emph{host} code should be built into position-independent
-machine code (with -fPIC), allowing it to be used within shared libraries,
-but yielding a slightly slower compiler.
+machine code (with @option{-fPIC}), allowing it to be used within shared
+libraries, but yielding a slightly slower compiler.
This option is required when building the libgccjit.so library.
Contrast with @option{--enable-shared}, which affects @emph{target}
libraries.
+@item --enable-host-pie
+Specify that the @emph{host} executables should be built into
+position-independent executables (with @option{-fPIE} and @option{-pie}),
+yielding a slightly slower compiler (but faster than
+@option{--enable-host-shared}). Position-independent executables are loaded
+at random addresses each time they are executed, therefore provide additional
+protection against Return Oriented Programming (ROP) attacks.
+
+@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
+in which case @option{-fPIC} is used when compiling, and @option{-pie} when
+linking.
+
@item @anchor{with-gnu-as}--with-gnu-as
Specify that the compiler should assume that the
assembler it finds is the GNU assembler. However, this does not modify
diff --git a/intl/Makefile.in b/intl/Makefile.in
index 409d693c48e..5beebdc152c 100644
--- a/intl/Makefile.in
+++ b/intl/Makefile.in
@@ -54,7 +54,7 @@ CTAGS = @CTAGS@
ETAGS = @ETAGS@
MKID = @MKID@
-COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(DEFS-$@) $(INCLUDES)
+COMPILE = $(CC) -c $(CPPFLAGS) $(CFLAGS) @PICFLAG@ $(DEFS) $(DEFS-$@) $(INCLUDES)
HEADERS = \
gmo.h \
diff --git a/intl/configure b/intl/configure
index 03f40487a92..79bb5831a47 100755
--- a/intl/configure
+++ b/intl/configure
@@ -623,6 +623,8 @@ ac_header_list=
ac_subst_vars='LTLIBOBJS
LIBOBJS
PICFLAG
+enable_host_pie
+enable_host_shared
BISON3_NO
BISON3_YES
INCINTL
@@ -731,6 +733,7 @@ with_libintl_prefix
with_libintl_type
enable_maintainer_mode
enable_host_shared
+enable_host_pie
'
ac_precious_vars='build_alias
host_alias
@@ -1356,6 +1359,7 @@ Optional Features:
--disable-rpath do not hardcode runtime library paths
--enable-maintainer-mode enable rules only needed by maintainers
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -6852,15 +6856,31 @@ fi
+# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
-
ac_config_files="$ac_config_files Makefile config.intl"
cat >confcache <<\_ACEOF
diff --git a/intl/configure.ac b/intl/configure.ac
index 16a740aa230..81aa831f59f 100644
--- a/intl/configure.ac
+++ b/intl/configure.ac
@@ -83,10 +83,25 @@ fi
AC_SUBST(BISON3_YES)
AC_SUBST(BISON3_NO)
+# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
AC_SUBST(PICFLAG)
AC_CONFIG_FILES(Makefile config.intl)
diff --git a/libcody/Makefile.in b/libcody/Makefile.in
index bb87468cb9a..cb01b0092d8 100644
--- a/libcody/Makefile.in
+++ b/libcody/Makefile.in
@@ -31,7 +31,7 @@ endif
CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
# Linker options
-LDFLAGS := @LDFLAGS@
+LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
LIBS := @LIBS@
# Per-source & per-directory compile flags (warning: recursive)
diff --git a/libcody/configure b/libcody/configure
index da52a5cfca5..0e536c0ccb0 100755
--- a/libcody/configure
+++ b/libcody/configure
@@ -591,7 +591,10 @@ configure_args
AR
RANLIB
EXCEPTIONS
+LD_PICFLAG
PICFLAG
+enable_host_pie
+enable_host_shared
OBJEXT
EXEEXT
ac_ct_CXX
@@ -653,6 +656,7 @@ enable_maintainer_mode
with_compiler
enable_checking
enable_host_shared
+enable_host_pie
enable_exceptions
'
ac_precious_vars='build_alias
@@ -1286,6 +1290,7 @@ Optional Features:
yes,no,all,none,release. Flags are: misc,valgrind or
other strings
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-exceptions enable exceptions & rtti
Optional Packages:
@@ -2635,11 +2640,34 @@ fi
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
+
# Check whether --enable-exceptions was given.
diff --git a/libcody/configure.ac b/libcody/configure.ac
index 960191ecb72..14e8dd4a226 100644
--- a/libcody/configure.ac
+++ b/libcody/configure.ac
@@ -63,9 +63,31 @@ fi
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
NMS_ENABLE_EXCEPTIONS
diff --git a/libcpp/configure b/libcpp/configure
index e9937cde330..1389ddab544 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -625,6 +625,8 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
MAINT
USED_CATALOGS
PACKAGE
@@ -738,6 +740,7 @@ enable_maintainer_mode
enable_checking
enable_canonical_system_headers
enable_host_shared
+enable_host_pie
enable_cet
enable_valgrind_annotations
'
@@ -1379,6 +1382,7 @@ Optional Features:
--enable-canonical-system-headers
enable or disable system headers canonicalization
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
--enable-valgrind-annotations
enable valgrind runtime interaction
@@ -7605,7 +7609,23 @@ esac
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 89ac99b04bd..b29b4d6acf1 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -211,8 +211,23 @@ esac
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/libdecnumber/configure b/libdecnumber/configure
index fb6db05565a..84bc4ffc767 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
ADDITIONAL_OBJS
enable_decimal_float
target_os
@@ -706,6 +708,7 @@ enable_werror_always
enable_maintainer_mode
enable_decimal_float
enable_host_shared
+enable_host_pie
enable_cet
'
ac_precious_vars='build_alias
@@ -1338,6 +1341,7 @@ Optional Features:
or 'dpd' choses which decimal floating point format
to use
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
Some influential environment variables:
@@ -5186,7 +5190,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
index aafd06f8a64..30a51ca410b 100644
--- a/libdecnumber/configure.ac
+++ b/libdecnumber/configure.ac
@@ -100,8 +100,23 @@ AC_C_BIGENDIAN
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/libiberty/configure b/libiberty/configure
index 860f981fa18..b8a19c42110 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5258,8 +5258,8 @@ case "${enable_shared}" in
*) shared=yes ;;
esac
-# ...unless --enable-host-shared was passed from top-level config:
-if [ "${enable_host_shared}" = "yes" ]; then
+# ...unless --enable-host-{shared,pie} was passed from top-level config:
+if [ "${enable_host_shared}" = "yes" ] || [ "${enable_host_pie}" = "yes" ]; then
shared=yes
fi
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 28d996f9cf7..6747a7b5cff 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -233,8 +233,8 @@ case "${enable_shared}" in
*) shared=yes ;;
esac
-# ...unless --enable-host-shared was passed from top-level config:
-if [[ "${enable_host_shared}" = "yes" ]]; then
+# ...unless --enable-host-{shared,pie} was passed from top-level config:
+if [[ "${enable_host_shared}" = "yes" ]] || [[ "${enable_host_pie}" = "yes" ]]; then
shared=yes
fi
diff --git a/zlib/configure b/zlib/configure
index e35ac6e7e17..77be6c284e3 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -635,6 +635,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
PICFLAG
+enable_host_pie
+enable_host_shared
TARGET_LIBRARY_FALSE
TARGET_LIBRARY_TRUE
toolexeclibdir
@@ -778,6 +780,7 @@ with_gnu_ld
enable_libtool_lock
with_toolexeclibdir
enable_host_shared
+enable_host_pie
'
ac_precious_vars='build_alias
host_alias
@@ -1420,6 +1423,7 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -10759,7 +10763,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10762 "configure"
+#line 10778 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10865,7 +10869,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10868 "configure"
+#line 10884 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11548,15 +11552,31 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
-
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
diff --git a/zlib/configure.ac b/zlib/configure.ac
index be1cfe29651..adf7aad4e51 100644
--- a/zlib/configure.ac
+++ b/zlib/configure.ac
@@ -122,11 +122,26 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
-AC_SUBST(PICFLAG)
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+AC_SUBST(PICFLAG)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
base-commit: bbb6cf926f1732559b3a8aaf2796d34e8651c066
--
2.40.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] configure: Implement --enable-host-pie
2022-02-10 16:48 Marek Polacek
@ 2022-02-10 21:10 ` Joseph Myers
0 siblings, 0 replies; 8+ messages in thread
From: Joseph Myers @ 2022-02-10 21:10 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches, Jakub Jelinek, Paolo Bonzini, Alexandre Oliva
Some general observations:
* There are various toplevel GCC subdirectories that are built for the
host (possibly in addition to the target in some cases) but aren't changed
in this patch. Do they get a PIE or PIC build anyway by default? Such
directories include, I think: fixincludes (as a corner case, for the
installed fixincludes), gmp, mpfr, mpc, isl (host libraries whose
configure scripts aren't part of GCC, so any changes to ensure they build
as PIE when needed would need to be at top level), intl, libbacktrace,
libiberty, gnattools, gotools.
(Using a bootstrap compiler that *doesn't* default to PIE might help
detect any such issues, though only for directores that get built for the
host in that build - some may not get built by default.)
For directories that are only used as host libraries but don't install any
executables, even if this patch needs additions the -z now one shouldn't.
* I don't see anything obvious here (or for the existing
--enable-host-shared) that actually causes the configure option to apply
only to the host and not to the target, in the case of subdirectories such
as libbacktrace that get built for both host and target. (Though static
target libraries may well default to PIC in many cases anyway.)
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] configure: Implement --enable-host-pie
@ 2022-02-10 16:48 Marek Polacek
2022-02-10 21:10 ` Joseph Myers
0 siblings, 1 reply; 8+ messages in thread
From: Marek Polacek @ 2022-02-10 16:48 UTC (permalink / raw)
To: GCC Patches; +Cc: Alexandre Oliva, Paolo Bonzini, Joseph Myers, Jakub Jelinek
This patch implements the --enable-host-pie configure option which
makes the compiler executables PIE. This can be used to enhance
protection against ROP attacks, and can be viewed as part of a wider
trend to harden binaries.
It is similar to the option --enable-host-shared, except that --e-h-s
won't add -shared to the linker flags whereas --e-h-p will add -pie.
It is different from --enable-default-pie because that option just
adds an implicit -fPIE/-pie when the compiler is invoked, but the
compiler itself isn't PIE.
Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH
regressions.
I plan to add an option to link with -Wl,-z,now.
Bootstrapped/regtested on x86_64-pc-linux-gnu (with the option enabled vs
not enabled). I suppose this is GCC 13 material, but maybe I'll get some
comments anyway.
c++tools/ChangeLog:
* Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it.
Use pic/libiberty.a if PICFLAG is set.
* configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG.
(--enable-host-pie): New check.
* configure: Regenerate.
gcc/ChangeLog:
* Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie.
Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to
ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
* d/Make-lang.in: Remove NO_PIE_CFLAGS.
* doc/install.texi: Document --enable-host-pie.
libcody/ChangeLog:
* Makefile.in: Pass LD_PICFLAG to LDFLAGS.
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this
check.
* configure: Regenerate.
libcpp/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
libdecnumber/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
zlib/ChangeLog:
* configure.ac (--enable-host-shared): Don't set PICFLAG here.
(--enable-host-pie): New check. Set PICFLAG after this check.
* configure: Regenerate.
---
c++tools/Makefile.in | 11 ++++++---
c++tools/configure | 17 +++++++++++---
c++tools/configure.ac | 11 +++++++--
gcc/Makefile.in | 29 ++++++++++++++----------
gcc/configure | 47 +++++++++++++++++++++++++++------------
gcc/configure.ac | 36 +++++++++++++++++++++---------
gcc/d/Make-lang.in | 2 +-
gcc/doc/install.texi | 16 +++++++++++--
libcody/Makefile.in | 2 +-
libcody/configure | 30 ++++++++++++++++++++++++-
libcody/configure.ac | 26 ++++++++++++++++++++--
libcpp/configure | 22 +++++++++++++++++-
libcpp/configure.ac | 19 ++++++++++++++--
libdecnumber/configure | 22 +++++++++++++++++-
libdecnumber/configure.ac | 19 ++++++++++++++--
zlib/configure | 30 ++++++++++++++++++++-----
zlib/configure.ac | 21 ++++++++++++++---
17 files changed, 295 insertions(+), 65 deletions(-)
diff --git a/c++tools/Makefile.in b/c++tools/Makefile.in
index d6a33613732..4d5a5b0522b 100644
--- a/c++tools/Makefile.in
+++ b/c++tools/Makefile.in
@@ -28,8 +28,9 @@ AUTOCONF := @AUTOCONF@
AUTOHEADER := @AUTOHEADER@
CXX := @CXX@
CXXFLAGS := @CXXFLAGS@
-PIEFLAG := @PIEFLAG@
-CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
+PICFLAG := @PICFLAG@
+LD_PICFLAG := @LD_PICFLAG@
+CXXOPTS := $(CXXFLAGS) $(PICFLAG) -fno-exceptions -fno-rtti
LDFLAGS := @LDFLAGS@
exeext := @EXEEXT@
LIBIBERTY := ../libiberty/libiberty.a
@@ -88,11 +89,15 @@ ifeq (@CXX_AUX_TOOLS@,yes)
all::g++-mapper-server$(exeext)
+ifneq ($(PICFLAG),)
+override LIBIBERTY := ../libiberty/pic/libiberty.a
+endif
+
MAPPER.O := server.o resolver.o
CODYLIB = ../libcody/libcody.a
CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I. -I../gcc
g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
- +$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
+ +$(CXX) $(LDFLAGS) $(PICFLAG) $(LD_PICFLAG) -o $@ $^ $(LIBIBERTY) $(NETLIBS)
# copy to gcc dir so tests there can run
all::../gcc/g++-mapper-server$(exeext)
diff --git a/c++tools/configure b/c++tools/configure
index 742816e4253..88087009383 100755
--- a/c++tools/configure
+++ b/c++tools/configure
@@ -627,7 +627,8 @@ get_gcc_base_ver
EGREP
GREP
CXXCPP
-PIEFLAG
+LD_PICFLAG
+PICFLAG
MAINTAINER
CXX_AUX_TOOLS
AUTOHEADER
@@ -700,6 +701,7 @@ enable_c___tools
enable_maintainer_mode
enable_checking
enable_default_pie
+enable_host_pie
with_gcc_major_version_only
'
ac_precious_vars='build_alias
@@ -1333,6 +1335,7 @@ Optional Features:
only specific categories of checks. Categories are:
yes,no,all,none,release.
--enable-default-pie enable Position Independent Executable as default
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -2990,12 +2993,20 @@ fi
# Check whether --enable-default-pie was given.
# Check whether --enable-default-pie was given.
if test "${enable_default_pie+set}" = set; then :
- enableval=$enable_default_pie; PIEFLAG=-fPIE
+ enableval=$enable_default_pie; PICFLAG=-fPIE
else
- PIEFLAG=
+ PICFLAG=
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie; PICFLAG=-fPIE; LD_PICFLAG=-pie
+fi
+
+
+
# Check if O_CLOEXEC is defined by fcntl
diff --git a/c++tools/configure.ac b/c++tools/configure.ac
index 6662b5ad7c9..1e42689f2eb 100644
--- a/c++tools/configure.ac
+++ b/c++tools/configure.ac
@@ -102,8 +102,15 @@ fi
AC_ARG_ENABLE(default-pie,
[AS_HELP_STRING([--enable-default-pie],
[enable Position Independent Executable as default])],
-[PIEFLAG=-fPIE], [PIEFLAG=])
-AC_SUBST([PIEFLAG])
+[PICFLAG=-fPIE], [PICFLAG=])
+
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])],
+[PICFLAG=-fPIE; LD_PICFLAG=-pie], [])
+AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
# Check if O_CLOEXEC is defined by fcntl
AC_CACHE_CHECK(for O_CLOEXEC, ac_cv_o_cloexec, [
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 31ff95500c9..151dbfa54ec 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -155,6 +155,9 @@ LDFLAGS = @LDFLAGS@
# Should we build position-independent host code?
PICFLAG = @PICFLAG@
+# The linker flag for the above.
+LD_PICFLAG = @LD_PICFLAG@
+
# Flags to determine code coverage. When coverage is disabled, this will
# contain the optimization flags, as you normally want code coverage
# without optimization.
@@ -263,18 +266,17 @@ LINKER = $(CC)
LINKER_FLAGS = $(CFLAGS)
endif
+enable_host_pie = @enable_host_pie@
+
# Enable Intel CET on Intel CET enabled host if needed.
CET_HOST_FLAGS = @CET_HOST_FLAGS@
COMPILER += $(CET_HOST_FLAGS)
-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
-NO_PIE_FLAG = @NO_PIE_FLAG@
-
-# We don't want to compile the compilers with -fPIE, it make PCH fail.
-COMPILER += $(NO_PIE_CFLAGS)
+# Maybe compile the compilers with -fPIE or -fPIC.
+COMPILER += $(PICFLAG)
-# Link with -no-pie since we compile the compiler with -fno-PIE.
-LINKER += $(NO_PIE_FLAG)
+# Link with -pie, or -no-pie, depending on the above.
+LINKER += $(LD_PICFLAG)
# Like LINKER, but use a mutex for serializing front end links.
ifeq (@DO_LINK_MUTEX@,true)
@@ -1057,18 +1059,21 @@ ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS)
ALL_COMPILERFLAGS = $(ALL_CXXFLAGS)
# This is the variable to use when using $(LINKER).
-ALL_LINKERFLAGS = $(ALL_CXXFLAGS)
+ALL_LINKERFLAGS = $(ALL_CXXFLAGS) $(LD_PICFLAG)
# Build and host support libraries.
-# Use the "pic" build of libiberty if --enable-host-shared, unless we are
-# building for mingw.
+# Use the "pic" build of libiberty if --enable-host-shared or --enable-host-pie,
+# unless we are building for mingw.
LIBIBERTY_PICDIR=$(if $(findstring mingw,$(target)),,pic)
-ifeq ($(enable_host_shared),yes)
+ifneq ($(enable_host_shared)$(enable_host_pie),)
LIBIBERTY = ../libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
-BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
else
LIBIBERTY = ../libiberty/libiberty.a
+endif
+ifeq ($(enable_host_shared),yes)
+BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/$(LIBIBERTY_PICDIR)/libiberty.a
+else
BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
endif
diff --git a/gcc/configure b/gcc/configure
index 258b17a226e..bd4fe1fd6ca 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -632,10 +632,10 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
-NO_PIE_FLAG
-NO_PIE_CFLAGS
-enable_default_pie
+LD_PICFLAG
PICFLAG
+enable_default_pie
+enable_host_pie
enable_host_shared
enable_plugin
pluginlibs
@@ -1025,6 +1025,7 @@ enable_link_serialization
enable_version_specific_runtime_libs
enable_plugin
enable_host_shared
+enable_host_pie
enable_libquadmath_support
with_linker_hash_style
with_diagnostics_color
@@ -1787,6 +1788,7 @@ Optional Features:
in a compiler-specific directory
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--disable-libquadmath-support
disable libquadmath support for Fortran
--enable-default-pie enable Position Independent Executable as default
@@ -19659,7 +19661,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19662 "configure"
+#line 19676 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19765,7 +19767,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 19768 "configure"
+#line 19782 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -32221,13 +32223,17 @@ fi
# Enable --enable-host-shared
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
-else
- PICFLAG=
+ enableval=$enable_host_shared;
fi
+# Enable --enable-host-pie
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
# Check whether --enable-libquadmath-support was given.
@@ -32381,10 +32387,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
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"
-fi
-
# Check if -no-pie works.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -no-pie option" >&5
@@ -32409,11 +32411,28 @@ rm -f core conftest.err conftest.$ac_objext \
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"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
fi
+
+
# Enable Intel CET on Intel CET enabled host if jit is enabled.
# Check whether --enable-cet was given.
if test "${enable_cet+set}" = set; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 06750cee977..dca995aeec7 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -7488,11 +7488,14 @@ fi
# Enable --enable-host-shared
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
AC_SUBST(enable_host_shared)
-AC_SUBST(PICFLAG)
+# Enable --enable-host-pie
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
AC_ARG_ENABLE(libquadmath-support,
[AS_HELP_STRING([--disable-libquadmath-support],
@@ -7614,10 +7617,6 @@ AC_CACHE_CHECK([for -fno-PIE option],
[gcc_cv_c_no_fpie=yes],
[gcc_cv_c_no_fpie=no])
CXXFLAGS="$saved_CXXFLAGS"])
-if test "$gcc_cv_c_no_fpie" = "yes"; then
- NO_PIE_CFLAGS="-fno-PIE"
-fi
-AC_SUBST([NO_PIE_CFLAGS])
# Check if -no-pie works.
AC_CACHE_CHECK([for -no-pie option],
@@ -7628,10 +7627,27 @@ AC_CACHE_CHECK([for -no-pie option],
[gcc_cv_no_pie=yes],
[gcc_cv_no_pie=no])
LDFLAGS="$saved_LDFLAGS"])
-if test "$gcc_cv_no_pie" = "yes"; then
- NO_PIE_FLAG="-no-pie"
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+elif test x$gcc_cv_c_no_fpie = xyes; then
+ PICFLAG=-fno-PIE
+else
+ PICFLAG=
fi
-AC_SUBST([NO_PIE_FLAG])
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+elif test x$gcc_cv_no_pie = xyes; then
+ LD_PICFLAG=-no-pie
+else
+ LD_PICFLAG=
+fi
+
+AC_SUBST([PICFLAG])
+AC_SUBST([LD_PICFLAG])
# Enable Intel CET on Intel CET enabled host if jit is enabled.
GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index 6c90657d65f..88573d5fac6 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -60,7 +60,7 @@ WARN_DFLAGS = -Wall -Wdeprecated $(NOCOMMON_FLAG)
ALL_DFLAGS = $(DFLAGS-$@) $(GDCFLAGS) -fversion=IN_GCC $(CHECKING_DFLAGS) \
$(PICFLAG) $(ALIASING_FLAGS) $(COVERAGE_FLAGS) $(WARN_DFLAGS)
-DCOMPILE.base = $(GDC) $(NO_PIE_CFLAGS) -c $(ALL_DFLAGS) -o $@
+DCOMPILE.base = $(GDC) -c $(ALL_DFLAGS) -o $@
DCOMPILE = $(DCOMPILE.base) -MT $@ -MMD -MP -MF $(@D)/$(DEPDIR)/$(*F).TPo
DPOSTCOMPILE = @mv $(@D)/$(DEPDIR)/$(*F).TPo $(@D)/$(DEPDIR)/$(*F).Po
DLINKER = $(GDC) $(NO_PIE_FLAG) -lstdc++
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 7258f9def6c..9747f832a75 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1021,14 +1021,26 @@ code.
@item --enable-host-shared
Specify that the @emph{host} code should be built into position-independent
-machine code (with -fPIC), allowing it to be used within shared libraries,
-but yielding a slightly slower compiler.
+machine code (with @option{-fPIC}), allowing it to be used within shared
+libraries, but yielding a slightly slower compiler.
This option is required when building the libgccjit.so library.
Contrast with @option{--enable-shared}, which affects @emph{target}
libraries.
+@item --enable-host-pie
+Specify that the @emph{host} executables should be built into
+position-independent executables (with @option{-fPIE} and @option{-pie}),
+yielding a slightly slower compiler (but faster than
+@option{--enable-host-shared}). Position-independent executables are loaded
+at random addresses each time they are executed, therefore provide additional
+protection against Return Oriented Programming (ROP) attacks.
+
+@option{--enable-host-pie}) may be used with @option{--enable-host-shared}),
+in which case @option{-fPIC} is used when compiling, and @option{-pie} when
+linking.
+
@item @anchor{with-gnu-as}--with-gnu-as
Specify that the compiler should assume that the
assembler it finds is the GNU assembler. However, this does not modify
diff --git a/libcody/Makefile.in b/libcody/Makefile.in
index 7eaf8ace8ce..0ff1625a39f 100644
--- a/libcody/Makefile.in
+++ b/libcody/Makefile.in
@@ -31,7 +31,7 @@ endif
CXXOPTS += $(filter-out -DHAVE_CONFIG_H,@DEFS@) -include config.h
# Linker options
-LDFLAGS := @LDFLAGS@
+LDFLAGS := @LDFLAGS@ @LD_PICFLAG@
LIBS := @LIBS@
# Per-source & per-directory compile flags (warning: recursive)
diff --git a/libcody/configure b/libcody/configure
index da52a5cfca5..0e536c0ccb0 100755
--- a/libcody/configure
+++ b/libcody/configure
@@ -591,7 +591,10 @@ configure_args
AR
RANLIB
EXCEPTIONS
+LD_PICFLAG
PICFLAG
+enable_host_pie
+enable_host_shared
OBJEXT
EXEEXT
ac_ct_CXX
@@ -653,6 +656,7 @@ enable_maintainer_mode
with_compiler
enable_checking
enable_host_shared
+enable_host_pie
enable_exceptions
'
ac_precious_vars='build_alias
@@ -1286,6 +1290,7 @@ Optional Features:
yes,no,all,none,release. Flags are: misc,valgrind or
other strings
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-exceptions enable exceptions & rtti
Optional Packages:
@@ -2635,11 +2640,34 @@ fi
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
+
# Check whether --enable-exceptions was given.
diff --git a/libcody/configure.ac b/libcody/configure.ac
index 960191ecb72..14e8dd4a226 100644
--- a/libcody/configure.ac
+++ b/libcody/configure.ac
@@ -63,9 +63,31 @@ fi
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
+if test x$enable_host_pie = xyes; then
+ LD_PICFLAG=-pie
+else
+ LD_PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
+AC_SUBST(LD_PICFLAG)
NMS_ENABLE_EXCEPTIONS
diff --git a/libcpp/configure b/libcpp/configure
index 75145390215..85168273cd1 100755
--- a/libcpp/configure
+++ b/libcpp/configure
@@ -625,6 +625,8 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
MAINT
USED_CATALOGS
PACKAGE
@@ -738,6 +740,7 @@ enable_maintainer_mode
enable_checking
enable_canonical_system_headers
enable_host_shared
+enable_host_pie
enable_cet
enable_valgrind_annotations
'
@@ -1379,6 +1382,7 @@ Optional Features:
--enable-canonical-system-headers
enable or disable system headers canonicalization
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
--enable-valgrind-annotations
enable valgrind runtime interaction
@@ -7605,7 +7609,23 @@ esac
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 9b6042518e5..d25bf5f414f 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -211,8 +211,23 @@ esac
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/libdecnumber/configure b/libdecnumber/configure
index da5302f9315..d805fdeab5a 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -626,6 +626,8 @@ ac_subst_vars='LTLIBOBJS
LIBOBJS
CET_HOST_FLAGS
PICFLAG
+enable_host_pie
+enable_host_shared
ADDITIONAL_OBJS
enable_decimal_float
target_os
@@ -706,6 +708,7 @@ enable_werror_always
enable_maintainer_mode
enable_decimal_float
enable_host_shared
+enable_host_pie
enable_cet
'
ac_precious_vars='build_alias
@@ -1338,6 +1341,7 @@ Optional Features:
or 'dpd' choses which decimal floating point format
to use
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
--enable-cet enable Intel CET in host libraries [default=auto]
Some influential environment variables:
@@ -5185,7 +5189,23 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
index 0794031ec83..14f67f926d1 100644
--- a/libdecnumber/configure.ac
+++ b/libdecnumber/configure.ac
@@ -100,8 +100,23 @@ AC_C_BIGENDIAN
# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+
AC_SUBST(PICFLAG)
# Enable Intel CET on Intel CET enabled host if jit is enabled.
diff --git a/zlib/configure b/zlib/configure
index f489f31bc70..0dfc1982844 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -635,6 +635,8 @@ am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
PICFLAG
+enable_host_pie
+enable_host_shared
TARGET_LIBRARY_FALSE
TARGET_LIBRARY_TRUE
toolexeclibdir
@@ -778,6 +780,7 @@ with_gnu_ld
enable_libtool_lock
with_toolexeclibdir
enable_host_shared
+enable_host_pie
'
ac_precious_vars='build_alias
host_alias
@@ -1420,6 +1423,7 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-host-shared build host code as shared libraries
+ --enable-host-pie build host code as PIE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -4169,7 +4173,7 @@ case "$host" in
case "$enable_cet" in
auto)
# Check if target supports multi-byte NOPs
- # and if assembler supports CET insn.
+ # and if compiler and assembler support CET insn.
cet_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fcf-protection"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -10735,7 +10739,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10748 "configure"
+#line 10754 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10841,7 +10845,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10854 "configure"
+#line 10860 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11524,15 +11528,31 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
# Check whether --enable-host-shared was given.
if test "${enable_host_shared+set}" = set; then :
- enableval=$enable_host_shared; PICFLAG=-fPIC
+ enableval=$enable_host_shared;
+fi
+
+
+
+# Enable --enable-host-pie.
+# Check whether --enable-host-pie was given.
+if test "${enable_host_pie+set}" = set; then :
+ enableval=$enable_host_pie;
+fi
+
+
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
else
PICFLAG=
fi
-
ac_config_files="$ac_config_files Makefile"
cat >confcache <<\_ACEOF
diff --git a/zlib/configure.ac b/zlib/configure.ac
index be1cfe29651..adf7aad4e51 100644
--- a/zlib/configure.ac
+++ b/zlib/configure.ac
@@ -122,11 +122,26 @@ else
multilib_arg=
fi
+# Enable --enable-host-shared.
AC_ARG_ENABLE(host-shared,
[AS_HELP_STRING([--enable-host-shared],
- [build host code as shared libraries])],
-[PICFLAG=-fPIC], [PICFLAG=])
-AC_SUBST(PICFLAG)
+ [build host code as shared libraries])])
+AC_SUBST(enable_host_shared)
+
+# Enable --enable-host-pie.
+AC_ARG_ENABLE(host-pie,
+[AS_HELP_STRING([--enable-host-pie],
+ [build host code as PIE])])
+AC_SUBST(enable_host_pie)
+
+if test x$enable_host_shared = xyes; then
+ PICFLAG=-fPIC
+elif test x$enable_host_pie = xyes; then
+ PICFLAG=-fPIE
+else
+ PICFLAG=
+fi
+AC_SUBST(PICFLAG)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
base-commit: b32305b41dcafc5fb6974c0da3ce2f62251afdbf
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-05-16 20:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 2:52 [PATCH] configure: Implement --enable-host-pie Marek Polacek
2022-11-20 15:06 ` Jeff Law
2022-11-23 2:18 ` Marek Polacek
-- strict thread matches above, loose matches on Subject: below --
2023-05-09 19:41 Marek Polacek
2023-05-16 15:29 ` Marek Polacek
2023-05-16 20:11 ` Iain Sandoe
2022-02-10 16:48 Marek Polacek
2022-02-10 21:10 ` Joseph Myers
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).