summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/cmake
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2019-04-03 18:11:36 +0000
committerDimitry Andric <dimitry@andric.com>2019-04-03 18:11:36 +0000
commit956168c8029b4cc8c1d317f0326a7c1238101cb7 (patch)
tree0ac716b88a04f5ce67dc0d8efc83f03757242a45 /openmp/runtime/cmake
parent9c3978188939680677e7b2128f7c048812c29f6f (diff)
downloadbcm5719-llvm-956168c8029b4cc8c1d317f0326a7c1238101cb7.tar.gz
bcm5719-llvm-956168c8029b4cc8c1d317f0326a7c1238101cb7.zip
Ensure correct pthread flags and libraries are used
On most platforms, certain compiler and linker flags have to be passed when using pthreads, otherwise linking against libomp.so might fail with undefined references to several pthread functions. Use CMake's `find_package(Threads)` to determine these for standalone builds, or take them (and optionally modify them) from the top-level LLVM cmake files. Also, On FreeBSD, ensure that libomp.so is linked against libm.so, similar to NetBSD. Adjust test cases with hardcoded `-lpthread` flag to use the common build flags, which should now have the required pthread flags. Reviewers: emaste, jlpeyton, krytarowski, mgorny, protze.joachim, Hahnfeld Reviewed By: Hahnfeld Subscribers: AndreyChurbanov, tra, EricWF, Hahnfeld, jfb, jdoerfert, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D59451 llvm-svn: 357618
Diffstat (limited to 'openmp/runtime/cmake')
-rw-r--r--openmp/runtime/cmake/LibompHandleFlags.cmake7
-rw-r--r--openmp/runtime/cmake/LibompMicroTests.cmake2
2 files changed, 4 insertions, 5 deletions
diff --git a/openmp/runtime/cmake/LibompHandleFlags.cmake b/openmp/runtime/cmake/LibompHandleFlags.cmake
index 1690b2b9b24..86f629478be 100644
--- a/openmp/runtime/cmake/LibompHandleFlags.cmake
+++ b/openmp/runtime/cmake/LibompHandleFlags.cmake
@@ -158,14 +158,13 @@ function(libomp_get_libflags libflags)
if(${IA32})
libomp_append(libflags_local -lirc_pic LIBOMP_HAVE_IRC_PIC_LIBRARY)
endif()
- IF(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
+ if(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
libomp_append(libflags_local "-Wl,--no-as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
libomp_append(libflags_local "-lm")
libomp_append(libflags_local "-Wl,--as-needed" LIBOMP_HAVE_AS_NEEDED_FLAG)
- ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "DragonFly")
- IF(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "(Free|Net)BSD")
libomp_append(libflags_local -lm)
- ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ endif()
set(libflags_local ${libflags_local} ${LIBOMP_LIBFLAGS})
libomp_setup_flags(libflags_local)
set(${libflags} ${libflags_local} PARENT_SCOPE)
diff --git a/openmp/runtime/cmake/LibompMicroTests.cmake b/openmp/runtime/cmake/LibompMicroTests.cmake
index 38f4486b30d..2fde724f6c7 100644
--- a/openmp/runtime/cmake/LibompMicroTests.cmake
+++ b/openmp/runtime/cmake/LibompMicroTests.cmake
@@ -170,7 +170,7 @@ add_custom_command(
add_custom_target(libomp-test-deps DEPENDS test-deps/.success)
set(libomp_expected_library_deps)
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- set(libomp_expected_library_deps libc.so.7 libthr.so.3)
+ set(libomp_expected_library_deps libc.so.7 libthr.so.3 libm.so.5)
libomp_append(libomp_expected_library_deps libhwloc.so.5 LIBOMP_USE_HWLOC)
elseif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(libomp_expected_library_deps libc.so.12 libpthread.so.1 libm.so.0)
OpenPOWER on IntegriCloud