From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 38FBE158041 for ; Sat, 23 Mar 2024 14:49:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 717EBE2A17; Sat, 23 Mar 2024 14:49:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 54022E2A17 for ; Sat, 23 Mar 2024 14:49:17 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7C48433BEEB for ; Sat, 23 Mar 2024 14:49:16 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C32B415CD for ; Sat, 23 Mar 2024 14:49:14 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1711205327.4fba38fc35fe2966574dd6bfd68ee82cd354976c.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/toolchain.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 4fba38fc35fe2966574dd6bfd68ee82cd354976c X-VCS-Branch: master Date: Sat, 23 Mar 2024 14:49:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 62521127-b27d-42f8-b182-8104e910beae X-Archives-Hash: 1f8ecaa984558c5d9f90a5c9ff9da65b commit: 4fba38fc35fe2966574dd6bfd68ee82cd354976c Author: Sam James gentoo org> AuthorDate: Sat Mar 23 14:16:38 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sat Mar 23 14:48:47 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4fba38fc 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 gentoo.org> eclass/toolchain.eclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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.