distribution/packages/lang/llvm/package.mk

118 lines
4.1 KiB
Makefile
Raw Normal View History

2022-02-05 14:23:32 +00:00
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="llvm"
PKG_VERSION="16.0.6"
2022-02-05 14:23:32 +00:00
PKG_LICENSE="Apache-2.0"
PKG_SITE="http://llvm.org/"
2022-06-30 10:28:25 +00:00
PKG_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${PKG_VERSION}/llvm-project-${PKG_VERSION}.src.tar.xz"
2022-02-05 14:23:32 +00:00
PKG_DEPENDS_HOST="toolchain:host"
PKG_DEPENDS_TARGET="toolchain llvm:host zlib"
PKG_LONGDESC="Low-Level Virtual Machine (LLVM) is a compiler infrastructure."
2022-06-30 10:28:25 +00:00
PKG_TOOLCHAIN="cmake"
2022-02-05 14:23:32 +00:00
PKG_CMAKE_OPTS_COMMON="-DLLVM_INCLUDE_TOOLS=ON \
-DCMAKE_BUILD_TYPE=Release \
2022-07-02 13:26:43 +00:00
-DLLVM_BUILD_TOOLS=OFF \
-DLLVM_BUILD_UTILS=OFF \
2022-02-05 14:23:32 +00:00
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_BUILD_TESTS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_GO_TESTS=OFF \
-DLLVM_BUILD_BENCHMARKS=OFF \
2022-06-30 10:28:25 +00:00
-DLLVM_INCLUDE_BENCHMARKS=OFF \
2022-02-05 14:23:32 +00:00
-DLLVM_BUILD_DOCS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DLLVM_ENABLE_DOXYGEN=OFF \
-DLLVM_ENABLE_SPHINX=OFF \
-DLLVM_ENABLE_OCAMLDOC=OFF \
2022-07-02 01:39:43 +00:00
-DLLVM_ENABLE_BINDINGS=ON \
-DLLVM_ENABLE_TERMINFO=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
2022-02-05 14:23:32 +00:00
-DLLVM_ENABLE_WERROR=OFF \
2022-06-30 10:28:25 +00:00
-DLLVM_ENABLE_ZLIB=OFF \
2022-02-05 14:23:32 +00:00
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_APPEND_VC_REV=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_UNWIND_TABLES=OFF \
2022-06-30 10:28:25 +00:00
-DLLVM_ENABLE_Z3_SOLVER=OFF \
-DCMAKE_SKIP_RPATH=ON"
2022-02-05 14:23:32 +00:00
2022-06-30 10:28:25 +00:00
pre_configure() {
PKG_CMAKE_SCRIPT=${PKG_BUILD}/llvm/CMakeLists.txt
2022-02-05 14:23:32 +00:00
}
2022-06-30 10:28:25 +00:00
pre_configure_host() {
case "${TARGET_ARCH}" in
"arm")
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="X86;ARM"
2022-06-30 10:28:25 +00:00
;;
"aarch64")
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="X86;AArch64"
2022-06-30 10:28:25 +00:00
;;
2023-03-04 16:20:58 +00:00
i*86|x86_64)
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="AMDGPU;X86"
2022-06-30 10:28:25 +00:00
;;
esac
mkdir -p ${PKG_BUILD}/.${HOST_NAME}
cd ${PKG_BUILD}/.${HOST_NAME}
PKG_CMAKE_OPTS_HOST="${PKG_CMAKE_OPTS_COMMON} \
-DCMAKE_BINARY_DIR=${PKG_BUILD}/.${HOST_NAME} \
-DLLVM_NATIVE_BUILD=${PKG_BUILD}/.${HOST_NAME}/native \
-DLLVM_ENABLE_PROJECTS='clang' \
-DCLANG_LINK_CLANG_DYLIB=ON \
-DLLVM_TARGETS_TO_BUILD=${LLVM_BUILD_TARGETS}"
2022-02-05 14:23:32 +00:00
}
2022-06-30 10:28:25 +00:00
post_make_host() {
2022-02-05 14:23:32 +00:00
ninja ${NINJA_OPTS} llvm-config llvm-tblgen
}
2022-06-30 10:28:25 +00:00
post_makeinstall_host() {
mkdir -p ${TOOLCHAIN}/bin
cp -a bin/llvm-config ${TOOLCHAIN}/bin
cp -a bin/llvm-tblgen ${TOOLCHAIN}/bin
}
pre_configure_target() {
2022-07-07 22:41:48 +00:00
case "${TARGET_ARCH}" in
2023-03-04 16:20:58 +00:00
arm)
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="X86;ARM"
;;
2023-03-04 16:20:58 +00:00
aarch64)
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="X86;AArch64"
;;
2023-03-04 16:20:58 +00:00
i*86|x86_64)
2022-07-07 22:41:48 +00:00
LLVM_BUILD_TARGETS="AMDGPU;X86"
;;
esac
2022-06-30 10:28:25 +00:00
mkdir -p ${PKG_BUILD}/.${TARGET_NAME}
cd ${PKG_BUILD}/.${TARGET_NAME}
PKG_CMAKE_OPTS_TARGET="${PKG_CMAKE_OPTS_COMMON} \
-DCMAKE_BINARY_DIR=${PKG_BUILD}/.${TARGET_NAME} \
-DLLVM_NATIVE_BUILD=${PKG_BUILD}/.${TARGET_NAME}/native \
-DCMAKE_CROSSCOMPILING=ON \
-DLLVM_ENABLE_PROJECTS='' \
-DLLVM_TARGETS_TO_BUILD=AMDGPU \
-DLLVM_TARGET_ARCH="${TARGET_ARCH}" \
2022-07-07 22:41:48 +00:00
-DLLVM_TABLEGEN=${TOOLCHAIN}/bin/llvm-tblgen \
-DLLVM_TARGETS_TO_BUILD=${LLVM_BUILD_TARGETS}"
2022-02-05 14:23:32 +00:00
}
post_makeinstall_target() {
2022-06-30 10:28:25 +00:00
mkdir -p ${SYSROOT_PREFIX}/usr/bin
cp -a ${TOOLCHAIN}/bin/llvm-config ${SYSROOT_PREFIX}/usr/bin
2022-02-05 14:23:32 +00:00
rm -rf ${INSTALL}/usr/bin
rm -rf ${INSTALL}/usr/lib/LLVMHello.so
rm -rf ${INSTALL}/usr/lib/libLTO.so
rm -rf ${INSTALL}/usr/share
}