0011-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 16ec16d11424040b83b360199ab785650bd1fb65 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 31 Jul 2019 22:51:39 -0700
  4. Subject: [PATCH] clang: Add -lpthread and -ldl along with -lunwind for static
  5. linking
  6. When doing static liking with --unwindlib=libunwind -static we encounter
  7. undefined symbols
  8. libunwind/src/RWMutex.hpp:68: undefined reference to `pthread_rwlock_wrlock'
  9. and
  10. libunwind/src/AddressSpace.hpp:597: undefined reference to `dladdr'
  11. therefore we need to link in libpthread and libdl to fill these symbols
  12. Upstream-Status: Pending
  13. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  14. ---
  15. clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 ++
  16. 1 file changed, 2 insertions(+)
  17. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  18. index 0883631dfe98..dfab4075e03e 100644
  19. --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
  20. +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  21. @@ -1718,6 +1718,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
  22. CmdArgs.push_back("-lunwind");
  23. } else if (LGT == LibGccType::StaticLibGcc) {
  24. CmdArgs.push_back("-l:libunwind.a");
  25. + CmdArgs.push_back("-lpthread");
  26. + CmdArgs.push_back("-ldl");
  27. } else if (LGT == LibGccType::SharedLibGcc) {
  28. if (TC.getTriple().isOSCygMing())
  29. CmdArgs.push_back("-l:libunwind.dll.a");