diff mbox series

[pushed] Darwin, config : Adjust X86 biarch definitions ordering [PR100269].

Message ID 21407674-0005-43D7-A6AC-290101CE0BFB@sandoe.co.uk
State New
Headers show
Series [pushed] Darwin, config : Adjust X86 biarch definitions ordering [PR100269]. | expand

Commit Message

Iain Sandoe July 4, 2021, 7:41 p.m. UTC
Hi

This reorganises the biarch definitions to cater for the
macro changes and removals at r12-36.

tested across the Darwin range,
pushed to master, thanks
Iain

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

PR target/100269 - [12 Regression] i686 biarch compiler fails for Darwin after r12-36.

        PR target/100269

gcc/ChangeLog:

	PR target/100269
	* config.gcc: Ensure that Darwin biarch definitions are
	added before i386.h.
	* config/i386/darwin.h (TARGET_64BIT): Remove.
	(PR80556_WORKAROUND): New.
	(REAL_LIBGCC_SPEC): Amend to use PR80556_WORKAROUND.
	(DARWIN_SUBARCH_SPEC): New.
	* config/i386/darwin32-biarch.h (TARGET_64BIT_DEFAULT,
	TARGET_BI_ARCH, PR80556_WORKAROUND): New.
	(REAL_LIBGCC_SPEC): Remove.
	* config/i386/darwin64-biarch.h (TARGET_64BIT_DEFAULT,
	TARGET_BI_ARCH, PR80556_WORKAROUND): New.
	(REAL_LIBGCC_SPEC): Remove.
---
 gcc/config.gcc                    | 10 +++++++---
 gcc/config/i386/darwin.h          | 22 ++++++++++------------
 gcc/config/i386/darwin32-biarch.h | 22 ++++++----------------
 gcc/config/i386/darwin64-biarch.h | 22 ++++++----------------
 4 files changed, 29 insertions(+), 47 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 0230bb88861..f3e94f7c0d8 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -591,6 +591,8 @@  i[34567]86-*-*)
 		exit 1
 	fi
 	;;
+x86_64-*-darwin*)
+	;;
 x86_64-*-*)
 	case ${with_abi} in
 	"")
@@ -1837,7 +1839,7 @@  hppa[12]*-*-hpux11*)
 		dwarf2=no
 	fi
 	;;
-i[34567]86-*-darwin1[89]*)
+i[34567]86-*-darwin1[89]* | i[34567]86-*-darwin2[0-9]*)
 	echo "Error: 32bit target is not supported after Darwin17" 1>&2
 	;;
 i[34567]86-*-darwin*)
@@ -1845,17 +1847,19 @@  i[34567]86-*-darwin*)
 	# Baseline choice for a machine that allows m64 support.
 	with_cpu=${with_cpu:-core2}
 	tmake_file="${tmake_file} ${cpu_type}/t-darwin32-biarch t-slibgcc"
-	tm_file="${tm_file} ${cpu_type}/darwin32-biarch.h"
+	tm_file="${cpu_type}/darwin32-biarch.h ${tm_file} "
 	;;
 x86_64-*-darwin1[89]* | x86_64-*-darwin2[01]*)
 	# Only 64b from now
+	tm_defines="${tm_defines} TARGET_64BIT_DEFAULT=(OPTION_MASK_ISA_64BIT|OPTION_MASK_ABI_64)"
+	tm_defines="${tm_defines} TARGET_BI_ARCH=0"
 	with_cpu=${with_cpu:-core2}
 	tmake_file="${tmake_file} t-slibgcc"
 	;;
 x86_64-*-darwin*)
 	with_cpu=${with_cpu:-core2}
 	tmake_file="${tmake_file} ${cpu_type}/t-darwin64-biarch t-slibgcc"
-	tm_file="${tm_file} ${cpu_type}/darwin64-biarch.h"
+	tm_file="${cpu_type}/darwin64-biarch.h ${tm_file} "
 	;;
 i[34567]86-*-elfiamcu)
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/iamcu.h"
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 5312003a321..bac32197e83 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -25,15 +25,6 @@  along with GCC; see the file COPYING3.  If not see
 #undef DARWIN_X86
 #define DARWIN_X86 1
 
-#ifdef IN_LIBGCC2
-#undef TARGET_64BIT
-#ifdef __x86_64__
-#define TARGET_64BIT 1
-#else
-#define TARGET_64BIT 0
-#endif
-#endif
-
 /* WORKAROUND pr80556:
    For x86_64 Darwin10 and later, the unwinder is in libunwind (redirected
    from libSystem).  This doesn't use the keymgr (see keymgr.c) and therefore
@@ -44,11 +35,15 @@  along with GCC; see the file COPYING3.  If not see
    even when static-libgcc is specified.  We put libSystem first so that
    unwinder symbols are satisfied from there.
    We default to 64b for single-arch builds, so apply this unconditionally. */
+#ifndef PR80556_WORKAROUND
+#define PR80556_WORKAROUND \
+" %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) "
+#endif
 #undef REAL_LIBGCC_SPEC
 #define REAL_LIBGCC_SPEC						   \
-   "%{static-libgcc|static: 						   \
-       %:version-compare(>= 10.6 mmacosx-version-min= -lSystem)		   \
-       -lgcc_eh -lgcc;							   \
+   "%{static-libgcc|static: "						   \
+       PR80556_WORKAROUND						   \
+      " -lgcc_eh -lgcc;							   \
       shared-libgcc|fexceptions|fgnu-runtime:				   \
        %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)	   \
        %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
@@ -142,8 +137,11 @@  along with GCC; see the file COPYING3.  If not see
    %{mpc64:crtprec64.o%s} \
    %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR
 
+#ifndef DARWIN_ARCH_SPEC
 /* We default to x86_64 for single-arch builds, bi-arch overrides.  */
 #define DARWIN_ARCH_SPEC "x86_64"
+#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
+#endif
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS                                   \
diff --git a/gcc/config/i386/darwin32-biarch.h b/gcc/config/i386/darwin32-biarch.h
index 73b83eb650c..5470edf3f8d 100644
--- a/gcc/config/i386/darwin32-biarch.h
+++ b/gcc/config/i386/darwin32-biarch.h
@@ -21,6 +21,9 @@  along with GCC; see the file COPYING3.  If not see
 #undef DARWIN_ARCH_SPEC
 #define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
 
+#define TARGET_64BIT_DEFAULT 0
+#define TARGET_BI_ARCH 1
+
 /* WORKAROUND pr80556:
    For x86_64 Darwin10 and later, the unwinder is in libunwind (redirected
    from libSystem).  This doesn't use the keymgr (see keymgr.c) and therefore
@@ -30,22 +33,9 @@  along with GCC; see the file COPYING3.  If not see
    Therefore, for 64b exes at least, we must use the libunwind implementation,
    even when static-libgcc is specified.  We put libSystem first so that
    unwinder symbols are satisfied from there. */
-#undef REAL_LIBGCC_SPEC
-#define REAL_LIBGCC_SPEC						   \
-   "%{static-libgcc|static: 						   \
-      %{m64:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)}	   \
-        -lgcc_eh -lgcc;							   \
-      shared-libgcc|fexceptions|fgnu-runtime:				   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)	   \
-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)	   \
-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)	   \
-       -lgcc ;								   \
-      :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)	   \
-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)	   \
-       -lgcc }"
+#undef PR80556_WORKAROUND
+#define PR80556_WORKAROUND \
+" %{m64:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)} "
 
 #undef  DARWIN_SUBARCH_SPEC
 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
diff --git a/gcc/config/i386/darwin64-biarch.h b/gcc/config/i386/darwin64-biarch.h
index 1ae76b8fb91..f5bc3d66750 100644
--- a/gcc/config/i386/darwin64-biarch.h
+++ b/gcc/config/i386/darwin64-biarch.h
@@ -22,6 +22,9 @@  along with GCC; see the file COPYING3.  If not see
 #undef  DARWIN_ARCH_SPEC
 #define DARWIN_ARCH_SPEC "%{m32:i386;:x86_64}"
 
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64)
+#define TARGET_BI_ARCH 1
+
 /* WORKAROUND pr80556:
    For x86_64 Darwin10 and later, the unwinder is in libunwind (redirected
    from libSystem).  This doesn't use the keymgr (see keymgr.c) and therefore
@@ -31,22 +34,9 @@  along with GCC; see the file COPYING3.  If not see
    Therefore, for 64b exes at least, we must use the libunwind implementation,
    even when static-libgcc is specified.  We put libSystem first so that
    unwinder symbols are satisfied from there. */
-#undef REAL_LIBGCC_SPEC
-#define REAL_LIBGCC_SPEC						   \
-   "%{static-libgcc|static: 						   \
-      %{!m32:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)}	   \
-        -lgcc_eh -lgcc;							   \
-      shared-libgcc|fexceptions|fgnu-runtime:				   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_s.10.4)	   \
-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)	   \
-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)	   \
-       -lgcc ;								   \
-      :%:version-compare(>< 10.3.9 10.5 mmacosx-version-min= -lgcc_s.10.4) \
-       %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5)   \
-       %:version-compare(!> 10.5 mmacosx-version-min= -lgcc_ext.10.4)	   \
-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)	   \
-       -lgcc }"
+#undef PR80556_WORKAROUND
+#define PR80556_WORKAROUND \
+" %{!m32:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)} "
 
 #undef  DARWIN_SUBARCH_SPEC
 #define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC