Some architectures need to add -latomic explicitly
authorAlberto Garcia <berto@igalia.com>
Fri, 6 Mar 2015 07:33:11 +0000 (07:33 +0000)
committerAlberto Garcia <berto@igalia.com>
Fri, 6 Mar 2015 07:33:11 +0000 (07:33 +0000)
===================================================================

Gbp-Pq: Name atomic_build_fix.patch

Source/cmake/OptionsCommon.cmake
atomic.cpp [new file with mode: 0644]

index ffcdfe529684019512f94796db26fb401d110efd..5c8ecb93fb04c4403281b140027879f51a24bec1 100644 (file)
@@ -69,3 +69,10 @@ endif ()
 # files must be used to deal with very long linker command lines.
 # See https://bugs.webkit.org/show_bug.cgi?id=129771
 set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
+
+try_compile(ATOMIC_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/atomic.cpp)
+if (NOT ATOMIC_BUILD_SUCCEEDED)
+    message(STATUS "Adding -latomic to the linker flags")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--push-state,--no-as-needed,-latomic,--pop-state")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--push-state,--no-as-needed,-latomic,--pop-state")
+endif()
diff --git a/atomic.cpp b/atomic.cpp
new file mode 100644 (file)
index 0000000..4ddf3ac
--- /dev/null
@@ -0,0 +1,7 @@
+#include <atomic>
+
+int main() {
+   std::atomic<int64_t> i(0);
+   i++;
+   return 0;
+}