diff options
| author | Michal Gorny <mgorny@gentoo.org> | 2017-02-24 22:15:24 +0000 |
|---|---|---|
| committer | Michal Gorny <mgorny@gentoo.org> | 2017-02-24 22:15:24 +0000 |
| commit | 018d13597acdcfcec0144076a9d546dcdd30803b (patch) | |
| tree | 6abe36362413e66a9d41422908e0dd1c559d6a1b /openmp/runtime/test | |
| parent | 42259cf35e0dbc7c174fa655d6e55e5178ac2087 (diff) | |
| download | bcm5719-llvm-018d13597acdcfcec0144076a9d546dcdd30803b.tar.gz bcm5719-llvm-018d13597acdcfcec0144076a9d546dcdd30803b.zip | |
[test] Try to link -latomic to provide atomics when available
When using -rtlib=libgcc, the fallback implementation of __atomic_*
builtins is provided via libatomic (included in GCC). However, neither
GCC itself nor clang link libatomic implicitly, and it seems that GCC
upstream expects projects to link it explicitly as necessary.
Since compiler-rt provides __atomic_* builtins directly in the main
library, check if they are provided by the default libraries first.
If they are not, check if -latomic is available to provide them
and add explicit -latomic for tests in this case.
This fixes unresolved __atomic_load() references when running openmp
tests on i386 with libgcc backend.
Differential Revision: https://reviews.llvm.org/D30083
llvm-svn: 296183
Diffstat (limited to 'openmp/runtime/test')
| -rw-r--r-- | openmp/runtime/test/CMakeLists.txt | 13 | ||||
| -rw-r--r-- | openmp/runtime/test/lit.cfg | 2 | ||||
| -rw-r--r-- | openmp/runtime/test/lit.site.cfg.in | 2 |
3 files changed, 16 insertions, 1 deletions
diff --git a/openmp/runtime/test/CMakeLists.txt b/openmp/runtime/test/CMakeLists.txt index 8162855163d..88c02c873f4 100644 --- a/openmp/runtime/test/CMakeLists.txt +++ b/openmp/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 @@ endif() # 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_SUPPORT) 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") diff --git a/openmp/runtime/test/lit.cfg b/openmp/runtime/test/lit.cfg index 7f18da4b1b7..bef61d444da 100644 --- a/openmp/runtime/test/lit.cfg +++ b/openmp/runtime/test/lit.cfg @@ -52,6 +52,8 @@ config.test_cflags = config.test_openmp_flag + \ libs = "" if config.has_libm: libs += " -lm" +if config.has_libatomic: + libs += " -latomic" # Allow XFAIL to work config.target_triple = [ ] diff --git a/openmp/runtime/test/lit.site.cfg.in b/openmp/runtime/test/lit.site.cfg.in index 448132eb513..b0d57ce2a7e 100644 --- a/openmp/runtime/test/lit.site.cfg.in +++ b/openmp/runtime/test/lit.site.cfg.in @@ -12,7 +12,7 @@ config.hwloc_library_dir = "@LIBOMP_HWLOC_LIBRARY_DIR@" 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") - |

