public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5418] Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556].
@ 2021-11-19 19:58 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2021-11-19 19:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d4943ce939d9654932624b9ece24c3a474ae4157

commit r12-5418-gd4943ce939d9654932624b9ece24c3a474ae4157
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Sep 20 18:41:56 2021 +0100

    Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556].
    
    This addresses a long-standing problem where a work-around for an unwinder
    issue (also a regression) regresses other functionality.  The patch replaces
    several work-arounds with a fix for PR80556 and a work-around for PR88590.
    
    * The fix for PR80556 requires a bump to the SO name for libgcc_s, since we
    need to remove the unwinder symbols from it.  This would trigger PR88590
    hence the work-around for that.
    
    * We weaken the symbols for emulated TLS support so that it is possible
    for a DSO linked with static-libgcc to interoperate with a DSO linked with
    libgcc_s.  Likewise main exes.
    
    * We remove all the gcc-4.2.1 era stubs machinery and workarounds.
    
    * libgcc is always now linked ahead of libc, which avoids fails where the
    libc (libSystem) builtins implementations are not up to date.
    
    * The unwinder now always comes from the system
     - for Darwin9 from /usr/lib/libgcc_s.1.dylib
     - for Darwin10 from /usr/lib/libSystem.dylib
     - for Darwin11+ from /usr/lib/system/libunwind.dylib.
    
     We still insert a shim on Darwin10 to fix an omitted unwind function, but
     the underlying unwinder remains the system one.
    
    * The work-around for PR88590 has two parts (1) we always link libgcc from
    its convenience lib on affected system versions (avoiding the need to find
    the DSO path); (2) we add and export the emutls functions from DSOs - this
    makes a relatively small (20k) addition to a DSO.  These can be backed out
    when a proper fix for PR88590 is committed.
    
    For distributions that wish to install a libgcc_s.1.dylib to satisfy linkage
    from exes that linked against the stubs can use a reexported libgcc_s.1.1
    (since that contains all the symbols that were previously exported via the
     stubs).
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    gcc/ChangeLog:
    
            PR target/80556
            * config/darwin-driver.c (darwin_driver_init): Handle exported
            symbols and symbol lists (suppress automatic export of the TLS
            symbols).
            * config/darwin.c (darwin_rename_builtins): Remove workaround.
            * config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
            (REAL_LIBGCC_SPEC): Handle revised library uses.
            * config/darwin.opt (nodefaultexport): New.
            * config/i386/darwin.h (PR80556_WORKAROUND): Remove.
            * config/i386/darwin32-biarch.h (PR80556_WORKAROUND): Likewise.
            * config/i386/darwin64-biarch.h (PR80556_WORKAROUND): Likewise.
    
    libgcc/ChangeLog:
    
            * config.host: Add weak emutls crt to the extra_parts.
            * config/i386/darwin-lib.h (DECLARE_LIBRARY_RENAMES): Remove
            workaround.
            * config/libgcc-libsystem.ver: Add exclude list for the system-
            provided unwinder.
            * config/t-slibgcc-darwin: Bump SO version, remove stubs code.
            * config/i386/libgcc-darwin.10.4.ver: Removed.
            * config/i386/libgcc-darwin.10.5.ver: Removed.
            * config/rs6000/libgcc-darwin.10.4.ver: Removed.
            * config/rs6000/libgcc-darwin.10.5.ver: Removed.
            * config/t-darwin-noeh: New file.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/torture/fp-int-convert-timode-3.c: Remove XFAIL.
            * gcc.dg/torture/fp-int-convert-timode-4.c: Likewise.

Diff:
---
 gcc/config/darwin-driver.c                         |  18 ++++
 gcc/config/darwin.c                                |  24 -----
 gcc/config/darwin.h                                |  98 ++++++++++++-------
 gcc/config/darwin.opt                              |   4 +
 gcc/config/i386/darwin.h                           |  31 ------
 gcc/config/i386/darwin32-biarch.h                  |  13 ---
 gcc/config/i386/darwin64-biarch.h                  |  13 ---
 .../gcc.dg/torture/fp-int-convert-timode-3.c       |   1 -
 .../gcc.dg/torture/fp-int-convert-timode-4.c       |   1 -
 libgcc/config.host                                 |   7 +-
 libgcc/config/i386/darwin-lib.h                    |   9 --
 libgcc/config/i386/libgcc-darwin.10.4.ver          |  98 -------------------
 libgcc/config/i386/libgcc-darwin.10.5.ver          | 102 --------------------
 libgcc/config/libgcc-libsystem.ver                 |  38 +++++++-
 libgcc/config/rs6000/libgcc-darwin.10.4.ver        |  93 ------------------
 libgcc/config/rs6000/libgcc-darwin.10.5.ver        | 106 ---------------------
 libgcc/config/t-darwin-noeh                        |   4 +
 libgcc/config/t-slibgcc-darwin                     |  74 ++++----------
 18 files changed, 153 insertions(+), 581 deletions(-)

diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c
index 4f0c6bad61f..7fa80abc314 100644
--- a/gcc/config/darwin-driver.c
+++ b/gcc/config/darwin-driver.c
@@ -281,6 +281,7 @@ darwin_driver_init (unsigned int *decoded_options_count,
   const char *vers_string = NULL;
   bool seen_version_min = false;
   bool seen_sysroot_p = false;
+  bool noexport_p = true;
 
   for (i = 1; i < *decoded_options_count; i++)
     {
@@ -349,6 +350,13 @@ darwin_driver_init (unsigned int *decoded_options_count,
 	  seen_sysroot_p = true;
 	  break;
 
+	case OPT_Xlinker:
+	case OPT_Wl_:
+	  gcc_checking_assert ((*decoded_options)[i].arg);
+	  if (startswith ((*decoded_options)[i].arg, "-exported_symbol"))
+	    noexport_p = false;
+	  break;
+
 	default:
 	  break;
 	}
@@ -474,4 +482,14 @@ darwin_driver_init (unsigned int *decoded_options_count,
 			  &(*decoded_options)[*decoded_options_count - 1]);
         }
     }
+
+  if (noexport_p)
+    {
+      ++*decoded_options_count;
+      *decoded_options = XRESIZEVEC (struct cl_decoded_option,
+				     *decoded_options,
+				     *decoded_options_count);
+      generate_option (OPT_nodefaultexport, NULL, 1, CL_DRIVER,
+		       &(*decoded_options)[*decoded_options_count - 1]);
+    }
 }
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 204114c96a2..c5ba7927ce1 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3637,30 +3637,6 @@ darwin_fold_builtin (tree fndecl, int n_args, tree *argp,
 void
 darwin_rename_builtins (void)
 {
-  /* The system ___divdc3 routine in libSystem on darwin10 is not
-     accurate to 1ulp, ours is, so we avoid ever using the system name
-     for this routine and instead install a non-conflicting name that
-     is accurate.
-
-     When -ffast-math or -funsafe-math-optimizations is given, we can
-     use the faster version.  */
-  if (!flag_unsafe_math_optimizations)
-    {
-      enum built_in_function dcode
-	= (enum built_in_function)(BUILT_IN_COMPLEX_DIV_MIN
-				   + DCmode - MIN_MODE_COMPLEX_FLOAT);
-      tree fn = builtin_decl_explicit (dcode);
-      /* Fortran and c call TARGET_INIT_BUILTINS and
-	 TARGET_INIT_LIBFUNCS at different times, so we have to put a
-	 call into each to ensure that at least one of them is called
-	 after build_common_builtin_nodes.  A better fix is to add a
-	 new hook to run after build_common_builtin_nodes runs.  */
-      if (fn)
-	set_user_assembler_name (fn, "___ieee_divdc3");
-      fn = builtin_decl_implicit (dcode);
-      if (fn)
-	set_user_assembler_name (fn, "___ieee_divdc3");
-    }
 }
 
 /* Implementation for the TARGET_LIBC_HAS_FUNCTION hook.  */
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 7ed01efa694..8d8d402325a 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -378,6 +378,16 @@ extern GTY(()) int darwin_ms_struct;
       %(link_ssp) \
       %:version-compare(>< 10.6 10.7 mmacosx-version-min= -ld10-uwfef) \
       %(link_gcc_c_sequence) \
+      %{!nodefaultexport:%{dylib|dynamiclib|bundle: \
+	%:version-compare(>= 10.11 asm_macosx_version_min= -U) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_get_address) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= -U) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= -exported_symbol) \
+	%:version-compare(>= 10.11 asm_macosx_version_min= ___emutls_register_common) \
+      }} \
     }}}\
     %{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
     DARWIN_PIE_SPEC \
@@ -404,14 +414,11 @@ extern GTY(()) int darwin_ms_struct;
 /* Tell collect2 to run dsymutil for us as necessary.  */
 #define COLLECT_RUN_DSYMUTIL 1
 
-/* Fix PR47558 by linking against libSystem ahead of libgcc. See also
-   PR 80556 and the fallout from this.  */
-
+/* We only want one instance of %G, since libSystem (Darwin's -lc) does not
+   depend on libgcc. */
 #undef  LINK_GCC_C_SEQUENCE_SPEC
 #define LINK_GCC_C_SEQUENCE_SPEC \
-"%{!static:%{!static-libgcc: \
-    %:version-compare(>= 10.6 mmacosx-version-min= -lSystem) } } \
-  %G %{!nolibc:%L}"
+ "%G %{!nolibc:%L} "
 
 /* ld64 supports a sysroot, it just has a different name and there's no easy
    way to check for it at config time.  */
@@ -456,37 +463,62 @@ extern GTY(()) int darwin_ms_struct;
 
 #define LIB_SPEC "%{!static:-lSystem}"
 
-/* Support -mmacosx-version-min by supplying different (stub) libgcc_s.dylib
-   libraries to link against, and by not linking against libgcc_s on
-   earlier-than-10.3.9.  If we need exceptions, prior to 10.3.9, then we have
-   to link the static eh lib, since there's no shared version on the system.
-
-   Note that by default, except as above, -lgcc_eh is not linked against.
+/*
+   Note that by default, -lgcc_eh is not linked against.
    This is because,in general, we need to unwind through system libraries that
    are linked with the shared unwinder in libunwind (or libgcc_s for 10.4/5).
 
-   The static version of the current libgcc unwinder (which differs from the
-   implementation in libunwind.dylib on systems Darwin10 [10.6]+) can be used
-   by specifying -static-libgcc.
-
-   If libgcc_eh is linked against, it has to be before -lgcc, because it might
-   need symbols from -lgcc.  */
-
+   For -static-libgcc: < 10.6, use the unwinder in libgcc_eh (and find
+   the emultls impl. there too).
+
+   For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
+   we find the emutls impl from lemutls_w. In either case, the builtins etc.
+   are linked from -lgcc.
+
+   When we have specified shared-libgcc or any case that might require
+   exceptions, we pull the libgcc content (including emulated tls) from
+   -lgcc_s.1 in GCC and the unwinder from /usr/lib/libgcc_s.1 for < 10.6 and
+   libSystem for >= 10.6 respectively.
+   Otherwise, we just link the emutls/builtins from convenience libs.
+
+   If we need exceptions, prior to 10.3.9, then we have to link the static
+   eh lib, since there's no shared version on the system.
+
+   In all cases, libgcc_s.1 will be installed with the compiler, or any app
+   built using it, so we can link the builtins and emutls shared on all.
+
+   We have to work around that DYLD_XXXX are disabled in macOS 10.11+ which
+   means that any bootstrap trying to use a shared libgcc with a bumped SO-
+   name will fail.  This means that we do not accept shared libgcc for these
+   versions.
+
+   For -static-libgcc: >= 10.6, the unwinder *still* comes from libSystem and
+   we find the emutls impl from lemutls_w. In either case, the builtins etc.
+   are linked from -lgcc.
+>
+   Otherwise, we just link the shared version of gcc_s.1.1 and pick up
+   exceptions:
+     * Prior to 10.3.9, then we have to link the static eh lib, since there
+       is no shared version on the system.
+     * from 10.3.9 to 10.5, from /usr/lib/libgcc_s.1.dylib
+     * from 10.6 onwards, from libSystem.dylib
+
+   In all cases, libgcc_s.1.1 will be installed with the compiler, or any app
+   built using it, so we can link the builtins and emutls shared on all.
+*/
 #undef REAL_LIBGCC_SPEC
-#define REAL_LIBGCC_SPEC						   \
-   "%{static-libgcc|static: -lgcc_eh -lgcc;				   \
-      shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:		   \
-       %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)	   \
-       %: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.3.9 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.3.9 10.5 mmacosx-version-min= -lgcc_ext.10.4) \
-       %:version-compare(>= 10.5 mmacosx-version-min= -lgcc_ext.10.5)	   \
-       -lgcc }"
+#define REAL_LIBGCC_SPEC \
+"%{static-libgcc|static:						  \
+    %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh)		  \
+    %:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w);		  \
+   shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime:		  \
+    %:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1)	  \
+    %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w)		  \
+    %:version-compare(!> 10.3.9 mmacosx-version-min= -lgcc_eh)		  \
+    %: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);	  \
+   : -lemutls_w								  \
+  } -lgcc "
 
 /* We specify crt0.o as -lcrt0.o so that ld will search the library path.  */
 
diff --git a/gcc/config/darwin.opt b/gcc/config/darwin.opt
index d1d1f816912..48d3aa97800 100644
--- a/gcc/config/darwin.opt
+++ b/gcc/config/darwin.opt
@@ -233,6 +233,10 @@ no_dead_strip_inits_and_terms
 Driver RejectNegative
 (Obsolete) Current linkers never dead-strip these items, so the option is not needed.
 
+nodefaultexport
+Driver RejectNegative
+Do not add a default symbol exports to modules or dynamic libraries.
+
 nofixprebinding
 Driver RejectNegative
 (Obsolete after 10.3.9) Set MH_NOPREFIXBINDING, in an executable.
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 741f29aa962..e946a8b261d 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -25,37 +25,6 @@ along with GCC; see the file COPYING3.  If not see
 #undef DARWIN_X86
 #define DARWIN_X86 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
-   the calls that libgcc makes to obtain the KEYMGR_GCC3_DW2_OBJ_LIST are not
-   updated to include new images, and might not even be valid for a single
-   image.
-   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.
-   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: "						   \
-       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)   \
-       %: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 }"
-
 /* Size of the Obj-C jump buffer.  */
 #define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18))
 
diff --git a/gcc/config/i386/darwin32-biarch.h b/gcc/config/i386/darwin32-biarch.h
index 5470edf3f8d..ee1508213f2 100644
--- a/gcc/config/i386/darwin32-biarch.h
+++ b/gcc/config/i386/darwin32-biarch.h
@@ -24,19 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 #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
-   the calls that libgcc makes to obtain the KEYMGR_GCC3_DW2_OBJ_LIST are not
-   updated to include new images, and might not even be valid for a single
-   image.
-   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 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 f5bc3d66750..d02f7fcc29e 100644
--- a/gcc/config/i386/darwin64-biarch.h
+++ b/gcc/config/i386/darwin64-biarch.h
@@ -25,19 +25,6 @@ along with GCC; see the file COPYING3.  If not see
 #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
-   the calls that libgcc makes to obtain the KEYMGR_GCC3_DW2_OBJ_LIST are not
-   updated to include new images, and might not even be valid for a single
-   image.
-   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 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
 
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
index 10702302bf8..707d539335f 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c
@@ -4,7 +4,6 @@
 /* { dg-require-effective-target int128 } */
 /* { dg-require-effective-target fenv } */
 /* { dg-options "-frounding-math" } */
-/* { dg-xfail-run-if "see PR80556 c63" { x86_64-*-darwin* i68?-*-darwin* } { "*" } { "" } } */
 
 #include <fenv.h>
 #include <stdlib.h>
diff --git a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
index 3facf32fb8b..09600f90903 100644
--- a/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
+++ b/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c
@@ -4,7 +4,6 @@
 /* { dg-require-effective-target int128 } */
 /* { dg-require-effective-target fenv } */
 /* { dg-options "-frounding-math" } */
-/* { dg-xfail-run-if "see PR80556 c63" { x86_64-*-darwin* i68?-*-darwin* } { "*" } { "" } } */
 
 #include <fenv.h>
 #include <stdlib.h>
diff --git a/libgcc/config.host b/libgcc/config.host
index 168535b1780..734d90ee39b 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -214,8 +214,11 @@ esac
 case ${host} in
 *-*-darwin*)
   asm_hidden_op=.private_extern
