Skip to content

Commit 9f1fd17

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 0a9aed0 commit 9f1fd17

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
@@ -2254,6 +2254,8 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
22542254
CmdArgs.push_back("-lunwind");
22552255
} else if (LGT == LibGccType::StaticLibGcc) {
22562256
CmdArgs.push_back("-l:libunwind.a");
2257+
CmdArgs.push_back("-lpthread");
2258+
CmdArgs.push_back("-ldl");
22572259
} else if (LGT == LibGccType::SharedLibGcc) {
22582260
if (TC.getTriple().isOSCygMing())
22592261
CmdArgs.push_back("-l:libunwind.dll.a");

0 commit comments

Comments
 (0)