0012-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From d687ffafecd9eab2e78cd8cce4b35b303e9fe482 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 9 Nov 2021 10:16:16 +0800
  4. Subject: [PATCH 12/34] clang: Add -lpthread and -ldl along with -lunwind for
  5. static 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. Rebased to LLVM 14.0.0 by Jun Yuan Tan
  13. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  14. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  15. ---
  16. clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 ++
  17. 1 file changed, 2 insertions(+)
  18. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  19. index 9f1895466c98..2682a9df9e1c 100644
  20. --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
  21. +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  22. @@ -1449,6 +1449,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
  23. CmdArgs.push_back("-lunwind");
  24. } else if (LGT == LibGccType::StaticLibGcc) {
  25. CmdArgs.push_back("-l:libunwind.a");
  26. + CmdArgs.push_back("-lpthread");
  27. + CmdArgs.push_back("-ldl");
  28. } else if (TC.getTriple().isOSCygMing()) {
  29. if (LGT == LibGccType::SharedLibGcc)
  30. CmdArgs.push_back("-l:libunwind.dll.a");
  31. --
  32. 2.33.1