-  tmake_file="$tmake_file t-darwin ${cpu_type}/t-darwin t-libgcc-pic t-slibgcc-darwin"
-  extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o"
+  tmake_file="$tmake_file t-darwin ${cpu_type}/t-darwin t-libgcc-pic"
+  extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
+  # The unwinder is provided by the system shared libraries, do not add one
+  # to the shared libgcc.
+  tmake_file="$tmake_file t-darwin-noeh t-slibgcc-darwin"
   ;;
 *-*-dragonfly*)
   tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
diff --git a/libgcc/config/i386/darwin-lib.h b/libgcc/config/i386/darwin-lib.h
index 5aeee335348..e22f732c87c 100644
--- a/libgcc/config/i386/darwin-lib.h
+++ b/libgcc/config/i386/darwin-lib.h
@@ -22,13 +22,4 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-/* The system ___divdc3 routine in libSystem on darwin10 is not
-   accurate to 1ulp, ours is, so we avoid ever using the system name
-   for this routine and instead install a non-conflicting name that is
-   accurate.  See darwin_rename_builtins.  */
-#ifdef L_divdc3
-#define DECLARE_LIBRARY_RENAMES \
-  asm(".text; ___divdc3: jmp ___ieee_divdc3 ; .globl ___divdc3");
-#endif
-
 extern void * _darwin10_Unwind_FindEnclosingFunction (void *);
