summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2017-07-27 10:40:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-07-31 15:13:32 +0100
commit5c77067ee9c18e056515a5e83e7282b0035dfb49 (patch)
tree50508739f29e81b23586480eab22bda43f0e936a /meta/recipes-devtools
parente7bb5ae841eabe86763f8e2fe5c92f4c7080420d (diff)
downloadpoky-5c77067ee9c18e056515a5e83e7282b0035dfb49.tar.gz
llvm: Add recipe for 5.0
Based on recipe from meta-oe and clang recipe from meta-clang Needed by mesa Fixes [YOCTO #11529] (From OE-Core rev: 8724ef9c53e7804ead9ba0f019369b0e4daada63) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch93
-rw-r--r--meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch39
-rw-r--r--meta/recipes-devtools/llvm/llvm_git.bb182
3 files changed, 314 insertions, 0 deletions
diff --git a/meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch b/meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
new file mode 100644
index 0000000000..e251799259
--- /dev/null
+++ b/meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
@@ -0,0 +1,93 @@
1From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 21 May 2016 00:33:20 +0000
4Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc functions if they
5 are macros
6
7musl defines some functions as macros and not inline functions
8if this is the case then make sure to undefine them
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12Upstream-Status: Pending
13
14 include/llvm/Analysis/TargetLibraryInfo.def | 21 +++++++++++++++++++++
15 1 file changed, 21 insertions(+)
16
17diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def
18index 9cbe917c146..aff8419cf54 100644
19--- a/include/llvm/Analysis/TargetLibraryInfo.def
20+++ b/include/llvm/Analysis/TargetLibraryInfo.def
21@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
22 TLI_DEFINE_ENUM_INTERNAL(fopen)
23 TLI_DEFINE_STRING_INTERNAL("fopen")
24 /// FILE *fopen64(const char *filename, const char *opentype)
25+#ifdef fopen64
26+#undef fopen64
27+#endif
28 TLI_DEFINE_ENUM_INTERNAL(fopen64)
29 TLI_DEFINE_STRING_INTERNAL("fopen64")
30 /// int fprintf(FILE *stream, const char *format, ...);
31@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
32 /// int fseeko(FILE *stream, off_t offset, int whence);
33 TLI_DEFINE_ENUM_INTERNAL(fseeko)
34 TLI_DEFINE_STRING_INTERNAL("fseeko")
35+#ifdef fseeko64
36+#undef fseeko64
37+#endif
38 /// int fseeko64(FILE *stream, off64_t offset, int whence)
39 TLI_DEFINE_ENUM_INTERNAL(fseeko64)
40 TLI_DEFINE_STRING_INTERNAL("fseeko64")
41@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
42 TLI_DEFINE_ENUM_INTERNAL(fstat)
43 TLI_DEFINE_STRING_INTERNAL("fstat")
44 /// int fstat64(int filedes, struct stat64 *buf)
45+#ifdef fstat64
46+#undef fstat64
47+#endif
48 TLI_DEFINE_ENUM_INTERNAL(fstat64)
49 TLI_DEFINE_STRING_INTERNAL("fstat64")
50 /// int fstatvfs(int fildes, struct statvfs *buf);
51@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
52 TLI_DEFINE_ENUM_INTERNAL(ftello)
53 TLI_DEFINE_STRING_INTERNAL("ftello")
54 /// off64_t ftello64(FILE *stream)
55+#ifdef ftello64
56+#undef ftello64
57+#endif
58 TLI_DEFINE_ENUM_INTERNAL(ftello64)
59 TLI_DEFINE_STRING_INTERNAL("ftello64")
60 /// int ftrylockfile(FILE *file);
61@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
62 TLI_DEFINE_ENUM_INTERNAL(lstat)
63 TLI_DEFINE_STRING_INTERNAL("lstat")
64 /// int lstat64(const char *path, struct stat64 *buf);
65+#ifdef lstat64
66+#undef lstat64
67+#endif
68 TLI_DEFINE_ENUM_INTERNAL(lstat64)
69 TLI_DEFINE_STRING_INTERNAL("lstat64")
70 /// void *malloc(size_t size);
71@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
72 TLI_DEFINE_ENUM_INTERNAL(stat)
73 TLI_DEFINE_STRING_INTERNAL("stat")
74 /// int stat64(const char *path, struct stat64 *buf);
75+#ifdef stat64
76+#undef stat64
77+#endif
78 TLI_DEFINE_ENUM_INTERNAL(stat64)
79 TLI_DEFINE_STRING_INTERNAL("stat64")
80 /// int statvfs(const char *path, struct statvfs *buf);
81@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
82 TLI_DEFINE_ENUM_INTERNAL(tmpfile)
83 TLI_DEFINE_STRING_INTERNAL("tmpfile")
84 /// FILE *tmpfile64(void)
85+#ifdef tmpfile64
86+#undef tmpfile64
87+#endif
88 TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
89 TLI_DEFINE_STRING_INTERNAL("tmpfile64")
90 /// int toascii(int c);
91--
922.13.1
93
diff --git a/meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch b/meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
new file mode 100644
index 0000000000..832bd729ef
--- /dev/null
+++ b/meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
@@ -0,0 +1,39 @@
1From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17 00:00:00 2001
2From: Martin Kelly <mkelly@xevo.com>
3Date: Fri, 19 May 2017 00:22:57 -0700
4Subject: [PATCH 2/2] llvm: allow env override of exe path
5
6When using a native llvm-config from inside a sysroot, we need llvm-config to
7return the libraries, include directories, etc. from inside the sysroot rather
8than from the native sysroot. Thus provide an env override for calling
9llvm-config from a target sysroot.
10
11Signed-off-by: Martin Kelly <mkelly@xevo.com>
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14Upstream-Status: Pending
15
16 tools/llvm-config/llvm-config.cpp | 7 +++++++
17 1 file changed, 7 insertions(+)
18
19diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
20index 08b096afb05..d8d7742744e 100644
21--- a/tools/llvm-config/llvm-config.cpp
22+++ b/tools/llvm-config/llvm-config.cpp
23@@ -225,6 +225,13 @@ Typical components:\n\
24
25 /// \brief Compute the path to the main executable.
26 std::string GetExecutablePath(const char *Argv0) {
27+ // Hack for Yocto: we need to override the root path when we are using
28+ // llvm-config from within a target sysroot.
29+ const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
30+ if (Sysroot != nullptr) {
31+ return Sysroot;
32+ }
33+
34 // This just needs to be some symbol in the binary; C++ doesn't
35 // allow taking the address of ::main however.
36 void *P = (void *)(intptr_t)GetExecutablePath;
37--
382.13.1
39
diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb
new file mode 100644
index 0000000000..5dcb508c23
--- /dev/null
+++ b/meta/recipes-devtools/llvm/llvm_git.bb
@@ -0,0 +1,182 @@
1# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4DESCRIPTION = "The LLVM Compiler Infrastructure"
5HOMEPAGE = "http://llvm.org"
6LICENSE = "NCSA"
7SECTION = "devel"
8
9LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e5251771"
10
11DEPENDS = "libffi libxml2-native zlib ninja-native llvm-native"
12
13DEPENDS_remove_toolchain-clang = "llvm-native"
14
15RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
16
17inherit perlnative pythonnative cmake pkgconfig
18
19PROVIDES += "llvm${PV}"
20
21LLVM_RELEASE = "${PV}"
22LLVM_DIR = "llvm${LLVM_RELEASE}"
23
24SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
25PV = "5.0"
26PATCH_VERSION = "0"
27SRC_URI = "git://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http \
28 file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
29 file://0002-llvm-allow-env-override-of-exe-path.patch \
30 "
31S = "${WORKDIR}/git"
32
33LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
34def get_llvm_arch(bb, d, arch_var):
35 import re
36 a = d.getVar(arch_var, True)
37 if re.match('(i.86|athlon|x86.64)$', a): return 'X86'
38 elif re.match('arm$', a): return 'ARM'
39 elif re.match('armeb$', a): return 'ARM'
40 elif re.match('aarch64$', a): return 'AArch64'
41 elif re.match('aarch64_be$', a): return 'AArch64'
42 elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
43 elif re.match('p(pc|owerpc)(|64)', a): return 'PowerPC'
44 else:
45 bb.error("cannot map '%s' to a supported llvm architecture" % a)
46 return ""
47
48def get_llvm_target_arch(bb, d):
49 return get_llvm_arch(bb, d, 'TARGET_ARCH')
50#
51# Default to build all OE-Core supported target arches (user overridable).
52#
53LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
54LLVM_TARGETS_prepend_x86 = "AMDGPU;"
55LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
56
57EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
58 -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
59 -DLLVM_ENABLE_PIC=ON \
60 -DLLVM_BINDINGS_LIST='' \
61 -DLLVM_LINK_LLVM_DYLIB=ON \
62 -DLLVM_ENABLE_FFI=ON \
63 -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
64 -DLLVM_OPTIMIZED_TABLEGEN=ON \
65 -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
66 -G Ninja"
67
68EXTRA_OECMAKE_append_class-target = "\
69 -DCMAKE_CROSSCOMPILING:BOOL=ON \
70 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
71 "
72
73EXTRA_OECMAKE_append_class-nativesdk = "\
74 -DCMAKE_CROSSCOMPILING:BOOL=ON \
75 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen \
76 "
77
78do_configure_prepend() {
79# Fix paths in llvm-config
80 sed -i "s|sys::path::parent_path(CurrentPath))\.str()|sys::path::parent_path(sys::path::parent_path(CurrentPath))).str()|g" ${S}/tools/llvm-config/llvm-config.cpp
81 sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g" ${S}/tools/llvm-config/llvm-config.cpp
82 sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g" ${S}/tools/llvm-config/llvm-config.cpp
83}
84
85do_compile() {
86 NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
87}
88
89do_compile_class-native() {
90 NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE} llvm-tblgen
91}
92
93do_install() {
94 NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja -v install
95 install -D -m 0755 ${B}/NATIVE/bin/llvm-config ${D}${libdir}/${LLVM_DIR}/llvm-config-host
96
97 install -d ${D}${bindir}/${LLVM_DIR}
98 cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
99
100 install -d ${D}${includedir}/${LLVM_DIR}
101 cp -r ${LLVM_INSTALL_DIR}${includedir}/* ${D}${includedir}/${LLVM_DIR}/
102
103 install -d ${D}${libdir}/${LLVM_DIR}
104
105 # The LLVM sources have "/lib" embedded and so we cannot completely rely on the ${libdir} variable
106 if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
107 cp -r ${LLVM_INSTALL_DIR}${libdir}/* ${D}${libdir}/${LLVM_DIR}/
108 elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
109 cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/* ${D}${libdir}/${LLVM_DIR}/
110 elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
111 cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/* ${D}${libdir}/${LLVM_DIR}/
112 fi
113
114 # Remove unnecessary cmake files
115 rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
116
117 ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV} ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
118
119 # We'll have to delete the libLLVM.so due to multiple reasons...
120 rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
121 rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
122}
123do_install_class-native() {
124 install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen
125}
126
127PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
128ALLOW_EMPTY_${PN} = "1"
129ALLOW_EMPTY_${PN}-staticdev = "1"
130FILES_${PN} = ""
131FILES_${PN}-staticdev = ""
132FILES_${PN}-dbg = " \
133 ${bindir}/${LLVM_DIR}/.debug \
134 ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
135 ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
136 ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
137 ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
138 /usr/src/debug \
139"
140
141FILES_${PN}-dev = " \
142 ${bindir}/${LLVM_DIR} \
143 ${includedir}/${LLVM_DIR} \
144 ${libdir}/${LLVM_DIR}/llvm-config-host \
145"
146
147RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
148
149FILES_${PN}-bugpointpasses = "\
150 ${libdir}/${LLVM_DIR}/BugpointPasses.so \
151"
152FILES_${PN} += "\
153 ${libdir}/${LLVM_DIR}/libLTO.so.* \
154"
155
156FILES_${PN}-llvmhello = "\
157 ${libdir}/${LLVM_DIR}/LLVMHello.so \
158"
159
160PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
161NOAUTOPACKAGEDEBUG = "1"
162
163INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION} += "dev-so"
164INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} += "dev-so"
165INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
166
167python llvm_populate_packages() {
168 libdir = bb.data.expand('${libdir}', d)
169 libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
170 split_dbg_packages = do_split_packages(d, libllvm_libdir+'/.debug', '^lib(.*)\.so$', 'libllvm${LLVM_RELEASE}-%s-dbg', 'Split debug package for %s', allow_dirs=True)
171 split_packages = do_split_packages(d, libdir, '^lib(.*)\.so$', 'libllvm${LLVM_RELEASE}-%s', 'Split package for %s', allow_dirs=True, allow_links=True, recursive=True)
172 split_staticdev_packages = do_split_packages(d, libllvm_libdir, '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev package for %s', allow_dirs=True)
173 if split_packages:
174 pn = d.getVar('PN', True)
175 d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
176 d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+' '.join(split_dbg_packages))
177 d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+' '.join(split_staticdev_packages))
178}
179
180PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
181
182BBCLASSEXTEND = "native nativesdk"