Skip to content

Commit e0a11d1

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 <[email protected]>
1 parent 10ea590 commit e0a11d1

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
@@ -2418,6 +2418,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
24182418
CmdArgs.push_back("-lunwind");
24192419
} else if (LGT == LibGccType::StaticLibGcc) {
24202420
CmdArgs.push_back("-l:libunwind.a");
2421+
CmdArgs.push_back("-lpthread");
2422+
CmdArgs.push_back("-ldl");
24212423
} else if (LGT == LibGccType::SharedLibGcc) {
24222424
if (TC.getTriple().isOSCygMing())
24232425
CmdArgs.push_back("-l:libunwind.dll.a");

0 commit comments

Comments
 (0)