Skip to content

Commit

Permalink
toolchain.eclass: add support for gcc 6.x with no spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
zorry committed Sep 12, 2016
1 parent 58a0c17 commit 34b8344
Showing 1 changed file with 56 additions and 31 deletions.
87 changes: 56 additions & 31 deletions eclass/toolchain.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
tc_version_is_at_least 4.8 && IUSE+=" graphite" IUSE_DEF+=( sanitize )
tc_version_is_at_least 4.9 && IUSE+=" cilk +vtv"
tc_version_is_at_least 5.0 && IUSE+=" jit mpx"
tc_version_is_at_least 6.0 && IUSE+=" pie +ssp +pch"
tc_version_is_at_least 6.0 && IUSE+=" pie ssp +pch"
fi

IUSE+=" ${IUSE_DEF[*]/#/+}"
Expand Down Expand Up @@ -626,6 +626,50 @@ do_gcc_PIE_patches() {

# configure to build with the hardened GCC specs as the default
make_gcc_hard() {

local gcc_hard_flags=""
# Gcc >= 6.X we can use configurations options to turn pie/ssp on as default
if tc_version_is_at_least 6.0 ; then
if use pie ; then
einfo "Updating gcc to use automatic PIE building ..."
fi
if use ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
fi
if use hardened ; then
# Will add some optimatizion as default.
gcc_hard_flags+=" -DEXTRA_OPTIONS"
# rebrand to make bug reports easier
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
fi
else
if use hardened ; then
# rebrand to make bug reports easier
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
if hardened_gcc_works ; then
einfo "Updating gcc to use automatic PIE + SSP building ..."
gcc_hard_flags+=" -DEFAULT_PIE_SSP"
elif hardened_gcc_works pie ; then
einfo "Updating gcc to use automatic PIE building ..."
ewarn "SSP has not been enabled by default"
gcc_hard_flags+=" -DEFAULT_PIE"
elif hardened_gcc_works ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
ewarn "PIE has not been enabled by default"
gcc_hard_flags+=" -DEFAULT_SSP"
else
# do nothing if hardened isn't supported, but don't die either
ewarn "hardened is not supported for this arch in this gcc version"
return 0
fi
else
if hardened_gcc_works ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
gcc_hard_flags+=" -DEFAULT_SSP"
fi
fi
fi

# we want to be able to control the pie patch logic via something other
# than ALL_CFLAGS...
sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
Expand All @@ -634,36 +678,8 @@ make_gcc_hard() {
# Need to add HARD_CFLAGS to ALL_CXXFLAGS on >= 4.7
if tc_version_is_at_least 4.7 ; then
sed -e '/^ALL_CXXFLAGS/iHARD_CFLAGS = ' \
-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-i "${S}"/gcc/Makefile.in
fi

# defaults to enable for all toolchains
local gcc_hard_flags=""
if use hardened ; then
if hardened_gcc_works ; then
einfo "Updating gcc to use automatic PIE + SSP building ..."
gcc_hard_flags+=" -DEFAULT_PIE_SSP"
elif hardened_gcc_works pie ; then
einfo "Updating gcc to use automatic PIE building ..."
ewarn "SSP has not been enabled by default"
gcc_hard_flags+=" -DEFAULT_PIE"
elif hardened_gcc_works ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
ewarn "PIE has not been enabled by default"
gcc_hard_flags+=" -DEFAULT_SSP"
else
# do nothing if hardened isn't supported, but don't die either
ewarn "hardened is not supported for this arch in this gcc version"
return 0
fi
# rebrand to make bug reports easier
BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
else
if hardened_gcc_works ssp ; then
einfo "Updating gcc to use automatic SSP building ..."
gcc_hard_flags+=" -DEFAULT_SSP"
fi
-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
-i "${S}"/gcc/Makefile.in
fi

sed -i \
Expand Down Expand Up @@ -1967,6 +1983,11 @@ create_gcc_env_entry() {
}

copy_minispecs_gcc_specs() {
# on gcc 6 we don't need minispecs
if tc_version_is_at_least 6.0 ; then
return 0
fi

# setup the hardenedno* specs files and the vanilla specs file.
if hardened_gcc_works ; then
create_gcc_env_entry hardenednopiessp
Expand Down Expand Up @@ -2307,6 +2328,10 @@ hardened_gcc_is_stable() {
}

want_minispecs() {
# on gcc 6 we don't need minispecs
if tc_version_is_at_least 6.0 ; then
return 0
fi
if tc_version_is_at_least 4.3.2 && use hardened ; then
if ! want_pie ; then
ewarn "PIE_VER or SPECS_VER is not defined in the GCC ebuild."
Expand Down

0 comments on commit 34b8344

Please sign in to comment.