This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Only include CMAKE_DL_LIBS on unix platforms
ClosedPublic

Authored by mstorsjo on Aug 1 2022, 3:05 AM.

Details

Summary

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 cutom-patched CMake.

Diff Detail

Event Timeline

mstorsjo created this revision.Aug 1 2022, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 3:05 AM
mstorsjo requested review of this revision.Aug 1 2022, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 3:05 AM
Herald added a subscriber: sstefan1. · View Herald Transcript
JonChesterfield accepted this revision.Aug 1 2022, 3:53 AM

OK. It's a bit of an edge case but the patch is reasonable. In general the hope is to move to using llvm libs to abstract over things like dlsym but it's a gradual process.

This revision is now accepted and ready to land.Aug 1 2022, 3:53 AM
This revision was automatically updated to reflect the committed changes.