Skip to content

Commit e28ace4

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 b4334f5 commit e28ace4

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
@@ -2297,6 +2297,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
22972297
CmdArgs.push_back("-lunwind");
22982298
} else if (LGT == LibGccType::StaticLibGcc) {
22992299
CmdArgs.push_back("-l:libunwind.a");
2300+
CmdArgs.push_back("-lpthread");
2301+
CmdArgs.push_back("-ldl");
23002302
} else if (LGT == LibGccType::SharedLibGcc) {
23012303
if (TC.getTriple().isOSCygMing())
23022304
CmdArgs.push_back("-l:libunwind.dll.a");

0 commit comments

Comments
 (0)