--- toolchain.eclass +++ toolchain.eclass @@ -1271,27 +1271,38 @@ popd >/dev/null } -# This function accepts one optional argument, the make target to be used. -# If ommitted, gcc_do_make will try to guess whether it should use all, -# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An -# example of how to use this function: +# This function accepts one optional argument: the make target to be used. +# If omitted, gcc_do_make will try to guess whether it should use make "all" +# or "bootstrap-lean" depending on CTARGET and arch. An example of how to use +# this function: # # gcc_do_make all-target-libstdc++-v3 # -# In addition to the target to be used, the following variables alter the -# behavior of this function: -# -# LDFLAGS -# Flags to pass to ld +# The following variables control the flags the compiler is built with: # # STAGE1_CFLAGS -# CFLAGS to use during stage1 of a gcc bootstrap +# Compiler flags used on the host for stage 1 / crosscompiling. +# +# STAGE1_LDFLAGS +# Linker flags used on the host for stage 1 / crosscompiling. (Note this +# wasn't added until around ~4.6 - older versions will just use LDFLAGS). +# +# * Note that we do not set either of these ourselves if we're bootstrapping. +# * It's created bugs in the past and the stage 1 compiler just gets thrown +# * out in the end anyways. # # BOOT_CFLAGS -# CFLAGS to use during stages 2+3 of a gcc bootstrap. +# Compiler flags used on the host for stage2+ when bootstrapping. # -# Travis Tilley (04 Sep 2004) +# BOOT_LDFLAGS +# Linker flags used on the host for stage2+ when bootstrapping. # +# CFLAGS_FOR_TARGET +# Compiler flags to use building libraries. +# +# LDFLAGS_FOR_TARGET +# Linker flags to use building libraries. + gcc_do_make() { # Set make target to $1 if passed [[ -n $1 ]] && GCC_MAKE_TARGET=$1 @@ -1315,29 +1326,29 @@ if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"} + STAGE1_LDFLAGS=${STAGE1_LDFLAGS-"${LDFLAGS}"} elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then # See bug #79852 STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"} fi - if is_crosscompile; then - # In 3.4, BOOT_CFLAGS is never used on a crosscompile... - # but I'll leave this in anyways as someone might have had - # some reason for putting it in here... --eradicator - BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"} - else - # we only want to use the system's CFLAGS if not building a - # cross-compiler. + if ! is_crosscompile ; then BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS ${TARGET_DEFAULT_ABI}) ${CFLAGS}"} + BOOT_LDFLAGS=${BOOT_LDFLAGS-"${LDFLAGS}"} + CFLAGS_FOR_TARGET=${CFLAGS_FOR_TARGET-"${CFLAGS}"} + LDFLAGS_FOR_TARGET=${LDFLAGS_FOR_TARGET-"${LDFLAGS}"} fi pushd "${WORKDIR}"/build >/dev/null emake \ - LDFLAGS="${LDFLAGS}" \ STAGE1_CFLAGS="${STAGE1_CFLAGS}" \ - LIBPATH="${LIBPATH}" \ + STAGE1_LDFLAGS="${STAGE1_LDFLAGS}" \ BOOT_CFLAGS="${BOOT_CFLAGS}" \ + BOOT_LDFLAGS="${BOOT_LDFLAGS}" \ + CFLAGS_FOR_TARGET="${CFLAGS_FOR_TARGET}" \ + LDFLAGS_FOR_TARGET="${LDFLAGS_FOR_TARGET}" \ + LIBPATH="${LIBPATH}" \ ${GCC_MAKE_TARGET} \ || die "emake failed with ${GCC_MAKE_TARGET}" @@ -1453,6 +1464,7 @@ gcc_do_filter_flags einfo "CFLAGS=\"${CFLAGS}\"" einfo "CXXFLAGS=\"${CXXFLAGS}\"" + einfo "LDFLAGS=\"${LDFLAGS}\"" # Force internal zip based jar script to avoid random # issues with 3rd party jar implementations. #384291