https://gcc.gnu.org/g:1a5fd574bdf25b93320bf039c73900e5597994f7

commit r16-7268-g1a5fd574bdf25b93320bf039c73900e5597994f7
Author: Rainer Orth <[email protected]>
Date:   Tue Feb 3 20:34:10 2026 +0100

    build: Use separate options for Darwin as [PR123841]
    
    Since
    
    commit 5fc4e333b42d12aca71587f83f2d2c5be9633146
    Author: Rainer Orth <[email protected]>
    Date:   Tue Jan 27 19:15:36 2026 +0100
    
        build: Unify 32 and 64-bit assembler handling
    
    gcc/acinclude.m4 uses gas-only flags --32/--64 on Darwin/x86 with the
    native assembler, which breaks many configure tests.
    
    This patch uses the Darwin as options instead, handling the PowerPC
    cases at the same time.
    
    Tested on x86_64-apple-darwin21.6.0 and 386-apple-darwin17.7.0.
    
    2026-01-28  Rainer Orth  <[email protected]>
    
            gcc:
            PR other/123841
            * acinclude.m4 (gcc_GAS_FLAGS): Handle Darwin as cases separately.
            * configure: Regenerate.

Diff:
---
 gcc/acinclude.m4 | 31 +++++++++++++++++++++++++++----
 gcc/configure    | 25 ++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
index aef4ca46db88..89e00a16f1d2 100644
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -465,6 +465,33 @@ dnl #
 AC_DEFUN([gcc_GAS_FLAGS],
 [AC_CACHE_CHECK([assembler flags], gcc_cv_as_flags,
 [ case "$target:$gas_flag" in
+  *-*-darwin*:*)
+    dnl Darwin with the native assembler uses -arch i386/x86_64/ppc/ppc64.
+    dnl
+    dnl Old cctools versions of the Darwin assembler identify as "GNU
+    dnl assembler version 1.38", but still accept the same options as later
+    dnl clang-based ones, so treat them all the same regardless.
+    case "$target" in
+      i?86-*-*)
+       gcc_cv_as_flags="-arch i386"
+       ;;
+      powerpc64*-*-*)
+       gcc_cv_as_flags="-arch ppc64"
+       ;;
+      powerpc*-*-*)
+       gcc_cv_as_flags="-arch ppc"
+       ;;
+      x86_64-*-*)
+       gcc_cv_as_flags="-arch x86_64"
+       ;;
+    esac
+    case "$target" in
+      i?86-*-* | x86_64-*-*)
+       as_32_opt="-arch i386"
+       as_64_opt="-arch x86_64"
+       ;;
+    esac
+    ;;
   *-*-solaris2*:no)
     dnl Override the default, which may be incompatible.
     case "$target" in
@@ -494,10 +521,6 @@ AC_DEFUN([gcc_GAS_FLAGS],
     as_32_opt=--32
     as_64_opt=--64
     ;;
-  powerpc*-*-darwin*:*)
-    dnl Always pass -arch ppc to assembler.
-    gcc_cv_as_flags="-arch ppc"
-    ;;
   amdgcn*:*)
     dnl Currently, only the llvm-mc assembler is supported.
     dnl Add flags to ensure an amdgcn ELF file is written.
diff --git a/gcc/configure b/gcc/configure
index b708db893d88..e8b5c4a7118a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -26146,6 +26146,28 @@ if ${gcc_cv_as_flags+:} false; then :
   $as_echo_n "(cached) " >&6
 else
    case "$target:$gas_flag" in
+  *-*-darwin*:*)
+                        case "$target" in
+      i?86-*-*)
+       gcc_cv_as_flags="-arch i386"
+       ;;
+      powerpc64*-*-*)
+       gcc_cv_as_flags="-arch ppc64"
+       ;;
+      powerpc*-*-*)
+       gcc_cv_as_flags="-arch ppc"
+       ;;
+      x86_64-*-*)
+       gcc_cv_as_flags="-arch x86_64"
+       ;;
+    esac
+    case "$target" in
+      i?86-*-* | x86_64-*-*)
+       as_32_opt="-arch i386"
+       as_64_opt="-arch x86_64"
+       ;;
+    esac
+    ;;
   *-*-solaris2*:no)
         case "$target" in
       i?86-*-* | sparc-*-*)
@@ -26173,9 +26195,6 @@ else
     as_32_opt=--32
     as_64_opt=--64
     ;;
-  powerpc*-*-darwin*:*)
-        gcc_cv_as_flags="-arch ppc"
-    ;;
   amdgcn*:*)
             gcc_cv_as_flags="--filetype=obj -triple=amdgcn--amdhsa"
     ;;

Reply via email to