All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/4] llvm: Add recipe for 5.0
@ 2017-07-29  8:35 Khem Raj
  2017-07-29  8:35 ` [PATCH 1/4] ninja: Add recipe Khem Raj
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-29  8:35 UTC (permalink / raw)
  To: openembedded-core

Create a recipe just for building llvm, which is needed by many other packages e.g. mesa
can use it for llvmpipe

Fix mesa to work with llvm 5.0.0

Add supporting recipes needed to build llvm

The following changes since commit 28fc6ba761ed4a47efa7c43e7f7dff5e2fe72b5e:

  core-image-minimal-initramfs: use initramfs-framework by default (2017-07-27 22:20:16 +0100)

are available in the git repository at:

  git://git.openembedded.org/openembedded-core-contrib kraj/llvm
  http://cgit.openembedded.org/openembedded-core-contrib/log/?h=kraj/llvm

Khem Raj (4):
  ninja: Add recipe
  re2c: Transfer recipe from meta-oe and upgrade to 0.16
  llvm: Add recipe for 5.0
  mesa: Fix build when building with llvmpipe

 ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93 ++++++++++++
 .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
 meta/recipes-devtools/llvm/llvm_git.bb             | 166 +++++++++++++++++++++
 meta/recipes-devtools/ninja/ninja_1.7.2.bb         |  29 ++++
 ...1-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch |  40 +++++
 ...allivm-Fix-build-against-LLVM-SVN-r302589.patch |  49 ++++++
 .../mesa/files/llvm-config-version.patch           |  23 +++
 meta/recipes-graphics/mesa/mesa.inc                |   7 +-
 meta/recipes-graphics/mesa/mesa_17.1.5.bb          |   3 +
 meta/recipes-support/re2c/re2c_0.16.bb             |  15 ++
 10 files changed, 462 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
 create mode 100644 meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
 create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
 create mode 100644 meta/recipes-devtools/ninja/ninja_1.7.2.bb
 create mode 100644 meta/recipes-graphics/mesa/files/0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch
 create mode 100644 meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch
 create mode 100644 meta/recipes-graphics/mesa/files/llvm-config-version.patch
 create mode 100644 meta/recipes-support/re2c/re2c_0.16.bb

-- 
2.13.3



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] ninja: Add recipe
  2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
@ 2017-07-29  8:35 ` Khem Raj
  2017-07-29  8:35 ` [PATCH 2/4] re2c: Transfer recipe from meta-oe and upgrade to 0.16 Khem Raj
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-29  8:35 UTC (permalink / raw)
  To: openembedded-core

llvm is using it, therefore move it from meta-oe

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-devtools/ninja/ninja_1.7.2.bb | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 meta/recipes-devtools/ninja/ninja_1.7.2.bb

diff --git a/meta/recipes-devtools/ninja/ninja_1.7.2.bb b/meta/recipes-devtools/ninja/ninja_1.7.2.bb
new file mode 100644
index 0000000000..20dca2f0af
--- /dev/null
+++ b/meta/recipes-devtools/ninja/ninja_1.7.2.bb
@@ -0,0 +1,29 @@
+SUMMARY = "Ninja is a small build system with a focus on speed."
+HOMEPAGE = "http://martine.github.com/ninja/"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://COPYING;md5=a81586a64ad4e476c791cda7e2f2c52e"
+
+DEPENDS = "re2c-native ninja-native"
+
+SRCREV = "717b7b4a31db6027207588c0fb89c3ead384747b"
+
+SRC_URI = "git://github.com/martine/ninja.git;branch=release"
+
+S = "${WORKDIR}/git"
+
+do_configure[noexec] = "1"
+
+do_compile_class-native() {
+	./configure.py --bootstrap
+}
+
+do_compile() {
+	./configure.py
+	ninja
+}
+
+do_install() {
+	install -D -m 0755  ${S}/ninja ${D}${bindir}/ninja
+}
+
+BBCLASSEXTEND = "native nativesdk"
-- 
2.13.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] re2c: Transfer recipe from meta-oe and upgrade to 0.16
  2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
  2017-07-29  8:35 ` [PATCH 1/4] ninja: Add recipe Khem Raj
@ 2017-07-29  8:35 ` Khem Raj
  2017-07-29  8:35 ` [PATCH 3/4] llvm: Add recipe for 5.0 Khem Raj
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-29  8:35 UTC (permalink / raw)
  To: openembedded-core

ninja needs it.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-support/re2c/re2c_0.16.bb | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 meta/recipes-support/re2c/re2c_0.16.bb

diff --git a/meta/recipes-support/re2c/re2c_0.16.bb b/meta/recipes-support/re2c/re2c_0.16.bb
new file mode 100644
index 0000000000..e82502c5f2
--- /dev/null
+++ b/meta/recipes-support/re2c/re2c_0.16.bb
@@ -0,0 +1,15 @@
+SUMMARY = "Tool for writing very fast and very flexible scanners"
+HOMEPAGE = "http://re2c.sourceforge.net/"
+AUTHOR = "Marcus Börger <helly@users.sourceforge.net>"
+SECTION = "devel"
+LICENSE = "PD"
+LIC_FILES_CHKSUM = "file://README;beginline=146;md5=881056c9add17f8019ccd8c382ba963a"
+
+SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/${BPN}-${PV}.tar.gz \
+"
+SRC_URI[md5sum] = "3bf508fabd52ed7334647d0ccb956e8d"
+SRC_URI[sha256sum] = "48c12564297641cceb5ff05aead57f28118db6277f31e2262437feba89069e84"
+
+BBCLASSEXTEND = "native"
+
+inherit autotools
-- 
2.13.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
  2017-07-29  8:35 ` [PATCH 1/4] ninja: Add recipe Khem Raj
  2017-07-29  8:35 ` [PATCH 2/4] re2c: Transfer recipe from meta-oe and upgrade to 0.16 Khem Raj
@ 2017-07-29  8:35 ` Khem Raj
  2017-07-29 11:39   ` Burton, Ross
  2017-07-29  8:35 ` [PATCH 4/4] mesa: Fix build when building with llvmpipe Khem Raj
  2017-07-29  9:01 ` ✗ patchtest: failure for llvm: Add recipe for 5.0 (rev3) Patchwork
  4 siblings, 1 reply; 11+ messages in thread
From: Khem Raj @ 2017-07-29  8:35 UTC (permalink / raw)
  To: openembedded-core

Based on recipe from meta-oe and clang recipe from meta-clang
Needed by mesa

