toolchain.eclass: abort if hybrid CPU detected w/ -march=native

Unfortunately, the previous approach can't work. --param doesn't fully
wipe out the previous value added by -march=native, so we still get a failed
comparison.

Users hitting this should install app-misc/resolve-march-native, run
resolve-march-native, and use that in their *FLAGS instead of -march=native -
at least for sys-devel/gcc via package.env, if not in make.conf.

Therefore, our only real option is to just abort when we detect a problematic
situation and tell users what to do.

The only other idea I had was to try taskset in src_compile which feels super
brittle and not sure it'd even work at all.

Thanks to Andrei for testing and debugging with us on IRC & the bug.

Bug: https://bugs.gentoo.org/904426
Bug: https://bugs.gentoo.org/908523
Bug: https://bugs.gentoo.org/915389
Bug: https://bugs.gentoo.org/927688
Thanks-to: Andrei Liavonchykau <andreil499@gmail.com>
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James 2024-03-24 17:19:46 +00:00
parent 7b39283101
commit e897f91e8e
No known key found for this signature in database
GPG Key ID: 738409F520DF9190
1 changed files with 9 additions and 2 deletions

View File

@ -1619,9 +1619,16 @@ gcc_do_filter_flags() {
[[ -n ${l1_cache_size} && ${l1_cache_size} =~ ^[0-9]+$ ]] || break
l1_cache_sizes[${l1_cache_size}]=1
done
# If any of them are different, just pick the first one.
# If any of them are different, abort. We can't just pass one value of
# l1-cache-size because it doesn't cancel out the -march=native one.
if [[ ${#l1_cache_sizes[@]} -gt 1 ]] ; then
append-flags --param=l1-cache-size=${l1_cache_size}
eerror "Different values of l1-cache-size detected!"
eerror "GCC will fail to bootstrap when comparing files with these flags."
eerror "This CPU is likely big.little/hybrid hardware with power/efficiency cores."
eerror "Please install app-misc/resolve-march-native and run 'resolve-march-native'"
eerror "to find a safe value of CFLAGS for this CPU. Note that this may vary"
eerror "depending on the core it ran on. taskset can be used to fix the cores used."
die "Varying l1-cache-size found, aborting (bug #915389, gcc PR#111768)"
fi
fi