diff options
author | Khem Raj <raj.khem@gmail.com> | 2016-08-07 22:57:00 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2016-08-07 22:57:00 -0700 |
commit | 5e711d32a3c605cba908dca8903f1bbf3eb67e5f (patch) | |
tree | 8de9c5ab052a77628b15f45b3a795de5e5aaa0d1 | |
parent | 6c352004fbd5368e8cafae0b8e58d3a840fff818 (diff) | |
download | meta-clang-5e711d32a3c605cba908dca8903f1bbf3eb67e5f.tar.gz |
llvm: Fix cfi erros for ARM seen with binutils 2.27
Signed-off-by: Khem Raj <raj.khem@gmail.com>
7 files changed, 163 insertions, 10 deletions
diff --git a/recipes-devtools/clang/clang.inc b/recipes-devtools/clang/clang.inc index 2971e9b..3b92d65 100644 --- a/recipes-devtools/clang/clang.inc +++ b/recipes-devtools/clang/clang.inc | |||
@@ -10,7 +10,7 @@ LLVM_GIT_PROTOCOL ?= "git" | |||
10 | 10 | ||
11 | PV = "3.9.0" | 11 | PV = "3.9.0" |
12 | BRANCH = "release_39" | 12 | BRANCH = "release_39" |
13 | SRCREV_llvm = "c39972a9b2a2cbfa5bca3e4e9f9a8ad6959c406d" | 13 | SRCREV_llvm = "2c01070bc51ac2ac8f9cff5e564f3ae09126f47e" |
14 | SRCREV_clang = "29427626008fc4322bb820814b3257981581e63d" | 14 | SRCREV_clang = "29427626008fc4322bb820814b3257981581e63d" |
15 | SRCREV_compiler-rt = "85cd828f87c0800e698b8d62334b2e1270375307" | 15 | SRCREV_compiler-rt = "85cd828f87c0800e698b8d62334b2e1270375307" |
16 | SRCREV_cxxabi = "82bb4c89734b6157de4a2fc2b9228be6529337a8" | 16 | SRCREV_cxxabi = "82bb4c89734b6157de4a2fc2b9228be6529337a8" |
diff --git a/recipes-devtools/clang/clang/0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch b/recipes-devtools/clang/clang/0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch index b659f24..c343ded 100644 --- a/recipes-devtools/clang/clang/0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch +++ b/recipes-devtools/clang/clang/0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch | |||
@@ -1,7 +1,7 @@ | |||
1 | From c69a4eba88cff26594193be9aca54f54733689e5 Mon Sep 17 00:00:00 2001 | 1 | From 2d4ae5fa80d95542ea4df12400c96f28ce2a4484 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Fri, 15 May 2015 12:13:17 -0700 | 3 | Date: Fri, 15 May 2015 12:13:17 -0700 |
4 | Subject: [PATCH 1/3] llvm: Remove CMAKE_CROSSCOMPILING so it can cross compile | 4 | Subject: [PATCH 1/5] llvm: Remove CMAKE_CROSSCOMPILING so it can cross compile |
5 | 5 | ||
6 | we already have llvm-config from clang-native | 6 | we already have llvm-config from clang-native |
7 | 7 | ||
@@ -30,5 +30,5 @@ index d458771..2e0c634 100644 | |||
30 | -endif(CMAKE_CROSSCOMPILING) | 30 | -endif(CMAKE_CROSSCOMPILING) |
31 | +endif(CMAKE_CROSSCOMPILING1) | 31 | +endif(CMAKE_CROSSCOMPILING1) |
32 | -- | 32 | -- |
33 | 2.9.0 | 33 | 2.9.2 |
34 | 34 | ||
diff --git a/recipes-devtools/clang/clang/0002-llvm-Do-not-assume-linux-glibc.patch b/recipes-devtools/clang/clang/0002-llvm-Do-not-assume-linux-glibc.patch index 94f79b0..9aaa5fd 100644 --- a/recipes-devtools/clang/clang/0002-llvm-Do-not-assume-linux-glibc.patch +++ b/recipes-devtools/clang/clang/0002-llvm-Do-not-assume-linux-glibc.patch | |||
@@ -1,7 +1,7 @@ | |||
1 | From 4a90b1c48b3aa8fe43a93e337def93bdbf82bf0f Mon Sep 17 00:00:00 2001 | 1 | From a478964d32e6521a68ef47464b26e50106dc943e Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Tue, 15 Mar 2016 05:26:47 +0000 | 3 | Date: Tue, 15 Mar 2016 05:26:47 +0000 |
4 | Subject: [PATCH 2/3] llvm: Do not assume linux == glibc | 4 | Subject: [PATCH 2/5] llvm: Do not assume linux == glibc |
5 | 5 | ||
6 | musl's implementation of std functions is different | 6 | musl's implementation of std functions is different |
7 | 7 | ||
@@ -24,5 +24,5 @@ index 9a7aeb5..e3b7fe2 100644 | |||
24 | EXPLICIT_SYMBOL(stderr); | 24 | EXPLICIT_SYMBOL(stderr); |
25 | EXPLICIT_SYMBOL(stdout); | 25 | EXPLICIT_SYMBOL(stdout); |
26 | -- | 26 | -- |
27 | 2.9.0 | 27 | 2.9.2 |
28 | 28 | ||
diff --git a/recipes-devtools/clang/clang/0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/recipes-devtools/clang/clang/0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch index d1b2aff..f62251d 100644 --- a/recipes-devtools/clang/clang/0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch +++ b/recipes-devtools/clang/clang/0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch | |||
@@ -1,7 +1,7 @@ | |||
1 | From b01b39e5b7c7803783ab7bc00fb4e414189d4d10 Mon Sep 17 00:00:00 2001 | 1 | From 9992bf63b2fa53e87d80372f89b6be51678cf6e5 Mon Sep 17 00:00:00 2001 |
2 | From: Khem Raj <raj.khem@gmail.com> | 2 | From: Khem Raj <raj.khem@gmail.com> |
3 | Date: Sat, 21 May 2016 00:33:20 +0000 | 3 | Date: Sat, 21 May 2016 00:33:20 +0000 |
4 | Subject: [PATCH 3/3] llvm: TargetLibraryInfo: Undefine libc functions if they | 4 | Subject: [PATCH 3/5] llvm: TargetLibraryInfo: Undefine libc functions if they |
5 | are macros | 5 | are macros |
6 | 6 | ||
7 | musl defines some functions as macros and not inline functions | 7 | musl defines some functions as macros and not inline functions |
@@ -87,5 +87,5 @@ index b2a593d..327894c 100644 | |||
87 | TLI_DEFINE_STRING_INTERNAL("tmpfile64") | 87 | TLI_DEFINE_STRING_INTERNAL("tmpfile64") |
88 | /// int toascii(int c); | 88 | /// int toascii(int c); |
89 | -- | 89 | -- |
90 | 2.9.0 | 90 | 2.9.2 |
91 | 91 | ||
diff --git a/recipes-devtools/clang/clang/0004-llvm-Fix-inconsistent-uses-of-.cfi_sections.patch b/recipes-devtools/clang/clang/0004-llvm-Fix-inconsistent-uses-of-.cfi_sections.patch new file mode 100644 index 0000000..c77a8d2 --- /dev/null +++ b/recipes-devtools/clang/clang/0004-llvm-Fix-inconsistent-uses-of-.cfi_sections.patch | |||
@@ -0,0 +1,124 @@ | |||
1 | From 260b42499a218f18730b946f053890cc1641e4c3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 7 Aug 2016 22:48:44 -0700 | ||
4 | Subject: [PATCH 4/5] llvm: Fix inconsistent uses of .cfi_sections | ||
5 | |||
6 | Error: inconsistent uses of .cfi_sections | ||
7 | |||
8 | From the 2.27 binutils assemblers. It seems that 2.27 doesn't like the | ||
9 | |||
10 | .cfi_sections .debug_frame | ||
11 | |||
12 | directive following previous .cfi directives. The assemblers seem to be happy if the .cfi_sections directive precedes any other .cfi directive. Is this a bug in binutils or LLVM? It looks as if a fix might be to move the generation of the .cfi_sections directive from endModule() to somewhere else (maybe a non-existant beginModule()?). | ||
13 | |||
14 | As a work-around I modified DwarfCFIException.cpp and ARMException.cpp to send the .cfi_sections directive before the first function is processed. Seems to work. | ||
15 | |||
16 | -Rich | ||
17 | |||
18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
19 | --- | ||
20 | lib/CodeGen/AsmPrinter/ARMException.cpp | 10 +++++++++- | ||
21 | lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | 11 ++++++++++- | ||
22 | lib/CodeGen/AsmPrinter/DwarfException.h | 4 ++++ | ||
23 | 3 files changed, 23 insertions(+), 2 deletions(-) | ||
24 | |||
25 | diff --git a/lib/CodeGen/AsmPrinter/ARMException.cpp b/lib/CodeGen/AsmPrinter/ARMException.cpp | ||
26 | index 5294c98..8295326 100644 | ||
27 | --- a/lib/CodeGen/AsmPrinter/ARMException.cpp | ||
28 | +++ b/lib/CodeGen/AsmPrinter/ARMException.cpp | ||
29 | @@ -34,7 +34,8 @@ | ||
30 | #include "llvm/Target/TargetRegisterInfo.h" | ||
31 | using namespace llvm; | ||
32 | |||
33 | -ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {} | ||
34 | +ARMException::ARMException(AsmPrinter *A) | ||
35 | + : DwarfCFIExceptionBase(A) {} | ||
36 | |||
37 | ARMException::~ARMException() {} | ||
38 | |||
39 | @@ -46,8 +47,10 @@ ARMTargetStreamer &ARMException::getTargetStreamer() { | ||
40 | /// endModule - Emit all exception information that should come after the | ||
41 | /// content. | ||
42 | void ARMException::endModule() { | ||
43 | +#if RICH | ||
44 | if (shouldEmitCFI) | ||
45 | Asm->OutStreamer->EmitCFISections(false, true); | ||
46 | +#endif | ||
47 | } | ||
48 | |||
49 | void ARMException::beginFunction(const MachineFunction *MF) { | ||
50 | @@ -59,6 +62,11 @@ void ARMException::beginFunction(const MachineFunction *MF) { | ||
51 | "non-EH CFI not yet supported in prologue with EHABI lowering"); | ||
52 | if (MoveType == AsmPrinter::CFI_M_Debug) { | ||
53 | shouldEmitCFI = true; | ||
54 | + // RICH: | ||
55 | + if (cfiSectionsNeeded) { | ||
56 | + Asm->OutStreamer->EmitCFISections(false, true); | ||
57 | + cfiSectionsNeeded = false; | ||
58 | + } | ||
59 | Asm->OutStreamer->EmitCFIStartProc(false); | ||
60 | } | ||
61 | } | ||
62 | diff --git a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
63 | index 2eae1b2..af4c081 100644 | ||
64 | --- a/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
65 | +++ b/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp | ||
66 | @@ -39,7 +39,7 @@ | ||
67 | using namespace llvm; | ||
68 | |||
69 | DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A) | ||
70 | - : EHStreamer(A), shouldEmitCFI(false) {} | ||
71 | + : EHStreamer(A), shouldEmitCFI(false), cfiSectionsNeeded(true) {} | ||
72 | |||
73 | void DwarfCFIExceptionBase::markFunctionEnd() { | ||
74 | endFragment(); | ||
75 | @@ -70,8 +70,10 @@ void DwarfCFIException::endModule() { | ||
76 | if (!Asm->MAI->usesCFIForEH()) | ||
77 | return; | ||
78 | |||
79 | +#if RICH | ||
80 | if (moveTypeModule == AsmPrinter::CFI_M_Debug) | ||
81 | Asm->OutStreamer->EmitCFISections(false, true); | ||
82 | +#endif | ||
83 | |||
84 | const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); | ||
85 | |||
86 | @@ -97,6 +99,13 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { | ||
87 | shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false; | ||
88 | const Function *F = MF->getFunction(); | ||
89 | |||
90 | + // RICH: SjLj uses this pass and it doesn't need this info. | ||
91 | + if (cfiSectionsNeeded && Asm->MAI->usesCFIForEH()) { | ||
92 | + if (moveTypeModule == AsmPrinter::CFI_M_Debug) | ||
93 | + Asm->OutStreamer->EmitCFISections(false, true); | ||
94 | + } | ||
95 | + cfiSectionsNeeded = false; | ||
96 | + | ||
97 | // If any landing pads survive, we need an EH table. | ||
98 | bool hasLandingPads = !MMI->getLandingPads().empty(); | ||
99 | |||
100 | diff --git a/lib/CodeGen/AsmPrinter/DwarfException.h b/lib/CodeGen/AsmPrinter/DwarfException.h | ||
101 | index 8287f28..f150f4e 100644 | ||
102 | --- a/lib/CodeGen/AsmPrinter/DwarfException.h | ||
103 | +++ b/lib/CodeGen/AsmPrinter/DwarfException.h | ||
104 | @@ -29,6 +29,9 @@ protected: | ||
105 | /// Per-function flag to indicate if frame CFI info should be emitted. | ||
106 | bool shouldEmitCFI; | ||
107 | |||
108 | + /// Cleared if the .cfi_sections directive has been output. | ||
109 | + bool cfiSectionsNeeded; | ||
110 | + | ||
111 | void markFunctionEnd() override; | ||
112 | void endFragment() override; | ||
113 | }; | ||
114 | @@ -46,6 +49,7 @@ class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase { | ||
115 | /// Per-function flag to indicate if frame moves info should be emitted. | ||
116 | bool shouldEmitMoves; | ||
117 | |||
118 | + | ||
119 | AsmPrinter::CFIMoveType moveTypeModule; | ||
120 | |||
121 | public: | ||
122 | -- | ||
123 | 2.9.2 | ||
124 | |||
diff --git a/recipes-devtools/clang/clang/0005-llvm-Fix-build-on-mips-ppc-disable-EH-table-support.patch b/recipes-devtools/clang/clang/0005-llvm-Fix-build-on-mips-ppc-disable-EH-table-support.patch new file mode 100644 index 0000000..82e0bb2 --- /dev/null +++ b/recipes-devtools/clang/clang/0005-llvm-Fix-build-on-mips-ppc-disable-EH-table-support.patch | |||
@@ -0,0 +1,27 @@ | |||
1 | From 28df3d17ac3f7925aba87eb2dc191342c11e59ae Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 7 Aug 2016 22:52:09 -0700 | ||
4 | Subject: [PATCH 5/5] llvm: Fix build on mips/ppc disable EH table support | ||
5 | |||
6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
7 | --- | ||
8 | lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp b/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | ||
12 | index e39acc7..69e165e 100644 | ||
13 | --- a/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | ||
14 | +++ b/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | ||
15 | @@ -34,7 +34,8 @@ RTDyldMemoryManager::~RTDyldMemoryManager() {} | ||
16 | |||
17 | // Determine whether we can register EH tables. | ||
18 | #if (defined(__GNUC__) && !defined(__ARM_EABI__) && !defined(__ia64__) && \ | ||
19 | - !defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)) | ||
20 | + !defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)) && \ | ||
21 | + !defined(__mips__) && !defined(__ppc__) | ||
22 | #define HAVE_EHTABLE_SUPPORT 1 | ||
23 | #else | ||
24 | #define HAVE_EHTABLE_SUPPORT 0 | ||
25 | -- | ||
26 | 2.9.2 | ||
27 | |||
diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index f2beb84..2c22ed4 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb | |||
@@ -18,6 +18,8 @@ SRC_URI = "${LLVM_GIT}/llvm.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};n | |||
18 | file://0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch \ | 18 | file://0001-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch \ |
19 | file://0002-llvm-Do-not-assume-linux-glibc.patch \ | 19 | file://0002-llvm-Do-not-assume-linux-glibc.patch \ |
20 | file://0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \ | 20 | file://0003-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \ |
21 | file://0004-llvm-Fix-inconsistent-uses-of-.cfi_sections.patch \ | ||
22 | file://0005-llvm-Fix-build-on-mips-ppc-disable-EH-table-support.patch \ | ||
21 | \ | 23 | \ |
22 | file://0001-clang-driver-Use-lib-for-ldso-on-OE.patch;patchdir=tools/clang \ | 24 | file://0001-clang-driver-Use-lib-for-ldso-on-OE.patch;patchdir=tools/clang \ |
23 | file://0002-clang-Driver-tools.cpp-Add-lssp-and-lssp_nonshared-o.patch;patchdir=tools/clang \ | 25 | file://0002-clang-Driver-tools.cpp-Add-lssp-and-lssp_nonshared-o.patch;patchdir=tools/clang \ |