[Openmp-commits] [PATCH] D96182: [OpenMP] Enable omp_get_num_devices() on Windows

Andrey Churbanov via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Feb 9 13:04:45 PST 2021

AndreyChurbanov added a comment.

If I add GetProcAddress result conversion to (void *) I get linker error if built by clang or gcc. E.g. for clang:

C:\Progs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\ld.exe: CMakeFiles\omp.dir/objects.a(z_Windows_NT_util.cpp.obj):z_Windows_NT_util.:(.text+0x1dfa): undefined reference to `EnumProcessModules'
C:\Progs\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\ld.exe: CMakeFiles\omp.dir/objects.a(z_Windows_NT_util.cpp.obj):z_Windows_NT_util.:(.text+0x1e26): undefined reference to `EnumProcessModules'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [runtime/src/libomp.dll] Error 1
make[1]: *** [runtime/src/CMakeFiles/omp.dir/all] Error 2
make: *** [all] Error 2

That indicates missing -lpsapi on link line.

Comment at: openmp/runtime/src/z_Windows_NT_util.cpp:1652
+  for (uint32_t i = 0; i < num_modules; i++) {
+    proc = GetProcAddress(modules[i], name);
+    if (proc)
clang complains on this line:

C:\tmp\llvm\trunk\runtime\src\z_Windows_NT_util.cpp:1652:12: error: assigning to 'void *' from 'FARPROC'
      (aka 'long long (*)()') converts between void pointer and function pointer
    proc = GetProcAddress(modules[i], name);

I guess the result should be converted to (void *) before assignment.

Similar complaint from gcc:

C:/tmp/llvm/trunk/runtime/src/z_Windows_NT_util.cpp:1652:26: error: invalid conversion from 'FARPROC' {aka 'long long int (*)()'} to 'void*' [-fpermissive]
 1652 |     proc = GetProcAddress(modules[i], name);
      |            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                          |
      |                          FARPROC {aka long long int (*)()}

  rG LLVM Github Monorepo



More information about the Openmp-commits mailing list