[PATCH] PR go/55201: Link libgo against libatomic

Andreas Schwab schwab@linux-m68k.org
Mon Dec 17 22:26:00 GMT 2012


Since libgo uses 8-byte atomic operations it needs to link against
libatomic.  Tested on m68k-linux and powerpc-linux.

Andreas.

	PR go/55201
	* Makefile.def (all-target-libgo): Depend on all-target-libatomic.
	* Makefile.in: Regenerate.

testsuite/:
	* lib/go.exp (go_link_flags): Add libatomic location to flags and
	ld_library_path.

diff --git a/Makefile.def b/Makefile.def
index 8d8af23..e25799a 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -497,6 +497,7 @@ dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
 dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
 dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
+dependencies = { module=all-target-libgo; on=all-target-libatomic; };
 dependencies = { module=configure-target-libjava; on=configure-target-zlib; };
 dependencies = { module=configure-target-libjava; on=configure-target-boehm-gc; };
 dependencies = { module=configure-target-libjava; on=configure-target-libffi; };
diff --git a/Makefile.in b/Makefile.in
index a9d2890..a0281e9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -46154,6 +46154,7 @@ configure-target-libgo: maybe-configure-target-libffi
 configure-target-libgo: maybe-all-target-libstdc++-v3
 all-target-libgo: maybe-all-target-libbacktrace
 all-target-libgo: maybe-all-target-libffi
+all-target-libgo: maybe-all-target-libatomic
 configure-target-libjava: maybe-configure-target-zlib
 configure-target-libjava: maybe-configure-target-boehm-gc
 configure-target-libjava: maybe-configure-target-libffi
diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c
index 20372f0..c22ad6c 100644
--- a/gcc/go/gospec.c
+++ b/gcc/go/gospec.c
@@ -45,6 +45,9 @@ along with GCC; see the file COPYING3.  If not see
 #define THREAD_LIBRARY "pthread"
 #define THREAD_LIBRARY_PROFILE THREAD_LIBRARY
 
+#define LIBATOMIC "atomic"
+#define LIBATOMIC_PROFILE LIBATOMIC
+
 #define LIBGO "go"
 #define LIBGO_PROFILE LIBGO
 #define LIBGOBEGIN "gobegin"
@@ -336,6 +339,11 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
       added_libraries++;
       j++;
 
+      generate_option (OPT_l, saw_profile_flag ? LIBATOMIC_PROFILE : LIBATOMIC,
+		       1, CL_DRIVER, &new_decoded_options[j]);
+      added_libraries++;
+      j++;
+
 #ifdef HAVE_LD_STATIC_DYNAMIC
       if (library > 1 && !static_link)
 	{
diff --git a/gcc/testsuite/lib/go.exp b/gcc/testsuite/lib/go.exp
index 8c908a5..8eea9fa 100644
--- a/gcc/testsuite/lib/go.exp
+++ b/gcc/testsuite/lib/go.exp
@@ -111,6 +111,11 @@ proc go_link_flags { paths } {
           append flags "-L${gccpath}/libgo/.libs "
           append ld_library_path ":${gccpath}/libgo/.libs"
       }
+      if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] \
+	   || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
+          append flags "-L${gccpath}/libatomic/.libs "
+          append ld_library_path ":${gccpath}/libatomic/.libs"
+      }
       if [file exists "${gccpath}/libiberty/libiberty.a"] {
           append flags "-L${gccpath}/libiberty "
       }
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index fe0f205..a7ac379 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -1909,6 +1909,7 @@ libgo_la_LDFLAGS = \
 
 libgo_la_LIBADD = \
 	$(libgo_go_objs) ../libbacktrace/libbacktrace.la \
+	../libatomic/libatomic.la \
 	$(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
 
 libgobegin_a_SOURCES = \
@@ -1948,7 +1949,7 @@ GOTESTFLAGS =
 
 # Check a package.
 CHECK = \
-	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
+	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs -L `${PWD_COMMAND}`/../libatomic -L `${PWD_COMMAND}`/../libatomic/.libs"; \
 	export GC; \
 	GOLIBS="$(MATH_LIBS) $(NET_LIBS)"; \
 	export GOLIBS; \
@@ -1957,7 +1958,7 @@ CHECK = \
 	MAKE="$(MAKE)"; \
 	export MAKE; \
 	libgccdir=`${GOC} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
-	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
+	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:`${PWD_COMMAND}`/../libatomic/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
 	LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
 	export LD_LIBRARY_PATH; \
 	$(MKDIR_P) $(@D); \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 9b8ea1a..31e38ba 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -175,9 +175,9 @@ am__DEPENDENCIES_2 = bufio.lo bytes.lo bytes/index.lo crypto.lo \
 	testing/iotest.lo testing/quick.lo unicode/utf16.lo \
 	unicode/utf8.lo
 libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \
-	../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_1) \
+	../libbacktrace/libbacktrace.la ../libatomic/libatomic.la \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1)
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 @LIBGO_IS_LINUX_FALSE@am__objects_1 = lock_sema.lo thread-sema.lo
 @LIBGO_IS_LINUX_TRUE@am__objects_1 = lock_futex.lo thread-linux.lo
 @HAVE_SYS_MMAN_H_FALSE@am__objects_2 = mem_posix_memalign.lo
@@ -2037,6 +2037,7 @@ libgo_la_LDFLAGS = \
 
 libgo_la_LIBADD = \
 	$(libgo_go_objs) ../libbacktrace/libbacktrace.la \
+	../libatomic/libatomic.la \
 	$(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
 
 libgobegin_a_SOURCES = \
@@ -2071,7 +2072,7 @@ GOTESTFLAGS =
 
 # Check a package.
 CHECK = \
-	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
+	GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs -L `${PWD_COMMAND}`/../libatomic -L `${PWD_COMMAND}`/../libatomic/.libs"; \
 	export GC; \
 	GOLIBS="$(MATH_LIBS) $(NET_LIBS)"; \
 	export GOLIBS; \
@@ -2080,7 +2081,7 @@ CHECK = \
 	MAKE="$(MAKE)"; \
 	export MAKE; \
 	libgccdir=`${GOC} -print-libgcc-file-name | sed -e 's|/[^/]*$$||'`; \
-	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
+	LD_LIBRARY_PATH="`${PWD_COMMAND}`/.libs:`${PWD_COMMAND}`/../libatomic/.libs:$${libgccdir}:${LD_LIBRARY_PATH}"; \
 	LD_LIBRARY_PATH=`echo $${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \
 	export LD_LIBRARY_PATH; \
 	$(MKDIR_P) $(@D); \
-- 
1.8.0.2


-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gcc-patches mailing list