diff options
author | Khem Raj <raj.khem@gmail.com> | 2016-05-21 00:37:53 +0000 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2016-05-21 00:37:53 +0000 |
commit | f5916043bd99cdfe5d435b9763e222faee99d064 (patch) | |
tree | 6a54f203425f1880d59f0ddbbe5fdd8fc895c503 | |
parent | 058623aaf01284151501167548cfbd0f85fe02ae (diff) | |
download | meta-clang-f5916043bd99cdfe5d435b9763e222faee99d064.tar.gz |
clang: Fix build with musl
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 63 insertions, 128 deletions
diff --git a/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch new file mode 100644 index 0000000..949a1ea --- /dev/null +++ b/recipes-devtools/clang/clang/0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch | |||
@@ -0,0 +1,61 @@ | |||
1 | From b1b73874dc3b81e6dd5e05b9f00b2010c9ab18fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 21 May 2016 00:33:20 +0000 | ||
4 | Subject: [PATCH] llvm: TargetLibraryInfo: Undefine libc functions if they are | ||
5 | macros | ||
6 | |||
7 | musl defines some functions as macros and not inline functions | ||
8 | if this is the case then make sure to undefine them | ||
9 | |||
10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
11 | --- | ||
12 | include/llvm/Analysis/TargetLibraryInfo.def | 12 ++++++++++++ | ||
13 | 1 file changed, 12 insertions(+) | ||
14 | |||
15 | diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def | ||
16 | index b2a593d..834f257 100644 | ||
17 | --- a/include/llvm/Analysis/TargetLibraryInfo.def | ||
18 | +++ b/include/llvm/Analysis/TargetLibraryInfo.def | ||
19 | @@ -531,6 +531,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl") | ||
20 | TLI_DEFINE_ENUM_INTERNAL(fopen) | ||
21 | TLI_DEFINE_STRING_INTERNAL("fopen") | ||
22 | /// FILE *fopen64(const char *filename, const char *opentype) | ||
23 | +#ifdef fopen64 | ||
24 | +#undef fopen64 | ||
25 | +#endif | ||
26 | TLI_DEFINE_ENUM_INTERNAL(fopen64) | ||
27 | TLI_DEFINE_STRING_INTERNAL("fopen64") | ||
28 | /// int fprintf(FILE *stream, const char *format, ...); | ||
29 | @@ -566,6 +569,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek") | ||
30 | /// int fseeko(FILE *stream, off_t offset, int whence); | ||
31 | TLI_DEFINE_ENUM_INTERNAL(fseeko) | ||
32 | TLI_DEFINE_STRING_INTERNAL("fseeko") | ||
33 | +#ifdef fseeko64 | ||
34 | +#undef fseeko64 | ||
35 | +#endif | ||
36 | /// int fseeko64(FILE *stream, off64_t offset, int whence) | ||
37 | TLI_DEFINE_ENUM_INTERNAL(fseeko64) | ||
38 | TLI_DEFINE_STRING_INTERNAL("fseeko64") | ||
39 | @@ -591,6 +597,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell") | ||
40 | TLI_DEFINE_ENUM_INTERNAL(ftello) | ||
41 | TLI_DEFINE_STRING_INTERNAL("ftello") | ||
42 | /// off64_t ftello64(FILE *stream) | ||
43 | +#ifdef ftello64 | ||
44 | +#undef ftello64 | ||
45 | +#endif | ||
46 | TLI_DEFINE_ENUM_INTERNAL(ftello64) | ||
47 | TLI_DEFINE_STRING_INTERNAL("ftello64") | ||
48 | /// int ftrylockfile(FILE *file); | ||
49 | @@ -1056,6 +1065,9 @@ TLI_DEFINE_STRING_INTERNAL("times") | ||
50 | TLI_DEFINE_ENUM_INTERNAL(tmpfile) | ||
51 | TLI_DEFINE_STRING_INTERNAL("tmpfile") | ||
52 | /// FILE *tmpfile64(void) | ||
53 | +#ifdef tmpfile64 | ||
54 | +#undef tmpfile64 | ||
55 | +#endif | ||
56 | TLI_DEFINE_ENUM_INTERNAL(tmpfile64) | ||
57 | TLI_DEFINE_STRING_INTERNAL("tmpfile64") | ||
58 | /// int toascii(int c); | ||
59 | -- | ||
60 | 1.8.3.1 | ||
61 | |||
diff --git a/recipes-devtools/clang/clang/0004-llvm-remove-fopen64-fseeko64-ftello64-tmpfile64-on-m.patch b/recipes-devtools/clang/clang/0004-llvm-remove-fopen64-fseeko64-ftello64-tmpfile64-on-m.patch deleted file mode 100644 index 7c78e21..0000000 --- a/recipes-devtools/clang/clang/0004-llvm-remove-fopen64-fseeko64-ftello64-tmpfile64-on-m.patch +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | From bc8a39484dc4db80baa846438a6908e2f9572572 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Thu, 19 May 2016 22:52:05 -0700 | ||
4 | Subject: [PATCH 4/4] llvm: remove fopen64/fseeko64/ftello64/tmpfile64 on musl | ||
5 | |||
6 | They are not available | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | include/llvm/Analysis/TargetLibraryInfo.def | 12 ------------ | ||
11 | lib/Analysis/TargetLibraryInfo.cpp | 13 ------------- | ||
12 | lib/Transforms/Utils/BuildLibCalls.cpp | 17 ----------------- | ||
13 | 3 files changed, 42 deletions(-) | ||
14 | |||
15 | diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def | ||
16 | index b2a593d..7bfafcc 100644 | ||
17 | --- a/include/llvm/Analysis/TargetLibraryInfo.def | ||
18 | +++ b/include/llvm/Analysis/TargetLibraryInfo.def | ||
19 | @@ -530,9 +530,6 @@ TLI_DEFINE_STRING_INTERNAL("fmodl") | ||
20 | /// FILE *fopen(const char *filename, const char *mode); | ||
21 | TLI_DEFINE_ENUM_INTERNAL(fopen) | ||
22 | TLI_DEFINE_STRING_INTERNAL("fopen") | ||
23 | -/// FILE *fopen64(const char *filename, const char *opentype) | ||
24 | -TLI_DEFINE_ENUM_INTERNAL(fopen64) | ||
25 | -TLI_DEFINE_STRING_INTERNAL("fopen64") | ||
26 | /// int fprintf(FILE *stream, const char *format, ...); | ||
27 | TLI_DEFINE_ENUM_INTERNAL(fprintf) | ||
28 | TLI_DEFINE_STRING_INTERNAL("fprintf") | ||
29 | @@ -566,9 +563,6 @@ TLI_DEFINE_STRING_INTERNAL("fseek") | ||
30 | /// int fseeko(FILE *stream, off_t offset, int whence); | ||
31 | TLI_DEFINE_ENUM_INTERNAL(fseeko) | ||
32 | TLI_DEFINE_STRING_INTERNAL("fseeko") | ||
33 | -/// int fseeko64(FILE *stream, off64_t offset, int whence) | ||
34 | -TLI_DEFINE_ENUM_INTERNAL(fseeko64) | ||
35 | -TLI_DEFINE_STRING_INTERNAL("fseeko64") | ||
36 | /// int fsetpos(FILE *stream, const fpos_t *pos); | ||
37 | TLI_DEFINE_ENUM_INTERNAL(fsetpos) | ||
38 | TLI_DEFINE_STRING_INTERNAL("fsetpos") | ||
39 | @@ -590,9 +584,6 @@ TLI_DEFINE_STRING_INTERNAL("ftell") | ||
40 | /// off_t ftello(FILE *stream); | ||
41 | TLI_DEFINE_ENUM_INTERNAL(ftello) | ||
42 | TLI_DEFINE_STRING_INTERNAL("ftello") | ||
43 | -/// off64_t ftello64(FILE *stream) | ||
44 | -TLI_DEFINE_ENUM_INTERNAL(ftello64) | ||
45 | -TLI_DEFINE_STRING_INTERNAL("ftello64") | ||
46 | /// int ftrylockfile(FILE *file); | ||
47 | TLI_DEFINE_ENUM_INTERNAL(ftrylockfile) | ||
48 | TLI_DEFINE_STRING_INTERNAL("ftrylockfile") | ||
49 | @@ -1055,9 +1046,6 @@ TLI_DEFINE_STRING_INTERNAL("times") | ||
50 | /// FILE *tmpfile(void); | ||
51 | TLI_DEFINE_ENUM_INTERNAL(tmpfile) | ||
52 | TLI_DEFINE_STRING_INTERNAL("tmpfile") | ||
53 | -/// FILE *tmpfile64(void) | ||
54 | -TLI_DEFINE_ENUM_INTERNAL(tmpfile64) | ||
55 | -TLI_DEFINE_STRING_INTERNAL("tmpfile64") | ||
56 | /// int toascii(int c); | ||
57 | TLI_DEFINE_ENUM_INTERNAL(toascii) | ||
58 | TLI_DEFINE_STRING_INTERNAL("toascii") | ||
59 | diff --git a/lib/Analysis/TargetLibraryInfo.cpp b/lib/Analysis/TargetLibraryInfo.cpp | ||
60 | index 71f15b15..6d98f06 100644 | ||
61 | --- a/lib/Analysis/TargetLibraryInfo.cpp | ||
62 | +++ b/lib/Analysis/TargetLibraryInfo.cpp | ||
63 | @@ -375,16 +375,12 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, | ||
64 | TLI.setUnavailable(LibFunc::under_IO_getc); | ||
65 | TLI.setUnavailable(LibFunc::under_IO_putc); | ||
66 | TLI.setUnavailable(LibFunc::memalign); | ||
67 | - TLI.setUnavailable(LibFunc::fopen64); | ||
68 | - TLI.setUnavailable(LibFunc::fseeko64); | ||
69 | TLI.setUnavailable(LibFunc::fstat64); | ||
70 | TLI.setUnavailable(LibFunc::fstatvfs64); | ||
71 | - TLI.setUnavailable(LibFunc::ftello64); | ||
72 | TLI.setUnavailable(LibFunc::lstat64); | ||
73 | TLI.setUnavailable(LibFunc::open64); | ||
74 | TLI.setUnavailable(LibFunc::stat64); | ||
75 | TLI.setUnavailable(LibFunc::statvfs64); | ||
76 | - TLI.setUnavailable(LibFunc::tmpfile64); | ||
77 | } | ||
78 | |||
79 | // As currently implemented in clang, NVPTX code has no standard library to | ||
80 | @@ -861,15 +857,6 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy, | ||
81 | case LibFunc::dunder_isoc99_sscanf: | ||
82 | return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy() && | ||
83 | FTy.getParamType(1)->isPointerTy()); | ||
84 | - case LibFunc::fopen64: | ||
85 | - return (NumParams == 2 && FTy.getReturnType()->isPointerTy() && | ||
86 | - FTy.getParamType(0)->isPointerTy() && | ||
87 | - FTy.getParamType(1)->isPointerTy()); | ||
88 | - case LibFunc::fseeko64: | ||
89 | - case LibFunc::ftello64: | ||
90 | - return (NumParams == 0 && FTy.getParamType(0)->isPointerTy()); | ||
91 | - case LibFunc::tmpfile64: | ||
92 | - return (FTy.getReturnType()->isPointerTy()); | ||
93 | case LibFunc::fstat64: | ||
94 | case LibFunc::fstatvfs64: | ||
95 | return (NumParams == 2 && FTy.getParamType(1)->isPointerTy()); | ||
96 | diff --git a/lib/Transforms/Utils/BuildLibCalls.cpp b/lib/Transforms/Utils/BuildLibCalls.cpp | ||
97 | index f4260a9..a9e673f 100644 | ||
98 | --- a/lib/Transforms/Utils/BuildLibCalls.cpp | ||
99 | +++ b/lib/Transforms/Utils/BuildLibCalls.cpp | ||
100 | @@ -638,23 +638,6 @@ bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) { | ||
101 | Changed |= setOnlyReadsMemory(F, 1); | ||
102 | Changed |= setOnlyReadsMemory(F, 2); | ||
103 | return Changed; | ||
104 | - case LibFunc::fopen64: | ||
105 | - Changed |= setDoesNotThrow(F); | ||
106 | - Changed |= setDoesNotAlias(F, 0); | ||
107 | - Changed |= setDoesNotCapture(F, 1); | ||
108 | - Changed |= setDoesNotCapture(F, 2); | ||
109 | - Changed |= setOnlyReadsMemory(F, 1); | ||
110 | - Changed |= setOnlyReadsMemory(F, 2); | ||
111 | - return Changed; | ||
112 | - case LibFunc::fseeko64: | ||
113 | - case LibFunc::ftello64: | ||
114 | - Changed |= setDoesNotThrow(F); | ||
115 | - Changed |= setDoesNotCapture(F, 1); | ||
116 | - return Changed; | ||
117 | - case LibFunc::tmpfile64: | ||
118 | - Changed |= setDoesNotThrow(F); | ||
119 | - Changed |= setDoesNotAlias(F, 0); | ||
120 | - return Changed; | ||
121 | case LibFunc::fstat64: | ||
122 | case LibFunc::fstatvfs64: | ||
123 | Changed |= setDoesNotThrow(F); | ||
124 | -- | ||
125 | 2.8.2 | ||
126 | |||
diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index b6804ac..5809478 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb | |||
@@ -18,7 +18,7 @@ SRC_URI = "${LLVM_GIT}/llvm.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};n | |||
18 | file://0001-llvm-triplet-Add-musl-support.patch \ | 18 | file://0001-llvm-triplet-Add-musl-support.patch \ |
19 | file://0002-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch \ | 19 | file://0002-llvm-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-com.patch \ |
20 | file://0003-llvm-Do-not-assume-linux-glibc.patch \ | 20 | file://0003-llvm-Do-not-assume-linux-glibc.patch \ |
21 | file://0004-llvm-remove-fopen64-fseeko64-ftello64-tmpfile64-on-m.patch \ | 21 | file://0004-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \ |
22 | file://0001-clang-driver-Add-musl-ldso-support.patch;patchdir=tools/clang \ | 22 | file://0001-clang-driver-Add-musl-ldso-support.patch;patchdir=tools/clang \ |
23 | file://0002-clang-driver-Use-lib-for-ldso-on-OE.patch;patchdir=tools/clang \ | 23 | file://0002-clang-driver-Use-lib-for-ldso-on-OE.patch;patchdir=tools/clang \ |
24 | file://0003-clang-Driver-tools.cpp-Add-lssp-and-lssp_nonshared-o.patch;patchdir=tools/clang \ | 24 | file://0003-clang-Driver-tools.cpp-Add-lssp-and-lssp_nonshared-o.patch;patchdir=tools/clang \ |
@@ -86,7 +86,7 @@ EXTRA_OEMAKE += "REQUIRES_RTTI=1 VERBOSE=1" | |||
86 | DEPENDS = "zlib libffi libxml2 binutils" | 86 | DEPENDS = "zlib libffi libxml2 binutils" |
87 | DEPENDS_remove_class-nativesdk = "nativesdk-binutils" | 87 | DEPENDS_remove_class-nativesdk = "nativesdk-binutils" |
88 | DEPENDS_append_class-nativesdk = " clang-native " | 88 | DEPENDS_append_class-nativesdk = " clang-native " |
89 | DEPENDS_append_class-target = " clang-native " | 89 | DEPENDS_append_class-target = " clang-cross-${TARGET_ARCH} " |
90 | 90 | ||
91 | do_configure_prepend() { | 91 | do_configure_prepend() { |
92 | # Remove RPATHs | 92 | # Remove RPATHs |