Patchwork PR go/55201: Link libgo against libatomic

login
register
mail settings
Submitter Andreas Schwab
Date Dec. 17, 2012, 10:26 p.m.
Message ID <m2wqwg5n91.fsf@igel.home>
Download mbox | patch
Permalink /patch/207005/
State New
Headers show

Comments

Andreas Schwab - Dec. 17, 2012, 10:26 p.m.
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.
Ian Taylor - Dec. 18, 2012, 2:28 p.m.
On Mon, Dec 17, 2012 at 2:26 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> 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.

Thanks.

Committed to mainline.

Ian
Matthias Klose - Dec. 18, 2012, 5:11 p.m.
Am 18.12.2012 15:28, schrieb Ian Lance Taylor:
> On Mon, Dec 17, 2012 at 2:26 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>> 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.
> 
> Thanks.
> 
> Committed to mainline.

this seems to break make install, at least for a multilib enabled build.

/usr/bin/ld: cannot find -latomic
collect2: error: ld returned 1 exit status
libtool: install: error: relink `libgo.la' with the above command before
installing it
make[10]: *** [install-toolexeclibLTLIBRARIES] Error 1
make[10]: Leaving directory
`/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo'
test -z "/usr/lib/../lib32" || /bin/mkdir -p "/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32"
 /usr/bin/install -c -m 644  libgobegin.a '/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32'
 ( cd '/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32' && ranlib libgobegin.a )
test -z "/usr/lib/../lib32" || /bin/mkdir -p "/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32"
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libgo.la '/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32'
libtool: install: warning: relinking `libgo.la'
libtool: install: (cd /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo; /bin/bash /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo/libtool  --tag CC --mode=relink /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/./gcc/xgcc -B/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/./gcc/ -B/usr/x86_64-linux-gnu/bin/ -B/usr/x86_64-linux-gnu/lib/ -isystem /usr/x86_64-linux-gnu/include -isystem /usr/x86_64-linux-gnu/sys-include -isystem /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/sys-include -m32 -fexceptions -fplan9-extensions -fsplit-stack -Wall -Wextra -Wwrite-strings -Wcast-qual -Werror -minline-all-stringops -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I ../../../../src/libgo/../libgcc -I ../../../../src/libgo/../libbacktrace -I ../../../gcc/include -g -O2 -m32 -version-info 3:1:0 -pthread -XCClinker -fsplit-stack -m32 -o libgo.la -rpath /usr/lib/../lib32 go-append.lo go-assert.lo go-assert-interface.lo go-byte-array-to-string.lo go-breakpoint.lo go-caller.lo go-callers.lo go-can-convert-interface.lo go-cgo.lo go-check-interface.lo go-construct-map.lo go-convert-interface.lo go-copy.lo go-defer.lo go-deferred-recover.lo go-eface-compare.lo go-eface-val-compare.lo go-fieldtrack.lo go-getgoroot.lo go-int-array-to-string.lo go-int-to-string.lo go-interface-compare.lo go-interface-eface-compare.lo go-interface-val-compare.lo go-make-slice.lo go-map-delete.lo go-map-index.lo go-map-len.lo go-map-range.lo go-matherr.lo go-memcmp.lo go-nanotime.lo go-now.lo go-new-map.lo go-new.lo go-nosys.lo go-panic.lo go-print.lo go-recover.lo go-reflect-call.lo go-reflect-map.lo go-rune.lo go-runtime-error.lo go-setenv.lo go-signal.lo go-strcmp.lo go-string-to-byte-array.lo go-string-to-int-array.lo go-strplus.lo go-strslice.lo go-traceback.lo go-trampoline.lo go-type-complex.lo go-type-eface.lo go-type-error.lo go-type-float.lo go-type-identity.lo go-type-interface.lo go-type-string.lo go-typedesc-equal.lo go-typestring.lo go-unsafe-new.lo go-unsafe-newarray.lo go-unsafe-pointer.lo go-unwind.lo chan.lo cpuprof.lo lfstack.lo lock_futex.lo thread-linux.lo mcache.lo mcentral.lo mem.lo mfinal.lo mfixalloc.lo mgc0.lo mheap.lo msize.lo panic.lo parfor.lo print.lo proc.lo runtime.lo signal_unix.lo thread.lo yield.lo iface.lo malloc.lo map.lo mprof.lo reflect.lo runtime1.lo sema.lo sigqueue.lo string.lo time.lo getncpu-linux.lo bufio.lo bytes.lo bytes/index.lo crypto.lo errors.lo expvar.lo flag.lo fmt.lo hash.lo html.lo image.lo io.lo log.lo math.lo mime.lo net.lo os.lo path.lo reflect-go.lo regexp.lo runtime-go.lo sort.lo strconv.lo strings.lo sync.lo syscall.lo syscall/errno.lo syscall/signame.lo syscall/wait.lo testing.lo time-go.lo unicode.lo archive/tar.lo archive/zip.lo compress/bzip2.lo compress/flate.lo compress/gzip.lo compress/lzw.lo compress/zlib.lo container/heap.lo container/list.lo container/ring.lo crypto/aes.lo crypto/cipher.lo crypto/des.lo crypto/dsa.lo crypto/ecdsa.lo crypto/elliptic.lo crypto/hmac.lo crypto/md5.lo crypto/rand.lo crypto/rc4.lo crypto/rsa.lo crypto/sha1.lo crypto/sha256.lo crypto/sha512.lo crypto/subtle.lo crypto/tls.lo crypto/x509.lo crypto/x509/pkix.lo database/sql.lo database/sql/driver.lo debug/dwarf.lo debug/elf.lo debug/gosym.lo debug/macho.lo debug/pe.lo encoding/ascii85.lo encoding/asn1.lo encoding/base32.lo encoding/base64.lo encoding/binary.lo encoding/csv.lo encoding/gob.lo encoding/hex.lo encoding/json.lo encoding/pem.lo encoding/xml.lo exp/cookiejar.lo exp/ebnf.lo exp/html.lo exp/html/atom.lo exp/locale/collate.lo exp/locale/collate/build.lo exp/norm.lo exp/proxy.lo exp/terminal.lo exp/types.lo exp/utf8string.lo html/template.lo go/ast.lo go/build.lo go/doc.lo go/format.lo go/parser.lo go/printer.lo go/scanner.lo go/token.lo hash/adler32.lo hash/crc32.lo hash/crc64.lo hash/fnv.lo net/http/cgi.lo net/http/fcgi.lo net/http/httptest.lo net/http/httputil.lo net/http/pprof.lo image/color.lo image/draw.lo image/gif.lo image/jpeg.lo image/png.lo index/suffixarray.lo io/ioutil.lo log/syslog.lo log/syslog/syslog_c.lo math/big.lo math/cmplx.lo math/rand.lo mime/multipart.lo net/http.lo net/mail.lo net/rpc.lo net/smtp.lo net/textproto.lo net/url.lo old/netchan.lo old/regexp.lo old/template.lo os/exec.lo os/signal.lo os/user.lo path/filepath.lo regexp/syntax.lo net/rpc/jsonrpc.lo runtime/debug.lo runtime/pprof.lo sync/atomic.lo sync/atomic_c.lo text/scanner.lo text/tabwriter.lo text/template.lo text/template/parse.lo testing/iotest.lo testing/quick.lo unicode/utf16.lo unicode/utf8.lo ../libbacktrace/libbacktrace.la ../libatomic/libatomic.la ../libffi/libffi_convenience.la -lpthread -lm -inst-prefix-dir /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp)
libtool: relink: /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/./gcc/xgcc -B/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/./gcc/ -B/usr/x86_64-linux-gnu/bin/ -B/usr/x86_64-linux-gnu/lib/ -isystem /usr/x86_64-linux-gnu/include -isystem /usr/x86_64-linux-gnu/sys-include -isystem /home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/sys-include  -m32 -shared  .libs/go-append.o .libs/go-assert.o .libs/go-assert-interface.o .libs/go-byte-array-to-string.o .libs/go-breakpoint.o .libs/go-caller.o .libs/go-callers.o .libs/go-can-convert-interface.o .libs/go-cgo.o .libs/go-check-interface.o .libs/go-construct-map.o .libs/go-convert-interface.o .libs/go-copy.o .libs/go-defer.o .libs/go-deferred-recover.o .libs/go-eface-compare.o .libs/go-eface-val-compare.o .libs/go-fieldtrack.o .libs/go-getgoroot.o .libs/go-int-array-to-string.o .libs/go-int-to-string.o .libs/go-interface-compare.o .libs/go-interface-eface-compare.o .libs/go-interface-val-compare.o .libs/go-make-slice.o .libs/go-map-delete.o .libs/go-map-index.o .libs/go-map-len.o .libs/go-map-range.o .libs/go-matherr.o .libs/go-memcmp.o .libs/go-nanotime.o .libs/go-now.o .libs/go-new-map.o .libs/go-new.o .libs/go-nosys.o .libs/go-panic.o .libs/go-print.o .libs/go-recover.o .libs/go-reflect-call.o .libs/go-reflect-map.o .libs/go-rune.o .libs/go-runtime-error.o .libs/go-setenv.o .libs/go-signal.o .libs/go-strcmp.o .libs/go-string-to-byte-array.o .libs/go-string-to-int-array.o .libs/go-strplus.o .libs/go-strslice.o .libs/go-traceback.o .libs/go-trampoline.o .libs/go-type-complex.o .libs/go-type-eface.o .libs/go-type-error.o .libs/go-type-float.o .libs/go-type-identity.o .libs/go-type-interface.o .libs/go-type-string.o .libs/go-typedesc-equal.o .libs/go-typestring.o .libs/go-unsafe-new.o .libs/go-unsafe-newarray.o .libs/go-unsafe-pointer.o .libs/go-unwind.o .libs/chan.o .libs/cpuprof.o .libs/lfstack.o .libs/lock_futex.o .libs/thread-linux.o .libs/mcache.o .libs/mcentral.o .libs/mem.o .libs/mfinal.o .libs/mfixalloc.o .libs/mgc0.o .libs/mheap.o .libs/msize.o .libs/panic.o .libs/parfor.o .libs/print.o .libs/proc.o .libs/runtime.o .libs/signal_unix.o .libs/thread.o .libs/yield.o .libs/iface.o .libs/malloc.o .libs/map.o .libs/mprof.o .libs/reflect.o .libs/runtime1.o .libs/sema.o .libs/sigqueue.o .libs/string.o .libs/time.o .libs/getncpu-linux.o .libs/bufio.o .libs/bytes.o bytes/.libs/index.o .libs/crypto.o .libs/errors.o .libs/expvar.o .libs/flag.o .libs/fmt.o .libs/hash.o .libs/html.o .libs/image.o .libs/io.o .libs/log.o .libs/math.o .libs/mime.o .libs/net.o .libs/os.o .libs/path.o .libs/reflect-go.o .libs/regexp.o .libs/runtime-go.o .libs/sort.o .libs/strconv.o .libs/strings.o .libs/sync.o .libs/syscall.o syscall/.libs/errno.o syscall/.libs/signame.o syscall/.libs/wait.o .libs/testing.o .libs/time-go.o .libs/unicode.o archive/.libs/tar.o archive/.libs/zip.o compress/.libs/bzip2.o compress/.libs/flate.o compress/.libs/gzip.o compress/.libs/lzw.o compress/.libs/zlib.o container/.libs/heap.o container/.libs/list.o container/.libs/ring.o crypto/.libs/aes.o crypto/.libs/cipher.o crypto/.libs/des.o crypto/.libs/dsa.o crypto/.libs/ecdsa.o crypto/.libs/elliptic.o crypto/.libs/hmac.o crypto/.libs/md5.o crypto/.libs/rand.o crypto/.libs/rc4.o crypto/.libs/rsa.o crypto/.libs/sha1.o crypto/.libs/sha256.o crypto/.libs/sha512.o crypto/.libs/subtle.o crypto/.libs/tls.o crypto/.libs/x509.o crypto/x509/.libs/pkix.o database/.libs/sql.o database/sql/.libs/driver.o debug/.libs/dwarf.o debug/.libs/elf.o debug/.libs/gosym.o debug/.libs/macho.o debug/.libs/pe.o encoding/.libs/ascii85.o encoding/.libs/asn1.o encoding/.libs/base32.o encoding/.libs/base64.o encoding/.libs/binary.o encoding/.libs/csv.o encoding/.libs/gob.o encoding/.libs/hex.o encoding/.libs/json.o encoding/.libs/pem.o encoding/.libs/xml.o exp/.libs/cookiejar.o exp/.libs/ebnf.o exp/.libs/html.o exp/html/.libs/atom.o exp/locale/.libs/collate.o exp/locale/collate/.libs/build.o exp/.libs/norm.o exp/.libs/proxy.o exp/.libs/terminal.o exp/.libs/types.o exp/.libs/utf8string.o html/.libs/template.o go/.libs/ast.o go/.libs/build.o go/.libs/doc.o go/.libs/format.o go/.libs/parser.o go/.libs/printer.o go/.libs/scanner.o go/.libs/token.o hash/.libs/adler32.o hash/.libs/crc32.o hash/.libs/crc64.o hash/.libs/fnv.o net/http/.libs/cgi.o net/http/.libs/fcgi.o net/http/.libs/httptest.o net/http/.libs/httputil.o net/http/.libs/pprof.o image/.libs/color.o image/.libs/draw.o image/.libs/gif.o image/.libs/jpeg.o image/.libs/png.o index/.libs/suffixarray.o io/.libs/ioutil.o log/.libs/syslog.o log/syslog/.libs/syslog_c.o math/.libs/big.o math/.libs/cmplx.o math/.libs/rand.o mime/.libs/multipart.o net/.libs/http.o net/.libs/mail.o net/.libs/rpc.o net/.libs/smtp.o net/.libs/textproto.o net/.libs/url.o old/.libs/netchan.o old/.libs/regexp.o old/.libs/template.o os/.libs/exec.o os/.libs/signal.o os/.libs/user.o path/.libs/filepath.o regexp/.libs/syntax.o net/rpc/.libs/jsonrpc.o runtime/.libs/debug.o runtime/.libs/pprof.o sync/.libs/atomic.o sync/.libs/atomic_c.o text/.libs/scanner.o text/.libs/tabwriter.o text/.libs/template.o text/template/.libs/parse.o testing/.libs/iotest.o testing/.libs/quick.o unicode/.libs/utf16.o unicode/.libs/utf8.o  -Wl,--whole-archive ../libbacktrace/.libs/libbacktrace.a ../libffi/.libs/libffi_convenience.a -Wl,--no-whole-archive  -Wl,-rpath -Wl,/usr/lib/../lib32 -L/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/debian/tmp/usr/lib/../lib32 -L/usr/lib/../lib32 -latomic -lpthread -lm  -m32 -minline-all-stringops -m32 -pthread -fsplit-stack -m32   -pthread -Wl,-soname -Wl,libgo.so.3 -o .libs/libgo.so.3.0.1
/usr/bin/ld: cannot find -latomic
collect2: error: ld returned 1 exit status
libtool: install: error: relink `libgo.la' with the above command before installing it
make[10]: *** [install-toolexeclibLTLIBRARIES] Error 1
make[10]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo'
make[9]: *** [install-am] Error 2
make[9]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo'
make[8]: *** [install-recursive] Error 1
make[8]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo'
make[7]: *** [multi-do] Error 1
make[7]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/libgo'
make[6]: *** [install-multi] Error 2
make[6]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/libgo'
make[5]: *** [install-am] Error 2
make[5]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/libgo'
make[4]: *** [install-recursive] Error 1
make[4]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/libgo'
make[3]: *** [install-target-libgo] Error 2
make[3]: Leaving directory `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build'
make[2]: *** [install] Error 2
Ian Taylor - Dec. 18, 2012, 5:57 p.m.
On Tue, Dec 18, 2012 at 9:11 AM, Matthias Klose <doko@ubuntu.com> wrote:
> Am 18.12.2012 15:28, schrieb Ian Lance Taylor:
>> On Mon, Dec 17, 2012 at 2:26 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
>>> 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.
>>
>> Thanks.
>>
>> Committed to mainline.
>
> this seems to break make install, at least for a multilib enabled build.
>
> /usr/bin/ld: cannot find -latomic
> collect2: error: ld returned 1 exit status
> libtool: install: error: relink `libgo.la' with the above command before
> installing it
> make[10]: *** [install-toolexeclibLTLIBRARIES] Error 1
> make[10]: Leaving directory
> `/home/packages/gcc/4.8/gcc-4.8-4.8-20121218/build/x86_64-linux-gnu/32/libgo'

This doesn't happen for me, and it's bizarre that libtool would turn a
link against ../libatomic/libatomic.la into a link against -latomic.
But in any case the fix is presumably going to be to add a convenience
library for libatomic, as is done for libffi.  I'll prepare a patch
for that.

Ian

Patch

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); \