Fixes
[YOCTO #11529]

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93 ++++++++++++
 .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
 meta/recipes-devtools/llvm/llvm_git.bb             | 166 +++++++++++++++++++++
 3 files changed, 298 insertions(+)
 create mode 100644 meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
 create mode 100644 meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
 create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb

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 @@
+From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sat, 21 May 2016 00:33:20 +0000
+Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc functions if they
+ are macros
+
+musl defines some functions as macros and not inline functions
+if this is the case then make sure to undefine them
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ include/llvm/Analysis/TargetLibraryInfo.def | 21 +++++++++++++++++++++
+ 1 file changed, 21 insertions(+)
+
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def
+index 9cbe917c146..aff8419cf54 100644
+--- a/include/llvm/Analysis/TargetLibraryInfo.def
++++ b/include/llvm/Analysis/TargetLibraryInfo.def
+@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
+ TLI_DEFINE_ENUM_INTERNAL(fopen)
+ TLI_DEFINE_STRING_INTERNAL("fopen")
+ /// FILE *fopen64(const char *filename, const char *opentype)
++#ifdef fopen64
++#undef fopen64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(fopen64)
+ TLI_DEFINE_STRING_INTERNAL("fopen64")
+ /// int fprintf(FILE *stream, const char *format, ...);
+@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
+ /// int fseeko(FILE *stream, off_t offset, int whence);
+ TLI_DEFINE_ENUM_INTERNAL(fseeko)
+ TLI_DEFINE_STRING_INTERNAL("fseeko")
++#ifdef fseeko64
++#undef fseeko64
++#endif
+ /// int fseeko64(FILE *stream, off64_t offset, int whence)
+ TLI_DEFINE_ENUM_INTERNAL(fseeko64)
+ TLI_DEFINE_STRING_INTERNAL("fseeko64")
+@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
+ TLI_DEFINE_ENUM_INTERNAL(fstat)
+ TLI_DEFINE_STRING_INTERNAL("fstat")
+ /// int fstat64(int filedes, struct stat64 *buf)
++#ifdef fstat64
++#undef fstat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(fstat64)
+ TLI_DEFINE_STRING_INTERNAL("fstat64")
+ /// int fstatvfs(int fildes, struct statvfs *buf);
+@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
+ TLI_DEFINE_ENUM_INTERNAL(ftello)
+ TLI_DEFINE_STRING_INTERNAL("ftello")
+ /// off64_t ftello64(FILE *stream)
++#ifdef ftello64
++#undef ftello64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(ftello64)
+ TLI_DEFINE_STRING_INTERNAL("ftello64")
+ /// int ftrylockfile(FILE *file);
+@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
+ TLI_DEFINE_ENUM_INTERNAL(lstat)
+ TLI_DEFINE_STRING_INTERNAL("lstat")
+ /// int lstat64(const char *path, struct stat64 *buf);
++#ifdef lstat64
++#undef lstat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(lstat64)
+ TLI_DEFINE_STRING_INTERNAL("lstat64")
+ /// void *malloc(size_t size);
+@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
+ TLI_DEFINE_ENUM_INTERNAL(stat)
+ TLI_DEFINE_STRING_INTERNAL("stat")
+ /// int stat64(const char *path, struct stat64 *buf);
++#ifdef stat64
++#undef stat64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(stat64)
+ TLI_DEFINE_STRING_INTERNAL("stat64")
+ /// int statvfs(const char *path, struct statvfs *buf);
+@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
+ TLI_DEFINE_ENUM_INTERNAL(tmpfile)
+ TLI_DEFINE_STRING_INTERNAL("tmpfile")
+ /// FILE *tmpfile64(void)
++#ifdef tmpfile64
++#undef tmpfile64
++#endif
+ TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
+ TLI_DEFINE_STRING_INTERNAL("tmpfile64")
+ /// int toascii(int c);
+-- 
+2.13.1
+
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 @@
+From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17 00:00:00 2001
+From: Martin Kelly <mkelly@xevo.com>
+Date: Fri, 19 May 2017 00:22:57 -0700
+Subject: [PATCH 2/2] llvm: allow env override of exe path
+
+When using a native llvm-config from inside a sysroot, we need llvm-config to
+return the libraries, include directories, etc. from inside the sysroot rather
+than from the native sysroot. Thus provide an env override for calling
+llvm-config from a target sysroot.
+
+Signed-off-by: Martin Kelly <mkelly@xevo.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+Upstream-Status: Pending
+
+ tools/llvm-config/llvm-config.cpp | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 08b096afb05..d8d7742744e 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -225,6 +225,13 @@ Typical components:\n\
+ 
+ /// \brief Compute the path to the main executable.
+ std::string GetExecutablePath(const char *Argv0) {
++  // Hack for Yocto: we need to override the root path when we are using
++  // llvm-config from within a target sysroot.
++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
++  if (Sysroot != nullptr) {
++    return Sysroot;
++  }
++
+   // This just needs to be some symbol in the binary; C++ doesn't
+   // allow taking the address of ::main however.
+   void *P = (void *)(intptr_t)GetExecutablePath;
+-- 
+2.13.1
+
diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb
new file mode 100644
index 0000000000..7b51d2153f
--- /dev/null
+++ b/meta/recipes-devtools/llvm/llvm_git.bb
@@ -0,0 +1,166 @@
+# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+
+DESCRIPTION = "The LLVM Compiler Infrastructure"
+HOMEPAGE = "http://llvm.org"
+LICENSE = "NCSA"
+SECTION = "devel"
+
+LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e5251771"
+
+DEPENDS = "libffi libxml2-native zlib ninja-native"
+
+RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
+
+inherit perlnative pythonnative cmake pkgconfig
+
+PROVIDES += "llvm${PV}"
+
+LLVM_RELEASE = "${PV}"
+LLVM_DIR = "llvm${LLVM_RELEASE}"
+
+SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
+PV = "5.0"
+PATCH_VERSION = "0"
+SRC_URI = "git://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http \
+           file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
+           file://0002-llvm-allow-env-override-of-exe-path.patch \
+          "
+S = "${WORKDIR}/git"
+
+LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
+def get_llvm_arch(bb, d, arch_var):
+    import re
+    a = d.getVar(arch_var, True)
+    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
+    elif re.match('arm$', a):                          return 'ARM'
+    elif re.match('armeb$', a):                        return 'ARM'
+    elif re.match('aarch64$', a):                      return 'AArch64'
+    elif re.match('aarch64_be$', a):                   return 'AArch64'
+    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
+    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
+    else:
+        bb.error("cannot map '%s' to a supported llvm architecture" % a)
+    return ""
+
+def get_llvm_target_arch(bb, d):
+    return get_llvm_arch(bb, d, 'TARGET_ARCH')
+#
+# Default to build all OE-Core supported target arches (user overridable).
+#
+LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
+LLVM_TARGETS_prepend_x86 = "AMDGPU;"
+LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
+
+EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
+                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
+                  -DLLVM_ENABLE_PIC=ON \
+                  -DLLVM_BINDINGS_LIST='' \
+                  -DLLVM_LINK_LLVM_DYLIB=ON \
+                  -DLLVM_ENABLE_FFI=ON \
+                  -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
+                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
+                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
+                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
+                  -G Ninja \
+                 "
+EXTRA_OECMAKE_remove_class-native = "-DCMAKE_CROSSCOMPILING:BOOL=ON"
+
+do_configure_prepend() {
+# Fix paths in llvm-config
+	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
+	sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g" ${S}/tools/llvm-config/llvm-config.cpp
+	sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g" ${S}/tools/llvm-config/llvm-config.cpp
+}
+
+do_compile() {
+	NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
+}
+
+do_install() {
+	NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja -v install
+	install -D -m 0755 ${B}/NATIVE/bin/llvm-config ${D}${libdir}/${LLVM_DIR}/llvm-config-host
+
+	install -d ${D}${bindir}/${LLVM_DIR}
+	cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
+
+	install -d ${D}${includedir}/${LLVM_DIR}
+	cp -r ${LLVM_INSTALL_DIR}${includedir}/* ${D}${includedir}/${LLVM_DIR}/
+
+	install -d ${D}${libdir}/${LLVM_DIR}
+
+	# The LLVM sources have "/lib" embedded and so we cannot completely rely on the ${libdir} variable
+	if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
+		cp -r ${LLVM_INSTALL_DIR}${libdir}/* ${D}${libdir}/${LLVM_DIR}/
+	elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
+		cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/* ${D}${libdir}/${LLVM_DIR}/
+	elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
+		cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/* ${D}${libdir}/${LLVM_DIR}/
+	fi
+
+	# Remove unnecessary cmake files
+	rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
+
+	ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV} ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
+
+	# We'll have to delete the libLLVM.so due to multiple reasons...
+	rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
+	rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
+}
+
+PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
+ALLOW_EMPTY_${PN} = "1"
+ALLOW_EMPTY_${PN}-staticdev = "1"
+FILES_${PN} = ""
+FILES_${PN}-staticdev = ""
+FILES_${PN}-dbg = " \
+    ${bindir}/${LLVM_DIR}/.debug \
+    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
+    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
+    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
+    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
+    /usr/src/debug \
+"
+
+FILES_${PN}-dev = " \
+    ${bindir}/${LLVM_DIR} \
+    ${includedir}/${LLVM_DIR} \
+    ${libdir}/${LLVM_DIR}/llvm-config-host \
+"
+
+RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
+
+FILES_${PN}-bugpointpasses = "\
+    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
+"
+FILES_${PN} += "\
+    ${libdir}/${LLVM_DIR}/libLTO.so.* \
+"
+
+FILES_${PN}-llvmhello = "\
+    ${libdir}/${LLVM_DIR}/LLVMHello.so \
+"
+
+PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
+NOAUTOPACKAGEDEBUG = "1"
+
+INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION} += "dev-so"
+INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} += "dev-so"
+INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
+
+python llvm_populate_packages() {
+    libdir = bb.data.expand('${libdir}', d)
+    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
+    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)
+    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)
+    split_staticdev_packages = do_split_packages(d, libllvm_libdir, '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev package for %s', allow_dirs=True)
+    if split_packages:
+        pn = d.getVar('PN', True)
+        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
+        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+' '.join(split_dbg_packages))
+        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+' '.join(split_staticdev_packages))
+}
+
+PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
+
+BBCLASSEXTEND = "native nativesdk"
-- 
2.13.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] mesa: Fix build when building with llvmpipe
  2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
                   ` (2 preceding siblings ...)
  2017-07-29  8:35 ` [PATCH 3/4] llvm: Add recipe for 5.0 Khem Raj
@ 2017-07-29  8:35 ` Khem Raj
  2017-07-29  9:01 ` ✗ patchtest: failure for llvm: Add recipe for 5.0 (rev3) Patchwork
  4 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-29  8:35 UTC (permalink / raw)
  To: openembedded-core

Add following in mesa.inc to enable llvmpipe

PACKAGECONFIG_append_x86 = " gallium-llvm gallium r600"
PACKAGECONFIG_append_x86-64 = " gallium-llvm gallium r600"

This would enable llvmpipe for swrast, to check run this

root@qemux86:~# glxinfo | grep llvm
    Device: llvmpipe (LLVM 5.0, 128 bits) (0xffffffff)
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 5.0, 128 bits)

Backport patches to support llvm 5.0.0+
Add a patch to understand llvm version when llvm is build from git/svn

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...1-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch | 40 ++++++++++++++++++
 ...allivm-Fix-build-against-LLVM-SVN-r302589.patch | 49 ++++++++++++++++++++++
 .../mesa/files/llvm-config-version.patch           | 23 ++++++++++
 meta/recipes-graphics/mesa/mesa.inc                |  7 +++-
 meta/recipes-graphics/mesa/mesa_17.1.5.bb          |  3 ++
 5 files changed, 120 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-graphics/mesa/files/0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch
 create mode 100644 meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch
 create mode 100644 meta/recipes-graphics/mesa/files/llvm-config-version.patch

diff --git a/meta/recipes-graphics/mesa/files/0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch b/meta/recipes-graphics/mesa/files/0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch
new file mode 100644
index 0000000000..b27a3bc8e4
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch
@@ -0,0 +1,40 @@
+From 9861437e58fdd0de01193a102608d34e5952953f Mon Sep 17 00:00:00 2001
+From: Christoph Haag <haagch+mesadev@frickel.club>
+Date: Thu, 20 Apr 2017 10:34:18 +0200
+Subject: [PATCH 1/2] ac: fix build after LLVM 5.0 SVN r300718
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+v2: previously getWithDereferenceableBytes() exists, but addAttr() doesn't take that type
+
+Signed-off-by: Christoph Haag <haagch+mesadev@frickel.club>
+Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
+Tested-and-reviewed-by: Mike Lothian <mike@fireburn.co.uk>
+---
+Upstream-Status: Backport
+
+ src/amd/common/ac_llvm_helper.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/amd/common/ac_llvm_helper.cpp b/src/amd/common/ac_llvm_helper.cpp
+index d9ea4b1..11fa809 100644
+--- a/src/amd/common/ac_llvm_helper.cpp
++++ b/src/amd/common/ac_llvm_helper.cpp
+@@ -44,9 +44,13 @@ typedef AttributeSet AttributeList;
+ void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
+ {
+    llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);
++#if HAVE_LLVM < 0x0500
+    llvm::AttrBuilder B;
+    B.addDereferenceableAttr(bytes);
+    A->addAttr(llvm::AttributeList::get(A->getContext(), A->getArgNo() + 1,  B));
++#else
++   A->addAttr(llvm::Attribute::getWithDereferenceableBytes(A->getContext(), bytes));
++#endif
+ }
+ 
+ bool ac_is_sgpr_param(LLVMValueRef arg)
+-- 
+2.13.3
+
diff --git a/meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch b/meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch
new file mode 100644
index 0000000000..ac8caec74d
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch
@@ -0,0 +1,49 @@
+From a02a0dfda2712d30ad62b8f0421ec7b8244ba2cb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>
+Date: Wed, 10 May 2017 17:26:07 +0900
+Subject: [PATCH 2/2] gallivm: Fix build against LLVM SVN >= r302589
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+deregisterEHFrames doesn't take any parameters anymore.
+
+Reviewed-by: Vedran Miletić <vedran@miletic.net>
+Reviewed-by: Marek Olšák <marek.olsak@amd.com>
+---
+Upstream-Status: Backport
+
+ src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+index 2a388cb..0e4a531 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+@@ -342,14 +342,20 @@ class DelegatingJITMemoryManager : public BaseMemoryManager {
+       virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
+          mgr()->registerEHFrames(Addr, LoadAddr, Size);
+       }
+-      virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
+-         mgr()->deregisterEHFrames(Addr, LoadAddr, Size);
+-      }
+ #else
+       virtual void registerEHFrames(llvm::StringRef SectionData) {
+          mgr()->registerEHFrames(SectionData);
+       }
+ #endif
++#if HAVE_LLVM >= 0x0500
++      virtual void deregisterEHFrames() {
++         mgr()->deregisterEHFrames();
++      }
++#elif HAVE_LLVM >= 0x0304
++      virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
++         mgr()->deregisterEHFrames(Addr, LoadAddr, Size);
++      }
++#endif
+       virtual void *getPointerToNamedFunction(const std::string &Name,
+                                               bool AbortOnFailure=true) {
+          return mgr()->getPointerToNamedFunction(Name, AbortOnFailure);
+-- 
+2.13.3
+
diff --git a/meta/recipes-graphics/mesa/files/llvm-config-version.patch b/meta/recipes-graphics/mesa/files/llvm-config-version.patch
new file mode 100644
index 0000000000..0c458c0fa4
--- /dev/null
+++ b/meta/recipes-graphics/mesa/files/llvm-config-version.patch
@@ -0,0 +1,23 @@
+When building llvm from git or svn it embeds the svn/git revision into internal version string
+
+$ /mnt/a/oe/build/tmp/work/corei7-64-bec-linux/mesa/2_17.1.5-r0/recipe-sysroot/usr/lib/llvm5.0/llvm-config-host --version
+5.0.0git-9a5c333388c
+
+We need to ignore everything after 5.0.0 which is what the cut cmd is doing
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Index: mesa-17.1.5/configure.ac
+===================================================================
+--- mesa-17.1.5.orig/configure.ac
++++ mesa-17.1.5/configure.ac
+@@ -2560,7 +2560,7 @@ if test "x$enable_llvm" = xyes; then
+     dnl (See https://llvm.org/bugs/show_bug.cgi?id=6823)
+     if test "x$enable_llvm_shared_libs" = xyes; then
+         dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
+-        LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version`
++        LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version|cut -c1-5`
+         AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.$IMP_LIB_EXT"], [llvm_have_one_so=yes])
+ 
+         if test "x$llvm_have_one_so" = xyes; then
diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 1b712a24ea..3b42fa9fe8 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -25,8 +25,11 @@ REQUIRED_DISTRO_FEATURES = "opengl"
 PLATFORMS ??= "${@bb.utils.filter('PACKAGECONFIG', 'x11 wayland', d)} \
                ${@bb.utils.contains('PACKAGECONFIG', 'gbm', 'drm', '', d)}"
 
+export LLVM_CONFIG = "${STAGING_LIBDIR}/llvm${MESA_LLVM_RELEASE}/llvm-config-host"
+
 EXTRA_OECONF = "--enable-shared-glapi \
-                --with-llvm-prefix=${STAGING_BINDIR_NATIVE} \
+                --disable-opencl \
+                --with-llvm-prefix=${STAGING_LIBDIR}/llvm${MESA_LLVM_RELEASE} \
                 --with-platforms='${PLATFORMS}'"
 
 PACKAGECONFIG ??= "gbm egl gles dri \
@@ -68,7 +71,7 @@ GALLIUMDRIVERS_append_x86 = "${@bb.utils.contains('PACKAGECONFIG', 'gallium-llvm
 GALLIUMDRIVERS_append_x86-64 = "${@bb.utils.contains('PACKAGECONFIG', 'gallium-llvm', ',${GALLIUMDRIVERS_LLVM}', '', d)}"
 # keep --with-gallium-drivers separate, because when only one of gallium versions is enabled, other 2 were adding --without-gallium-drivers
 PACKAGECONFIG[gallium]      = "--enable-texture-float --with-gallium-drivers=${GALLIUMDRIVERS}, --without-gallium-drivers"
-MESA_LLVM_RELEASE ?= "3.3"
+MESA_LLVM_RELEASE ?= "5.0"
 PACKAGECONFIG[gallium-llvm] = "--enable-llvm --enable-llvm-shared-libs, --disable-llvm, llvm${MESA_LLVM_RELEASE} \
                                ${@'elfutils' if ${GALLIUMDRIVERS_LLVM33_ENABLED} else ''}"
 export WANT_LLVM_RELEASE = "${MESA_LLVM_RELEASE}"
diff --git a/meta/recipes-graphics/mesa/mesa_17.1.5.bb b/meta/recipes-graphics/mesa/mesa_17.1.5.bb
index ddfcb371ec..36b0377453 100644
--- a/meta/recipes-graphics/mesa/mesa_17.1.5.bb
+++ b/meta/recipes-graphics/mesa/mesa_17.1.5.bb
@@ -7,6 +7,9 @@ SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
            file://0002-hardware-gloat.patch \
            file://0001-mapi-Only-install-khrplatform.h-with-EGL-or-GLES.patch \
            file://vulkan-mkdir.patch \
+           file://llvm-config-version.patch \
+           file://0001-ac-fix-build-after-LLVM-5.0-SVN-r300718.patch \
+           file://0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch \
 "
 SRC_URI[md5sum] = "6cf936fbcaadd98924298a7009e8265d"
 SRC_URI[sha256sum] = "378516b171712687aace4c7ea8b37c85895231d7a6d61e1e27362cf6034fded9"
-- 
2.13.3



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* ✗ patchtest: failure for llvm: Add recipe for 5.0 (rev3)
  2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
                   ` (3 preceding siblings ...)
  2017-07-29  8:35 ` [PATCH 4/4] mesa: Fix build when building with llvmpipe Khem Raj
@ 2017-07-29  9:01 ` Patchwork
  4 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-07-29  9:01 UTC (permalink / raw)
  To: Khem Raj; +Cc: openembedded-core

== Series Details ==

Series: llvm: Add recipe for 5.0 (rev3)
Revision: 3
URL   : https://patchwork.openembedded.org/series/7983/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             A patch file has been added, but does not have a Signed-off-by tag [test_signed_off_by_presence] 
  Suggested fix    Sign off the added patch file (meta/recipes-graphics/mesa/files/0002-gallivm-Fix-build-against-LLVM-SVN-r302589.patch)



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29  8:35 ` [PATCH 3/4] llvm: Add recipe for 5.0 Khem Raj
@ 2017-07-29 11:39   ` Burton, Ross
  2017-07-29 11:54     ` Burton, Ross
  0 siblings, 1 reply; 11+ messages in thread
From: Burton, Ross @ 2017-07-29 11:39 UTC (permalink / raw)
  To: Khem Raj; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 15841 bytes --]

Fails like this for me:

| FAILED: tools/llvm-cvtres/Opts.inc.tmp
| cd
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build &&
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
-gen-opt-parser-defs -I
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres
-I
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/include
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres/Opts.td
-o tools/llvm-cvtres/Opts.inc.tmp -d tools/llvm-cvtres/Opts.inc.d
| /bin/sh: 1:
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
not found

It is there though:

$ ls -l
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
-rwxr-xr-x 1 ross ross 49807224 Jul 29 12:25
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen

$
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
-bash:
/data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
No such file or directory

Might be related to having uninative enabled?

Ross


On 29 July 2017 at 09:35, Khem Raj <raj.khem@gmail.com> wrote:

> Based on recipe from meta-oe and clang recipe from meta-clang
> Needed by mesa
>
> Fixes
> [YOCTO #11529]
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93 ++++++++++++
>  .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
>  meta/recipes-devtools/llvm/llvm_git.bb             | 166
> +++++++++++++++++++++
>  3 files changed, 298 insertions(+)
>  create mode 100644 meta/recipes-devtools/llvm/llvm/0001-llvm-
> TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>  create mode 100644 meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-
> override-of-exe-path.patch
>  create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
>
> 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 @@
> +From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17 00:00:00 2001
> +From: Khem Raj <raj.khem@gmail.com>
> +Date: Sat, 21 May 2016 00:33:20 +0000
> +Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc functions if
> they
> + are macros
> +
> +musl defines some functions as macros and not inline functions
> +if this is the case then make sure to undefine them
> +
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +---
> +Upstream-Status: Pending
> +
> + include/llvm/Analysis/TargetLibraryInfo.def | 21 +++++++++++++++++++++
> + 1 file changed, 21 insertions(+)
> +
> +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def
> b/include/llvm/Analysis/TargetLibraryInfo.def
> +index 9cbe917c146..aff8419cf54 100644
> +--- a/include/llvm/Analysis/TargetLibraryInfo.def
> ++++ b/include/llvm/Analysis/TargetLibraryInfo.def
> +@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
> + TLI_DEFINE_ENUM_INTERNAL(fopen)
> + TLI_DEFINE_STRING_INTERNAL("fopen")
> + /// FILE *fopen64(const char *filename, const char *opentype)
> ++#ifdef fopen64
> ++#undef fopen64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(fopen64)
> + TLI_DEFINE_STRING_INTERNAL("fopen64")
> + /// int fprintf(FILE *stream, const char *format, ...);
> +@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
> + /// int fseeko(FILE *stream, off_t offset, int whence);
> + TLI_DEFINE_ENUM_INTERNAL(fseeko)
> + TLI_DEFINE_STRING_INTERNAL("fseeko")
> ++#ifdef fseeko64
> ++#undef fseeko64
> ++#endif
> + /// int fseeko64(FILE *stream, off64_t offset, int whence)
> + TLI_DEFINE_ENUM_INTERNAL(fseeko64)
> + TLI_DEFINE_STRING_INTERNAL("fseeko64")
> +@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
> + TLI_DEFINE_ENUM_INTERNAL(fstat)
> + TLI_DEFINE_STRING_INTERNAL("fstat")
> + /// int fstat64(int filedes, struct stat64 *buf)
> ++#ifdef fstat64
> ++#undef fstat64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(fstat64)
> + TLI_DEFINE_STRING_INTERNAL("fstat64")
> + /// int fstatvfs(int fildes, struct statvfs *buf);
> +@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
> + TLI_DEFINE_ENUM_INTERNAL(ftello)
> + TLI_DEFINE_STRING_INTERNAL("ftello")
> + /// off64_t ftello64(FILE *stream)
> ++#ifdef ftello64
> ++#undef ftello64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(ftello64)
> + TLI_DEFINE_STRING_INTERNAL("ftello64")
> + /// int ftrylockfile(FILE *file);
> +@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
> + TLI_DEFINE_ENUM_INTERNAL(lstat)
> + TLI_DEFINE_STRING_INTERNAL("lstat")
> + /// int lstat64(const char *path, struct stat64 *buf);
> ++#ifdef lstat64
> ++#undef lstat64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(lstat64)
> + TLI_DEFINE_STRING_INTERNAL("lstat64")
> + /// void *malloc(size_t size);
> +@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
> + TLI_DEFINE_ENUM_INTERNAL(stat)
> + TLI_DEFINE_STRING_INTERNAL("stat")
> + /// int stat64(const char *path, struct stat64 *buf);
> ++#ifdef stat64
> ++#undef stat64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(stat64)
> + TLI_DEFINE_STRING_INTERNAL("stat64")
> + /// int statvfs(const char *path, struct statvfs *buf);
> +@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
> + TLI_DEFINE_ENUM_INTERNAL(tmpfile)
> + TLI_DEFINE_STRING_INTERNAL("tmpfile")
> + /// FILE *tmpfile64(void)
> ++#ifdef tmpfile64
> ++#undef tmpfile64
> ++#endif
> + TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
> + TLI_DEFINE_STRING_INTERNAL("tmpfile64")
> + /// int toascii(int c);
> +--
> +2.13.1
> +
> 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 @@
> +From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17 00:00:00 2001
> +From: Martin Kelly <mkelly@xevo.com>
> +Date: Fri, 19 May 2017 00:22:57 -0700
> +Subject: [PATCH 2/2] llvm: allow env override of exe path
> +
> +When using a native llvm-config from inside a sysroot, we need
> llvm-config to
> +return the libraries, include directories, etc. from inside the sysroot
> rather
> +than from the native sysroot. Thus provide an env override for calling
> +llvm-config from a target sysroot.
> +
> +Signed-off-by: Martin Kelly <mkelly@xevo.com>
> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
> +---
> +Upstream-Status: Pending
> +
> + tools/llvm-config/llvm-config.cpp | 7 +++++++
> + 1 file changed, 7 insertions(+)
> +
> +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-
> config.cpp
> +index 08b096afb05..d8d7742744e 100644
> +--- a/tools/llvm-config/llvm-config.cpp
> ++++ b/tools/llvm-config/llvm-config.cpp
> +@@ -225,6 +225,13 @@ Typical components:\n\
> +
> + /// \brief Compute the path to the main executable.
> + std::string GetExecutablePath(const char *Argv0) {
> ++  // Hack for Yocto: we need to override the root path when we are using
> ++  // llvm-config from within a target sysroot.
> ++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
> ++  if (Sysroot != nullptr) {
> ++    return Sysroot;
> ++  }
> ++
> +   // This just needs to be some symbol in the binary; C++ doesn't
> +   // allow taking the address of ::main however.
> +   void *P = (void *)(intptr_t)GetExecutablePath;
> +--
> +2.13.1
> +
> diff --git a/meta/recipes-devtools/llvm/llvm_git.bb
> b/meta/recipes-devtools/llvm/llvm_git.bb
> new file mode 100644
> index 0000000000..7b51d2153f
> --- /dev/null
> +++ b/meta/recipes-devtools/llvm/llvm_git.bb
> @@ -0,0 +1,166 @@
> +# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
> +# Released under the MIT license (see COPYING.MIT for the terms)
> +
> +DESCRIPTION = "The LLVM Compiler Infrastructure"
> +HOMEPAGE = "http://llvm.org"
> +LICENSE = "NCSA"
> +SECTION = "devel"
> +
> +LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e52517
> 71"
> +
> +DEPENDS = "libffi libxml2-native zlib ninja-native"
> +
> +RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
> +
> +inherit perlnative pythonnative cmake pkgconfig
> +
> +PROVIDES += "llvm${PV}"
> +
> +LLVM_RELEASE = "${PV}"
> +LLVM_DIR = "llvm${LLVM_RELEASE}"
> +
> +SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
> +PV = "5.0"
> +PATCH_VERSION = "0"
> +SRC_URI = "git://github.com/llvm-mirror/llvm.git;branch=release_50;
> protocol=http \
> +           file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
> \
> +           file://0002-llvm-allow-env-override-of-exe-path.patch \
> +          "
> +S = "${WORKDIR}/git"
> +
> +LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
> +def get_llvm_arch(bb, d, arch_var):
> +    import re
> +    a = d.getVar(arch_var, True)
> +    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
> +    elif re.match('arm$', a):                          return 'ARM'
> +    elif re.match('armeb$', a):                        return 'ARM'
> +    elif re.match('aarch64$', a):                      return 'AArch64'
> +    elif re.match('aarch64_be$', a):                   return 'AArch64'
> +    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
> +    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
> +    else:
> +        bb.error("cannot map '%s' to a supported llvm architecture" % a)
> +    return ""
> +
> +def get_llvm_target_arch(bb, d):
> +    return get_llvm_arch(bb, d, 'TARGET_ARCH')
> +#
> +# Default to build all OE-Core supported target arches (user overridable).
> +#
> +LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
> +LLVM_TARGETS_prepend_x86 = "AMDGPU;"
> +LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
> +
> +EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
> +                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
> +                  -DLLVM_ENABLE_PIC=ON \
> +                  -DLLVM_BINDINGS_LIST='' \
> +                  -DLLVM_LINK_LLVM_DYLIB=ON \
> +                  -DLLVM_ENABLE_FFI=ON \
> +                  -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir
> libffi) \
> +                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
> +                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
> +                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
> +                  -G Ninja \
> +                 "
> +EXTRA_OECMAKE_remove_class-native = "-DCMAKE_CROSSCOMPILING:BOOL=ON"
> +
> +do_configure_prepend() {
> +# Fix paths in llvm-config
> +       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
> +       sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g"
> ${S}/tools/llvm-config/llvm-config.cpp
> +       sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g"
> ${S}/tools/llvm-config/llvm-config.cpp
> +}
> +
> +do_compile() {
> +       NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
> +}
> +
> +do_install() {
> +       NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja -v install
> +       install -D -m 0755 ${B}/NATIVE/bin/llvm-config
> ${D}${libdir}/${LLVM_DIR}/llvm-config-host
> +
> +       install -d ${D}${bindir}/${LLVM_DIR}
> +       cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
> +
> +       install -d ${D}${includedir}/${LLVM_DIR}
> +       cp -r ${LLVM_INSTALL_DIR}${includedir}/*
> ${D}${includedir}/${LLVM_DIR}/
> +
> +       install -d ${D}${libdir}/${LLVM_DIR}
> +
> +       # The LLVM sources have "/lib" embedded and so we cannot
> completely rely on the ${libdir} variable
> +       if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
> +               cp -r ${LLVM_INSTALL_DIR}${libdir}/*
> ${D}${libdir}/${LLVM_DIR}/
> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/*
> ${D}${libdir}/${LLVM_DIR}/
> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/*
> ${D}${libdir}/${LLVM_DIR}/
> +       fi
> +
> +       # Remove unnecessary cmake files
> +       rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
> +
> +       ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV}
> ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
> +
> +       # We'll have to delete the libLLVM.so due to multiple reasons...
> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
> +}
> +
> +PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
> +ALLOW_EMPTY_${PN} = "1"
> +ALLOW_EMPTY_${PN}-staticdev = "1"
> +FILES_${PN} = ""
> +FILES_${PN}-staticdev = ""
> +FILES_${PN}-dbg = " \
> +    ${bindir}/${LLVM_DIR}/.debug \
> +    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
> +    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
> +    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
> +    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
> +    /usr/src/debug \
> +"
> +
> +FILES_${PN}-dev = " \
> +    ${bindir}/${LLVM_DIR} \
> +    ${includedir}/${LLVM_DIR} \
> +    ${libdir}/${LLVM_DIR}/llvm-config-host \
> +"
> +
> +RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
> +
> +FILES_${PN}-bugpointpasses = "\
> +    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
> +"
> +FILES_${PN} += "\
> +    ${libdir}/${LLVM_DIR}/libLTO.so.* \
> +"
> +
> +FILES_${PN}-llvmhello = "\
> +    ${libdir}/${LLVM_DIR}/LLVMHello.so \
> +"
> +
> +PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
> +NOAUTOPACKAGEDEBUG = "1"
> +
> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION}
> += "dev-so"
> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} +=
> "dev-so"
> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
> +
> +python llvm_populate_packages() {
> +    libdir = bb.data.expand('${libdir}', d)
> +    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
> +    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)
> +    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)
> +    split_staticdev_packages = do_split_packages(d, libllvm_libdir,
> '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev
> package for %s', allow_dirs=True)
> +    if split_packages:
> +        pn = d.getVar('PN', True)
> +        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
> +        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+'
> '.join(split_dbg_packages))
> +        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+'
> '.join(split_staticdev_packages))
> +}
> +
> +PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
> +
> +BBCLASSEXTEND = "native nativesdk"
> --
> 2.13.3
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[-- Attachment #2: Type: text/html, Size: 20070 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29 11:39   ` Burton, Ross
@ 2017-07-29 11:54     ` Burton, Ross
  2017-07-29 14:16       ` Khem Raj
                         ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Burton, Ross @ 2017-07-29 11:54 UTC (permalink / raw)
  To: Khem Raj; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 16426 bytes --]

Replicated without uninative, so it's not that.

Ross

On 29 July 2017 at 12:39, Burton, Ross <ross.burton@intel.com> wrote:

> Fails like this for me:
>
> | FAILED: tools/llvm-cvtres/Opts.inc.tmp
> | cd /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build
> && /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen -gen-opt-parser-defs -I
> /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/git/tools/llvm-cvtres -I /data/poky-tmp/master/build/
> work/corei7-64-poky-linux/llvm/5.0-r0/git/include
> /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/git/tools/llvm-cvtres/Opts.td -o
> tools/llvm-cvtres/Opts.inc.tmp -d tools/llvm-cvtres/Opts.inc.d
> | /bin/sh: 1: /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen: not found
>
> It is there though:
>
> $ ls -l /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
> -rwxr-xr-x 1 ross ross 49807224 Jul 29 12:25 /data/poky-tmp/master/build/
> work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>
> $ /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
> -bash: /data/poky-tmp/master/build/work/corei7-64-poky-linux/
> llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen: No such file or directory
>
> Might be related to having uninative enabled?
>
> Ross
>
>
> On 29 July 2017 at 09:35, Khem Raj <raj.khem@gmail.com> wrote:
>
>> Based on recipe from meta-oe and clang recipe from meta-clang
>> Needed by mesa
>>
>> Fixes
>> [YOCTO #11529]
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> ---
>>  ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93 ++++++++++++
>>  .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
>>  meta/recipes-devtools/llvm/llvm_git.bb             | 166
>> +++++++++++++++++++++
>>  3 files changed, 298 insertions(+)
>>  create mode 100644 meta/recipes-devtools/llvm/llv
>> m/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>>  create mode 100644 meta/recipes-devtools/llvm/llv
>> m/0002-llvm-allow-env-override-of-exe-path.patch
>>  create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
>>
>> diff --git a/meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInf
>> o-Undefine-libc-functions-if-th.patch b/meta/recipes-devtools/llvm/l
>> lvm/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-TargetLibraryInf
>> o-Undefine-libc-functions-if-th.patch
>> @@ -0,0 +1,93 @@
>> +From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17 00:00:00 2001
>> +From: Khem Raj <raj.khem@gmail.com>
>> +Date: Sat, 21 May 2016 00:33:20 +0000
>> +Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc functions if
>> they
>> + are macros
>> +
>> +musl defines some functions as macros and not inline functions
>> +if this is the case then make sure to undefine them
>> +
>> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> +---
>> +Upstream-Status: Pending
>> +
>> + include/llvm/Analysis/TargetLibraryInfo.def | 21 +++++++++++++++++++++
>> + 1 file changed, 21 insertions(+)
>> +
>> +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def
>> b/include/llvm/Analysis/TargetLibraryInfo.def
>> +index 9cbe917c146..aff8419cf54 100644
>> +--- a/include/llvm/Analysis/TargetLibraryInfo.def
>> ++++ b/include/llvm/Analysis/TargetLibraryInfo.def
>> +@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
>> + TLI_DEFINE_ENUM_INTERNAL(fopen)
>> + TLI_DEFINE_STRING_INTERNAL("fopen")
>> + /// FILE *fopen64(const char *filename, const char *opentype)
>> ++#ifdef fopen64
>> ++#undef fopen64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(fopen64)
>> + TLI_DEFINE_STRING_INTERNAL("fopen64")
>> + /// int fprintf(FILE *stream, const char *format, ...);
>> +@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
>> + /// int fseeko(FILE *stream, off_t offset, int whence);
>> + TLI_DEFINE_ENUM_INTERNAL(fseeko)
>> + TLI_DEFINE_STRING_INTERNAL("fseeko")
>> ++#ifdef fseeko64
>> ++#undef fseeko64
>> ++#endif
>> + /// int fseeko64(FILE *stream, off64_t offset, int whence)
>> + TLI_DEFINE_ENUM_INTERNAL(fseeko64)
>> + TLI_DEFINE_STRING_INTERNAL("fseeko64")
>> +@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
>> + TLI_DEFINE_ENUM_INTERNAL(fstat)
>> + TLI_DEFINE_STRING_INTERNAL("fstat")
>> + /// int fstat64(int filedes, struct stat64 *buf)
>> ++#ifdef fstat64
>> ++#undef fstat64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(fstat64)
>> + TLI_DEFINE_STRING_INTERNAL("fstat64")
>> + /// int fstatvfs(int fildes, struct statvfs *buf);
>> +@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
>> + TLI_DEFINE_ENUM_INTERNAL(ftello)
>> + TLI_DEFINE_STRING_INTERNAL("ftello")
>> + /// off64_t ftello64(FILE *stream)
>> ++#ifdef ftello64
>> ++#undef ftello64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(ftello64)
>> + TLI_DEFINE_STRING_INTERNAL("ftello64")
>> + /// int ftrylockfile(FILE *file);
>> +@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
>> + TLI_DEFINE_ENUM_INTERNAL(lstat)
>> + TLI_DEFINE_STRING_INTERNAL("lstat")
>> + /// int lstat64(const char *path, struct stat64 *buf);
>> ++#ifdef lstat64
>> ++#undef lstat64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(lstat64)
>> + TLI_DEFINE_STRING_INTERNAL("lstat64")
>> + /// void *malloc(size_t size);
>> +@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
>> + TLI_DEFINE_ENUM_INTERNAL(stat)
>> + TLI_DEFINE_STRING_INTERNAL("stat")
>> + /// int stat64(const char *path, struct stat64 *buf);
>> ++#ifdef stat64
>> ++#undef stat64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(stat64)
>> + TLI_DEFINE_STRING_INTERNAL("stat64")
>> + /// int statvfs(const char *path, struct statvfs *buf);
>> +@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
>> + TLI_DEFINE_ENUM_INTERNAL(tmpfile)
>> + TLI_DEFINE_STRING_INTERNAL("tmpfile")
>> + /// FILE *tmpfile64(void)
>> ++#ifdef tmpfile64
>> ++#undef tmpfile64
>> ++#endif
>> + TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
>> + TLI_DEFINE_STRING_INTERNAL("tmpfile64")
>> + /// int toascii(int c);
>> +--
>> +2.13.1
>> +
>> 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-overri
>> de-of-exe-path.patch
>> new file mode 100644
>> index 0000000000..832bd729ef
>> --- /dev/null
>> +++ b/meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-overri
>> de-of-exe-path.patch
>> @@ -0,0 +1,39 @@
>> +From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17 00:00:00 2001
>> +From: Martin Kelly <mkelly@xevo.com>
>> +Date: Fri, 19 May 2017 00:22:57 -0700
>> +Subject: [PATCH 2/2] llvm: allow env override of exe path
>> +
>> +When using a native llvm-config from inside a sysroot, we need
>> llvm-config to
>> +return the libraries, include directories, etc. from inside the sysroot
>> rather
>> +than from the native sysroot. Thus provide an env override for calling
>> +llvm-config from a target sysroot.
>> +
>> +Signed-off-by: Martin Kelly <mkelly@xevo.com>
>> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> +---
>> +Upstream-Status: Pending
>> +
>> + tools/llvm-config/llvm-config.cpp | 7 +++++++
>> + 1 file changed, 7 insertions(+)
>> +
>> +diff --git a/tools/llvm-config/llvm-config.cpp
>> b/tools/llvm-config/llvm-config.cpp
>> +index 08b096afb05..d8d7742744e 100644
>> +--- a/tools/llvm-config/llvm-config.cpp
>> ++++ b/tools/llvm-config/llvm-config.cpp
>> +@@ -225,6 +225,13 @@ Typical components:\n\
>> +
>> + /// \brief Compute the path to the main executable.
>> + std::string GetExecutablePath(const char *Argv0) {
>> ++  // Hack for Yocto: we need to override the root path when we are using
>> ++  // llvm-config from within a target sysroot.
>> ++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
>> ++  if (Sysroot != nullptr) {
>> ++    return Sysroot;
>> ++  }
>> ++
>> +   // This just needs to be some symbol in the binary; C++ doesn't
>> +   // allow taking the address of ::main however.
>> +   void *P = (void *)(intptr_t)GetExecutablePath;
>> +--
>> +2.13.1
>> +
>> diff --git a/meta/recipes-devtools/llvm/llvm_git.bb
>> b/meta/recipes-devtools/llvm/llvm_git.bb
>> new file mode 100644
>> index 0000000000..7b51d2153f
>> --- /dev/null
>> +++ b/meta/recipes-devtools/llvm/llvm_git.bb
>> @@ -0,0 +1,166 @@
>> +# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
>> +# Released under the MIT license (see COPYING.MIT for the terms)
>> +
>> +DESCRIPTION = "The LLVM Compiler Infrastructure"
>> +HOMEPAGE = "http://llvm.org"
>> +LICENSE = "NCSA"
>> +SECTION = "devel"
>> +
>> +LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=e825e0
>> 17edc35cfd58e26116e5251771"
>> +
>> +DEPENDS = "libffi libxml2-native zlib ninja-native"
>> +
>> +RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
>> +
>> +inherit perlnative pythonnative cmake pkgconfig
>> +
>> +PROVIDES += "llvm${PV}"
>> +
>> +LLVM_RELEASE = "${PV}"
>> +LLVM_DIR = "llvm${LLVM_RELEASE}"
>> +
>> +SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
>> +PV = "5.0"
>> +PATCH_VERSION = "0"
>> +SRC_URI = "git://github.com/llvm-mirror/llvm.git;branch=release_50;pro
>> tocol=http \
>> +           file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>> \
>> +           file://0002-llvm-allow-env-override-of-exe-path.patch \
>> +          "
>> +S = "${WORKDIR}/git"
>> +
>> +LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
>> +def get_llvm_arch(bb, d, arch_var):
>> +    import re
>> +    a = d.getVar(arch_var, True)
>> +    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
>> +    elif re.match('arm$', a):                          return 'ARM'
>> +    elif re.match('armeb$', a):                        return 'ARM'
>> +    elif re.match('aarch64$', a):                      return 'AArch64'
>> +    elif re.match('aarch64_be$', a):                   return 'AArch64'
>> +    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
>> +    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
>> +    else:
>> +        bb.error("cannot map '%s' to a supported llvm architecture" % a)
>> +    return ""
>> +
>> +def get_llvm_target_arch(bb, d):
>> +    return get_llvm_arch(bb, d, 'TARGET_ARCH')
>> +#
>> +# Default to build all OE-Core supported target arches (user
>> overridable).
>> +#
>> +LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
>> +LLVM_TARGETS_prepend_x86 = "AMDGPU;"
>> +LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
>> +
>> +EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
>> +                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
>> +                  -DLLVM_ENABLE_PIC=ON \
>> +                  -DLLVM_BINDINGS_LIST='' \
>> +                  -DLLVM_LINK_LLVM_DYLIB=ON \
>> +                  -DLLVM_ENABLE_FFI=ON \
>> +                  -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir
>> libffi) \
>> +                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
>> +                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
>> +                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
>> +                  -G Ninja \
>> +                 "
>> +EXTRA_OECMAKE_remove_class-native = "-DCMAKE_CROSSCOMPILING:BOOL=ON"
>> +
>> +do_configure_prepend() {
>> +# Fix paths in llvm-config
>> +       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
>> +       sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g"
>> ${S}/tools/llvm-config/llvm-config.cpp
>> +       sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g"
>> ${S}/tools/llvm-config/llvm-config.cpp
>> +}
>> +
>> +do_compile() {
>> +       NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
>> +}
>> +
>> +do_install() {
>> +       NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja -v install
>> +       install -D -m 0755 ${B}/NATIVE/bin/llvm-config
>> ${D}${libdir}/${LLVM_DIR}/llvm-config-host
>> +
>> +       install -d ${D}${bindir}/${LLVM_DIR}
>> +       cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
>> +
>> +       install -d ${D}${includedir}/${LLVM_DIR}
>> +       cp -r ${LLVM_INSTALL_DIR}${includedir}/*
>> ${D}${includedir}/${LLVM_DIR}/
>> +
>> +       install -d ${D}${libdir}/${LLVM_DIR}
>> +
>> +       # The LLVM sources have "/lib" embedded and so we cannot
>> completely rely on the ${libdir} variable
>> +       if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
>> +               cp -r ${LLVM_INSTALL_DIR}${libdir}/*
>> ${D}${libdir}/${LLVM_DIR}/
>> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
>> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/*
>> ${D}${libdir}/${LLVM_DIR}/
>> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
>> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/*
>> ${D}${libdir}/${LLVM_DIR}/
>> +       fi
>> +
>> +       # Remove unnecessary cmake files
>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
>> +
>> +       ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV}
>> ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
>> +
>> +       # We'll have to delete the libLLVM.so due to multiple reasons...
>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
>> +}
>> +
>> +PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
>> +ALLOW_EMPTY_${PN} = "1"
>> +ALLOW_EMPTY_${PN}-staticdev = "1"
>> +FILES_${PN} = ""
>> +FILES_${PN}-staticdev = ""
>> +FILES_${PN}-dbg = " \
>> +    ${bindir}/${LLVM_DIR}/.debug \
>> +    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
>> +    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
>> +    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
>> +    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
>> +    /usr/src/debug \
>> +"
>> +
>> +FILES_${PN}-dev = " \
>> +    ${bindir}/${LLVM_DIR} \
>> +    ${includedir}/${LLVM_DIR} \
>> +    ${libdir}/${LLVM_DIR}/llvm-config-host \
>> +"
>> +
>> +RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
>> +
>> +FILES_${PN}-bugpointpasses = "\
>> +    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
>> +"
>> +FILES_${PN} += "\
>> +    ${libdir}/${LLVM_DIR}/libLTO.so.* \
>> +"
>> +
>> +FILES_${PN}-llvmhello = "\
>> +    ${libdir}/${LLVM_DIR}/LLVMHello.so \
>> +"
>> +
>> +PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
>> +NOAUTOPACKAGEDEBUG = "1"
>> +
>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION}
>> += "dev-so"
>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} +=
>> "dev-so"
>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
>> +
>> +python llvm_populate_packages() {
>> +    libdir = bb.data.expand('${libdir}', d)
>> +    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
>> +    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)
>> +    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)
>> +    split_staticdev_packages = do_split_packages(d, libllvm_libdir,
>> '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev
>> package for %s', allow_dirs=True)
>> +    if split_packages:
>> +        pn = d.getVar('PN', True)
>> +        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
>> +        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+'
>> '.join(split_dbg_packages))
>> +        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+'
>> '.join(split_staticdev_packages))
>> +}
>> +
>> +PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
>> +
>> +BBCLASSEXTEND = "native nativesdk"
>> --
>> 2.13.3
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>>
>
>

[-- Attachment #2: Type: text/html, Size: 20904 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29 11:54     ` Burton, Ross
@ 2017-07-29 14:16       ` Khem Raj
  2017-07-30  3:22       ` Khem Raj
  2017-07-30  3:52       ` Khem Raj
  2 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-29 14:16 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

On Sat, Jul 29, 2017 at 4:54 AM, Burton, Ross <ross.burton@intel.com> wrote:
> Replicated without uninative, so it's not that.
>
> Ross
>
> On 29 July 2017 at 12:39, Burton, Ross <ross.burton@intel.com> wrote:
>>
>> Fails like this for me:
>>
>> | FAILED: tools/llvm-cvtres/Opts.inc.tmp
>> | cd
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build &&
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>> -gen-opt-parser-defs -I
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres
>> -I
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/include
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres/Opts.td
>> -o tools/llvm-cvtres/Opts.inc.tmp -d tools/llvm-cvtres/Opts.inc.d
>> | /bin/sh: 1:
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>> not found
>>
>> It is there though:
>>
>> $ ls -l
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>> -rwxr-xr-x 1 ross ross 49807224 Jul 29 12:25
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>>
>> $
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>> -bash:
>> /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>> No such file or directory
>>
>> Might be related to having uninative enabled?

Not really, I think it could be build race.  I will take a look

>>
>> Ross
>>
>>
>> On 29 July 2017 at 09:35, Khem Raj <raj.khem@gmail.com> wrote:
>>>
>>> Based on recipe from meta-oe and clang recipe from meta-clang
>>> Needed by mesa
>>>
>>> Fixes
>>> [YOCTO #11529]
>>>
>>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>>> ---
>>>  ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93 ++++++++++++
>>>  .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
>>>  meta/recipes-devtools/llvm/llvm_git.bb             | 166
>>> +++++++++++++++++++++
>>>  3 files changed, 298 insertions(+)
>>>  create mode 100644
>>> meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>>>  create mode 100644
>>> meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
>>>  create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
>>>
>>> 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 @@
>>> +From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17 00:00:00 2001
>>> +From: Khem Raj <raj.khem@gmail.com>
>>> +Date: Sat, 21 May 2016 00:33:20 +0000
>>> +Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc functions if
>>> they
>>> + are macros
>>> +
>>> +musl defines some functions as macros and not inline functions
>>> +if this is the case then make sure to undefine them
>>> +
>>> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
>>> +---
>>> +Upstream-Status: Pending
>>> +
>>> + include/llvm/Analysis/TargetLibraryInfo.def | 21 +++++++++++++++++++++
>>> + 1 file changed, 21 insertions(+)
>>> +
>>> +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def
>>> b/include/llvm/Analysis/TargetLibraryInfo.def
>>> +index 9cbe917c146..aff8419cf54 100644
>>> +--- a/include/llvm/Analysis/TargetLibraryInfo.def
>>> ++++ b/include/llvm/Analysis/TargetLibraryInfo.def
>>> +@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
>>> + TLI_DEFINE_ENUM_INTERNAL(fopen)
>>> + TLI_DEFINE_STRING_INTERNAL("fopen")
>>> + /// FILE *fopen64(const char *filename, const char *opentype)
>>> ++#ifdef fopen64
>>> ++#undef fopen64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(fopen64)
>>> + TLI_DEFINE_STRING_INTERNAL("fopen64")
>>> + /// int fprintf(FILE *stream, const char *format, ...);
>>> +@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
>>> + /// int fseeko(FILE *stream, off_t offset, int whence);
>>> + TLI_DEFINE_ENUM_INTERNAL(fseeko)
>>> + TLI_DEFINE_STRING_INTERNAL("fseeko")
>>> ++#ifdef fseeko64
>>> ++#undef fseeko64
>>> ++#endif
>>> + /// int fseeko64(FILE *stream, off64_t offset, int whence)
>>> + TLI_DEFINE_ENUM_INTERNAL(fseeko64)
>>> + TLI_DEFINE_STRING_INTERNAL("fseeko64")
>>> +@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
>>> + TLI_DEFINE_ENUM_INTERNAL(fstat)
>>> + TLI_DEFINE_STRING_INTERNAL("fstat")
>>> + /// int fstat64(int filedes, struct stat64 *buf)
>>> ++#ifdef fstat64
>>> ++#undef fstat64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(fstat64)
>>> + TLI_DEFINE_STRING_INTERNAL("fstat64")
>>> + /// int fstatvfs(int fildes, struct statvfs *buf);
>>> +@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
>>> + TLI_DEFINE_ENUM_INTERNAL(ftello)
>>> + TLI_DEFINE_STRING_INTERNAL("ftello")
>>> + /// off64_t ftello64(FILE *stream)
>>> ++#ifdef ftello64
>>> ++#undef ftello64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(ftello64)
>>> + TLI_DEFINE_STRING_INTERNAL("ftello64")
>>> + /// int ftrylockfile(FILE *file);
>>> +@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
>>> + TLI_DEFINE_ENUM_INTERNAL(lstat)
>>> + TLI_DEFINE_STRING_INTERNAL("lstat")
>>> + /// int lstat64(const char *path, struct stat64 *buf);
>>> ++#ifdef lstat64
>>> ++#undef lstat64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(lstat64)
>>> + TLI_DEFINE_STRING_INTERNAL("lstat64")
>>> + /// void *malloc(size_t size);
>>> +@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
>>> + TLI_DEFINE_ENUM_INTERNAL(stat)
>>> + TLI_DEFINE_STRING_INTERNAL("stat")
>>> + /// int stat64(const char *path, struct stat64 *buf);
>>> ++#ifdef stat64
>>> ++#undef stat64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(stat64)
>>> + TLI_DEFINE_STRING_INTERNAL("stat64")
>>> + /// int statvfs(const char *path, struct statvfs *buf);
>>> +@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
>>> + TLI_DEFINE_ENUM_INTERNAL(tmpfile)
>>> + TLI_DEFINE_STRING_INTERNAL("tmpfile")
>>> + /// FILE *tmpfile64(void)
>>> ++#ifdef tmpfile64
>>> ++#undef tmpfile64
>>> ++#endif
>>> + TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
>>> + TLI_DEFINE_STRING_INTERNAL("tmpfile64")
>>> + /// int toascii(int c);
>>> +--
>>> +2.13.1
>>> +
>>> 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 @@
>>> +From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17 00:00:00 2001
>>> +From: Martin Kelly <mkelly@xevo.com>
>>> +Date: Fri, 19 May 2017 00:22:57 -0700
>>> +Subject: [PATCH 2/2] llvm: allow env override of exe path
>>> +
>>> +When using a native llvm-config from inside a sysroot, we need
>>> llvm-config to
>>> +return the libraries, include directories, etc. from inside the sysroot
>>> rather
>>> +than from the native sysroot. Thus provide an env override for calling
>>> +llvm-config from a target sysroot.
>>> +
>>> +Signed-off-by: Martin Kelly <mkelly@xevo.com>
>>> +Signed-off-by: Khem Raj <raj.khem@gmail.com>
>>> +---
>>> +Upstream-Status: Pending
>>> +
>>> + tools/llvm-config/llvm-config.cpp | 7 +++++++
>>> + 1 file changed, 7 insertions(+)
>>> +
>>> +diff --git a/tools/llvm-config/llvm-config.cpp
>>> b/tools/llvm-config/llvm-config.cpp
>>> +index 08b096afb05..d8d7742744e 100644
>>> +--- a/tools/llvm-config/llvm-config.cpp
>>> ++++ b/tools/llvm-config/llvm-config.cpp
>>> +@@ -225,6 +225,13 @@ Typical components:\n\
>>> +
>>> + /// \brief Compute the path to the main executable.
>>> + std::string GetExecutablePath(const char *Argv0) {
>>> ++  // Hack for Yocto: we need to override the root path when we are
>>> using
>>> ++  // llvm-config from within a target sysroot.
>>> ++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
>>> ++  if (Sysroot != nullptr) {
>>> ++    return Sysroot;
>>> ++  }
>>> ++
>>> +   // This just needs to be some symbol in the binary; C++ doesn't
>>> +   // allow taking the address of ::main however.
>>> +   void *P = (void *)(intptr_t)GetExecutablePath;
>>> +--
>>> +2.13.1
>>> +
>>> diff --git a/meta/recipes-devtools/llvm/llvm_git.bb
>>> b/meta/recipes-devtools/llvm/llvm_git.bb
>>> new file mode 100644
>>> index 0000000000..7b51d2153f
>>> --- /dev/null
>>> +++ b/meta/recipes-devtools/llvm/llvm_git.bb
>>> @@ -0,0 +1,166 @@
>>> +# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com>
>>> +# Released under the MIT license (see COPYING.MIT for the terms)
>>> +
>>> +DESCRIPTION = "The LLVM Compiler Infrastructure"
>>> +HOMEPAGE = "http://llvm.org"
>>> +LICENSE = "NCSA"
>>> +SECTION = "devel"
>>> +
>>> +LIC_FILES_CHKSUM =
>>> "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e5251771"
>>> +
>>> +DEPENDS = "libffi libxml2-native zlib ninja-native"
>>> +
>>> +RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
>>> +
>>> +inherit perlnative pythonnative cmake pkgconfig
>>> +
>>> +PROVIDES += "llvm${PV}"
>>> +
>>> +LLVM_RELEASE = "${PV}"
>>> +LLVM_DIR = "llvm${LLVM_RELEASE}"
>>> +
>>> +SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
>>> +PV = "5.0"
>>> +PATCH_VERSION = "0"
>>> +SRC_URI =
>>> "git://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http \
>>> +
>>> file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch \
>>> +           file://0002-llvm-allow-env-override-of-exe-path.patch \
>>> +          "
>>> +S = "${WORKDIR}/git"
>>> +
>>> +LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
>>> +def get_llvm_arch(bb, d, arch_var):
>>> +    import re
>>> +    a = d.getVar(arch_var, True)
>>> +    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
>>> +    elif re.match('arm$', a):                          return 'ARM'
>>> +    elif re.match('armeb$', a):                        return 'ARM'
>>> +    elif re.match('aarch64$', a):                      return 'AArch64'
>>> +    elif re.match('aarch64_be$', a):                   return 'AArch64'
>>> +    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips'
>>> +    elif re.match('p(pc|owerpc)(|64)', a):             return 'PowerPC'
>>> +    else:
>>> +        bb.error("cannot map '%s' to a supported llvm architecture" % a)
>>> +    return ""
>>> +
>>> +def get_llvm_target_arch(bb, d):
>>> +    return get_llvm_arch(bb, d, 'TARGET_ARCH')
>>> +#
>>> +# Default to build all OE-Core supported target arches (user
>>> overridable).
>>> +#
>>> +LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
>>> +LLVM_TARGETS_prepend_x86 = "AMDGPU;"
>>> +LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
>>> +
>>> +EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
>>> +                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
>>> +                  -DLLVM_ENABLE_PIC=ON \
>>> +                  -DLLVM_BINDINGS_LIST='' \
>>> +                  -DLLVM_LINK_LLVM_DYLIB=ON \
>>> +                  -DLLVM_ENABLE_FFI=ON \
>>> +                  -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir
>>> libffi) \
>>> +                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
>>> +                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
>>> +                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
>>> +                  -G Ninja \
>>> +                 "
>>> +EXTRA_OECMAKE_remove_class-native = "-DCMAKE_CROSSCOMPILING:BOOL=ON"
>>> +
>>> +do_configure_prepend() {
>>> +# Fix paths in llvm-config
>>> +       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
>>> +       sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g"
>>> ${S}/tools/llvm-config/llvm-config.cpp
>>> +       sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g"
>>> ${S}/tools/llvm-config/llvm-config.cpp
>>> +}
>>> +
>>> +do_compile() {
>>> +       NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
>>> +}
>>> +
>>> +do_install() {
>>> +       NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja -v install
>>> +       install -D -m 0755 ${B}/NATIVE/bin/llvm-config
>>> ${D}${libdir}/${LLVM_DIR}/llvm-config-host
>>> +
>>> +       install -d ${D}${bindir}/${LLVM_DIR}
>>> +       cp -r ${LLVM_INSTALL_DIR}${bindir}/* ${D}${bindir}/${LLVM_DIR}/
>>> +
>>> +       install -d ${D}${includedir}/${LLVM_DIR}
>>> +       cp -r ${LLVM_INSTALL_DIR}${includedir}/*
>>> ${D}${includedir}/${LLVM_DIR}/
>>> +
>>> +       install -d ${D}${libdir}/${LLVM_DIR}
>>> +
>>> +       # The LLVM sources have "/lib" embedded and so we cannot
>>> completely rely on the ${libdir} variable
>>> +       if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
>>> +               cp -r ${LLVM_INSTALL_DIR}${libdir}/*
>>> ${D}${libdir}/${LLVM_DIR}/
>>> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
>>> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/*
>>> ${D}${libdir}/${LLVM_DIR}/
>>> +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
>>> +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/*
>>> ${D}${libdir}/${LLVM_DIR}/
>>> +       fi
>>> +
>>> +       # Remove unnecessary cmake files
>>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
>>> +
>>> +       ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV}
>>> ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
>>> +
>>> +       # We'll have to delete the libLLVM.so due to multiple reasons...
>>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
>>> +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
>>> +}
>>> +
>>> +PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
>>> +ALLOW_EMPTY_${PN} = "1"
>>> +ALLOW_EMPTY_${PN}-staticdev = "1"
>>> +FILES_${PN} = ""
>>> +FILES_${PN}-staticdev = ""
>>> +FILES_${PN}-dbg = " \
>>> +    ${bindir}/${LLVM_DIR}/.debug \
>>> +    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
>>> +    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
>>> +    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
>>> +    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
>>> +    /usr/src/debug \
>>> +"
>>> +
>>> +FILES_${PN}-dev = " \
>>> +    ${bindir}/${LLVM_DIR} \
>>> +    ${includedir}/${LLVM_DIR} \
>>> +    ${libdir}/${LLVM_DIR}/llvm-config-host \
>>> +"
>>> +
>>> +RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
>>> +
>>> +FILES_${PN}-bugpointpasses = "\
>>> +    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
>>> +"
>>> +FILES_${PN} += "\
>>> +    ${libdir}/${LLVM_DIR}/libLTO.so.* \
>>> +"
>>> +
>>> +FILES_${PN}-llvmhello = "\
>>> +    ${libdir}/${LLVM_DIR}/LLVMHello.so \
>>> +"
>>> +
>>> +PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
>>> +NOAUTOPACKAGEDEBUG = "1"
>>> +
>>>
>>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION}
>>> += "dev-so"
>>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE} +=
>>> "dev-so"
>>> +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
>>> +
>>> +python llvm_populate_packages() {
>>> +    libdir = bb.data.expand('${libdir}', d)
>>> +    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
>>> +    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)
>>> +    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)
>>> +    split_staticdev_packages = do_split_packages(d, libllvm_libdir,
>>> '^lib(.*)\.a$', 'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev
>>> package for %s', allow_dirs=True)
>>> +    if split_packages:
>>> +        pn = d.getVar('PN', True)
>>> +        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
>>> +        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+'
>>> '.join(split_dbg_packages))
>>> +        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+'
>>> '.join(split_staticdev_packages))
>>> +}
>>> +
>>> +PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
>>> +
>>> +BBCLASSEXTEND = "native nativesdk"
>>> --
>>> 2.13.3
>>>
>>> --
>>> _______________________________________________
>>> Openembedded-core mailing list
>>> Openembedded-core@lists.openembedded.org
>>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>>
>>
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29 11:54     ` Burton, Ross
  2017-07-29 14:16       ` Khem Raj
@ 2017-07-30  3:22       ` Khem Raj
  2017-07-30  3:52       ` Khem Raj
  2 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-30  3:22 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core


[-- Attachment #1.1: Type: text/plain, Size: 20663 bytes --]

Ross

I have refreshed the pull branch which should hopefully address mesa
configure issue you are seeing along with llvm fix to adjust with clang
layer

On 7/29/17 4:54 AM, Burton, Ross wrote:
> Replicated without uninative, so it's not that.
> 
> Ross
> 
> On 29 July 2017 at 12:39, Burton, Ross <ross.burton@intel.com
> <mailto:ross.burton@intel.com>> wrote:
> 
>     Fails like this for me:
> 
>     | FAILED: tools/llvm-cvtres/Opts.inc.tmp
>     | cd
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build
>     &&
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -gen-opt-parser-defs -I
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres
>     -I
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/include
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres/Opts.td
>     -o tools/llvm-cvtres/Opts.inc.tmp -d tools/llvm-cvtres/Opts.inc.d
>     | /bin/sh: 1:
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>     not found
> 
>     It is there though:
> 
>     $ ls -l
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -rwxr-xr-x 1 ross ross 49807224 Jul 29 12:25
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
> 
>     $
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -bash:
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>     No such file or directory
> 
>     Might be related to having uninative enabled?
> 
>     Ross
> 
> 
>     On 29 July 2017 at 09:35, Khem Raj <raj.khem@gmail.com
>     <mailto:raj.khem@gmail.com>> wrote:
> 
>         Based on recipe from meta-oe and clang recipe from meta-clang
>         Needed by mesa
> 
>         Fixes
>         [YOCTO #11529]
> 
>         Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         ---
>          ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93
>         ++++++++++++
>          .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
>          meta/recipes-devtools/llvm/llvm_git.bb <http://llvm_git.bb>   
>                  | 166 +++++++++++++++++++++
>          3 files changed, 298 insertions(+)
>          create mode 100644
>         meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>          create mode 100644
>         meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
>          create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb>
> 
>         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 @@
>         +From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17
>         00:00:00 2001
>         +From: Khem Raj <raj.khem@gmail.com <mailto:raj.khem@gmail.com>>
>         +Date: Sat, 21 May 2016 00:33:20 +0000
>         +Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc
>         functions if they
>         + are macros
>         +
>         +musl defines some functions as macros and not inline functions
>         +if this is the case then make sure to undefine them
>         +
>         +Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +---
>         +Upstream-Status: Pending
>         +
>         + include/llvm/Analysis/TargetLibraryInfo.def | 21
>         +++++++++++++++++++++
>         + 1 file changed, 21 insertions(+)
>         +
>         +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def
>         b/include/llvm/Analysis/TargetLibraryInfo.def
>         +index 9cbe917c146..aff8419cf54 100644
>         +--- a/include/llvm/Analysis/TargetLibraryInfo.def
>         ++++ b/include/llvm/Analysis/TargetLibraryInfo.def
>         +@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
>         + TLI_DEFINE_ENUM_INTERNAL(fopen)
>         + TLI_DEFINE_STRING_INTERNAL("fopen")
>         + /// FILE *fopen64(const char *filename, const char *opentype)
>         ++#ifdef fopen64
>         ++#undef fopen64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(fopen64)
>         + TLI_DEFINE_STRING_INTERNAL("fopen64")
>         + /// int fprintf(FILE *stream, const char *format, ...);
>         +@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
>         + /// int fseeko(FILE *stream, off_t offset, int whence);
>         + TLI_DEFINE_ENUM_INTERNAL(fseeko)
>         + TLI_DEFINE_STRING_INTERNAL("fseeko")
>         ++#ifdef fseeko64
>         ++#undef fseeko64
>         ++#endif
>         + /// int fseeko64(FILE *stream, off64_t offset, int whence)
>         + TLI_DEFINE_ENUM_INTERNAL(fseeko64)
>         + TLI_DEFINE_STRING_INTERNAL("fseeko64")
>         +@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
>         + TLI_DEFINE_ENUM_INTERNAL(fstat)
>         + TLI_DEFINE_STRING_INTERNAL("fstat")
>         + /// int fstat64(int filedes, struct stat64 *buf)
>         ++#ifdef fstat64
>         ++#undef fstat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(fstat64)
>         + TLI_DEFINE_STRING_INTERNAL("fstat64")
>         + /// int fstatvfs(int fildes, struct statvfs *buf);
>         +@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
>         + TLI_DEFINE_ENUM_INTERNAL(ftello)
>         + TLI_DEFINE_STRING_INTERNAL("ftello")
>         + /// off64_t ftello64(FILE *stream)
>         ++#ifdef ftello64
>         ++#undef ftello64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(ftello64)
>         + TLI_DEFINE_STRING_INTERNAL("ftello64")
>         + /// int ftrylockfile(FILE *file);
>         +@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
>         + TLI_DEFINE_ENUM_INTERNAL(lstat)
>         + TLI_DEFINE_STRING_INTERNAL("lstat")
>         + /// int lstat64(const char *path, struct stat64 *buf);
>         ++#ifdef lstat64
>         ++#undef lstat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(lstat64)
>         + TLI_DEFINE_STRING_INTERNAL("lstat64")
>         + /// void *malloc(size_t size);
>         +@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
>         + TLI_DEFINE_ENUM_INTERNAL(stat)
>         + TLI_DEFINE_STRING_INTERNAL("stat")
>         + /// int stat64(const char *path, struct stat64 *buf);
>         ++#ifdef stat64
>         ++#undef stat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(stat64)
>         + TLI_DEFINE_STRING_INTERNAL("stat64")
>         + /// int statvfs(const char *path, struct statvfs *buf);
>         +@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
>         + TLI_DEFINE_ENUM_INTERNAL(tmpfile)
>         + TLI_DEFINE_STRING_INTERNAL("tmpfile")
>         + /// FILE *tmpfile64(void)
>         ++#ifdef tmpfile64
>         ++#undef tmpfile64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
>         + TLI_DEFINE_STRING_INTERNAL("tmpfile64")
>         + /// int toascii(int c);
>         +--
>         +2.13.1
>         +
>         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 @@
>         +From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17
>         00:00:00 2001
>         +From: Martin Kelly <mkelly@xevo.com <mailto:mkelly@xevo.com>>
>         +Date: Fri, 19 May 2017 00:22:57 -0700
>         +Subject: [PATCH 2/2] llvm: allow env override of exe path
>         +
>         +When using a native llvm-config from inside a sysroot, we need
>         llvm-config to
>         +return the libraries, include directories, etc. from inside the
>         sysroot rather
>         +than from the native sysroot. Thus provide an env override for
>         calling
>         +llvm-config from a target sysroot.
>         +
>         +Signed-off-by: Martin Kelly <mkelly@xevo.com
>         <mailto:mkelly@xevo.com>>
>         +Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +---
>         +Upstream-Status: Pending
>         +
>         + tools/llvm-config/llvm-config.cpp | 7 +++++++
>         + 1 file changed, 7 insertions(+)
>         +
>         +diff --git a/tools/llvm-config/llvm-config.cpp
>         b/tools/llvm-config/llvm-config.cpp
>         +index 08b096afb05..d8d7742744e 100644
>         +--- a/tools/llvm-config/llvm-config.cpp
>         ++++ b/tools/llvm-config/llvm-config.cpp
>         +@@ -225,6 +225,13 @@ Typical components:\n\
>         +
>         + /// \brief Compute the path to the main executable.
>         + std::string GetExecutablePath(const char *Argv0) {
>         ++  // Hack for Yocto: we need to override the root path when we
>         are using
>         ++  // llvm-config from within a target sysroot.
>         ++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
>         ++  if (Sysroot != nullptr) {
>         ++    return Sysroot;
>         ++  }
>         ++
>         +   // This just needs to be some symbol in the binary; C++ doesn't
>         +   // allow taking the address of ::main however.
>         +   void *P = (void *)(intptr_t)GetExecutablePath;
>         +--
>         +2.13.1
>         +
>         diff --git a/meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb> b/meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb>
>         new file mode 100644
>         index 0000000000..7b51d2153f
>         --- /dev/null
>         +++ b/meta/recipes-devtools/llvm/llvm_git.bb <http://llvm_git.bb>
>         @@ -0,0 +1,166 @@
>         +# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +# Released under the MIT license (see COPYING.MIT for the terms)
>         +
>         +DESCRIPTION = "The LLVM Compiler Infrastructure"
>         +HOMEPAGE = "http://llvm.org"
>         +LICENSE = "NCSA"
>         +SECTION = "devel"
>         +
>         +LIC_FILES_CHKSUM =
>         "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e5251771"
>         +
>         +DEPENDS = "libffi libxml2-native zlib ninja-native"
>         +
>         +RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
>         +
>         +inherit perlnative pythonnative cmake pkgconfig
>         +
>         +PROVIDES += "llvm${PV}"
>         +
>         +LLVM_RELEASE = "${PV}"
>         +LLVM_DIR = "llvm${LLVM_RELEASE}"
>         +
>         +SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
>         +PV = "5.0"
>         +PATCH_VERSION = "0"
>         +SRC_URI =
>         "git://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http
>         <http://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http>
>         \
>         +         
>          file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>         \
>         +           file://0002-llvm-allow-env-override-of-exe-path.patch \
>         +          "
>         +S = "${WORKDIR}/git"
>         +
>         +LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
>         +def get_llvm_arch(bb, d, arch_var):
>         +    import re
>         +    a = d.getVar(arch_var, True)
>         +    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
>         +    elif re.match('arm$', a):                          return 'ARM'
>         +    elif re.match('armeb$', a):                        return 'ARM'
>         +    elif re.match('aarch64$', a):                      return
>         'AArch64'
>         +    elif re.match('aarch64_be$', a):                   return
>         'AArch64'
>         +    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return
>         'Mips'
>         +    elif re.match('p(pc|owerpc)(|64)', a):             return
>         'PowerPC'
>         +    else:
>         +        bb.error("cannot map '%s' to a supported llvm
>         architecture" % a)
>         +    return ""
>         +
>         +def get_llvm_target_arch(bb, d):
>         +    return get_llvm_arch(bb, d, 'TARGET_ARCH')
>         +#
>         +# Default to build all OE-Core supported target arches (user
>         overridable).
>         +#
>         +LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
>         +LLVM_TARGETS_prepend_x86 = "AMDGPU;"
>         +LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
>         +
>         +EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
>         +                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
>         +                  -DLLVM_ENABLE_PIC=ON \
>         +                  -DLLVM_BINDINGS_LIST='' \
>         +                  -DLLVM_LINK_LLVM_DYLIB=ON \
>         +                  -DLLVM_ENABLE_FFI=ON \
>         +                  -DFFI_INCLUDE_DIR=$(pkg-config
>         --variable=includedir libffi) \
>         +                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
>         +                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
>         +                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
>         +                  -G Ninja \
>         +                 "
>         +EXTRA_OECMAKE_remove_class-native =
>         "-DCMAKE_CROSSCOMPILING:BOOL=ON"
>         +
>         +do_configure_prepend() {
>         +# Fix paths in llvm-config
>         +       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
>         +       sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g"
>         ${S}/tools/llvm-config/llvm-config.cpp
>         +       sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g"
>         ${S}/tools/llvm-config/llvm-config.cpp
>         +}
>         +
>         +do_compile() {
>         +       NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
>         +}
>         +
>         +do_install() {
>         +       NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja
>         -v install
>         +       install -D -m 0755 ${B}/NATIVE/bin/llvm-config
>         ${D}${libdir}/${LLVM_DIR}/llvm-config-host
>         +
>         +       install -d ${D}${bindir}/${LLVM_DIR}
>         +       cp -r ${LLVM_INSTALL_DIR}${bindir}/*
>         ${D}${bindir}/${LLVM_DIR}/
>         +
>         +       install -d ${D}${includedir}/${LLVM_DIR}
>         +       cp -r ${LLVM_INSTALL_DIR}${includedir}/*
>         ${D}${includedir}/${LLVM_DIR}/
>         +
>         +       install -d ${D}${libdir}/${LLVM_DIR}
>         +
>         +       # The LLVM sources have "/lib" embedded and so we cannot
>         completely rely on the ${libdir} variable
>         +       if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${libdir}/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       fi
>         +
>         +       # Remove unnecessary cmake files
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
>         +
>         +       ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV}
>         ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
>         +
>         +       # We'll have to delete the libLLVM.so due to multiple
>         reasons...
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
>         +}
>         +
>         +PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
>         +ALLOW_EMPTY_${PN} = "1"
>         +ALLOW_EMPTY_${PN}-staticdev = "1"
>         +FILES_${PN} = ""
>         +FILES_${PN}-staticdev = ""
>         +FILES_${PN}-dbg = " \
>         +    ${bindir}/${LLVM_DIR}/.debug \
>         +    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
>         +    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
>         +    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
>         +    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
>         +    /usr/src/debug \
>         +"
>         +
>         +FILES_${PN}-dev = " \
>         +    ${bindir}/${LLVM_DIR} \
>         +    ${includedir}/${LLVM_DIR} \
>         +    ${libdir}/${LLVM_DIR}/llvm-config-host \
>         +"
>         +
>         +RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
>         +
>         +FILES_${PN}-bugpointpasses = "\
>         +    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
>         +"
>         +FILES_${PN} += "\
>         +    ${libdir}/${LLVM_DIR}/libLTO.so.* \
>         +"
>         +
>         +FILES_${PN}-llvmhello = "\
>         +    ${libdir}/${LLVM_DIR}/LLVMHello.so \
>         +"
>         +
>         +PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
>         +NOAUTOPACKAGEDEBUG = "1"
>         +
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION}
>         += "dev-so"
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}
>         += "dev-so"
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
>         +
>         +python llvm_populate_packages() {
>         +    libdir = bb.data.expand('${libdir}', d)
>         +    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
>         +    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)
>         +    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)
>         +    split_staticdev_packages = do_split_packages(d,
>         libllvm_libdir, '^lib(.*)\.a$',
>         'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev package
>         for %s', allow_dirs=True)
>         +    if split_packages:
>         +        pn = d.getVar('PN', True)
>         +        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
>         +        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+'
>         '.join(split_dbg_packages))
>         +        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+'
>         '.join(split_staticdev_packages))
>         +}
>         +
>         +PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
>         +
>         +BBCLASSEXTEND = "native nativesdk"
>         --
>         2.13.3
> 
>         --
>         _______________________________________________
>         Openembedded-core mailing list
>         Openembedded-core@lists.openembedded.org
>         <mailto:Openembedded-core@lists.openembedded.org>
>         http://lists.openembedded.org/mailman/listinfo/openembedded-core
>         <http://lists.openembedded.org/mailman/listinfo/openembedded-core>
> 
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 169 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] llvm: Add recipe for 5.0
  2017-07-29 11:54     ` Burton, Ross
  2017-07-29 14:16       ` Khem Raj
  2017-07-30  3:22       ` Khem Raj
@ 2017-07-30  3:52       ` Khem Raj
  2 siblings, 0 replies; 11+ messages in thread
From: Khem Raj @ 2017-07-30  3:52 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core


[-- Attachment #1.1: Type: text/plain, Size: 20637 bytes --]

Ross

I have refreshed the pull branch which should hopefully address mesa
configure issue you are seeing along with llvm fix

On 7/29/17 4:54 AM, Burton, Ross wrote:
> Replicated without uninative, so it's not that.
> 
> Ross
> 
> On 29 July 2017 at 12:39, Burton, Ross <ross.burton@intel.com
> <mailto:ross.burton@intel.com>> wrote:
> 
>     Fails like this for me:
> 
>     | FAILED: tools/llvm-cvtres/Opts.inc.tmp
>     | cd
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build
>     &&
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -gen-opt-parser-defs -I
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres
>     -I
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/include
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/git/tools/llvm-cvtres/Opts.td
>     -o tools/llvm-cvtres/Opts.inc.tmp -d tools/llvm-cvtres/Opts.inc.d
>     | /bin/sh: 1:
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>     not found
> 
>     It is there though:
> 
>     $ ls -l
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -rwxr-xr-x 1 ross ross 49807224 Jul 29 12:25
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
> 
>     $
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen
>     -bash:
>     /data/poky-tmp/master/build/work/corei7-64-poky-linux/llvm/5.0-r0/build/NATIVE/bin/llvm-tblgen:
>     No such file or directory
> 
>     Might be related to having uninative enabled?
> 
>     Ross
> 
> 
>     On 29 July 2017 at 09:35, Khem Raj <raj.khem@gmail.com
>     <mailto:raj.khem@gmail.com>> wrote:
> 
>         Based on recipe from meta-oe and clang recipe from meta-clang
>         Needed by mesa
> 
>         Fixes
>         [YOCTO #11529]
> 
>         Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         ---
>          ...LibraryInfo-Undefine-libc-functions-if-th.patch |  93
>         ++++++++++++
>          .../0002-llvm-allow-env-override-of-exe-path.patch |  39 +++++
>          meta/recipes-devtools/llvm/llvm_git.bb <http://llvm_git.bb>   
>                  | 166 +++++++++++++++++++++
>          3 files changed, 298 insertions(+)
>          create mode 100644
>         meta/recipes-devtools/llvm/llvm/0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>          create mode 100644
>         meta/recipes-devtools/llvm/llvm/0002-llvm-allow-env-override-of-exe-path.patch
>          create mode 100644 meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb>
> 
>         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 @@
>         +From 28293e48cf1a52004c6a78de448718441f9e05f9 Mon Sep 17
>         00:00:00 2001
>         +From: Khem Raj <raj.khem@gmail.com <mailto:raj.khem@gmail.com>>
>         +Date: Sat, 21 May 2016 00:33:20 +0000
>         +Subject: [PATCH 1/2] llvm: TargetLibraryInfo: Undefine libc
>         functions if they
>         + are macros
>         +
>         +musl defines some functions as macros and not inline functions
>         +if this is the case then make sure to undefine them
>         +
>         +Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +---
>         +Upstream-Status: Pending
>         +
>         + include/llvm/Analysis/TargetLibraryInfo.def | 21
>         +++++++++++++++++++++
>         + 1 file changed, 21 insertions(+)
>         +
>         +diff --git a/include/llvm/Analysis/TargetLibraryInfo.def
>         b/include/llvm/Analysis/TargetLibraryInfo.def
>         +index 9cbe917c146..aff8419cf54 100644
>         +--- a/include/llvm/Analysis/TargetLibraryInfo.def
>         ++++ b/include/llvm/Analysis/TargetLibraryInfo.def
>         +@@ -656,6 +656,9 @@ TLI_DEFINE_STRING_INTERNAL("fmodl")
>         + TLI_DEFINE_ENUM_INTERNAL(fopen)
>         + TLI_DEFINE_STRING_INTERNAL("fopen")
>         + /// FILE *fopen64(const char *filename, const char *opentype)
>         ++#ifdef fopen64
>         ++#undef fopen64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(fopen64)
>         + TLI_DEFINE_STRING_INTERNAL("fopen64")
>         + /// int fprintf(FILE *stream, const char *format, ...);
>         +@@ -691,6 +694,9 @@ TLI_DEFINE_STRING_INTERNAL("fseek")
>         + /// int fseeko(FILE *stream, off_t offset, int whence);
>         + TLI_DEFINE_ENUM_INTERNAL(fseeko)
>         + TLI_DEFINE_STRING_INTERNAL("fseeko")
>         ++#ifdef fseeko64
>         ++#undef fseeko64
>         ++#endif
>         + /// int fseeko64(FILE *stream, off64_t offset, int whence)
>         + TLI_DEFINE_ENUM_INTERNAL(fseeko64)
>         + TLI_DEFINE_STRING_INTERNAL("fseeko64")
>         +@@ -701,6 +707,9 @@ TLI_DEFINE_STRING_INTERNAL("fsetpos")
>         + TLI_DEFINE_ENUM_INTERNAL(fstat)
>         + TLI_DEFINE_STRING_INTERNAL("fstat")
>         + /// int fstat64(int filedes, struct stat64 *buf)
>         ++#ifdef fstat64
>         ++#undef fstat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(fstat64)
>         + TLI_DEFINE_STRING_INTERNAL("fstat64")
>         + /// int fstatvfs(int fildes, struct statvfs *buf);
>         +@@ -716,6 +725,9 @@ TLI_DEFINE_STRING_INTERNAL("ftell")
>         + TLI_DEFINE_ENUM_INTERNAL(ftello)
>         + TLI_DEFINE_STRING_INTERNAL("ftello")
>         + /// off64_t ftello64(FILE *stream)
>         ++#ifdef ftello64
>         ++#undef ftello64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(ftello64)
>         + TLI_DEFINE_STRING_INTERNAL("ftello64")
>         + /// int ftrylockfile(FILE *file);
>         +@@ -836,6 +848,9 @@ TLI_DEFINE_STRING_INTERNAL("logl")
>         + TLI_DEFINE_ENUM_INTERNAL(lstat)
>         + TLI_DEFINE_STRING_INTERNAL("lstat")
>         + /// int lstat64(const char *path, struct stat64 *buf);
>         ++#ifdef lstat64
>         ++#undef lstat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(lstat64)
>         + TLI_DEFINE_STRING_INTERNAL("lstat64")
>         + /// void *malloc(size_t size);
>         +@@ -1055,6 +1070,9 @@ TLI_DEFINE_STRING_INTERNAL("sscanf")
>         + TLI_DEFINE_ENUM_INTERNAL(stat)
>         + TLI_DEFINE_STRING_INTERNAL("stat")
>         + /// int stat64(const char *path, struct stat64 *buf);
>         ++#ifdef stat64
>         ++#undef stat64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(stat64)
>         + TLI_DEFINE_STRING_INTERNAL("stat64")
>         + /// int statvfs(const char *path, struct statvfs *buf);
>         +@@ -1184,6 +1202,9 @@ TLI_DEFINE_STRING_INTERNAL("times")
>         + TLI_DEFINE_ENUM_INTERNAL(tmpfile)
>         + TLI_DEFINE_STRING_INTERNAL("tmpfile")
>         + /// FILE *tmpfile64(void)
>         ++#ifdef tmpfile64
>         ++#undef tmpfile64
>         ++#endif
>         + TLI_DEFINE_ENUM_INTERNAL(tmpfile64)
>         + TLI_DEFINE_STRING_INTERNAL("tmpfile64")
>         + /// int toascii(int c);
>         +--
>         +2.13.1
>         +
>         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 @@
>         +From d776487bac17650704614248d19d1e6b35775001 Mon Sep 17
>         00:00:00 2001
>         +From: Martin Kelly <mkelly@xevo.com <mailto:mkelly@xevo.com>>
>         +Date: Fri, 19 May 2017 00:22:57 -0700
>         +Subject: [PATCH 2/2] llvm: allow env override of exe path
>         +
>         +When using a native llvm-config from inside a sysroot, we need
>         llvm-config to
>         +return the libraries, include directories, etc. from inside the
>         sysroot rather
>         +than from the native sysroot. Thus provide an env override for
>         calling
>         +llvm-config from a target sysroot.
>         +
>         +Signed-off-by: Martin Kelly <mkelly@xevo.com
>         <mailto:mkelly@xevo.com>>
>         +Signed-off-by: Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +---
>         +Upstream-Status: Pending
>         +
>         + tools/llvm-config/llvm-config.cpp | 7 +++++++
>         + 1 file changed, 7 insertions(+)
>         +
>         +diff --git a/tools/llvm-config/llvm-config.cpp
>         b/tools/llvm-config/llvm-config.cpp
>         +index 08b096afb05..d8d7742744e 100644
>         +--- a/tools/llvm-config/llvm-config.cpp
>         ++++ b/tools/llvm-config/llvm-config.cpp
>         +@@ -225,6 +225,13 @@ Typical components:\n\
>         +
>         + /// \brief Compute the path to the main executable.
>         + std::string GetExecutablePath(const char *Argv0) {
>         ++  // Hack for Yocto: we need to override the root path when we
>         are using
>         ++  // llvm-config from within a target sysroot.
>         ++  const char *Sysroot = std::getenv("YOCTO_ALTERNATE_EXE_PATH");
>         ++  if (Sysroot != nullptr) {
>         ++    return Sysroot;
>         ++  }
>         ++
>         +   // This just needs to be some symbol in the binary; C++ doesn't
>         +   // allow taking the address of ::main however.
>         +   void *P = (void *)(intptr_t)GetExecutablePath;
>         +--
>         +2.13.1
>         +
>         diff --git a/meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb> b/meta/recipes-devtools/llvm/llvm_git.bb
>         <http://llvm_git.bb>
>         new file mode 100644
>         index 0000000000..7b51d2153f
>         --- /dev/null
>         +++ b/meta/recipes-devtools/llvm/llvm_git.bb <http://llvm_git.bb>
>         @@ -0,0 +1,166 @@
>         +# Copyright (C) 2017 Khem Raj <raj.khem@gmail.com
>         <mailto:raj.khem@gmail.com>>
>         +# Released under the MIT license (see COPYING.MIT for the terms)
>         +
>         +DESCRIPTION = "The LLVM Compiler Infrastructure"
>         +HOMEPAGE = "http://llvm.org"
>         +LICENSE = "NCSA"
>         +SECTION = "devel"
>         +
>         +LIC_FILES_CHKSUM =
>         "file://LICENSE.TXT;md5=e825e017edc35cfd58e26116e5251771"
>         +
>         +DEPENDS = "libffi libxml2-native zlib ninja-native"
>         +
>         +RDEPENDS_${PN}_append_class-target = " ncurses-terminfo"
>         +
>         +inherit perlnative pythonnative cmake pkgconfig
>         +
>         +PROVIDES += "llvm${PV}"
>         +
>         +LLVM_RELEASE = "${PV}"
>         +LLVM_DIR = "llvm${LLVM_RELEASE}"
>         +
>         +SRCREV = "9a5c333388cbb54a0ce3a67c4f539f5e590a089b"
>         +PV = "5.0"
>         +PATCH_VERSION = "0"
>         +SRC_URI =
>         "git://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http
>         <http://github.com/llvm-mirror/llvm.git;branch=release_50;protocol=http>
>         \
>         +         
>          file://0001-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch
>         \
>         +           file://0002-llvm-allow-env-override-of-exe-path.patch \
>         +          "
>         +S = "${WORKDIR}/git"
>         +
>         +LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install"
>         +def get_llvm_arch(bb, d, arch_var):
>         +    import re
>         +    a = d.getVar(arch_var, True)
>         +    if   re.match('(i.86|athlon|x86.64)$', a):         return 'X86'
>         +    elif re.match('arm$', a):                          return 'ARM'
>         +    elif re.match('armeb$', a):                        return 'ARM'
>         +    elif re.match('aarch64$', a):                      return
>         'AArch64'
>         +    elif re.match('aarch64_be$', a):                   return
>         'AArch64'
>         +    elif re.match('mips(isa|)(32|64|)(r6|)(el|)$', a): return
>         'Mips'
>         +    elif re.match('p(pc|owerpc)(|64)', a):             return
>         'PowerPC'
>         +    else:
>         +        bb.error("cannot map '%s' to a supported llvm
>         architecture" % a)
>         +    return ""
>         +
>         +def get_llvm_target_arch(bb, d):
>         +    return get_llvm_arch(bb, d, 'TARGET_ARCH')
>         +#
>         +# Default to build all OE-Core supported target arches (user
>         overridable).
>         +#
>         +LLVM_TARGETS ?= "${@get_llvm_target_arch(bb, d)}"
>         +LLVM_TARGETS_prepend_x86 = "AMDGPU;"
>         +LLVM_TARGETS_prepend_x86-64 = "AMDGPU;"
>         +
>         +EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \
>         +                  -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \
>         +                  -DLLVM_ENABLE_PIC=ON \
>         +                  -DLLVM_BINDINGS_LIST='' \
>         +                  -DLLVM_LINK_LLVM_DYLIB=ON \
>         +                  -DLLVM_ENABLE_FFI=ON \
>         +                  -DFFI_INCLUDE_DIR=$(pkg-config
>         --variable=includedir libffi) \
>         +                  -DLLVM_OPTIMIZED_TABLEGEN=ON \
>         +                  -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS}" \
>         +                  -DCMAKE_CROSSCOMPILING:BOOL=ON \
>         +                  -G Ninja \
>         +                 "
>         +EXTRA_OECMAKE_remove_class-native =
>         "-DCMAKE_CROSSCOMPILING:BOOL=ON"
>         +
>         +do_configure_prepend() {
>         +# Fix paths in llvm-config
>         +       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
>         +       sed -ri "s#/(bin|include|lib)(/?\")#/\1/${LLVM_DIR}\2#g"
>         ${S}/tools/llvm-config/llvm-config.cpp
>         +       sed -ri "s#lib/${LLVM_DIR}#${baselib}/${LLVM_DIR}#g"
>         ${S}/tools/llvm-config/llvm-config.cpp
>         +}
>         +
>         +do_compile() {
>         +       NINJA_STATUS="[%p] " ninja -v ${PARALLEL_MAKE}
>         +}
>         +
>         +do_install() {
>         +       NINJA_STATUS="[%p] " DESTDIR=${LLVM_INSTALL_DIR} ninja
>         -v install
>         +       install -D -m 0755 ${B}/NATIVE/bin/llvm-config
>         ${D}${libdir}/${LLVM_DIR}/llvm-config-host
>         +
>         +       install -d ${D}${bindir}/${LLVM_DIR}
>         +       cp -r ${LLVM_INSTALL_DIR}${bindir}/*
>         ${D}${bindir}/${LLVM_DIR}/
>         +
>         +       install -d ${D}${includedir}/${LLVM_DIR}
>         +       cp -r ${LLVM_INSTALL_DIR}${includedir}/*
>         ${D}${includedir}/${LLVM_DIR}/
>         +
>         +       install -d ${D}${libdir}/${LLVM_DIR}
>         +
>         +       # The LLVM sources have "/lib" embedded and so we cannot
>         completely rely on the ${libdir} variable
>         +       if [ -d ${LLVM_INSTALL_DIR}${libdir}/ ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${libdir}/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       elif [ -d ${LLVM_INSTALL_DIR}${prefix}/lib64 ]; then
>         +               cp -r ${LLVM_INSTALL_DIR}${prefix}/lib64/*
>         ${D}${libdir}/${LLVM_DIR}/
>         +       fi
>         +
>         +       # Remove unnecessary cmake files
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/cmake
>         +
>         +       ln -s ${LLVM_DIR}/libLLVM-${PV}${SOLIBSDEV}
>         ${D}${libdir}/libLLVM-${PV}${SOLIBSDEV}
>         +
>         +       # We'll have to delete the libLLVM.so due to multiple
>         reasons...
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLLVM.so
>         +       rm -rf ${D}${libdir}/${LLVM_DIR}/libLTO.so
>         +}
>         +
>         +PACKAGES += "${PN}-bugpointpasses ${PN}-llvmhello"
>         +ALLOW_EMPTY_${PN} = "1"
>         +ALLOW_EMPTY_${PN}-staticdev = "1"
>         +FILES_${PN} = ""
>         +FILES_${PN}-staticdev = ""
>         +FILES_${PN}-dbg = " \
>         +    ${bindir}/${LLVM_DIR}/.debug \
>         +    ${libdir}/${LLVM_DIR}/.debug/BugpointPasses.so \
>         +    ${libdir}/${LLVM_DIR}/.debug/LLVMHello.so \
>         +    ${libdir}/${LLVM_DIR}/.debug/libLTO.so* \
>         +    ${libdir}/${LLVM_DIR}/.debug/llvm-config-host \
>         +    /usr/src/debug \
>         +"
>         +
>         +FILES_${PN}-dev = " \
>         +    ${bindir}/${LLVM_DIR} \
>         +    ${includedir}/${LLVM_DIR} \
>         +    ${libdir}/${LLVM_DIR}/llvm-config-host \
>         +"
>         +
>         +RRECOMMENDS_${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello"
>         +
>         +FILES_${PN}-bugpointpasses = "\
>         +    ${libdir}/${LLVM_DIR}/BugpointPasses.so \
>         +"
>         +FILES_${PN} += "\
>         +    ${libdir}/${LLVM_DIR}/libLTO.so.* \
>         +"
>         +
>         +FILES_${PN}-llvmhello = "\
>         +    ${libdir}/${LLVM_DIR}/LLVMHello.so \
>         +"
>         +
>         +PACKAGES_DYNAMIC = "^libllvm${LLVM_RELEASE}-.*$"
>         +NOAUTOPACKAGEDEBUG = "1"
>         +
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}.${PATCH_VERSION}
>         += "dev-so"
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm-${LLVM_RELEASE}
>         += "dev-so"
>         +INSANE_SKIP_${MLPREFIX}libllvm${LLVM_RELEASE}-llvm += "dev-so"
>         +
>         +python llvm_populate_packages() {
>         +    libdir = bb.data.expand('${libdir}', d)
>         +    libllvm_libdir = bb.data.expand('${libdir}/${LLVM_DIR}', d)
>         +    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)
>         +    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)
>         +    split_staticdev_packages = do_split_packages(d,
>         libllvm_libdir, '^lib(.*)\.a$',
>         'libllvm${LLVM_RELEASE}-%s-staticdev', 'Split staticdev package
>         for %s', allow_dirs=True)
>         +    if split_packages:
>         +        pn = d.getVar('PN', True)
>         +        d.appendVar('RDEPENDS_' + pn, ' '+' '.join(split_packages))
>         +        d.appendVar('RDEPENDS_' + pn + '-dbg', ' '+'
>         '.join(split_dbg_packages))
>         +        d.appendVar('RDEPENDS_' + pn + '-staticdev', ' '+'
>         '.join(split_staticdev_packages))
>         +}
>         +
>         +PACKAGESPLITFUNCS_prepend = "llvm_populate_packages "
>         +
>         +BBCLASSEXTEND = "native nativesdk"
>         --
>         2.13.3
> 
>         --
>         _______________________________________________
>         Openembedded-core mailing list
>         Openembedded-core@lists.openembedded.org
>         <mailto:Openembedded-core@lists.openembedded.org>
>         http://lists.openembedded.org/mailman/listinfo/openembedded-core
>         <http://lists.openembedded.org/mailman/listinfo/openembedded-core>
> 
> 
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 169 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-30  3:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-29  8:35 [PATCH V3 0/4] llvm: Add recipe for 5.0 Khem Raj
2017-07-29  8:35 ` [PATCH 1/4] ninja: Add recipe Khem Raj
2017-07-29  8:35 ` [PATCH 2/4] re2c: Transfer recipe from meta-oe and upgrade to 0.16 Khem Raj
2017-07-29  8:35 ` [PATCH 3/4] llvm: Add recipe for 5.0 Khem Raj
2017-07-29 11:39   ` Burton, Ross
2017-07-29 11:54     ` Burton, Ross
2017-07-29 14:16       ` Khem Raj
2017-07-30  3:22       ` Khem Raj
2017-07-30  3:52       ` Khem Raj
2017-07-29  8:35 ` [PATCH 4/4] mesa: Fix build when building with llvmpipe Khem Raj
2017-07-29  9:01 ` ✗ patchtest: failure for llvm: Add recipe for 5.0 (rev3) Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.