diff --git a/libgcc/config/i386/libgcc-darwin.10.4.ver b/libgcc/config/i386/libgcc-darwin.10.4.ver
deleted file mode 100644
index b8a73b1f10f..00000000000
--- a/libgcc/config/i386/libgcc-darwin.10.4.ver
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright (C) 2005-2021 Free Software Foundation, Inc.
-#
-# This file is part of GCC.
-#
-# GCC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GCC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3.  If not see
-# <http://www.gnu.org/licenses/>.
-__Unwind_Backtrace
-__Unwind_DeleteException
-__Unwind_FindEnclosingFunction
-__Unwind_Find_FDE
-__Unwind_ForcedUnwind
-__Unwind_GetCFA
-__Unwind_GetDataRelBase
-__Unwind_GetGR
-__Unwind_GetIP
-__Unwind_GetLanguageSpecificData
-__Unwind_GetRegionStart
-__Unwind_GetTextRelBase
-__Unwind_RaiseException
-__Unwind_Resume
-__Unwind_Resume_or_Rethrow
-__Unwind_SetGR
-__Unwind_SetIP
-___absvdi2
-___absvsi2
-___addvdi3
-___addvsi3
-___ashldi3
-___ashrdi3
-___clear_cache
-___clzdi2
-___clzsi2
-___cmpdi2
-___ctzdi2
-___ctzsi2
-___deregister_frame
-___deregister_frame_info
-___deregister_frame_info_bases
-___divdc3
-___divdi3
-___divsc3
-___divxc3
-___enable_execute_stack
-___ffsdi2
-___fixdfdi
-___fixsfdi
-___fixunsdfdi
-___fixunsdfsi
-___fixunssfdi
-___fixunssfsi
-___fixunsxfdi
-___fixunsxfsi
-___fixxfdi
-___floatdidf
-___floatdisf
-___floatdixf
-___gcc_personality_v0
-___lshrdi3
-___moddi3
-___muldc3
-___muldi3
-___mulsc3
-___mulvdi3
-___mulvsi3
-___mulxc3
-___negdi2
-___negvdi2
-___negvsi2
-___paritydi2
-___paritysi2
-___popcountdi2
-___popcountsi2
-___powidf2
-___powisf2
-___powixf2
-___register_frame
-___register_frame_info
-___register_frame_info_bases
-___register_frame_info_table
-___register_frame_info_table_bases
-___register_frame_table
-___subvdi3
-___subvsi3
-___ucmpdi2
-___udivdi3
-___udivmoddi4
-___umoddi3
diff --git a/libgcc/config/i386/libgcc-darwin.10.5.ver b/libgcc/config/i386/libgcc-darwin.10.5.ver
deleted file mode 100644
index 49fd9279d28..00000000000
--- a/libgcc/config/i386/libgcc-darwin.10.5.ver
+++ /dev/null
@@ -1,102 +0,0 @@
-# Copyright (C) 2005-2021 Free Software Foundation, Inc.
-#
-# This file is part of GCC.
-#
-# GCC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GCC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3.  If not see
-# <http://www.gnu.org/licenses/>.
-__Unwind_Backtrace
-__Unwind_DeleteException
-__Unwind_FindEnclosingFunction
-__Unwind_Find_FDE
-__Unwind_ForcedUnwind
-__Unwind_GetCFA
-__Unwind_GetDataRelBase
-__Unwind_GetGR
-__Unwind_GetIP
-__Unwind_GetIPInfo
-__Unwind_GetLanguageSpecificData
-__Unwind_GetRegionStart
-__Unwind_GetTextRelBase
-__Unwind_RaiseException
-__Unwind_Resume
-__Unwind_Resume_or_Rethrow
-__Unwind_SetGR
-__Unwind_SetIP
-___absvdi2
-___absvsi2
-___addvdi3
-___addvsi3
-___ashldi3
-___ashrdi3
-___clear_cache
-___clzdi2
-___clzsi2
-___cmpdi2
-___ctzdi2
-___ctzsi2
-___deregister_frame
-___deregister_frame_info
-___deregister_frame_info_bases
-___divdc3
-___divdi3
-___divsc3
-___divxc3
-___enable_execute_stack
-___ffsdi2
-___fixdfdi
-___fixsfdi
-___fixunsdfdi
-___fixunsdfsi
-___fixunssfdi
-___fixunssfsi
-___fixunsxfdi
-___fixunsxfsi
-___fixxfdi
-___floatdidf
-___floatdisf
-___floatdixf
-___floatundidf
-___floatundisf
-___floatundixf
-___gcc_personality_v0
-___lshrdi3
-___moddi3
-___muldc3
-___muldi3
-___mulsc3
-___mulvdi3
-___mulvsi3
-___mulxc3
-___negdi2
-___negvdi2
-___negvsi2
-___paritydi2
-___paritysi2
-___popcountdi2
-___popcountsi2
-___powidf2
-___powisf2
-___powixf2
-___register_frame
-___register_frame_info
-___register_frame_info_bases
-___register_frame_info_table
-___register_frame_info_table_bases
-___register_frame_table
-___subvdi3
-___subvsi3
-___ucmpdi2
-___udivdi3
-___udivmoddi4
-___umoddi3
diff --git a/libgcc/config/libgcc-libsystem.ver b/libgcc/config/libgcc-libsystem.ver
index 47631749dc2..697a245869e 100644
--- a/libgcc/config/libgcc-libsystem.ver
+++ b/libgcc/config/libgcc-libsystem.ver
@@ -1 +1,37 @@
-_darwin10_Unwind_FindEnclosingFunction
+# We must use the unwinder provided by the OS, even if that has
+# limitations or bug, so exclude the libgcc_s symbols.
+
+%exclude {
+ _Unwind_DeleteException
+ _Unwind_Find_FDE
+ _Unwind_ForcedUnwind
+ _Unwind_GetGR
+ _Unwind_GetIP
+ _Unwind_GetLanguageSpecificData
+ _Unwind_GetRegionStart
+ _Unwind_GetTextRelBase
+ _Unwind_GetDataRelBase
+ _Unwind_RaiseException
+ _Unwind_Resume
+ _Unwind_SetGR
+ _Unwind_SetIP
+ _Unwind_SjLj_Register
+ _Unwind_SjLj_Unregister
+ _Unwind_SjLj_RaiseException
+ _Unwind_SjLj_ForcedUnwind
+ _Unwind_SjLj_Resume
+ _Unwind_FindEnclosingFunction
+ _Unwind_GetCFA
+ _Unwind_Backtrace
+ _Unwind_Resume_or_Rethrow
+ _Unwind_SjLj_Resume_or_Rethrow
+ _Unwind_GetIPInfo
+
+  __register_frame
+  __register_frame_table
+  __deregister_frame
+  __register_frame_info
+  __deregister_frame_info
+  __frame_state_for
+  __register_frame_info_table
+}
diff --git a/libgcc/config/rs6000/libgcc-darwin.10.4.ver b/libgcc/config/rs6000/libgcc-darwin.10.4.ver
deleted file mode 100644
index b050cb8e704..00000000000
--- a/libgcc/config/rs6000/libgcc-darwin.10.4.ver
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright (C) 2005-2021 Free Software Foundation, Inc.
-#
-# This file is part of GCC.
-#
-# GCC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GCC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3.  If not see
-# <http://www.gnu.org/licenses/>.
-__Unwind_Backtrace
-__Unwind_DeleteException
-__Unwind_FindEnclosingFunction
-__Unwind_Find_FDE
-__Unwind_ForcedUnwind
-__Unwind_GetCFA
-__Unwind_GetDataRelBase
-__Unwind_GetGR
-__Unwind_GetIP
-__Unwind_GetLanguageSpecificData
-__Unwind_GetRegionStart
-__Unwind_GetTextRelBase
-__Unwind_RaiseException
-__Unwind_Resume
-__Unwind_Resume_or_Rethrow
-__Unwind_SetGR
-__Unwind_SetIP
-___absvdi2
-___absvsi2
-___addvdi3
-___addvsi3
-___ashldi3
-___ashrdi3
-___clear_cache
-___clzdi2
-___clzsi2
-___cmpdi2
-___ctzdi2
-___ctzsi2
-___deregister_frame
-___deregister_frame_info
-___deregister_frame_info_bases
-___divdi3
-___enable_execute_stack
-___ffsdi2
-___fixdfdi
-___fixsfdi
-___fixtfdi
-___fixunsdfdi
-___fixunsdfsi
-___fixunssfdi
-___fixunssfsi
-___fixunstfdi
-___floatdidf
-___floatdisf
-___floatditf
-___gcc_personality_v0
-___gcc_qadd
-___gcc_qdiv
-___gcc_qmul
-___gcc_qsub
-___lshrdi3
-___moddi3
-___muldi3
-___mulvdi3
-___mulvsi3
-___negdi2
-___negvdi2
-___negvsi2
-___paritydi2
-___paritysi2
-___popcountdi2
-___popcountsi2
-___register_frame
-___register_frame_info
-___register_frame_info_bases
-___register_frame_info_table
-___register_frame_info_table_bases
-___register_frame_table
-___subvdi3
-___subvsi3
-___trampoline_setup
-___ucmpdi2
-___udivdi3
-___udivmoddi4
-___umoddi3
diff --git a/libgcc/config/rs6000/libgcc-darwin.10.5.ver b/libgcc/config/rs6000/libgcc-darwin.10.5.ver
deleted file mode 100644
index dcc548f8a52..00000000000
--- a/libgcc/config/rs6000/libgcc-darwin.10.5.ver
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright (C) 2005-2021 Free Software Foundation, Inc.
-#
-# This file is part of GCC.
-#
-# GCC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GCC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3.  If not see
-# <http://www.gnu.org/licenses/>.
-__Unwind_Backtrace
-__Unwind_DeleteException
-__Unwind_FindEnclosingFunction
-__Unwind_Find_FDE
-__Unwind_ForcedUnwind
-__Unwind_GetCFA
-__Unwind_GetDataRelBase
-__Unwind_GetGR
-__Unwind_GetIP
-__Unwind_GetIPInfo
-__Unwind_GetLanguageSpecificData
-__Unwind_GetRegionStart
-__Unwind_GetTextRelBase
-__Unwind_RaiseException
-__Unwind_Resume
-__Unwind_Resume_or_Rethrow
-__Unwind_SetGR
-__Unwind_SetIP
-___absvdi2
-___absvsi2
-___addvdi3
-___addvsi3
-___ashldi3
-___ashrdi3
-___clear_cache
-___clzdi2
-___clzsi2
-___cmpdi2
-___ctzdi2
-___ctzsi2
-___deregister_frame
-___deregister_frame_info
-___deregister_frame_info_bases
-___divdc3
-___divdi3
-___divsc3
-___divtc3
-___enable_execute_stack
-___ffsdi2
-___fixdfdi
-___fixsfdi
-___fixtfdi
-___fixunsdfdi
-___fixunsdfsi
-___fixunssfdi
-___fixunssfsi
-___fixunstfdi
-___floatdidf
-___floatdisf
-___floatditf
-___floatundidf
-___floatundisf
-___floatunditf
-___gcc_personality_v0
-___gcc_qadd
-___gcc_qdiv
-___gcc_qmul
-___gcc_qsub
-___lshrdi3
-___moddi3
-___muldc3
-___muldi3
-___mulsc3
-___multc3
-___mulvdi3
-___mulvsi3
-___negdi2
-___negvdi2
-___negvsi2
-___paritydi2
-___paritysi2
-___popcountdi2
-___popcountsi2
-___powidf2
-___powisf2
-___powitf2
-___register_frame
-___register_frame_info
-___register_frame_info_bases
-___register_frame_info_table
-___register_frame_info_table_bases
-___register_frame_table
-___subvdi3
-___subvsi3
-___trampoline_setup
-___ucmpdi2
-___udivdi3
-___udivmoddi4
-___umoddi3
diff --git a/libgcc/config/t-darwin-noeh b/libgcc/config/t-darwin-noeh
new file mode 100644
index 00000000000..08d9c1affd3
--- /dev/null
+++ b/libgcc/config/t-darwin-noeh
@@ -0,0 +1,4 @@
+# Most Darwin versions get their unwinder from libSystem.
+# so remove the unwinder from the shared lib.
+# We still need it in the _eh.a for Darwin8/9.
+LIB2ADDEHSHARED =
diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
index bd1e9631c17..1512267b5aa 100644
--- a/libgcc/config/t-slibgcc-darwin
+++ b/libgcc/config/t-slibgcc-darwin
@@ -1,43 +1,34 @@
 # Build a shared libgcc library with the darwin linker.
