This is an archive of the discontinued LLVM Phabricator instance.

Check for libdl, and only use it when available
ClosedPublic

Authored by dim on Jun 26 2017, 10:32 AM.

Details

Summary

On BSDs, there is no libdl.so, and functions like dlopen are implemented in the main C library instead. Check for the existence of libdl in the main CMakeLists.txt file, and only use it if it exists.

Diff Detail

Repository
rL LLVM

Event Timeline

dim created this revision.Jun 26 2017, 10:32 AM

CMake has a variable CMAKE_DL_LIBS which I believe contains the information you want. It essentially gets defined to "-ldl" on unices that need it and "" on platforms which don't need it.

dim added a comment.Jun 26 2017, 10:55 AM

CMake has a variable CMAKE_DL_LIBS which I believe contains the information you want. It essentially gets defined to "-ldl" on unices that need it and "" on platforms which don't need it.

Hm, this isn't used in the main LLVM build though. I basically copied what is done in cmake/config-ix.cmake there. But I'll have a look at CMAKE_DL_LIBS, I wonder which version of CMake introduced that variable, the documentation doesn't specify it.

dim updated this revision to Diff 103996.Jun 26 2017, 11:01 AM
dim edited the summary of this revision. (Show Details)

Use CMAKE_DL_LIBS instead. This is in CMake since at least 2012, if not before.

emaste accepted this revision.Jun 26 2017, 11:25 AM
This revision is now accepted and ready to land.Jun 26 2017, 11:25 AM
This revision was automatically updated to reflect the committed changes.