diff options
author | 2024-03-23 14:16:38 +0000 | |
---|---|---|
committer | 2024-03-23 14:48:47 +0000 | |
commit | 4fba38fc35fe2966574dd6bfd68ee82cd354976c (patch) | |
tree | dc12da1473d4f4ae73c3cfb32002c1ab85093c55 /eclass/toolchain.eclass | |
parent | toolchain.eclass: fix whitespace (diff) | |
download | gentoo-4fba38fc35fe2966574dd6bfd68ee82cd354976c.tar.gz gentoo-4fba38fc35fe2966574dd6bfd68ee82cd354976c.tar.bz2 gentoo-4fba38fc35fe2966574dd6bfd68ee82cd354976c.zip |
toolchain.eclass: add workaround for hybrid CPUs
Hybrid/big.little/PE CPUs may report an inconsistent cache size across cores
which can cause GCC's bootstrapping to fail its self-comparison.
When CBUILD is amd64 or x86 and -march=native is in CFLAGS, iterate over
all cores and record l1-cache-size. If any differ, use the first one we found.
Bug: https://gcc.gnu.org/PR111768
Closes: https://bugs.gentoo.org/904426
Closes: https://bugs.gentoo.org/908523
Closes: https://bugs.gentoo.org/915389
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'eclass/toolchain.eclass')
-rw-r--r-- | eclass/toolchain.eclass | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index f59b8d61f6f5..ec35591ec8fb 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1567,6 +1567,24 @@ gcc_do_filter_flags() { fi fi + declare -A l1_cache_sizes=() + # Workaround for inconsistent cache sizes on hybrid P/E cores + # See PR111768 (and bug #904426, bug #908523, and bug #915389) + if [[ ${CBUILD} == x86_64* || ${CBUILD} == i?86* && ${CFLAGS} == *-march=native* ]] && tc-is-gcc ; then + local x + local l1_cache_size + # Iterate over all cores and find their L1 cache size + for x in $(seq 0 $(($(nproc)-1))) ; do + [[ -z ${x} || ${x} -gt 64 ]] && break + l1_cache_size=$(taskset --cpu-list ${x} $(tc-getCC) -Q --help=params -O2 -march=native \ + | awk '{ if ($1 ~ /^.*param.*l1-cache-size/) print $2; }' || die) + l1_cache_sizes[${l1_cache_size}]=1 + done + # If any of them are different, just pick the first one. + if [[ ${#l1_cache_sizes} != 1 ]] ; then + append-flags --param=l1-cache-size=${l1_cache_size} + fi + fi if ver_test -lt 13.6 ; then # These aren't supported by the just-built compiler either. |