diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2021-09-20 18:41:56 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2021-11-19 19:58:11 +0000 |
commit | d4943ce939d9654932624b9ece24c3a474ae4157 (patch) | |
tree | ee14e5881aff9ad57a3b9c861536949f8d4194a2 /gcc | |
parent | b9873b4e2c9a9955789318f4d550147ef9405b07 (diff) | |
download | gcc-d4943ce939d9654932624b9ece24c3a474ae4157.zip gcc-d4943ce939d9654932624b9ece24c3a474ae4157.tar.gz gcc-d4943ce939d9654932624b9ece24c3a474ae4157.tar.bz2 |
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/darwin-driver.c | 18 | ||||
-rw-r--r-- | gcc/config/darwin.c | 24 | ||||
-rw-r--r-- | gcc/config/darwin.h | 98 | ||||
-rw-r--r-- | gcc/config/darwin.opt | 4 | ||||
-rw-r--r-- | gcc/config/i386/darwin.h | 31 | ||||
-rw-r--r-- | gcc/config/i386/darwin32-biarch.h | 13 | ||||
-rw-r--r-- | gcc/config/i386/darwin64-biarch.h | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-3.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/fp-int-convert-timode-4.c | 1 |
9 files changed, 87 insertions, 116 deletions
diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c index 4f0c6ba..7fa80ab 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 204114c..c5ba792 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 7ed01ef..8d8d402 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 d1d1f81..48d3aa9 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 741f29a..e946a8b 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 5470edf..ee15082 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 f5bc3d6..d02f7fc 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 1070230..707d539 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 3facf32..09600f9 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> |