This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR/32009, separate BOOT_CFLAGS and BOOT_LIBCFLAGS
- From: Paolo Bonzini <bonzini at gnu dot org>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 19 Feb 2008 15:37:01 +0100
- Subject: PR/32009, separate BOOT_CFLAGS and BOOT_LIBCFLAGS
The PR is about being able to specify different CFLAGS for bootstrapped
host and target modules. In particular, powerpc-darwin has a flag that
is okay for programs and speeds up the build, but not for libraries.
The fix is quite complicated, hence I am proposing it for mainline first
with the intention of backporting it to 4.3.1 (or even earlier,
depending on when rc1 is rolled).
It is made even more complicated by the mess that is LIBCFLAGS and
LIBCXXFLAGS which, time permitting, I will try to fix for 4.4.
Tested by playing (on i686-pc-linux-gnu) with a custom option behaving
like -mdynamic-no-pic, full bootstrap/regtest in progress.
Paolo
2008-02-19 Paolo Bonzini <bonzini@gnu.org>
PR bootstrap/32009
* Makefile.def: Define stage_libcflags for all bootstrap stages.
* Makefile.tpl (BOOT_LIBCFLAGS, STAGE2_LIBCFLAGS, STAGE3_LIBCFLAGS,
STAGE4_LIBCFLAGS): New.
(CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Don't tack on
$(SYSROOT_CFLAGS_FOR_TARGET) and $(DEBUG_PREFIX_CFLAGS_FOR_TARGET).
(EXTRA_TARGET_FLAGS): Do it here, for LIBCFLAGS and LIBCXXFLAGS too.
(configure-stage[+id+]-[+prefix+][+module+]): Pass stage_libcflags.
(all-stage[+id+]-[+prefix+][+module+]): Pass stage_libcflags; pass
$(BASE_FLAGS_TO_PASS) where [+args+] was passed, and [+args+] after
the overridden CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
(invocations of `all'): Replace $(TARGET_FLAGS_TO_PASS) with
$(EXTRA_TARGET_FLAGS), $(FLAGS_TO_PASS) with $(EXTRA_HOST_FLAGS).
* Makefile.in: Regenerate.
2008-02-19 Paolo Bonzini <bonzini@gnu.org>
PR bootstrap/32009
* mh-ppc-darwin (BOOT_CFLAGS): Reenable.
Index: Makefile.def
===================================================================
--- Makefile.def (revision 131960)
+++ Makefile.def (working copy)
@@ -511,43 +511,51 @@ bootstrap_stage = {
// compiler probably has never heard of them.
stage_configure_flags='--disable-intermodule $(STAGE1_CHECKING) \
--disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"' ;
- stage_cflags='$(STAGE1_CFLAGS)' ; };
+ stage_cflags='$(STAGE1_CFLAGS)' ;
+ stage_libcflags='$(STAGE1_LIBCFLAGS)' ; };
bootstrap_stage = {
id=2 ; prev=1 ;
bootstrap_target=bootstrap2 ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags="$(STAGE2_CFLAGS)" ; };
+ stage_cflags="$(STAGE2_CFLAGS)" ;
+ stage_libcflags="$(STAGE2_LIBCFLAGS)" ; };
bootstrap_stage = {
id=b2g0 ; prev=1 ;
bootstrap_target=bootstrap2-debug ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags="$(STAGE2_CFLAGS) -g0" ; };
+ stage_cflags="$(STAGE2_CFLAGS) -g0" ;
+ stage_libcflags="$(STAGE2_LIBCFLAGS) -g0" ; };
bootstrap_stage = {
id=3 ; prev=2 ; lean=1 ;
compare_target=compare ;
bootstrap_target=bootstrap ;
cleanstrap_target=cleanstrap ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags="$(STAGE3_CFLAGS)" ; };
+ stage_cflags="$(STAGE3_CFLAGS)" ;
+ stage_libcflags="$(STAGE3_LIBCFLAGS)" ; };
bootstrap_stage = {
id=b3g2 ; prev=b2g0 ; lean=1 ;
compare_target=compare-debug ;
bootstrap_target=bootstrap-debug ;
cleanstrap_target=cleanstrap-debug ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags="$(STAGE3_CFLAGS) -g2" ; };
+ stage_cflags="$(STAGE3_CFLAGS) -g2" ;
+ stage_libcflags="$(STAGE3_LIBCFLAGS) -g2" ; };
bootstrap_stage = {
id=4 ; prev=3 ; lean=2 ;
compare_target=compare3 ;
bootstrap_target=bootstrap4 ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags="$(STAGE4_CFLAGS)" ; };
+ stage_cflags="$(STAGE4_CFLAGS)" ;
+ stage_libcflags="$(STAGE4_CFLAGS)" ; };
bootstrap_stage = {
id=profile ; prev=1 ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags='$(STAGE2_CFLAGS) -fprofile-generate' ; };
+ stage_cflags='$(STAGE2_CFLAGS) -fprofile-generate' ;
+ stage_libcflags='$(STAGE2_LIBCFLAGS) -fprofile-generate' ; };
bootstrap_stage = {
id=feedback ; prev=profile ;
bootstrap_target=profiledbootstrap ;
stage_configure_flags="@stage2_werror_flag@" ;
- stage_cflags='$(STAGE3_CFLAGS) -fprofile-use' ; };
+ stage_cflags='$(STAGE3_CFLAGS) -fprofile-use' ;
+ stage_libcflags='$(STAGE3_LIBCFLAGS) -fprofile-use' ; };
Index: Makefile.tpl
===================================================================
--- Makefile.tpl (revision 131960)
+++ Makefile.tpl (working copy)
@@ -278,6 +278,7 @@ BUILD_PREFIX_1 = @BUILD_PREFIX_1@
# Flags to pass to stage2 and later makes. They are defined
# here so that they can be overridden by Makefile fragments.
BOOT_CFLAGS= -g -O2
+BOOT_LIBCFLAGS= -g -O2 -fbooh-not-pic
BOOT_LDFLAGS=
BISON = @BISON@
@@ -330,14 +331,19 @@ PICFLAG =
# MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
# overrideable (for a bootstrap build stage1 also builds gcc.info).
-STAGE1_CFLAGS=@stage1_cflags@
STAGE1_CHECKING=@stage1_checking@
STAGE1_LANGUAGES=@stage1_languages@
+STAGE1_CFLAGS=@stage1_cflags@
STAGE2_CFLAGS=$(BOOT_CFLAGS)
STAGE3_CFLAGS=$(BOOT_CFLAGS)
STAGE4_CFLAGS=$(BOOT_CFLAGS)
+STAGE1_LIBCFLAGS=@stage1_cflags@
+STAGE2_LIBCFLAGS=$(BOOT_LIBCFLAGS)
+STAGE3_LIBCFLAGS=$(BOOT_LIBCFLAGS)
+STAGE4_LIBCFLAGS=$(BOOT_LIBCFLAGS)
+
do-compare = @do_compare@
do-compare3 = $(do-compare)
do-compare-debug = $(SHELL) $(srcdir)/contrib/compare-debug $$f1 $$f2
@@ -382,12 +388,11 @@ COMPILER_NM_FOR_TARGET=@COMPILER_NM_FOR_
# We want to ensure that TARGET libraries (which we know are built with
# gcc) are built with "-O2 -g", so prepend those options when setting
# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
-CFLAGS_FOR_TARGET = -O2 -g $(CFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET) \
- $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
+CFLAGS_FOR_TARGET = -O2 -g $(CFLAGS)
+CXXFLAGS_FOR_TARGET = -O2 -g $(CXXFLAGS)
SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@
DEBUG_PREFIX_CFLAGS_FOR_TARGET = @DEBUG_PREFIX_CFLAGS_FOR_TARGET@
-CXXFLAGS_FOR_TARGET = -O2 -g $(CXXFLAGS) $(SYSROOT_CFLAGS_FOR_TARGET) \
- $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)
+
LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET)
LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates
LDFLAGS_FOR_TARGET =
@@ -491,19 +496,20 @@ POSTSTAGE1_FLAGS_TO_PASS = \
# Flags to pass down to makes which are built with the target environment.
# The double $ decreases the length of the command line; those variables
# are set in BASE_FLAGS_TO_PASS, and the sub-make will expand them. The
-# COMPILER_ prefixed variables are not passed down so we expand them here.
+# *_CFLAGS_FOR_TARGET variables are not passed down and most often empty,
+# so we expand them here.
EXTRA_TARGET_FLAGS = \
'AR=$$(AR_FOR_TARGET)' \
'AS=$(COMPILER_AS_FOR_TARGET)' \
'CC=$$(CC_FOR_TARGET)' \
- 'CFLAGS=$$(CFLAGS_FOR_TARGET)' \
+ 'CFLAGS=$$(CFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
'CXX=$$(CXX_FOR_TARGET)' \
- 'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET)' \
+ 'CXXFLAGS=$$(CXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
'DLLTOOL=$$(DLLTOOL_FOR_TARGET)' \
'LD=$(COMPILER_LD_FOR_TARGET)' \
'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \
- 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \
- 'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET)' \
+ 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
+ 'LIBCXXFLAGS=$$(LIBCXXFLAGS_FOR_TARGET) $(SYSROOT_CFLAGS_FOR_TARGET) $(DEBUG_PREFIX_CFLAGS_FOR_TARGET)' \
'NM=$(COMPILER_NM_FOR_TARGET)' \
'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
'RANLIB=$$(RANLIB_FOR_TARGET)' \
@@ -853,7 +859,7 @@ configure-stage[+id+]-[+prefix+][+module
[+exports+][+ IF prev +] \
[+poststage1_exports+][+ ENDIF prev +] \
CFLAGS="[+stage_cflags+]"; export CFLAGS; \
- LIBCFLAGS="[+stage_cflags+]"; export LIBCFLAGS; \
+ LIBCFLAGS="[+stage_libcflags+]"; export LIBCFLAGS; \
echo Configuring stage [+id+] in [+subdir+]/[+module+] ; \
$(SHELL) $(srcdir)/mkinstalldirs [+subdir+]/[+module+] ; \
cd [+subdir+]/[+module+] || exit 1; \
@@ -890,7 +896,8 @@ all-[+prefix+][+module+]: configure-[+pr
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
[+exports+] \
(cd [+subdir+]/[+module+] && \
- $(MAKE) [+args+] [+extra_make_flags+] $(TARGET-[+prefix+][+module+]))
+ $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+extra_make_flags+] \
+ $(TARGET-[+prefix+][+module+]))
@endif [+prefix+][+module+]
[+ IF bootstrap +]
@@ -910,10 +917,13 @@ all-stage[+id+]-[+prefix+][+module+]: co
[+exports+][+ IF prev +] \
[+poststage1_exports+][+ ENDIF prev +] \
cd [+subdir+]/[+module+] && \
- $(MAKE) [+args+] \
- CFLAGS="[+stage_cflags+]" LIBCFLAGS="[+stage_cflags+]" [+
+ $(MAKE) $(BASE_FLAGS_TO_PASS) \
+ CFLAGS="[+stage_cflags+]" CXXFLAGS="[+stage_cflags+]" \
+ LIBCFLAGS="[+stage_libcflags+]" \
+ CFLAGS_FOR_TARGET="[+stage_libcflags+]" \
+ CXXFLAGS_FOR_TARGET="[+stage_libcflags+]" [+
IF prev +][+poststage1_args+][+ ENDIF prev
- +] [+extra_make_flags+] \
+ +] [+args+] [+extra_make_flags+] \
$(TARGET-stage[+id+]-[+prefix+][+module+])
maybe-clean-stage[+id+]-[+prefix+][+module+]: clean-stage[+id+]-[+prefix+][+module+]
@@ -961,7 +971,7 @@ clean-stage[+id+]-[+prefix+][+module+]:
[+ all prefix="" subdir="$(HOST_SUBDIR)"
exports="$(HOST_EXPORTS)"
poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
- args="$(FLAGS_TO_PASS)"
+ args="$(EXTRA_HOST_FLAGS)"
poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +]
.PHONY: check-[+module+] maybe-check-[+module+]
@@ -1059,7 +1069,7 @@ maybe-[+make_target+]-[+module+]: [+make
[+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
exports="$(RAW_CXX_TARGET_EXPORTS)"
- args="$(TARGET_FLAGS_TO_PASS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'" +]
+ args="$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'" +]
[+ ELSE +]
[+ configure prefix="target-" subdir="$(TARGET_SUBDIR)"
check_multilibs=true
@@ -1070,7 +1080,7 @@ maybe-[+make_target+]-[+module+]: [+make
[+ all prefix="target-" subdir="$(TARGET_SUBDIR)"
exports="$(NORMAL_TARGET_EXPORTS)"
- args="$(TARGET_FLAGS_TO_PASS)" +]
+ args="$(EXTRA_TARGET_FLAGS)" +]
[+ ENDIF +]
.PHONY: check-target-[+module+] maybe-check-target-[+module+]
Index: config/mh-ppc-darwin
===================================================================
--- config/mh-ppc-darwin (revision 131960)
+++ config/mh-ppc-darwin (working copy)
@@ -2,5 +2,4 @@
# position-independent-code -- the usual default on Darwin. This fix speeds
# compiles by 3-5%.
-# Broken because of PR32009.
-# BOOT_CFLAGS=-g -O2 -mdynamic-no-pic
+BOOT_CFLAGS=-g -O2 -mdynamic-no-pic