@@ -314,13 +314,17 @@ extern GTY(()) int darwin_ms_struct;
# define DARWIN_RPATH_LINK \
"%{!r:%{!nostdlib:%{!nodefaultrpaths:%(darwin_rpaths)}}}"
# define DARWIN_SHARED_LIBGCC "-lgcc_s.1.1"
+# define DARWIN_SHARED_WEAK_ADDS " "
#else
# define DARWIN_RPATH_LINK ""
# define DARWIN_SHARED_LIBGCC \
-"%:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1) \
- %:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w) "
+"%:version-compare(!> 10.11 mmacosx-version-min= -lgcc_s.1.1)"
+# define DARWIN_SHARED_WEAK_ADDS \
+"%{%:version-compare(>= 10.11 mmacosx-version-min= -lemutls_w): \
+ " DARWIN_HEAP_T_LIB "}"
#endif
+
/* We might elect to add a path even when this compiler does not use embedded
run paths, so that we can use libraries from an alternate compiler that is
using embedded runpaths. */
@@ -398,7 +402,9 @@ extern GTY(()) int darwin_ms_struct;
%{e*} %{r} \
%{o*}%{!o:-o a.out} \
%{!r:%{!nostdlib:%{!nostartfiles:%S}}} \
- %{L*} %(link_libgcc) %o \
+ %{L*} %(link_libgcc) \
+ %{!r:%{!nostdlib:%{!nodefaultlibs: " DARWIN_WEAK_CRTS "}}} \
+ %o \
%{!r:%{!nostdlib:%{!nodefaultlibs:\
%{fprofile-arcs|fprofile-generate*|coverage:-lgcov} \
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1): \
@@ -412,15 +418,15 @@ 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) \
+ %{!nodefaultexport: \
+ %{%:version-compare(>= 10.11 asm_macosx_version_min= -U): \
+ ___emutls_get_address -exported_symbol ___emutls_get_address \
+ -U ___emutls_register_common \
+ -exported_symbol ___emutls_register_common \
+ -U ___gcc_nested_func_ptr_created \
+ -exported_symbol ___gcc_nested_func_ptr_created \
+ -U ___gcc_nested_func_ptr_deleted \
+ -exported_symbol ___gcc_nested_func_ptr_deleted \
}} \
}}}\
%{!r:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} "\
@@ -542,16 +548,21 @@ extern GTY(()) int darwin_ms_struct;
#undef REAL_LIBGCC_SPEC
#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); \
+ %:version-compare(!> 10.6 mmacosx-version-min= -lgcc_eh); \
shared-libgcc|fexceptions|fobjc-exceptions|fgnu-runtime: \
" DARWIN_SHARED_LIBGCC " \
%: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 \
+ %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lgcc_s.10.5) \
} -lgcc "
+#define DARWIN_WEAK_CRTS \
+"%{static-libgcc|static: \
+ %{%:version-compare(>= 10.6 mmacosx-version-min= -lemutls_w): \
+ " DARWIN_HEAP_T_LIB "} ; \
+ : -lemutls_w " DARWIN_HEAP_T_LIB " \
+ }"
+
/* We specify crt0.o as -lcrt0.o so that ld will search the library path. */
#undef STARTFILE_SPEC
@@ -119,6 +119,8 @@ along with GCC; see the file COPYING3. If not see
/* We default to x86_64 for single-arch builds, bi-arch overrides. */
#define DARWIN_ARCH_SPEC "x86_64"
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
+#undef DARWIN_HEAP_T_LIB
+#define DARWIN_HEAP_T_LIB " -lheapt_w "
#endif
#undef SUBTARGET_EXTRA_SPECS
@@ -27,6 +27,9 @@ along with GCC; see the file COPYING3. If not see
#undef DARWIN_SUBARCH_SPEC
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
+#undef DARWIN_HEAP_T_LIB
+#define DARWIN_HEAP_T_LIB " %{m64:-lheapt_w}"
+
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
@@ -28,6 +28,9 @@ along with GCC; see the file COPYING3. If not see
#undef DARWIN_SUBARCH_SPEC
#define DARWIN_SUBARCH_SPEC DARWIN_ARCH_SPEC
+#undef DARWIN_HEAP_T_LIB
+#define DARWIN_HEAP_T_LIB "%{!m32:-lheapt_w}"
+
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
DARWIN_EXTRA_SPECS \
@@ -113,6 +113,9 @@
-lSystem \
}"
+#undef DARWIN_HEAP_T_LIB
+#define DARWIN_HEAP_T_LIB " "
+
/* We want -fPIC by default, unless we're using -static to compile for
the kernel or some such. The "-faltivec" option should have been
called "-maltivec" all along. */
@@ -715,12 +715,15 @@ hppa*-*-netbsd*)
i[34567]86-*-darwin*)
tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi"
tm_file="$tm_file i386/darwin-lib.h"
- extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o"
+ extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
+ tmake_file="${tmake_file} i386/t-heap-trampoline"
;;
x86_64-*-darwin*)
tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-msabi"
tm_file="$tm_file i386/darwin-lib.h"
- extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o"
+ extra_parts="$extra_parts crtfastmath.o libheapt_w.a"
tmake_file="${tmake_file} i386/t-heap-trampoline"
;;
i[34567]86-*-elfiamcu)
@@ -15,6 +15,12 @@
#include <pthread.h>
#endif
+/* HEAP_T_ATTR is provided to allow targets to build the exported functions
+ as weak definitions. */
+#ifndef HEAP_T_ATTR
+# define HEAP_T_ATTR
+#endif
+
void *allocate_trampoline_page (void);
int get_trampolines_per_page (void);
struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
@@ -107,6 +113,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent)
return p;
}
+HEAP_T_ATTR
void
__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
{
@@ -154,6 +161,7 @@ __gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
*dst = &trampoline->insns;
}
+HEAP_T_ATTR
void
__gcc_nested_func_ptr_deleted (void)
{
@@ -15,6 +15,12 @@
#include <pthread.h>
#endif
+/* HEAP_T_ATTR is provided to allow targets to build the exported functions
+ as weak definitions. */
+#ifndef HEAP_T_ATTR
+# define HEAP_T_ATTR
+#endif
+
void *allocate_trampoline_page (void);
int get_trampolines_per_page (void);
struct tramp_ctrl_data *allocate_tramp_ctrl (struct tramp_ctrl_data *parent);
@@ -107,6 +113,7 @@ allocate_tramp_ctrl (struct tramp_ctrl_data *parent)
return p;
}
+HEAP_T_ATTR
void
__gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
{
@@ -154,6 +161,7 @@ __gcc_nested_func_ptr_created (void *chain, void *func, void **dst)
*dst = &trampoline->insns;
}
+HEAP_T_ATTR
void
__gcc_nested_func_ptr_deleted (void)
{
@@ -51,5 +51,18 @@ LIB2ADDEH = $(srcdir)/unwind-dw2.c \
# Do not build a shared unwind lib by default.
LIBEHSOBJS=
+# Make heap trampoline helpers weak definitions so that we can merge them from
+# multiple DSOs.
+heap-trampoline.o: HOST_LIBGCC2_CFLAGS += \
+ -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))'
+heap-trampoline_s.o: HOST_LIBGCC2_CFLAGS += \
+ -DHEAP_T_ATTR='__attribute__((__weak__,__visibility__("default")))'
+
+# Make a heap trampoline support CRT so that it can be linked optionally, use
+# the shared version so that we can link with DSOs.
+libheapt_w.a: heap-trampoline_s.o
+ $(AR_CREATE_FOR_TARGET) $@ $<
+ $(RANLIB_FOR_TARGET) $@
+
# Symbols for all the sub-ports.
SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/libgcc-libsystem.ver