Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | # Copyright (C) 2017 Khem Raj <raj.khem@gmail.com> |
| 2 | # Released under the MIT license (see COPYING.MIT for the terms) |
| 3 | |
| 4 | DESCRIPTION = "The LLVM Compiler Infrastructure" |
| 5 | HOMEPAGE = "http://llvm.org" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 6 | LICENSE = "Apache-2.0-with-LLVM-exception" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 7 | SECTION = "devel" |
| 8 | |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 9 | LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=8a15a0759ef07f2682d2ba4b893c9afe" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 11 | DEPENDS = "libffi libxml2 zlib libedit ninja-native llvm-native" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 13 | COMPATIBLE_HOST:riscv64 = "null" |
| 14 | COMPATIBLE_HOST:riscv32 = "null" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 15 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 16 | RDEPENDS:${PN}:append:class-target = " ncurses-terminfo" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 17 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | inherit cmake pkgconfig |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | |
| 20 | PROVIDES += "llvm${PV}" |
| 21 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 22 | PV = "14.0.1" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 23 | |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 24 | MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 25 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | LLVM_RELEASE = "${PV}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 27 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 28 | BRANCH = "release/${MAJOR_VERSION}.x" |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 29 | SRCREV = "c62053979489ccb002efe411c3af059addcb5d7d" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 30 | SRC_URI = "git://github.com/llvm/llvm-project.git;branch=${BRANCH};protocol=https \ |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 31 | file://0006-llvm-TargetLibraryInfo-Undefine-libc-functions-if-th.patch;striplevel=2 \ |
| 32 | file://0007-llvm-allow-env-override-of-exe-path.patch;striplevel=2 \ |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 33 | file://0001-AsmMatcherEmitter-sort-ClassInfo-lists-by-name-as-we.patch;striplevel=2 \ |
| 34 | " |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 36 | UPSTREAM_CHECK_GITTAGREGEX = "llvmorg-(?P<pver>\d+(\.\d+)+)" |
| 37 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 38 | S = "${WORKDIR}/git/llvm" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 39 | |
| 40 | LLVM_INSTALL_DIR = "${WORKDIR}/llvm-install" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 42 | def get_llvm_arch(bb, d, arch_var): |
| 43 | import re |
| 44 | a = d.getVar(arch_var) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | if re.match(r'(i.86|athlon|x86.64)$', a): return 'X86' |
| 46 | elif re.match(r'arm$', a): return 'ARM' |
| 47 | elif re.match(r'armeb$', a): return 'ARM' |
| 48 | elif re.match(r'aarch64$', a): return 'AArch64' |
| 49 | elif re.match(r'aarch64_be$', a): return 'AArch64' |
| 50 | elif re.match(r'mips(isa|)(32|64|)(r6|)(el|)$', a): return 'Mips' |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 51 | elif re.match(r'riscv(32|64)(eb|)$', a): return 'RISCV' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | elif re.match(r'p(pc|owerpc)(|64)', a): return 'PowerPC' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | else: |
| 54 | raise bb.parse.SkipRecipe("Cannot map '%s' to a supported LLVM architecture" % a) |
| 55 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 56 | def get_llvm_host_arch(bb, d): |
| 57 | return get_llvm_arch(bb, d, 'HOST_ARCH') |
| 58 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 59 | # |
| 60 | # Default to build all OE-Core supported target arches (user overridable). |
| 61 | # |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 62 | LLVM_TARGETS ?= "AMDGPU;${@get_llvm_host_arch(bb, d)}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 64 | ARM_INSTRUCTION_SET:armv5 = "arm" |
| 65 | ARM_INSTRUCTION_SET:armv4t = "arm" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 66 | |
| 67 | EXTRA_OECMAKE += "-DLLVM_ENABLE_ASSERTIONS=OFF \ |
| 68 | -DLLVM_ENABLE_EXPENSIVE_CHECKS=OFF \ |
| 69 | -DLLVM_ENABLE_PIC=ON \ |
| 70 | -DLLVM_BINDINGS_LIST='' \ |
| 71 | -DLLVM_LINK_LLVM_DYLIB=ON \ |
| 72 | -DLLVM_ENABLE_FFI=ON \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 73 | -DLLVM_ENABLE_RTTI=ON \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 74 | -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \ |
| 75 | -DLLVM_OPTIMIZED_TABLEGEN=ON \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 76 | -DLLVM_TARGETS_TO_BUILD='${LLVM_TARGETS}' \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 77 | -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON \ |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 78 | -DPYTHON_EXECUTABLE=${HOSTTOOLS_DIR}/python3 \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 79 | -G Ninja" |
| 80 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 81 | EXTRA_OECMAKE:append:class-target = "\ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 82 | -DCMAKE_CROSSCOMPILING:BOOL=ON \ |
| 83 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 85 | " |
| 86 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 87 | EXTRA_OECMAKE:append:class-nativesdk = "\ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 88 | -DCMAKE_CROSSCOMPILING:BOOL=ON \ |
| 89 | -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm-tblgen${PV} \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 90 | -DLLVM_CONFIG_PATH=${STAGING_BINDIR_NATIVE}/llvm-config${PV} \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 91 | " |
| 92 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 93 | # patch out build host paths for reproducibility |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 94 | do_compile:prepend:class-target() { |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 95 | sed -i -e "s,${WORKDIR},,g" ${B}/tools/llvm-config/BuildVariables.inc |
| 96 | } |
| 97 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 98 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 99 | ninja -v ${PARALLEL_MAKE} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 100 | } |
| 101 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 102 | do_compile:class-native() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 103 | ninja -v ${PARALLEL_MAKE} llvm-config llvm-tblgen |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | do_install() { |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 107 | DESTDIR=${D} ninja -v install |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 108 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 109 | # llvm harcodes usr/lib as install path, so this corrects it to actual libdir |
| 110 | mv -T -n ${D}/${prefix}/lib ${D}/${libdir} || true |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 111 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 112 | # Remove opt-viewer: https://llvm.org/docs/Remarks.html |
| 113 | rm -rf ${D}${datadir}/opt-viewer |
| 114 | rmdir ${D}${datadir} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 115 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 116 | # reproducibility |
| 117 | sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 118 | } |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 119 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 120 | do_install:class-native() { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 121 | install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV} |
| 122 | install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 123 | } |
| 124 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 125 | PACKAGES =+ "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-libllvm ${PN}-liboptremarks ${PN}-liblto" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 126 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 127 | RRECOMMENDS:${PN}-dev += "${PN}-bugpointpasses ${PN}-llvmhello ${PN}-liboptremarks" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 128 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 129 | FILES:${PN}-bugpointpasses = "\ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 130 | ${libdir}/BugpointPasses.so \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 131 | " |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 132 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 133 | FILES:${PN}-libllvm = "\ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 134 | ${libdir}/libLLVM-${MAJOR_VERSION}.so \ |
| 135 | " |
| 136 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 137 | FILES:${PN}-liblto += "\ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 138 | ${libdir}/libLTO.so.* \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 139 | " |
| 140 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 141 | FILES:${PN}-liboptremarks += "\ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 142 | ${libdir}/libRemarks.so.* \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 143 | " |
| 144 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 145 | FILES:${PN}-llvmhello = "\ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 146 | ${libdir}/LLVMHello.so \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 147 | " |
| 148 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 149 | FILES:${PN}-dev += " \ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 150 | ${libdir}/llvm-config \ |
| 151 | ${libdir}/libRemarks.so \ |
| 152 | ${libdir}/libLLVM-${PV}.so \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 153 | " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 154 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 155 | FILES:${PN}-staticdev += "\ |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 156 | ${libdir}/*.a \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 157 | " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 158 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 159 | INSANE_SKIP:${PN}-libllvm += "dev-so" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 160 | |
| 161 | BBCLASSEXTEND = "native nativesdk" |