summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iains@gcc.gnu.org>2011-11-22 13:51:07 +0000
committerIain Sandoe <iains@gcc.gnu.org>2011-11-22 13:51:07 +0000
commite2362f5de06d4ba52f86421b0869b0ab04f89315 (patch)
treecb37d55577828a0e4d3083598574060fadac99a9
parent018076e705f8783a471dc36cef10b60d30d95ebf (diff)
downloadgcc-e2362f5de06d4ba52f86421b0869b0ab04f89315.tar.gz
darwin.h (ENDFILE_SPEC): New.
gcc: * config/darwin.h (ENDFILE_SPEC): New. (DARWIN_CRT1_SPEC): Add crttms.o. (STARTFILE_SPEC): Likewise for dynamic libs and bundles. * config/i386.h (ENDFILE_SPEC): Amend to include crttme.o. libgcc: * config/darwin-crt-tm.c: New file. * config.host (darwin): Build crttms.o crttme.o to provide startup and shutdown for tm clones. * config/t-darwin (crttms.o): New build rule. (crttme.o): Likewise. From-SVN: r181616
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/darwin.h13
-rw-r--r--gcc/config/i386/darwin.h3
-rw-r--r--libgcc/ChangeLog8
-rw-r--r--libgcc/config.host2
-rw-r--r--libgcc/config/darwin-crt-tm.c83
-rw-r--r--libgcc/config/t-darwin6
7 files changed, 113 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b5a855a5a5c..28d5deb2a85 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-22 Iain Sandoe <iains@gcc.gnu.org>
+
+ * config/darwin.h (ENDFILE_SPEC): New.
+ (DARWIN_CRT1_SPEC): Add crttms.o.
+ (STARTFILE_SPEC): Likewise for dynamic libs and bundles.
+ * config/i386.h (ENDFILE_SPEC): Amend to include crttme.o.
+
2011-11-22 Michael Matz <matz@suse.de>
PR c++/51264
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index efff4c9a435..29a24ddc6d6 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -359,8 +359,8 @@ extern GTY(()) int darwin_ms_struct;
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
- "%{Zdynamiclib: %(darwin_dylib1) } \
- %{!Zdynamiclib:%{Zbundle:%{!static:-lbundle1.o}} \
+ "%{Zdynamiclib: %(darwin_dylib1) %{fgnu-tm: -lcrttms.o}} \
+ %{!Zdynamiclib:%{Zbundle:%{!static:-lbundle1.o %{fgnu-tm: -lcrttms.o}}} \
%{!Zbundle:%{pg:%{static:-lgcrt0.o} \
%{!static:%{object:-lgcrt0.o} \
%{!object:%{preload:-lgcrt0.o} \
@@ -372,10 +372,8 @@ extern GTY(()) int darwin_ms_struct;
%(darwin_crt2)}}}}}} \
%{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
-/* The native Darwin linker doesn't necessarily place files in the order
- that they're specified on the link line. Thus, it is pointless
- to put anything in ENDFILE_SPEC. */
-/* #define ENDFILE_SPEC "" */
+/* We want a destructor last in the list. */
+#define ENDFILE_SPEC "%{fgnu-tm: -lcrttme.o}"
#define DARWIN_EXTRA_SPECS \
{ "darwin_crt1", DARWIN_CRT1_SPEC }, \
@@ -388,7 +386,8 @@ extern GTY(()) int darwin_ms_struct;
#define DARWIN_CRT1_SPEC \
"%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o) \
- %:version-compare(>= 10.5 mmacosx-version-min= -lcrt1.10.5.o)"
+ %:version-compare(>= 10.5 mmacosx-version-min= -lcrt1.10.5.o) \
+ %{fgnu-tm: -lcrttms.o}"
/* Default Darwin ASM_SPEC, very simple. */
#define ASM_SPEC "-arch %(darwin_arch) \
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index 705fe98c613..83da2932512 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -132,7 +132,8 @@ extern int darwin_emit_branch_islands;
"%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
- %{mpc80:crtprec80.o%s}"
+ %{mpc80:crtprec80.o%s} \
+ %{fgnu-tm: -lcrttme.o}"
#undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index b1ad4781388..305e8ad3c3c 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-22 Iain Sandoe <iains@gcc.gnu.org>
+
+ * config/darwin-crt-tm.c: New file.
+ * config.host (darwin): Build crttms.o crttme.o to provide
+ startup and shutdown for tm clones.
+ * config/t-darwin (crttms.o): New build rule.
+ (crttme.o): Likewise.
+
2011-11-21 Hans-Peter Nilsson <hp@axis.com>
* Makefile.in ($(srcdir)/emutls.c): Explain why it's in LIB2ADDEH
diff --git a/libgcc/config.host b/libgcc/config.host
index caf5cbcf210..447c41c46a0 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -170,7 +170,7 @@ 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
+ extra_parts="crt3.o crttms.o crttme.o"
;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
diff --git a/libgcc/config/darwin-crt-tm.c b/libgcc/config/darwin-crt-tm.c
new file mode 100644
index 00000000000..cfb66147662
--- /dev/null
+++ b/libgcc/config/darwin-crt-tm.c
@@ -0,0 +1,83 @@
+/* Provide the runtime intrastructure the transactional memory lib.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+ Contributed by Iain Sandoe <iains@gcc.gnu.org>
+
+ 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/>. */
+
+#include <mach-o/dyld.h>
+
+/* not listed in mach-o/dyld.h for some reason. */
+extern char * getsectdata (const char*,const char*,unsigned long*);
+
+#define WEAK __attribute__((weak))
+
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
+
+extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
+extern void _ITM_deregisterTMCloneTable (void *) WEAK;
+
+#ifdef START
+
+void __doTMRegistrations (void) __attribute__ ((constructor));
+
+void __doTMRegistrations (void)
+{
+ char * tm_clone_table_sect_data;
+ unsigned long tmct_siz;
+
+ tm_clone_table_sect_data = getsectdata ("__DATA",
+ "__tm_clone_table",
+ &tmct_siz);
+ tmct_siz /= (sizeof (size_t) * 2);
+ if (_ITM_registerTMCloneTable != NULL
+ && tm_clone_table_sect_data != NULL
+ && tmct_siz > 0)
+ _ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
+}
+
+#endif
+
+#ifdef END
+
+void __doTMdeRegistrations (void) __attribute__ ((destructor));
+
+void __doTMdeRegistrations (void)
+{
+ char * tm_clone_table_sect_data;
+ unsigned long tmct_siz;
+
+ tm_clone_table_sect_data = getsectdata ("__DATA",
+ "__tm_clone_table",
+ &tmct_siz);
+
+ if (_ITM_deregisterTMCloneTable != NULL
+ && tm_clone_table_sect_data != NULL
+ && tmct_siz > 0)
+ _ITM_deregisterTMCloneTable (tm_clone_table_sect_data);
+
+}
+
+/* Provide dumy funcs for the weak ones - needed on most Darwin versions
+ for now. */
+
+void _ITM_registerTMCloneTable (void *n ATTRIBUTE_UNUSED, size_t s ATTRIBUTE_UNUSED)
+{}
+void _ITM_deregisterTMCloneTable (void *n ATTRIBUTE_UNUSED)
+{}
+#endif
diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin
index e32127e9d8a..3365f010225 100644
--- a/libgcc/config/t-darwin
+++ b/libgcc/config/t-darwin
@@ -3,6 +3,12 @@ crt3.o: $(srcdir)/config/darwin-crt3.c
$(crt_compile) \
-fno-tree-dominator-opts $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -c $<
+crttms.o: $(srcdir)/config/darwin-crt-tm.c
+ $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -DSTART -c $<
+
+crttme.o: $(srcdir)/config/darwin-crt-tm.c
+ $(crt_compile) $(DARWIN_EXTRA_CRT_BUILD_CFLAGS) -DEND -c $<
+
# -pipe because there's an assembler bug, 4077127, which causes
# it to not properly process the first # directive, causing temporary
# file names to appear in stabs, causing the bootstrap to fail. Using -pipe