Skip to content

Commit

Permalink
[libunwind] Emit dependent libraries only when detected by CMake
Browse files Browse the repository at this point in the history
996e62e added Linux-specific dependent libraries to libunwind
sources.  As a result, building libunwind with modern LLD on *BSD
started failing due to trying to link libdl.  Instead, add those
libraries only if they were detected by CMake.

While technically we could create a long list of systems that need -ldl
and -lpthread, maintaining a duplicate list makes little sense when
CMake needs to detect it for non-LLD systems anyway.  Remove existing
system exceptions since they should be covered by the CMake check
anyway.

Remove -D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA since it is no longer
explicitly needed, if we make the library-specific defines dependent
on presence of this pragma support.

Differential Revision: https://reviews.llvm.org/D70868
  • Loading branch information
mgorny committed Dec 1, 2019
1 parent 89c4731 commit 35bc527
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion libunwind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,12 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AND NOT LIBUNWIND_ENABLE_SHARED)
endif()

if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
if (LIBUNWIND_HAS_DL_LIB)
add_definitions(-D_LIBUNWIND_LINK_DL_LIB)
endif()
if (LIBUNWIND_HAS_PTHREAD_LIB)
add_definitions(-D_LIBUNWIND_LINK_PTHREAD_LIB)
endif()
endif()

#===============================================================================
Expand Down
2 changes: 1 addition & 1 deletion libunwind/src/AddressSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#if _LIBUNWIND_USE_DLADDR
#include <dlfcn.h>
#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#if defined(__ELF__) && defined(_LIBUNWIND_LINK_DL_LIB)
#pragma comment(lib, "dl")
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion libunwind/src/RWMutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <windows.h>
#elif !defined(_LIBUNWIND_HAS_NO_THREADS)
#include <pthread.h>
#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#if defined(__ELF__) && defined(_LIBUNWIND_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread")
#endif
#endif
Expand Down

0 comments on commit 35bc527

Please sign in to comment.