summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/clang/clang/0013-clang-Add-lpthread-and-ldl-along-with-lunwind-for-st.patch
blob: 3584d70a0d79da958133bf94aaf78214cf5fe0dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From b40a8752cea684e392a25f45028493711352e1e2 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 31 Jul 2019 22:51:39 -0700
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

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b74a9fe3eb92..4c7a2ec15a2e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1444,8 +1444,11 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
     break;
   }
   case ToolChain::UNW_CompilerRT:
-    if (LGT == LibGccType::StaticLibGcc)
+    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");