Skip to content

Commit d76573e

Browse files
committed
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 Upstream-Status: Pending Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 parent 68b5484 commit d76573e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
22222222
CmdArgs.push_back("-lunwind");
22232223
} else if (LGT == LibGccType::StaticLibGcc) {
22242224
CmdArgs.push_back("-l:libunwind.a");
2225+
CmdArgs.push_back("-lpthread");
2226+
CmdArgs.push_back("-ldl");
22252227
} else if (LGT == LibGccType::SharedLibGcc) {
22262228
if (TC.getTriple().isOSCygMing())
22272229
CmdArgs.push_back("-l:libunwind.dll.a");

0 commit comments

Comments
 (0)