diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -271,6 +271,9 @@ option(LIBCXX_HERMETIC_STATIC_LIBRARY "Do not export any symbols from the static library." OFF) +option(LIBCXX_ENABLE_DEPENDENT_LIBRARIES + "Embed library dependencies in object files on platforms that support that" OFF) + #=============================================================================== # Check option configurations #=============================================================================== @@ -540,6 +543,10 @@ add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() +if (LIBCXX_ENABLE_DEPENDENT_LIBRARIES) + add_definitions(-D_LIBCPP_ENABLE_DEPENDENT_LIBRARIES) +endif() + # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support --- a/libcxx/include/__threading_support +++ b/libcxx/include/__threading_support @@ -25,6 +25,9 @@ #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # include # include +#if defined(__ELF__) && defined(__clang__) && defined(_LIBCPP_ENABLE_DEPENDENT_LIBRARIES) +#pragma comment(lib, "pthread") +#endif #endif _LIBCPP_PUSH_MACROS diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -171,6 +171,9 @@ option(LIBUNWIND_HERMETIC_STATIC_LIBRARY "Do not export any symbols from the static library." OFF) +option(LIBUNWIND_ENABLE_DEPENDENT_LIBRARIES + "Embed library dependencies in object files on platforms that support that" OFF) + #=============================================================================== # Configure System #=============================================================================== @@ -362,6 +365,10 @@ add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) endif() +if (LIBUNWIND_ENABLE_DEPENDENT_LIBRARIES) + add_definitions(-D_LIBUNWIND_ENABLE_DEPENDENT_LIBRARIES) +endif() + #=============================================================================== # Setup Source Code #=============================================================================== diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -27,6 +27,9 @@ #if _LIBUNWIND_USE_DLADDR #include +#if defined(__ELF__) && defined(__clang__) && defined(_LIBUNWIND_ENABLE_DEPENDENT_LIBRARIES) +#pragma comment(lib, "dl") +#endif #endif #ifdef __APPLE__