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..fba8b22 100644 --- a/recipes-devtools/rust/rust-llvm.inc +++ b/recipes-devtools/rust/rust-llvm.inc @@ -3,42 +3,115 @@ 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" +EXTRA_OECMAKE_append_class-target = "\ + -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/native_toolchain.cmake' \ +" -# Add the extra locations to avoid the complaints about unpackaged files -FILES_${PN}-data = "${datadir}" -FILES_${PN}-dev += "${libdir}" +do_generate_native_toolchain_file() { + cat > ${WORKDIR}/native_toolchain.cmake <2 GB) as part of normal operation - rm -rf ${D}${bindir}/.debug +# only search in the paths provided so cmake doesnt pick +# up libraries and tools from the native build machine +set( CMAKE_FIND_ROOT_PATH ${STAGING_DIR_HOST} ${STAGING_DIR_NATIVE} ${CROSS_DIR} ${OECMAKE_PERLNATIVE_DIR} ${OECMAKE_EXTRA_ROOT_PATH} ${EXTERNAL_TOOLCHAIN}) +set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) +set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) - 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 +# Use native cmake modules +set( CMAKE_MODULE_PATH ${STAGING_DATADIR}/cmake/Modules/ ) + +# add for non /usr/lib libdir, e.g. /usr/lib64 +set( CMAKE_LIBRARY_PATH ${libdir} ${base_libdir}) + +EOF } +addtask generate_native_toolchain_file after do_patch before do_configure + +do_configure_prepend_class-native() { + # Use host paths for native tools + sed -i -e '/CMAKE_FIND_ROOT_PATH_MODE/d' ${WORKDIR}/toolchain.cmake +} + +do_compile_prepend_class-target() { + # 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 + + # Fix the hardcoded libdir in llvm-config + sed -i 's:/lib\>:/${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}-bugpointpasses ${PN}-llvmhello ${PN}-liblto" + +# Add the extra locations to avoid the complaints about unpackaged files +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"