From 3f1be2af12937c77c962bb864a8254ffebedc15b Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 11 Aug 2024 18:18:52 +0200 Subject: scripts/bootstrap-prefix: set CPU_FLAGS_* when we can Signed-off-by: Fabian Groffen --- scripts/bootstrap-prefix.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh index dfdff4c99e..a20af50355 100755 --- a/scripts/bootstrap-prefix.sh +++ b/scripts/bootstrap-prefix.sh @@ -3289,6 +3289,47 @@ EOF [[ ${STOP_BOOTSTRAP_AFTER} == stage3 ]] && exit 0 + # do some sanity USE-flag enabling based on CPU, use cpuid2cpuflags + # if keyworded for this arg, else see if there's fallbacks to be + # made + mkdir -p "${EPREFIX}/etc/portage/package.use" + if emerge -1v cpuid2cpuflags ; then + hash -r + echo "*/* $(cpuid2cpuflags)" \ + > "${EPREFIX}/etc/portage/package.use/00cpu-flags" + else + case "${CHOST}" in + arm64-*darwin*) + # https://github.com/RustCrypto/utils/issues/378 + local flags=( "aes" "sha1" "sha2" ) + local line + sysctl hw.optional | while read -r line ; do + line=${line#hw.optional.} + [[ ${line%%*: } == "1" ]] || continue + line=${line%: *} + case "${line}" in + "neon") + flags+=( "${line}" ) + ;; + "armv8_"*) + line=${line#armv8_} + case "${line}" in + "crc32") + flags+=( "${line}" ) + ;; + "2_sha"*) + flags+=( "${line#2_}" ) + ;; + esac + ;; + esac + done + echo "*/* CPU_FLAGS_ARM: ${flags}" \ + > "${EPREFIX}/etc/portage/package.use/00cpu-flags" + ;; + esac + fi + local cmd="emerge -v --deep --update --changed-use @world" if [[ -e ${EPREFIX}/var/cache/edb/mtimedb ]] && \ grep -q resume "${EPREFIX}"/var/cache/edb/mtimedb ; -- cgit v1.2.3-65-gdbad