0001-Fix-linkage-with-a-system-libatomic_ops-shared-library.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 02a44ee1df8176c72e75fd706d1a8f063d3196d5 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Mon, 5 Nov 2018 22:50:40 +0100
  4. Subject: Fix linkage with a system libatomic_ops shared library
  5. Issue #247 (bdwgc).
  6. When bdwgc is linked with the external libatomic_ops, bdw-gc.pc must
  7. contain the needed dynamic libraries (such as -latomic_ops) otherwise
  8. build of applications could fail on the link stage on some hosts:
  9. * libgc.so: undefined reference to 'AO_fetch_compare_and_swap_emulation'
  10. * libgc.so: undefined reference to 'AO_store_full_emulation'
  11. So, this commit sets ATOMIC_OPS_LIBS to "-latomic_ops" when a system
  12. atomic_ops library is used and uses ATOMIC_OPS_LIBS in bdw-gc.pc.in.
  13. * bdw-gc.pc.in (Libs): Add @ATOMIC_OPS_LIBS@.
  14. * configure.ac [$with_libatomic_ops!=no && $with_libatomic_ops!=none
  15. && $THREADS!=none] (ATOMIC_OPS_LIBS): Set to -latomic_ops; do AC_SUBST.
  16. Fix is cherry-picked from bdwgc upstream
  17. Link to original commit https://github.com/ivmai/bdwgc/commit/02a44ee1df8176c72e75fd706d1a8f063d3196d5?branch=02a44ee1df8176c72e75fd706d1a8f063d3196d5&diff=unified
  18. Signed-off-by: Illia Bitkov <illia.bitkov@mind.be>
  19. diff --git a/external/bdwgc/bdw-gc.pc.in b/external/bdwgc/bdw-gc.pc.in
  20. index ef4c2341..a32e7598 100644
  21. --- a/external/bdwgc/bdw-gc.pc.in
  22. +++ b/external/bdwgc/bdw-gc.pc.in
  23. @@ -6,5 +6,5 @@ includedir=@includedir@
  24. Name: Boehm-Demers-Weiser Conservative Garbage Collector
  25. Description: A garbage collector for C and C++
  26. Version: @PACKAGE_VERSION@
  27. -Libs: -L${libdir} -lgc
  28. +Libs: -L${libdir} @ATOMIC_OPS_LIBS@ -lgc
  29. Cflags: -I${includedir}
  30. diff --git a/external/bdwgc/configure.ac b/external/bdwgc/configure.ac
  31. index 21abe8fa..9ffe81de 100644
  32. --- a/external/bdwgc/configure.ac
  33. +++ b/external/bdwgc/configure.ac
  34. @@ -1081,7 +1081,9 @@ AS_IF([test x"$with_libatomic_ops" = xno \
  35. AC_MSG_CHECKING([which libatomic_ops to use])
  36. AS_IF([test x"$with_libatomic_ops" != xno],
  37. [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
  38. - [ AC_MSG_RESULT([external]) ],
  39. + [ AC_MSG_RESULT([external])
  40. + ATOMIC_OPS_LIBS="-latomic_ops"
  41. + AC_SUBST([ATOMIC_OPS_LIBS]) ],
  42. [ AC_MSG_RESULT([none])
  43. AS_IF([test x"$THREADS" != xnone],
  44. [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],