[runtimes] Support ELF dependent libraries feature

As of r360984, LLD supports dependent libraries feature for ELF.
libunwind, libc++abi and libc++ have library dependencies: libdl librt
and libpthread, which means that when libunwind and libc++ are being
statically linked (using -static-libstdc++ flag), user has to manually
specify -ldl -lpthread which is onerous.

This change includes the lib pragma to specify the library dependencies
directly in the source that uses those libraries. This doesn't make any
difference when using linkers that don't support dependent libraries.
However, when using LLD that has dependent libraries feature, users no
longer have to manually specifying library dependencies when using
static linking, linker will pick the library automatically.

Differential Revision: https://reviews.llvm.org/D62090

git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@362048 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
index fb370ad..6643953 100644
--- a/src/AddressSpace.hpp
+++ b/src/AddressSpace.hpp
@@ -27,6 +27,9 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include <dlfcn.h>
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "dl")
+#endif
 #endif
 
 #ifdef __APPLE__
diff --git a/src/RWMutex.hpp b/src/RWMutex.hpp
index 7a08bb2..4f234a7 100644
--- a/src/RWMutex.hpp
+++ b/src/RWMutex.hpp
@@ -17,6 +17,9 @@
 #include <windows.h>
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include <pthread.h>
+#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#pragma comment(lib, "pthread")
+#endif
 #endif
 
 namespace libunwind {