[gcc r11-9878] Darwin: Rework handling for unwinder code in libgcc_s and specs [PR80556].
Iain D Sandoe
iains@gcc.gnu.org
Thu Apr 14 05:28:03 GMT 2022
https://gcc.gnu.org/g:94c9c6acdc14de186abe4ea59c54920fbfb60beb
commit r11-9878-g94c9c6acdc14de186abe4ea59c54920fbfb60beb
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sat Sep 18 23:38:53 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).
The replacement libgcc_s.1 forwards the symbols from the new SO.
In order to support DYLD_LIBRARY_PATH on systems (where it works)
we forward the libSystem unwinder symbols from 10.7+ and a
compiler-local version of the libgcc unwinder on earlier.
For macOS 10.4 to 10.6 this is 'bug-compatible' with existing uses.
For 10.7+ the behaviour will now actually be correct.
Backported from commits d4943ce939d9654932624b9ece24c3a474ae4157,
7add7f7bb3d35726a0c45322ffdbbab2bbf6a348,
b504917e43b9a559c9ac779e08784ad412125f2e,
32731fa5b0abf092029b8e2be64319b978bda514,
574c09da48a5a0ff4c32dd4577eaf65bac8c94a0 and
c18ddb05b0391a397f8882fc6a12a1bab7e0df52
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.
(*-*-darwin*): Add logic to build a shared unwinder library for
Darwin8-10. Add shim declaration header to powerpc*-darwin builds.
* 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.
Build a legacy libgcc_s.1 and the supporting pieces (all FAT libs).
* config/t-darwin-ehs: Add dependencies to the shared unwinder
objects. Add dependency on unwind.h.
* config/t-darwin: Reorganise the EH fragments to place them for
inclusion in a shared EH lib. Add libgcc_tm.h to the dependencies
for darwin10-unwind-find-enc-func.
* 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/i386/t-darwin: Build legacy libgcc_s.1.
* config/rs6000/t-darwin: Likewise.
* config/rs6000/t-darwin-ehs: Remove dependency on the powerpc end
file. Add darwin-fallback.o.
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 | 28 ---
gcc/config/i386/darwin32-biarch.h | 26 ---
gcc/config/i386/darwin64-biarch.h | 26 ---
.../gcc.dg/torture/fp-int-convert-timode-3.c | 1 -
.../gcc.dg/torture/fp-int-convert-timode-4.c | 1 -
libgcc/config.host | 18 +-
libgcc/config/darwin-unwind.ver | 30 ++++
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/i386/libgcc-darwin.ver | 4 +
libgcc/config/i386/t-darwin | 6 +
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/rs6000/t-darwin | 3 +
libgcc/config/rs6000/t-darwin-ehs | 3 +
libgcc/config/t-darwin | 24 ++-
libgcc/config/t-darwin-ehs | 7 +
libgcc/config/t-slibgcc-darwin | 199 +++++++++++++--------
24 files changed, 336 insertions(+), 630 deletions(-)
diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c
index 440b8d948dc..e48dd4559eb 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 (strncmp ((*decoded_options)[i].arg, "-exported_symbol", 16) == 0)
+ noexport_p = false;
+ break;
+
default:
break;
}
@@ -470,4 +478,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 b8ec0997017..0dc26a9f252 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -3635,30 +3635,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");
- }
}
bool
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index ee2b38aa5fa..3206b70c7c2 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -373,6 +373,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 \
@@ -399,14 +409,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. */
@@ -451,37 +458,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 8c6e9f786ec..d4a7520240f 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -39,34 +39,6 @@ along with GCC; see the file COPYING3. If not see
#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
- 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. */
-#undef REAL_LIBGCC_SPEC
-#define REAL_LIBGCC_SPEC \
- "%{static-libgcc|static: \
- %: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 }"
-
-/* Size of the Obj-C jump buffer. */
#define OBJC_JBLEN ((TARGET_64BIT) ? ((9 * 2) + 3 + 16) : (18))
#undef TARGET_FPMATH_DEFAULT
diff --git a/gcc/config/i386/darwin32-biarch.h b/gcc/config/i386/darwin32-biarch.h
index 73b83eb650c..c0989068fd9 100644
--- a/gcc/config/i386/darwin32-biarch.h
+++ b/gcc/config/i386/darwin32-biarch.h
@@ -21,32 +21,6 @@ along with GCC; see the file COPYING3. If not see
#undef DARWIN_ARCH_SPEC
#define DARWIN_ARCH_SPEC "%{m64:x86_64;:i386}"
-/* 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 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 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..e543e635801 100644
--- a/gcc/config/i386/darwin64-biarch.h
+++ b/gcc/config/i386/darwin64-biarch.h
@@ -22,32 +22,6 @@ along with GCC; see the file COPYING3. If not see
#undef DARWIN_ARCH_SPEC
#define DARWIN_ARCH_SPEC "%{m32:i386;:x86_64}"
-/* 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 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 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 f9f55e5eea0..f2dc7e266f4 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -214,8 +214,18 @@ 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"
+ # The unwinder is provided by the system shared libraries, do not add one
+ # to the shared libgcc but, for older systems, we build a shared unwinder
+ # separately so that we can construct a libgcc_s.1 to use for binaries
+ # linked against the old libgcc_ext.10.x stubs.
+ case ${host} in
+ *-*-darwin[89]* | *-*-darwin10*)
+ tmake_file="$tmake_file t-darwin-ehs ${cpu_type}/t-darwin-ehs"
+ ;;
+ esac
+ tmake_file="$tmake_file t-slibgcc-darwin"
+ extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
;;
*-*-dragonfly*)
tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip"
@@ -1143,10 +1153,14 @@ powerpc-*-darwin*)
md_unwind_header=rs6000/darwin-unwind.h
;;
esac
+ # We build the darwin10 EH shim for Rosetta (running on x86 machines).
+ tm_file="$tm_file i386/darwin-lib.h"
tmake_file="$tmake_file rs6000/t-ppc64-fp rs6000/t-ibm-ldouble"
extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
;;
powerpc64-*-darwin*)
+ # We build the darwin10 EH shim for Rosetta (running on x86 machines).
+ tm_file="$tm_file i386/darwin-lib.h"
tmake_file="$tmake_file rs6000/t-darwin64 rs6000/t-ibm-ldouble"
extra_parts="$extra_parts crt2.o crt3_2.o libef_ppc.a dw_ppc.o"
;;
diff --git a/libgcc/config/darwin-unwind.ver b/libgcc/config/darwin-unwind.ver
new file mode 100644
index 00000000000..fb74cb2c5d2
--- /dev/null
+++ b/libgcc/config/darwin-unwind.ver
@@ -0,0 +1,30 @@
+# unwinder
+__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_FindEnclosingFunction
+__Unwind_GetCFA
+__Unwind_Backtrace
+__Unwind_Resume_or_Rethrow
+__Unwind_GetIPInfo
+
+___register_frame
+___register_frame_table
+___register_frame_info
+___register_frame_info_bases
+___register_frame_info_table
+___register_frame_info_table_bases
+
+___deregister_frame
+___deregister_frame_info
+___deregister_frame_info_bases
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/i386/libgcc-darwin.ver b/libgcc/config/i386/libgcc-darwin.ver
new file mode 100644
index 00000000000..ff3f8ea24c5
--- /dev/null
+++ b/libgcc/config/i386/libgcc-darwin.ver
@@ -0,0 +1,4 @@
+GCC_4.8.0 {
+ __cpu_model
+ __cpu_indicator_init
+}
diff --git a/libgcc/config/i386/t-darwin b/libgcc/config/i386/t-darwin
index 5f2c69725d0..4c18da1efbf 100644
--- a/libgcc/config/i386/t-darwin
+++ b/libgcc/config/i386/t-darwin
@@ -1,3 +1,9 @@
LIB2_SIDITI_CONV_FUNCS = yes
LIB2ADD = $(srcdir)/config/darwin-64.c
LIB2FUNCS_EXCLUDE = _fixtfdi _fixunstfdi _floatditf _floatunditf
+
+# Extra symbols for this port.
+SHLIB_MAPFILES += $(srcdir)/config/i386/libgcc-darwin.ver
+
+# Build a legacy libgcc_s.1
+BUILD_LIBGCCS1 = YES
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/rs6000/t-darwin b/libgcc/config/rs6000/t-darwin
index 8b513bdb1d7..183d0df92ce 100644
--- a/libgcc/config/rs6000/t-darwin
+++ b/libgcc/config/rs6000/t-darwin
@@ -56,3 +56,6 @@ unwind-dw2_s.o: HOST_LIBGCC2_CFLAGS += -maltivec
unwind-dw2.o: HOST_LIBGCC2_CFLAGS += -maltivec
LIB2ADDEH += $(srcdir)/config/rs6000/darwin-fallback.c
+
+# Build a legacy libgcc_s.1
+BUILD_LIBGCCS1 = YES
diff --git a/libgcc/config/rs6000/t-darwin-ehs b/libgcc/config/rs6000/t-darwin-ehs
new file mode 100644
index 00000000000..581344e862a
--- /dev/null
+++ b/libgcc/config/rs6000/t-darwin-ehs
@@ -0,0 +1,3 @@
+# We need the save_world and anu unwind fallback code for the EH library.
+
+LIBEHSOBJS += darwin-world_s.o darwin-fallback.o
diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin
index 7e791b29f7a..299d26c2c96 100644
--- a/libgcc/config/t-darwin
+++ b/libgcc/config/t-darwin
@@ -11,10 +11,6 @@ crttms.o: $(srcdir)/config/darwin-crt-tm.c
crttme.o: $(srcdir)/config/darwin-crt-tm.c
$(crt_compile) -mmacosx-version-min=10.4 -DEND -c $<
-# Use unwind-dw2-fde-darwin
-LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/config/unwind-dw2-fde-darwin.c \
- $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
-
# Make emutls weak so that we can deal with -static-libgcc, override the
# hidden visibility when this is present in libgcc_eh.
emutls.o: HOST_LIBGCC2_CFLAGS += \
@@ -29,7 +25,7 @@ libemutls_w.a: emutls_s.o
$(RANLIB_FOR_TARGET) $@
# Patch to __Unwind_Find_Enclosing_Function for Darwin10.
-d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c
+d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c libgcc_tm.h
$(crt_compile) -mmacosx-version-min=10.6 -c $<
# Using this crt as a library means that it will not be added to an exe
@@ -37,3 +33,21 @@ d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c
libd10-uwfef.a: d10-uwfef.o
$(AR_CREATE_FOR_TARGET) $@ d10-uwfef.o
$(RANLIB_FOR_TARGET) $@
+
+###### Unwinder #######
+# Most Darwin versions get their unwinder from libSystem; older versions
+# have an installed /usr/lib/libgcc_s.1.dylib.
+# So do not add the unwinder to the shared libgcc.
+LIB2ADDEHSHARED =
+
+# We still need it in the _eh.a for earlier platform versions.
+# Use unwind-dw2-fde-darwin
+LIB2ADDEH = $(srcdir)/unwind-dw2.c \
+ $(srcdir)/config/unwind-dw2-fde-darwin.c \
+ $(srcdir)/unwind-c.c
+
+# Do not build a shared unwind lib by default.
+LIBEHSOBJS=
+
+# Symbols for all the sub-ports.
+SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/libgcc-libsystem.ver
diff --git a/libgcc/config/t-darwin-ehs b/libgcc/config/t-darwin-ehs
new file mode 100644
index 00000000000..df46f8a6529
--- /dev/null
+++ b/libgcc/config/t-darwin-ehs
@@ -0,0 +1,7 @@
+# Build the unwinder separately so that we can construct a replacement for
+# libgcc_s.1 on systems that used the unwinder in libgcc_s.
+
+LIBEHSOBJS = unwind-dw2_s.o unwind-dw2-fde-darwin_s.o unwind-c_s.o
+
+unwind-dw2_s.o: gthr-default.h md-unwind-support.h unwind.h
+$(LIBEHSOBJS): libgcc_tm.h
diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
index 9970d003436..a8f69666a82 100644
--- a/libgcc/config/t-slibgcc-darwin
+++ b/libgcc/config/t-slibgcc-darwin
@@ -1,50 +1,86 @@
# 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
+SHLIB_INSTALL_DIR = $(slibdir)
+
+SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
+SHLIB_MKMAP_OPTS = -v leading_underscore=1
+
+# Shorthand expressions for the LINK below, these are substituted in the
+# link expression.
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) -dynamiclib -nodefaultlibs \
- -install_name @shlib_slibdir@/$(SHLIB_INSTALL_NAME) \
+SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
+ -install_name $(SHLIB_INSTALL_DIR)/$(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_MAPFILES = libgcc-std.ver $(srcdir)/config/libgcc-libsystem.ver
-SHLIB_VERPFX = $(srcdir)/config/$(cpu_type)/libgcc-darwin
+# we do our own thing
+SHLIB_INSTALL =
+
+LGCC_FILES = libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+
+ifeq ($(BUILD_LIBGCCS1),YES)
+
+# We are going to build a libgcc_s.1.dylib so that distributions can
+# install it for compatibility with binaries linked against the old
+# libgcc_ext.10.x.dylib stubs.
+
+# For systems after macOS 10.7 we can forward the correct unwinder symbols
+# from libSystem.
+
+# For older systems we have to forward an entire library (since they cannot
+# selectively forward symbols, which means that we cannot forward the unwinder
+# in /usr/lib/libgcc_s.1.dylib). We also cannot forward the entire library
+# since that creates a self-referencing loop when DYLD_LIBRARY_PATH is used.
+# To provide the unwinder symbols in this case, we build the unwinder into a
+# separate shared lib (libgcc_ehs) and forward that.
+
+# These targets are local to this make fragment, which means that they do not
+# get the substitutions seen in SHLIB_LINK.
+
+ifneq ($(LIBEHSOBJS),)
+
+EHS_INSTNAME = libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+
+# multilib build for a shared EH lib.
+
+libgcc_ehs$(SHLIB_EXT): $(LIBEHSOBJS) $(extra-parts)
+ mkdir -p $(MULTIDIR)
+ $(CC) $(LIBGCC2_CFLAGS) $(LDFLAGS) -dynamiclib -nodefaultlibs \
+ -install_name $(SHLIB_INSTALL_DIR)/$(EHS_INSTNAME) \
+ -o $(MULTIDIR)/libgcc_ehs$(SHLIB_EXT) $(SHLIB_VERSTRING) \
+ $(LIBEHSOBJS) $(SHLIB_LC)
+
+all: libgcc_ehs$(SHLIB_EXT)
+
+LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
-# 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)
+# Provide libgcc_s.1 for backwards compatibility.
+LGCC_FILES += libgcc_s.1.dylib
-# we do our own thing
-SHLIB_INSTALL =
+endif
+
+INSTALL_FILES=$(LGCC_FILES)
-# For the toplevel multilib, build a fat archive including all the multilibs.
+# For the toplevel multilib, build FAT dylibs including all the multilibs.
ifeq ($(MULTIBUILDTOP),)
ifeq ($(enable_shared),yes)
@@ -52,65 +88,86 @@ 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)
+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 \
- $(STRIP) -o $(@)_T$${mlib} \
- -s $(SHLIB_VERPFX).$(*).ver -c -u \
- ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) || exit 1 ; \
+ cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
+ ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
done
- $(LIPO) -output $@ -create $(@)_T*
- rm $(@)_T*
+ $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
+ -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+ rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+
+ifeq ($(BUILD_LIBGCCS1),YES)
+ifneq ($(LIBEHSOBJS),)
-libgcc_ext.%.dylib : all-multi $(SHLIB_VERPFX).%.ver libgcc_s$(SHLIB_EXT)
+libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_ehs$(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 ; \
+ cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
+ ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
done
- $(LIPO) -output $@ -create $(@)_T*
- rm $(@)_T*
+ $(LIPO) -output libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
+ -create libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+ rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
-libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT): all-multi libgcc_s$(SHLIB_EXT)
+
+libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
+ libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
for mlib in $$MLIBS ; do \
cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+ cp ../$${mlib}/libgcc/$${mlib}/libgcc_ehs$(SHLIB_EXT) \
+ ./libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+ arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
+ $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
+ -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
+ -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+ -Wl,-reexport_library,libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+ -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
+ -compatibility_version 1 -current_version 1 ; \
done
- $(LIPO) -output libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT) \
- -create libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+ $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+ rm libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+
+else
+
+libgcc_s.1.dylib: all-multi libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)
+ MLIBS=`$(CC) --print-multi-lib | sed -e 's/;.*$$//'` ; \
+ for mlib in $$MLIBS ; do \
+ cp ../$${mlib}/libgcc/$${mlib}/libgcc_s$(SHLIB_EXT) \
+ ./libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} || exit 1 ; \
+ arch=`$(LIPO) -info libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} | sed -e 's/.*:\ //'` ; \
+ $(CC) -arch $${arch} -nodefaultlibs -dynamiclib \
+ -o libgcc_s.1$(SHLIB_EXT)_T_$${mlib} \
+ -Wl,-reexport_library,libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T_$${mlib} \
+ -lSystem \
+ -Wl,-reexported_symbols_list,$(srcdir)/config/darwin-unwind.ver \
+ -install_name $(SHLIB_INSTALL_DIR)/libgcc_s.1.dylib \
+ -compatibility_version 1 -current_version 1 ; \
+ done
+ $(LIPO) -output libgcc_s.1$(SHLIB_EXT) -create libgcc_s.1$(SHLIB_EXT)_T*
+ rm libgcc_s.$(SHLIB_SOVERSION)$(SHLIB_EXT)_T*
+
+endif
+endif
+
+# Install the shared libraries.
install-darwin-libgcc-stubs :
$(mkinstalldirs) $(DESTDIR)$(slibdir)
for d in $(INSTALL_FILES) ; do \
$(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
done
- if [ -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib ]; then \
- rm -f $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib; \
- else true; fi
- $(LN_S) libgcc_s.1.dylib \
- $(DESTDIR)$(slibdir)/libgcc_s_ppc64.1.dylib
- if [ -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib ]; then \
- rm -f $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib; \
- else true; fi
- $(LN_S) libgcc_s.1.dylib \
- $(DESTDIR)$(slibdir)/libgcc_s_x86_64.1.dylib
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 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
+# multilib sub-directories.
ifeq ($(enable_shared),yes)
all: install-darwin-libgcc-links
@@ -123,12 +180,4 @@ install-darwin-libgcc-links:
$(LN_S) ../$$file $(gcc_objdir)$(MULTISUBDIR)/; \
done
- rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
- $(LN_S) libgcc_s.1.dylib \
- $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_x86_64.1.dylib
-
- rm -f $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
- $(LN_S) libgcc_s.1.dylib \
- $(gcc_objdir)$(MULTISUBDIR)/libgcc_s_ppc64.1.dylib
-
endif
More information about the Gcc-cvs
mailing list