-SHLIB_SOVERSION = 1
-SHLIB_VERSTRING = -compatibility_version $(SHLIB_SOVERSION) -current_version $(SHLIB_SOVERSION).0
+
+SHLIB_SOVERSION = 1.1
+SHLIB_SO_MINVERSION = 1
+SHLIB_VERSTRING = -compatibility_version $(SHLIB_SO_MINVERSION) -current_version $(SHLIB_SOVERSION)
 SHLIB_EXT = .dylib
+SHLIB_LC = -lSystem
+
+# Shorthand expressions for the LINK below.
 SHLIB_INSTALL_NAME = @shlib_base_name@.$(SHLIB_SOVERSION)$(SHLIB_EXT)
-SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
-SHLIB_SOLINK = @shlib_base_name@.so
 SHLIB_MAP = @shlib_map_file@
-SHLIB_OBJS = @shlib_objs@
 SHLIB_DIR = @multilib_dir@
-SHLIB_LC = -lc
+SHLIB_SONAME = @shlib_base_name@$(SHLIB_EXT)
 
-# Darwin only searches in /usr/lib for shared libraries, not in subdirectories,
-# so the libgcc variants have different names not different locations.
-# Note that this version is used for the loader, not the linker; the linker
-# uses the stub versions named by the versioned members of $(INSTALL_FILES).
+# Darwin only searches in shlib_slibdir for shared libraries, not in
+# subdirectories.  The link builds one architecture slice in its designated
+# subdir.  The code under MULTIBUILDTOP combines these into a single FAT
+# library, that is what we eventually install.
 
 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
 	-install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
 	-single_module -o $(SHLIB_DIR)/$(SHLIB_SONAME) \
 	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
 	$(SHLIB_VERSTRING) \
