diff options
author | Mike Frysinger <vapier@gentoo.org> | 2014-06-01 17:29:42 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2014-06-01 17:29:42 +0000 |
commit | c13f7251df4e069085f6822c8598a02843acf387 (patch) | |
tree | d6ddf9d57c906be366a688cda25a56e867de9b84 | |
parent | bump (diff) | |
download | gentoo-2-c13f7251df4e069085f6822c8598a02843acf387.tar.gz gentoo-2-c13f7251df4e069085f6822c8598a02843acf387.tar.bz2 gentoo-2-c13f7251df4e069085f6822c8598a02843acf387.zip |
downgrade_arch_flags: simplify bash logic a bit
-rw-r--r-- | eclass/toolchain.eclass | 177 |
1 files changed, 89 insertions, 88 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 078470c4e687..7c013532fd8d 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.630 2014/05/21 21:30:26 rhill Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.631 2014/06/01 17:29:42 vapier Exp $ # Maintainer: Toolchain Ninjas <toolchain@gentoo.org> @@ -619,7 +619,6 @@ do_gcc_PIE_patches() { # configure to build with the hardened GCC specs as the default make_gcc_hard() { - # we want to be able to control the pie patch logic via something other # than ALL_CFLAGS... sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \ @@ -1222,8 +1221,8 @@ downgrade_arch_flags() { # If -march=native isn't supported we have to tease out the actual arch if [[ ${myarch} == native || ${mytune} == native ]] ; then if [[ ${bver} < 4.2 ]] ; then - arch=$(echo "" | $(tc-getCC) -march=native -v -E - 2>&1 \ - | grep cc1 | sed -e 's:.*-march=\([^ ]*\).*:\1:') + arch=$($(tc-getCC) -march=native -v -E -P - </dev/null 2>&1 \ + | sed -rn "/cc1.*-march/s:.*-march=([^ ']*).*:\1:p") replace-cpu-flags native ${arch} fi fi @@ -1234,55 +1233,56 @@ downgrade_arch_flags() { [[ ${mytune} == x86-64 ]] && filter-flags '-mtune=*' [[ ${bver} < 3.4 ]] && filter-flags '-mtune=*' - declare -a archlist - # "arch" "added" "replacement" - archlist=("bdver4 4.9 bdver3") - archlist+=("bonnell 4.9 atom") - archlist+=("broadwell 4.9 core-avx2") - archlist+=("haswell 4.9 core-avx2") - archlist+=("ivybridge 4.9 core-avx-i") - archlist+=("nehalem 4.9 corei7") - archlist+=("sandybridge 4.9 corei7-avx") - archlist+=("silvermont 4.9 corei7") - archlist+=("westmere 4.9 corei7") - archlist+=("bdver3 4.8 bdver2") - archlist+=("btver2 4.8 btver1") - archlist+=("bdver2 4.7 bdver1") - archlist+=("core-avx2 4.7 core-avx-i") - archlist+=("bdver1 4.6 amdfam10") - archlist+=("btver1 4.6 amdfam10") - archlist+=("core-avx-i 4.6 core2") - archlist+=("corei7 4.6 core2") - archlist+=("corei7-avx 4.6 core2") - archlist+=("atom 4.5 core2") - archlist+=("amdfam10 4.3 k8") - archlist+=("athlon64-sse3 4.3 k8") - archlist+=("barcelona 4.3 k8") - archlist+=("core2 4.3 nocona") - archlist+=("geode 4.3 k6-2") # gcc.gnu.org/PR41989#c22 - archlist+=("k8-sse3 4.3 k8") - archlist+=("opteron-sse3 4.3 k8") - archlist+=("athlon-fx 3.4 x86-64") - archlist+=("athlon64 3.4 x86-64") - archlist+=("c3-2 3.4 c3") - archlist+=("k8 3.4 x86-64") - archlist+=("opteron 3.4 x86-64") - archlist+=("pentium-m 3.4 pentium3") - archlist+=("pentium3m 3.4 pentium3") - archlist+=("pentium4m 3.4 pentium4") + local archlist=( + # "added" "arch" "replacement" + 4.9 bdver4 bdver3 + 4.9 bonnell atom + 4.9 broadwell core-avx2 + 4.9 haswell core-avx2 + 4.9 ivybridge core-avx-i + 4.9 nehalem corei7 + 4.9 sandybridge corei7-avx + 4.9 silvermont corei7 + 4.9 westmere corei7 + 4.8 bdver3 bdver2 + 4.8 btver2 btver1 + 4.7 bdver2 bdver1 + 4.7 core-avx2 core-avx-i + 4.6 bdver1 amdfam10 + 4.6 btver1 amdfam10 + 4.6 core-avx-i core2 + 4.6 corei7 core2 + 4.6 corei7-avx core2 + 4.5 atom core2 + 4.3 amdfam10 k8 + 4.3 athlon64-sse3 k8 + 4.3 barcelona k8 + 4.3 core2 nocona + 4.3 geode k6-2 # gcc.gnu.org/PR41989#c22 + 4.3 k8-sse3 k8 + 4.3 opteron-sse3 k8 + 3.4 athlon-fx x86-64 + 3.4 athlon64 x86-64 + 3.4 c3-2 c3 + 3.4 k8 x86-64 + 3.4 opteron x86-64 + 3.4 pentium-m pentium3 + 3.4 pentium3m pentium3 + 3.4 pentium4m pentium4 + ) myarch=$(get-flag march) mytune=$(get-flag mtune) - for ((i=0; i < ${#archlist[@]}; i++)) ; do - arch=${archlist[i]%% *} - ver=${archlist[i]#* } ver=${ver% *} - rep=${archlist[i]##* } + for ((i = 0; i < ${#archlist[@]}; i += 3)) ; do + ver=${archlist[i]} + arch=${archlist[i + 1]} + rep=${archlist[i + 2]} [[ ${myarch} != ${arch} && ${mytune} != ${arch} ]] && continue - + if [[ ${ver} > ${bver} ]] ; then - einfo "Replacing ${myarch} (added in ${ver}) with ${rep}..." + einfo "Replacing ${myarch} (added in gcc ${ver}) with ${rep}..." [[ ${myarch} == ${arch} ]] && replace-cpu-flags ${myarch} ${rep} [[ ${mytune} == ${arch} ]] && replace-cpu-flags ${mytune} ${rep} downgrade_arch_flags ${1:-${GCC_BRANCH_VER}} @@ -1292,45 +1292,46 @@ downgrade_arch_flags() { fi done - declare -a isalist - # we only check -mno* here since -m* get removed by strip-flags later on - isalist=("-mno-sha 4.9") - isalist+=("-mno-avx512pf 4.9") - isalist+=("-mno-avx512f 4.9") - isalist+=("-mno-avx512er 4.9") - isalist+=("-mno-avx512cd 4.9") - isalist+=("-mno-xsaveopt 4.8") - isalist+=("-mno-xsave 4.8") - isalist+=("-mno-rtm 4.8") - isalist+=("-mno-fxsr 4.8") - isalist+=("-mno-lzcnt 4.7") - isalist+=("-mno-bmi2 4.7") - isalist+=("-mno-avx2 4.7") - isalist+=("-mno-tbm 4.6") - isalist+=("-mno-rdrnd 4.6") - isalist+=("-mno-fsgsbase 4.6") - isalist+=("-mno-f16c 4.6") - isalist+=("-mno-bmi 4.6") - isalist+=("-mno-xop 4.5") - isalist+=("-mno-movbe 4.5") - isalist+=("-mno-lwp 4.5") - isalist+=("-mno-fma4 4.5") - isalist+=("-mno-pclmul 4.4") - isalist+=("-mno-fma 4.4") - isalist+=("-mno-avx 4.4") - isalist+=("-mno-aes 4.4") - isalist+=("-mno-ssse3 4.3") - isalist+=("-mno-sse4a 4.3") - isalist+=("-mno-sse4 4.3") - isalist+=("-mno-sse4.2 4.3") - isalist+=("-mno-sse4.1 4.3") - isalist+=("-mno-popcnt 4.3") - isalist+=("-mno-abm 4.3") - - for ((i=0; i < ${#isalist[@]}; i++)) ; do - isa=${isalist[i]%% *} - ver=${isalist[i]##* } - [[ ${ver} > ${bver} ]] && filter-flags ${isa} + local isalist=( + # we only check -mno* here since -m* get removed by strip-flags later on + 4.9 -mno-sha + 4.9 -mno-avx512pf + 4.9 -mno-avx512f + 4.9 -mno-avx512er + 4.9 -mno-avx512cd + 4.8 -mno-xsaveopt + 4.8 -mno-xsave + 4.8 -mno-rtm + 4.8 -mno-fxsr + 4.7 -mno-lzcnt + 4.7 -mno-bmi2 + 4.7 -mno-avx2 + 4.6 -mno-tbm + 4.6 -mno-rdrnd + 4.6 -mno-fsgsbase + 4.6 -mno-f16c + 4.6 -mno-bmi + 4.5 -mno-xop + 4.5 -mno-movbe + 4.5 -mno-lwp + 4.5 -mno-fma4 + 4.4 -mno-pclmul + 4.4 -mno-fma + 4.4 -mno-avx + 4.4 -mno-aes + 4.3 -mno-ssse3 + 4.3 -mno-sse4a + 4.3 -mno-sse4 + 4.3 -mno-sse4.2 + 4.3 -mno-sse4.1 + 4.3 -mno-popcnt + 4.3 -mno-abm + ) + + for ((i = 0; i < ${#isalist[@]}; i += 2)) ; do + ver=${isalist[i]} + isa=${isalist[i + 1]} + [[ ${ver} > ${bver} ]] && filter-flags ${isa} ${isa/-m/-mno-} done } @@ -1361,9 +1362,9 @@ gcc_do_filter_flags() { case $(tc-arch) in amd64|x86) filter-flags '-mcpu=*' - + tc_version_is_between 4.4 4.5 && append-flags -mno-avx # 357287 - + if tc_version_is_between 4.6 4.7 ; then # https://bugs.gentoo.org/411333 # https://bugs.gentoo.org/466454 @@ -1485,7 +1486,7 @@ gcc_do_make() { # gcc_do_make all-target-libstdc++-v3 [[ -n ${1} ]] && GCC_MAKE_TARGET=${1} - + # default target if is_crosscompile || tc-is-cross-compiler ; then # 3 stage bootstrapping doesnt quite work when you cant run the |