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

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 0ff61cb900ac870458ffa5a0b49755c3eb0367e1 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Fri, 22 Oct 2021 11:35:03 +0800
  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. 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 c3abdf446cfa..99dac6d394f8 100644
  20. --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
  21. +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
  22. @@ -1450,6 +1450,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.0