-	@multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC)
+	@multilib_flags@ @shlib_objs@ $(SHLIB_LC)
 
 SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
 SHLIB_MKMAP_OPTS = -v leading_underscore=1
-SHLIB_VERPFX = $(srcdir)/config/$(cpu_type)/libgcc-darwin
-
-# we're only going to build the stubs if the target slib is /usr/lib
-# there is no other case in which they're useful in a live system.
-ifeq (/usr/lib,$(shlib_slibdir))
-LGCC_STUBS = libgcc_s.10.4.dylib libgcc_s.10.5.dylib
-else
-LGCC_STUBS =
-endif
 
 LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
-LGCC_FILES += $(LGCC_STUBS)
-LEXT_STUBS = libgcc_ext.10.4$(SHLIB_EXT) libgcc_ext.10.5$(SHLIB_EXT)
-LGCC_FILES += $(LEXT_STUBS)
+
 INSTALL_FILES=$(LGCC_FILES)
 
 # we do our own thing
@@ -51,33 +42,6 @@ all: $(INSTALL_FILES)
 install-leaf: install-darwin-libgcc-stubs
 endif
 
-# In order to support -mmacosx-version-min, you need to have multiple
-# different libgcc_s libraries that actually get linked against, one for
-# each system version supported.  They are 'stub' libraries that
-# contain no code, just a list of exported symbols.
-# The actual use of the libraries is controlled by REAL_LIBGCC_SPEC.
-#
-# This assumes each multilib corresponds to a different architecture.
-libgcc_s.%.dylib : all-multi $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT)
-	MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
-	for mlib in $$MLIBS ; do \
-	  $(STRIP) -o $(@)_T$${mlib} \
-	    -s $(SHLIB_VERPFX).$(*).ver -c -u \
-	    ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT)  || exit 1 ; \
-	done
-	$(LIPO) -output $@ -create $(@)_T*
-	rm $(@)_T*
-
-libgcc_ext.%.dylib : all-multi $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT) 
-	MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
-	for mlib in $$MLIBS ; do \
-	  $(STRIP) -o $(@)_T$${mlib} \
-	    -R $(SHLIB_VERPFX).$(*).ver -c -urx \
-	    ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) || exit 1 ; \
-	done
-	$(LIPO) -output $@ -create $(@)_T*
-	rm $(@)_T*
-
 libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
 	MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
 	for mlib in $$MLIBS ; do \
@@ -88,6 +52,8 @@ libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
 	  -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
 	rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
 
+# Install the shared library.
+
 install-darwin-libgcc-stubs :
 	$(mkinstalldirs) $(DESTDIR)$(slibdir)
 	for d in $(INSTALL_FILES) ; do \
@@ -96,10 +62,10 @@ install-darwin-libgcc-stubs :
 
 else
 
-# Do not install shared libraries for any other multilibs.  Unless
-# we're putting them in the gcc directory during a build, for
-# compatibility with the pre-top-level layout.  In that case we
-# need symlinks.
+# Do not install shared libraries for any other multilibs.  Unless we are
+# putting them in the gcc directory during a build, for compatibility with
+# the pre-top-level layout.  In that case we provide symlinks to the FAT lib
+# from the sub-directories.
 
 ifeq ($(enable_shared),yes)
 all: install-darwin-libgcc-links


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-19 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 19:58 [gcc r12-5418] Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556] Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).