[Openmp-commits] [openmp] 7763242 - [OpenMP] Fix the check for libpsapi for i386

Martin Storsjö via Openmp-commits openmp-commits at lists.llvm.org
Fri Feb 12 11:56:11 PST 2021


Author: Martin Storsjö
Date: 2021-02-12T21:55:30+02:00
New Revision: 77632422bcca9800fe4733f470f1939db029c0ba

URL: https://github.com/llvm/llvm-project/commit/77632422bcca9800fe4733f470f1939db029c0ba
DIFF: https://github.com/llvm/llvm-project/commit/77632422bcca9800fe4733f470f1939db029c0ba.diff

LOG: [OpenMP] Fix the check for libpsapi for i386

check_library_exists fails for stdcall functions, because that
check doesn't include the necessary headers (and thus fails with
an undefined reference to _EnumProcessModules, when the import
library symbol actually is called _EnumProcessModules at 16).

Merge the two previous checks check_include_files and
check_library_exists into one with check_c_source_compiles, and
merge the variables that indicate whether it succeeded.

Differential Revision: https://reviews.llvm.org/D96580

Added: 
    

Modified: 
    openmp/runtime/cmake/LibompHandleFlags.cmake
    openmp/runtime/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/cmake/LibompHandleFlags.cmake b/openmp/runtime/cmake/LibompHandleFlags.cmake
index 82a2e884bc41..fe4d4ccacc97 100644
--- a/openmp/runtime/cmake/LibompHandleFlags.cmake
+++ b/openmp/runtime/cmake/LibompHandleFlags.cmake
@@ -127,7 +127,7 @@ function(libomp_get_libflags libflags)
     libomp_append(libflags_local -lirc_pic LIBOMP_HAVE_IRC_PIC_LIBRARY)
   endif()
   if(MINGW)
-    libomp_append(libflags_local -lpsapi LIBOMP_HAVE_LIBPSAPI)
+    libomp_append(libflags_local -lpsapi LIBOMP_HAVE_PSAPI)
   endif()
   if(LIBOMP_HAVE_SHM_OPEN_WITH_LRT)
     libomp_append(libflags_local -lrt)

diff  --git a/openmp/runtime/cmake/config-ix.cmake b/openmp/runtime/cmake/config-ix.cmake
index f06fda6c0221..8b57b7e9ac9a 100644
--- a/openmp/runtime/cmake/config-ix.cmake
+++ b/openmp/runtime/cmake/config-ix.cmake
@@ -278,11 +278,13 @@ check_c_source_compiles("int main(int argc, char** argv) {
 check_c_source_compiles("__attribute__ ((weak)) int foo(int a) { return a*a; }
   int main(int argc, char** argv) {
   return foo(argc);}" LIBOMP_HAVE_WEAK_ATTRIBUTE)
-check_include_files("windows.h;psapi.h" LIBOMP_HAVE_PSAPI_H)
-check_library_exists(psapi EnumProcessModules "" LIBOMP_HAVE_LIBPSAPI)
-if(LIBOMP_HAVE_PSAPI_H AND LIBOMP_HAVE_LIBPSAPI)
-  set(LIBOMP_HAVE_PSAPI TRUE)
-endif()
+set(CMAKE_REQUIRED_LIBRARIES psapi)
+check_c_source_compiles("#include <windows.h>
+  #include <psapi.h>
+  int main(int artc, char** argv) {
+    return EnumProcessModules(NULL, NULL, 0, NULL);
+  }" LIBOMP_HAVE_PSAPI)
+set(CMAKE_REQUIRED_LIBRARIES)
 if(NOT LIBOMP_HAVE___BUILTIN_FRAME_ADDRESS)
   set(LIBOMP_HAVE_OMPT_SUPPORT FALSE)
 else()


        


More information about the Openmp-commits mailing list