]> granicus.if.org Git - gc/commitdiff
Fix linkage with a system libatomic_ops shared library
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Mon, 5 Nov 2018 21:50:40 +0000 (22:50 +0100)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 23 Nov 2018 22:24:25 +0000 (01:24 +0300)
Issue #247 (bdwgc).

When bdwgc is linked with the external libatomic_ops, bdw-gc.pc must
contain the needed dynamic libraries (such as -latomic_ops) otherwise
build of applications could fail on the link stage on some hosts:
* libgc.so: undefined reference to 'AO_fetch_compare_and_swap_emulation'
* libgc.so: undefined reference to 'AO_store_full_emulation'

So, this commit sets ATOMIC_OPS_LIBS to "-latomic_ops" when a system
atomic_ops library is used and uses ATOMIC_OPS_LIBS in bdw-gc.pc.in.

* bdw-gc.pc.in (Libs): Add @ATOMIC_OPS_LIBS@.
* configure.ac [$with_libatomic_ops!=no && $with_libatomic_ops!=none
&& $THREADS!=none] (ATOMIC_OPS_LIBS): Set to -latomic_ops; do AC_SUBST.

bdw-gc.pc.in
configure.ac

index ef4c23410de338407ee892dd80bd2bc488e3e733..a32e7598c2e5533e6ff29b6b16db868e810ee84c 100644 (file)
@@ -6,5 +6,5 @@ includedir=@includedir@
 Name: Boehm-Demers-Weiser Conservative Garbage Collector
 Description: A garbage collector for C and C++
 Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lgc
+Libs: -L${libdir} @ATOMIC_OPS_LIBS@ -lgc
 Cflags: -I${includedir}
index 3275569e6f350add6bfae432247ed0bd2309362a..073d007794dc9f605489eb672d53d12f48580dae 100644 (file)
@@ -1080,7 +1080,9 @@ AS_IF([test x"$with_libatomic_ops" = xno \
 AC_MSG_CHECKING([which libatomic_ops to use])
 AS_IF([test x"$with_libatomic_ops" != xno],
   [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
-          [ AC_MSG_RESULT([external]) ],
+          [ AC_MSG_RESULT([external])
+            ATOMIC_OPS_LIBS="-latomic_ops"
+            AC_SUBST([ATOMIC_OPS_LIBS]) ],
           [ AC_MSG_RESULT([none])
             AS_IF([test x"$THREADS" != xnone],
                   [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],