# Maintainer: Lone_Wolf # Contributor: yurikoles # Contributor: bearoso # Contributor: Luchesar V. ILIEV # Contributor: Anders Bergh # Contributor: Armin K. # Contributor: Christian Babeux # Contributor: Jan "heftig" Steffens # Contributor: Evangelos Foutras # Contributor: Hesiod (https://github.com/hesiod) # Contributor: Roberto Alsina # Contributor: Thomas Dziedzic < gostrc at gmail > # Contributor: Tomas Lindquist Olsen # Contributor: Tomas Wilhelmsson pkgbase=llvm-minimal-git pkgname=('llvm-minimal-git' 'llvm-libs-minimal-git') pkgver=16.0.0_r441632.1a6d770447c5 pkgrel=1 arch=('x86_64') url="https://llvm.org/" license=('custom:Apache 2.0 with LLVM Exception') makedepends=('git' 'cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2' 'libxcrypt' 'python' 'python-setuptools' 'spirv-headers' 'spirv-tools') source=("llvm-project::git+https://github.com/llvm/llvm-project.git" 'local://llvm-config.h' "git+https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git") md5sums=('SKIP' '295c343dcd457dc534662f011d7cff1a' 'SKIP') sha512sums=('SKIP' '75e743dea28b280943b3cc7f8bbb871b57d110a7f2b9da2e6845c1c36bf170dd883fca54e463f5f49e0c3effe07fbd0db0f8cf5a12a2469d3f792af21a73fcdd' 'SKIP') options=('staticlibs' '!lto') # explicitly disable lto to reduce number of build hangs / test failures # NINJAFLAGS is an env var used to pass commandline options to ninja # NOTE: It's your responbility to validate the value of $NINJAFLAGS. If unsure, don't set it. pkgver() { cd llvm-project/llvm # This will almost match the output of `llvm-config --version` when the # LLVM_APPEND_VC_REV cmake flag is turned on. The only difference is # dash being replaced with underscore because of Pacman requirements. local _pkgver=$(awk -F 'MAJOR |MINOR |PATCH |)' \ 'BEGIN { ORS="." ; i=0 } \ /set\(LLVM_VERSION_/ { print $2 ; i++ ; if (i==2) ORS="" } \ END { print "\n" }' \ CMakeLists.txt)_r$(git rev-list --count HEAD).$(git rev-parse --short HEAD) echo "${_pkgver}" } build() { export CFLAGS+=" ${CPPFLAGS}" export CXXFLAGS+=" ${CPPFLAGS}" cmake \ -B _build \ -S "$srcdir"/llvm-project/llvm \ -G Ninja \ -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_INSTALL_PREFIX=/usr \ -D LLVM_BINUTILS_INCDIR=/usr/include \ -D FFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \ -D LLVM_VERSION_SUFFIX="" \ -D LLVM_APPEND_VC_REV=ON \ -D LLVM_HOST_TRIPLE=$CHOST \ -D LLVM_TARGETS_TO_BUILD="AMDGPU;X86" \ -D LLVM_BUILD_LLVM_DYLIB=ON \ -D LLVM_LINK_LLVM_DYLIB=ON \ -D CLANG_LINK_CLANG_DYLIB=ON \ -D LLVM_INSTALL_UTILS=ON \ -D LLVM_ENABLE_RTTI=ON \ -D LLVM_ENABLE_FFI=ON \ -D LLVM_USE_PERF=ON \ -D LLVM_INCLUDE_BENCHMARKS=OFF \ -D LLVM_INCLUDE_EXAMPLES=OFF \ -D LLVM_BUILD_DOCS=OFF \ -D LLVM_INCLUDE_DOCS=OFF \ -D LLVM_ENABLE_OCAMLDOC=OFF \ -D LLVM_ENABLE_SPHINX=OFF \ -D LLVM_ENABLE_DOXYGEN=OFF \ -D LLVM_ENABLE_BINDINGS=OFF \ -D LLVM_ENABLE_PROJECTS="compiler-rt;clang-tools-extra;clang" \ -D LLVM_ENABLE_DUMP=ON \ -D LLVM_EXTERNAL_PROJECTS="SPIRV-LLVM-Translator" \ -D LLVM_EXTERNAL_SPIRV_LLVM_TRANSLATOR_SOURCE_DIR="$srcdir"/SPIRV-LLVM-Translator \ -D LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr/include/spirv/ \ -D LLVM_SPIRV_INCLUDE_TESTS=ON \ -D LLVM_LIT_ARGS="-sv --ignore-fail" \ -Wno-dev ninja -C _build $NINJAFLAGS } check() { ninja -C _build $NINJAFLAGS check-llvm ninja -C _build $NINJAFLAGS check-clang ninja -C _build $NINJAFLAGS check-clang-tools ninja -C _build $NINJAFLAGS check-llvm-spirv } package_llvm-minimal-git() { pkgdesc="Collection of modular and reusable compiler and toolchain technologies" depends=(llvm-libs-minimal-git=$pkgver-$pkgrel 'perl' 'spirv-tools') provides=('llvm' 'compiler-rt' 'clang' 'spirv-llvm-translator') conflicts=('llvm' 'compiler-rt' 'clang') optdepends=('python: for using lit (LLVM Integrated Tester)' 'python-setuptools: for using lit' ) DESTDIR="$pkgdir" ninja -C _build $NINJAFLAGS install # Include lit for running lit-based tests in other projects pushd "$srcdir"/llvm-project/llvm/utils/lit python3 setup.py install --root="$pkgdir" -O1 popd # The runtime libraries go into a separate package mv -f "$pkgdir"/usr/lib/lib{LLVM-*.so,LTO.so.*,Remarks.so.*,clang-cpp.so.*} "$srcdir" # Remove files which conflict with llvm-libs rm "$pkgdir"/usr/lib/{LLVMgold,lib{LLVM,LTO}}.so rm "$pkgdir"/usr/lib/libRemarks.so # llvm project uses /usr/libexec and setting CMAKE_INSTALL_LIBEXECDIR doesn't change that. # to comply with archlinux packaging standards we have to move some files manually for libexec_file in "analyze-c++" "analyze-cc" "c++-analyzer" "ccc-analyzer" "intercept-c++" "intercept-cc" do mv "$pkgdir"/usr/libexec/$libexec_file "$pkgdir"/usr/lib/clang/$libexec_file done rmdir "$pkgdir"/usr/libexec sed -i 's|libexec|lib/clang|' "$pkgdir"/usr/bin/scan-build if [[ $CARCH == x86_64 ]]; then # Needed for multilib (https://bugs.archlinux.org/task/29951) # Header stub is taken from Fedora mv "$pkgdir"/usr/include/llvm/Config/llvm-config{,-64}.h install -Dm644 "$srcdir"/llvm-config.h "$pkgdir"/usr/include/llvm/Config/llvm-config.h fi install -Dm644 "$srcdir"/llvm-project/llvm/LICENSE.TXT "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE install -Dm644 "$srcdir"/llvm-project/compiler-rt/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/LICENSE install -Dm644 "$srcdir"/llvm-project/clang-tools-extra/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/clang-tools-extra-LICENSE install -Dm644 "$srcdir"/llvm-project/clang/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/LICENSE } package_llvm-libs-minimal-git() { pkgdesc="LLVM runtime libraries" depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2') provides=('llvm-libs') optdepends=('llvm-libs: for LLVMgold linker') install -d "$pkgdir/usr/lib" cp -P \ "$srcdir"/lib{LLVM,LTO,Remarks,clang-cpp}*.so* \ "$pkgdir"/usr/lib/ install -Dm644 "$srcdir"/llvm-project/llvm/LICENSE.TXT "$pkgdir"/usr/share/licenses/$pkgname/LICENSE } # vim:set ts=2 sw=2 et: