From ea888066a3d1d7503137fa0615f246739f8ec4a8 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Wed, 2 Nov 2016 16:25:14 -0500 Subject: [PATCH 1/3] rust-llvm: convert to cmake build Future versions of LLVM require cmake to build so it will be easier to prove that out on a known good build and to allow future versions to use this as common code. --- .../0001-Don-t-build-unittests.patch | 34 --------------- recipes-devtools/rust/rust-llvm.inc | 42 +++++++++---------- 2 files changed, 19 insertions(+), 57 deletions(-) delete mode 100644 recipes-devtools/rust/files/rust-llvm/0001-Don-t-build-unittests.patch diff --git a/recipes-devtools/rust/files/rust-llvm/0001-Don-t-build-unittests.patch b/recipes-devtools/rust/files/rust-llvm/0001-Don-t-build-unittests.patch deleted file mode 100644 index 7a297d3..0000000 --- a/recipes-devtools/rust/files/rust-llvm/0001-Don-t-build-unittests.patch +++ /dev/null @@ -1,34 +0,0 @@ -From eee79cc95f57434c4b530da96c88494e9b5d056b Mon Sep 17 00:00:00 2001 -From: Steven Walter -Date: Sat, 27 Aug 2016 13:20:48 -0400 -Subject: [PATCH] Don't build unittests - ---- - Makefile | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Makefile b/Makefile -index 2b9468a..2bb30f6 100644 ---- a/Makefile -+++ b/Makefile -@@ -31,7 +31,7 @@ ifeq ($(BUILD_DIRS_ONLY),1) - OPTIONAL_DIRS := tools/clang/utils/TableGen - else - DIRS := lib/Support lib/TableGen utils lib/IR lib tools/llvm-shlib \ -- tools/llvm-config tools docs cmake unittests -+ tools/llvm-config tools docs cmake - OPTIONAL_DIRS := projects bindings - endif - -@@ -39,7 +39,7 @@ ifeq ($(BUILD_EXAMPLES),1) - OPTIONAL_DIRS += examples - endif - --EXTRA_DIST := test unittests llvm.spec include win32 Xcode -+EXTRA_DIST := test llvm.spec include win32 Xcode - - include $(LEVEL)/Makefile.config - --- -2.7.4 - diff --git a/recipes-devtools/rust/rust-llvm.inc b/recipes-devtools/rust/rust-llvm.inc index 201b1d0..880e3ec 100644 --- a/recipes-devtools/rust/rust-llvm.inc +++ b/recipes-devtools/rust/rust-llvm.inc @@ -3,25 +3,33 @@ LICENSE = "NCSA" SRC_URI = "\ https://static.rust-lang.org/dist/rustc-${PV}-src.tar.gz;name=rust \ - file://rust-llvm/0001-Don-t-build-unittests.patch \ " S = "${WORKDIR}/rustc-${PV}/src/llvm" LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=4c0bc17c954e99fd547528d938832bfa" -inherit autotools +inherit cmake pythonnative -EXTRA_OECONF += "--enable-targets=x86,x86_64,arm,aarch64,mips,powerpc" -EXTRA_OECONF += "--enable-optimized" -EXTRA_OECONF += "--disable-assertions" -EXTRA_OECONF += "--disable-docs" -EXTRA_OECONF += "--enable-bindings=none" -EXTRA_OECONF += "--disable-terminfo" -EXTRA_OECONF += "--disable-zlib" -EXTRA_OECONF += "--disable-libffi" +EXTRA_OECMAKE = " \ + -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;PowerPC' \ + -DLLVM_ENABLE_ASSERTIONS=OFF \ + -DLLVM_BUILD_DOCS=OFF \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_ZLIB=OFF \ + -DLLVM_ENABLE_FFI=OFF \ + -DLLVM_INSTALL_UTILS=ON \ + -DLLVM_BUILD_TOOLS=ON \ + -DLLVM_BUILD_EXAMPLES=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_BUILD_TESTS=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_TARGET_ARCH=${TARGET_ARCH} \ +" -EXTRA_OECONF += "--enable-keep-symbols" +# The debug symbols are huge here (>2GB) so suppress them since they +# provide almost no value. If you really need them then override this +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" PACKAGES += "${PN}-data" @@ -29,16 +37,4 @@ PACKAGES += "${PN}-data" FILES_${PN}-data = "${datadir}" FILES_${PN}-dev += "${libdir}" -do_install_append () { - # Remove the debug info (>2 GB) as part of normal operation - rm -rf ${D}${bindir}/.debug - - cd ${D}${bindir} || bbfatal "failed to cd ${D}${bindir}" - for i in *-llvm-* *-llc *-lli *-FileCheck; do - link=$(echo $i | sed -e "s/${TARGET_SYS}-\(.*\)/\1/") - [ -e "${i}" ] || bbfatal "no such file to symlink to ${i}" - ln -sf "$i" "${link}" || bbfatal "failed to symlink ${link} to ${i}" - done -} - BBCLASSEXTEND = "native" From 404cbe3dccba9475ca6aaca9ad318bfe6b2682d9 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 3 Nov 2016 10:29:50 -0500 Subject: [PATCH 2/3] rust-llvm: cmake build bits from openswitch Grabbed this chunk from http://git.openswitch.net/cgit/openswitch/ops-build/tree/yocto/openswitch/meta-foss-openswitch/recipes-core/llvm/llvm.inc The cmake.bbclass that poky ships with does not generate the proper values for native builds so this is necessary to fix that up. --- recipes-devtools/rust/rust-llvm.inc | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/recipes-devtools/rust/rust-llvm.inc b/recipes-devtools/rust/rust-llvm.inc index 880e3ec..c8800b6 100644 --- a/recipes-devtools/rust/rust-llvm.inc +++ b/recipes-devtools/rust/rust-llvm.inc @@ -31,6 +31,80 @@ EXTRA_OECMAKE = " \ # provide almost no value. If you really need them then override this INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +EXTRA_OECMAKE_append_class-target = "\ + -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/native_toolchain.cmake' \ +" + +do_generate_native_toolchain_file() { + cat > ${WORKDIR}/native_toolchain.cmake <:/${baselib}:g' ${S}/tools/llvm-config/llvm-config.cpp +} + +do_compile() { + oe_runmake +} + +do_install_append_class-target() { + # Disable checks on the native tools, since these should came from the native recipe + sed -i -e 's/\(.*APPEND.*_IMPORT_CHECK_FILES_FOR_.*{_IMPORT_PREFIX}\/bin\/.*\)/#\1/' ${D}/usr/share/llvm/cmake/LLVMExports-noconfig.cmake +} + +SYSROOT_PREPROCESS_FUNCS_append_class-target = " llvm_sysroot_preprocess" +SYSROOT_PREPROCESS_FUNCS_append_class-native = " llvm_native_sysroot_preprocess" + +llvm_sysroot_preprocess() { + install -d ${SYSROOT_DESTDIR}${bindir} + cp ${B}/NATIVE/bin/llvm-config ${SYSROOT_DESTDIR}/${bindir} || bbfatal "missing llvm-config" + cp ${B}/NATIVE/bin/llvm-tblgen ${SYSROOT_DESTDIR}/${bindir} || bbfatal "missing llvm-tblgen" +} + +llvm_native_sysroot_preprocess() { + sysroot_stage_dir ${D}${STAGING_DIR_NATIVE}/usr/libexec ${SYSROOT_DESTDIR}${bindir} +} + PACKAGES += "${PN}-data" # Add the extra locations to avoid the complaints about unpackaged files From 3b28ddab2b0a1f1440055b6cf8822d9194cbeeda Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 3 Nov 2016 22:22:58 -0500 Subject: [PATCH 3/3] rust-llvm: fix up generated packages Avoid issues with non-native builds by splitting up the packages a little closer to how they should be while still leaving the main package containing everything Rust uses. This makes it possible to build rust-llvm for the target, hopefully improving issue #81. --- recipes-devtools/rust/rust-llvm.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes-devtools/rust/rust-llvm.inc b/recipes-devtools/rust/rust-llvm.inc index c8800b6..fba8b22 100644 --- a/recipes-devtools/rust/rust-llvm.inc +++ b/recipes-devtools/rust/rust-llvm.inc @@ -105,10 +105,13 @@ llvm_native_sysroot_preprocess() { sysroot_stage_dir ${D}${STAGING_DIR_NATIVE}/usr/libexec ${SYSROOT_DESTDIR}${bindir} } -PACKAGES += "${PN}-data" +PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liblto" # Add the extra locations to avoid the complaints about unpackaged files -FILES_${PN}-data = "${datadir}" -FILES_${PN}-dev += "${libdir}" +FILES_${PN} += "${libdir}/libLLVM*.so" +FILES_${PN}-dev += "${datadir}/llvm" +FILES_${PN}-bugpointpasses = "${libdir}/BugpointPasses.so" +FILES_${PN}-llvmhello = "${libdir}/LLVMHello.so" +FILES_${PN}-liblto = "${libdir}/libLTO.so" BBCLASSEXTEND = "native"