aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-04-10 19:30:00 +0200
committerJay Berkenbilt <ejb@ql.org>2020-04-10 19:33:03 +0200
commit66198f447f45a87718b6457756976baa8defb2fd (patch)
tree95fb212d79fd6bb17e8db9f3f8ba3f4fd39d022f /configure.ac
parent578c5ac66c80cd1bfb43206dbba091a3985bb4bc (diff)
downloadqpdf-66198f447f45a87718b6457756976baa8defb2fd.tar.zst
Use -latomic if needed with gcc
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac26
1 files changed, 26 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 9a887b90..a3c3d064 100644
--- a/configure.ac
+++ b/configure.ac
@@ -240,6 +240,32 @@ for i in 0 1; do
done
AC_LANG_POP
+AC_LANG_PUSH([C++])
+AC_MSG_CHECKING(whether to use -latomic)
+dnl On some platforms with some versions of gcc, you have to link with
+dnl -latomic in order for std::atomic to work. Passing --as-needed
+dnl prevents unnecessary linking with -latomic.
+oLDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS -Wl,--as-needed -latomic"
+AC_LINK_IFELSE([AC_LANG_SOURCE(
+ [[#include <atomic>
+ int main()
+ {
+ static std::atomic<int> a{0};
+ a = a.fetch_add(1);
+ return 0;
+ }
+ ]])],
+ [qpdf_USE_ATOMIC=1],
+ [qpdf_USE_ATOMIC=0])
+if test "$qpdf_USE_ATOMIC" = "1"; then
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+ LDFLAGS="$oLDFLAGS"
+fi
+AC_LANG_POP
+
if test "x$qpdf_OS_SECURE_RANDOM" = "x1"; then
OLIBS=$LIBS
LIBS="$LIBS Advapi32.lib"