Author: Martin Storsjö Date: 2022-08-09T13:34:06+02:00 New Revision: bab8af8ea062f6332b5c5d13ae688bb8900f244a
URL: https://github.com/llvm/llvm-project/commit/bab8af8ea062f6332b5c5d13ae688bb8900f244a DIFF: https://github.com/llvm/llvm-project/commit/bab8af8ea062f6332b5c5d13ae688bb8900f244a.diff LOG: [OpenMP] Only include CMAKE_DL_LIBS on unix platforms CMAKE_DL_LIBS is documented as "Name of library containing dlopen and dlclose". On Windows platforms, there's no system provided dlopen/dlclose, but it can be argued that if you really intend to call dlopen/dlclose, you're going to be using a third party compat library like https://github.com/dlfcn-win32/dlfcn-win32, and CMAKE_DL_LIBS should expand to its name. This has been argued upstream in CMake in https://gitlab.kitware.com/cmake/cmake/-/issues/17600 and https://gitlab.kitware.com/cmake/cmake/-/merge_requests/1642, that CMAKE_DL_LIBS should expand to "dl" on mingw platforms. The merge request wasn't merged though, as it caused some amount of breakage, but in practice, Fedora still carries a custom CMake patch with the same effect. Thus, this patch fixes cross compiling OpenMP for mingw targets on Fedora with their custom-patched CMake. Differential Revision: https://reviews.llvm.org/D130892 (cherry picked from commit 7f24fd26a8abaef2fa4561aa399adde81d9c563a) Added: Modified: openmp/runtime/src/CMakeLists.txt Removed: ################################################################################ diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt index 9bc8837d0377d..df1ca9d9088b8 100644 --- a/openmp/runtime/src/CMakeLists.txt +++ b/openmp/runtime/src/CMakeLists.txt @@ -139,6 +139,10 @@ else() set(LIBOMP_LINKER_LANGUAGE CXX) endif() +if(UNIX) + set(LIBOMP_DL_LIBS ${CMAKE_DL_LIBS}) +endif() + # Add the OpenMP library libomp_get_ldflags(LIBOMP_CONFIGURED_LDFLAGS) @@ -147,10 +151,10 @@ libomp_get_libflags(LIBOMP_CONFIGURED_LIBFLAGS) if(OPENMP_STANDALONE_BUILD OR (NOT OPENMP_ENABLE_LIBOMP_PROFILING)) add_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES}) # Linking command will include libraries in LIBOMP_CONFIGURED_LIBFLAGS - target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${CMAKE_DL_LIBS}) + target_link_libraries(omp ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS}) else() add_llvm_library(omp ${LIBOMP_LIBRARY_KIND} ${LIBOMP_SOURCE_FILES} PARTIAL_SOURCES_INTENDED - LINK_LIBS ${LIBOMP_CONFIGURED_LIBFLAGS} ${CMAKE_DL_LIBS} + LINK_LIBS ${LIBOMP_CONFIGURED_LIBFLAGS} ${LIBOMP_DL_LIBS} LINK_COMPONENTS Support ) # libomp must be a C++ library such that it can link libLLVMSupport _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits