Bug 1178266 - Link against libatomic when necessary
authorMike Hommey <mh@glandium.org>
Sun, 30 Aug 2015 09:35:43 +0000 (18:35 +0900)
committerMike Hommey <glandium@debian.org>
Sun, 14 Feb 2016 09:25:51 +0000 (09:25 +0000)
Gbp-Pq: Topic fixes
Gbp-Pq: Name Bug-1178266-Link-against-libatomic-when-necessary.patch

build/autoconf/toolchain.m4
mfbt/moz.build

index 120a63c350cfe4489929b196931cf542d46280a8..90d852865a541fcd6ac69f9f292ee037ce878efe 100644 (file)
@@ -224,7 +224,33 @@ if test "$GNU_CXX"; then
     elif test "$ac_cv_cxx0x_headers_bug" = "yes"; then
         AC_MSG_ERROR([Your toolchain does not support C++0x/C++11 mode properly. Please upgrade your toolchain])
     fi
+
+    AC_CACHE_CHECK([whether 64-bits std::atomic requires -latomic],
+        ac_cv_needs_atomic,
+        AC_TRY_LINK(
+            [#include <cstdint>
+             #include <atomic>],
+            [ std::atomic<uint64_t> foo; foo = 1; ],
+            ac_cv_needs_atomic=no,
+            _SAVE_LIBS="$LIBS"
+            LIBS="$LIBS -latomic"
+            AC_TRY_LINK(
+                [#include <cstdint>
+                 #include <atomic>],
+                [ std::atomic<uint64_t> foo; foo = 1; ],
+                ac_cv_needs_atomic=yes,
+                ac_cv_needs_atomic="do not know; assuming no")
+            LIBS="$_SAVE_LIBS"
+        )
+    )
+    if test "$ac_cv_needs_atomic" = yes; then
+      MOZ_NEEDS_LIBATOMIC=1
+    else
+      MOZ_NEEDS_LIBATOMIC=
+    fi
+    AC_SUBST(MOZ_NEEDS_LIBATOMIC)
 fi
+
 if test -n "$CROSS_COMPILE"; then
     dnl When cross compile, we have no variable telling us what the host compiler is. Figure it out.
     cat > conftest.C <<EOF
index f4ae83fbf40416896def686c2cf47afc33989a67..bf3d398d953091544c7239275a6c6201052bf072 100644 (file)
@@ -122,6 +122,10 @@ DISABLE_STL_WRAPPING = True
 if CONFIG['GNU_CXX']:
     SOURCES['/mfbt/Compression.cpp'].flags += ['-Wno-unused-function']
 
+
 if CONFIG['_MSC_VER']:
     # Error 4804 is "'>' : unsafe use of type 'bool' in operation"
     SOURCES['/mfbt/Compression.cpp'].flags += ['-wd4804']
+
+if CONFIG['MOZ_NEEDS_LIBATOMIC']:
+    OS_LIBS += ['atomic']