12345678910111213141516171819202122232425262728293031323334353637383940 |
- From 0ff61cb900ac870458ffa5a0b49755c3eb0367e1 Mon Sep 17 00:00:00 2001
- From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
- Date: Fri, 22 Oct 2021 11:35:03 +0800
- Subject: [PATCH] clang: Add -lpthread and -ldl along with -lunwind for static
- linking
- When doing static liking with --unwindlib=libunwind -static we encounter
- undefined symbols
- libunwind/src/RWMutex.hpp:68: undefined reference to `pthread_rwlock_wrlock'
- and
- libunwind/src/AddressSpace.hpp:597: undefined reference to `dladdr'
- therefore we need to link in libpthread and libdl to fill these symbols
- Rebased to LLVM 14.0.0 by Jun Yuan Tan
- Signed-off-by: Khem Raj <raj.khem@gmail.com>
- Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
- ---
- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
- index c3abdf446cfa..99dac6d394f8 100644
- --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
- +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
- @@ -1450,6 +1450,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
- CmdArgs.push_back("-lunwind");
- } else if (LGT == LibGccType::StaticLibGcc) {
- CmdArgs.push_back("-l:libunwind.a");
- + CmdArgs.push_back("-lpthread");
- + CmdArgs.push_back("-ldl");
- } else if (TC.getTriple().isOSCygMing()) {
- if (LGT == LibGccType::SharedLibGcc)
- CmdArgs.push_back("-l:libunwind.dll.a");
- --
- 2.33.0
|