commit:     ef78854564d1927cd8c44099287446049fe7521f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Aug  6 10:52:25 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Aug  6 10:54:18 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef788545

prefix/darwin/macos/arch/arm64: force -O1 where necessary as workaround

The GCC toolchain seems somewhat funky for certain packages, producing
objects that the (host) linker doesn't agree with, so for the time being
force -O1 as workaround for these few packages.

Bug: https://bugs.gentoo.org/778014
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .../prefix/darwin/macos/arch/arm64/profile.bashrc  | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/profiles/prefix/darwin/macos/arch/arm64/profile.bashrc 
b/profiles/prefix/darwin/macos/arch/arm64/profile.bashrc
index 6bfe36915c9d..314c9a7e4f99 100644
--- a/profiles/prefix/darwin/macos/arch/arm64/profile.bashrc
+++ b/profiles/prefix/darwin/macos/arch/arm64/profile.bashrc
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 pre_src_configure() {
@@ -11,13 +11,23 @@ pre_src_configure() {
        # triplets, so patch that for various versions of autoconf
        # This bit should be kept in sync with fix_config_sub in
        # bootstrap-prefix.sh
-       if [[ ${CHOST} == arm64-apple-darwin* ]] ; then
-               # Apple Silicon doesn't use aarch64, but arm64
-               find . -name "config.sub" | \
-                       xargs sed -i -e 's/ arm\(-\*\)* / arm\1 | arm64\1 /'
-               find . -name "config.sub" | \
-                       xargs sed -i -e 's/ aarch64 / aarch64 | arm64 /'
-       fi
+       # Apple Silicon doesn't use aarch64, but arm64
+       find . -name "config.sub" | \
+               ${XARGS} sed -i -e 's/ arm\(-\*\)* / arm\1 | arm64\1 /'
+       find . -name "config.sub" | \
+               ${XARGS} sed -i -e 's/ aarch64 / aarch64 | arm64 /'
+
+       # currently the toolchain appears to be a bit funky, and generates
+       # code the (host) linker thinks is invalid with -O2 and up:
+       # ld: in section __TEXT,__text reloc 442: symbol index out of range
+       # file 'src/preproc/refer/refer-label.o' for architecture arm64
+       case ${CATEGORY}/${PN} in
+               sys-apps/groff |\
+               app-editors/vim)
+                       [[ ${CFLAGS}   == *-O[23456789]* ]] &&   
CFLAGS="${CFLAGS} -O1"
+                       [[ ${CXXFLAGS} == *-O[23456789]* ]] && 
CXXFLAGS="${CFLAGS} -O1"
+               ;;
+       esac
 
        popd > /dev/null
 }

Reply via email to