[Openmp-commits] [PATCH] D30083: [openmp] [test] Try to link -latomic to provide atomics when available

Michał Górny via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Feb 24 14:27:13 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL296183: [test] Try to link -latomic to provide atomics when available (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D30083?vs=88866&id=89726#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30083

Files:
  openmp/trunk/runtime/test/CMakeLists.txt
  openmp/trunk/runtime/test/lit.cfg
  openmp/trunk/runtime/test/lit.site.cfg.in


Index: openmp/trunk/runtime/test/lit.site.cfg.in
===================================================================
--- openmp/trunk/runtime/test/lit.site.cfg.in
+++ openmp/trunk/runtime/test/lit.site.cfg.in
@@ -12,7 +12,7 @@
 config.using_hwloc = @LIBOMP_USE_HWLOC@
 config.has_ompt = @LIBOMP_OMPT_SUPPORT@ and @LIBOMP_OMPT_BLAME@ and @LIBOMP_OMPT_TRACE@
 config.has_libm = @LIBOMP_HAVE_LIBM@
+config.has_libatomic = @LIBOMP_HAVE_LIBATOMIC@
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBOMP_BASE_DIR@/test/lit.cfg")
-
Index: openmp/trunk/runtime/test/lit.cfg
===================================================================
--- openmp/trunk/runtime/test/lit.cfg
+++ openmp/trunk/runtime/test/lit.cfg
@@ -52,6 +52,8 @@
 libs = ""
 if config.has_libm:
     libs += " -lm"
+if config.has_libatomic:
+    libs += " -latomic"
 
 # Allow XFAIL to work
 config.target_triple = [ ]
Index: openmp/trunk/runtime/test/CMakeLists.txt
===================================================================
--- openmp/trunk/runtime/test/CMakeLists.txt
+++ openmp/trunk/runtime/test/CMakeLists.txt
@@ -1,6 +1,7 @@
 # CMakeLists.txt file for unit testing OpenMP Library
 include(FindPythonInterp)
 include(CheckTypeSize)
+include(CheckFunctionExists)
 include(CheckLibraryExists)
 
 if(NOT PYTHONINTERP_FOUND)
@@ -11,6 +12,17 @@
 
 # Some tests use math functions
 check_library_exists(m sqrt "" LIBOMP_HAVE_LIBM)
+# When using libgcc, -latomic may be needed for atomics
+# (but when using compiler-rt, the atomics will be built-in)
+# Note: we can not check for __atomic_load because clang treats it
+# as special built-in and that breaks CMake checks
+check_function_exists(__atomic_load_1 LIBOMP_HAVE_BUILTIN_ATOMIC)
+if(NOT LIBOMP_HAVE_BUILTIN_ATOMIC)
+  check_library_exists(atomic __atomic_load_1 "" LIBOMP_HAVE_LIBATOMIC)
+else()
+  # not needed
+  set(LIBOMP_HAVE_LIBATOMIC 0)
+endif()
 
 macro(pythonize_bool var)
   if (${var})
@@ -25,6 +37,7 @@
 pythonize_bool(LIBOMP_OMPT_BLAME)
 pythonize_bool(LIBOMP_OMPT_TRACE)
 pythonize_bool(LIBOMP_HAVE_LIBM)
+pythonize_bool(LIBOMP_HAVE_LIBATOMIC)
 
 set(LIBOMP_TEST_CFLAGS "" CACHE STRING
   "Extra compiler flags to send to the test compiler")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30083.89726.patch
Type: text/x-patch
Size: 2217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170224/234793f9/attachment.bin>


More information about the Openmp-commits mailing list