http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59365
Bug ID: 59365 Summary: Configure script does not pass CFLAGS/CXXFLAGS down to subtargets @ stage1 Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: djfd at mail dot ru Hi, If I confgure gcc build with CFLAGS/CXXFLAGS set to custom values, these are not propagate down to subtargets (to gcc @ stage1, particularly). how to reproduce ---------------- mkdir -p ~/tmp-gcc/bld cd ~/tmp-gcc #companion libraries wget ftp://ftp.gnu.org/gnu/gmp/gmp-5.1.3.tar.bz2 tar -xf gmp-5.1.3.tar.bz2 wget ftp://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.bz2 tar -xf mpfr-3.1.2.tar.bz2 wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz tar -xf mpc-1.0.1.tar.gz # gcc itself wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2 tar -xf gcc-4.8.2.tar.bz2 PFX=$HOME/fresh-gcc mkdir bld/gmp ; cd bld/gmp ../../gmp-5.1.3/configure --prefix=$PFX && make && make install cd ../.. mkdir bld/mpfr ; cd bld/mpfr ../../mpfr-3.1.2/configure --prefix=$PFX --with-gmp=$PFX && make && make install cd ../.. mkdir bld/mpc ; cd bld/mpc ../../mpc-1.0.1/configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX && make && make install cd ../.. mkdir bld/gcc ; cd bld/gcc CFLAGS="--sysroot=/" \ CXXFLAGS="--sysroot=/" \ ../../gcc-4.8.2/configure \ --prefix=$PFX \ --with-gmp=$PFX \ --with-mpfr=$PFX \ --with-mpc=$PFX \ && make then sit back, relax until ~/tmp-gcc/bld/gcc/gcc/config.cache is created. After that stop the process by ^C and check the flags passed: find ~/tmp-gc/bld/gcc -name config.status -print0 | xargs -0 egrep '"C(XX)?FLAGS"' which gives: bld/gcc/config.status:S["CXXFLAGS"]="--sysroot=/" bld/gcc/config.status:S["CFLAGS"]="--sysroot=/" bld/gcc/libiberty/config.status:S["CFLAGS"]="-g" bld/gcc/lto-plugin/config.status:S["CFLAGS"]="-g" bld/gcc/gcc/config.status:S["CXXFLAGS"]="-g " bld/gcc/gcc/config.status:S["CFLAGS"]="-g " bld/gcc/intl/config.status:S["CFLAGS"]="-g" ie. main config.cache (two first lines) has correct values set and lower ones are wrong (or at least unexpected). a possible way to fix --------------------- there is a line in main configure script: # Stage specific cflags for build. stage1_cflags="-g" this causes such behaviour, as it will be later expanded (in ~/tmp-gcc/bld/gcc/Makefile) as STAGE1_CFLAGS = -g ... # Override the above if we're bootstrapping C++. STAGE1_CXXFLAGS = $(STAGE1_CFLAGS) ... BASE_FLAGS_TO_PASS = ... "STAGE1_CFLAGS=$(STAGE1_CFLAGS)" "STAGE1_CXXFLAGS=$(STAGE1_CXXFLAGS)"... ... RECURSE_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) which in turn will be passed to other subtargets via $(MAKE) $(RECURSE_FLAGS_TO_PASS)... calls So maybe make it more sophisticated instead of just assigning "-g" flag? Say, `stage1_cflags="-g" $CFLAGS` (or, if we want to have that -g flag, reverse the order, ie. stage1_cflags=$CFLAGS "-g" Or maybe am I wrong and it is intentionally, by design? Regards