pkgname=(llvm llvm-libs clang) pkgbase=llvm pkgver=19.1.6 pkgrel=1 arch=('x86_64') url="https://llvm.org" license=('Apache-2.0 WITH LLVM-exception') makedepends=( 'cmake' 'ninja' 'zlib' 'zstd' 'libffi' 'ncurses' 'libxml2' 'python-setuptools' ) options=('!staticlibs' '!lto' '!emptydirs') source=(https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/${pkgbase}-${pkgver}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/cmake-${pkgver}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/third-party-${pkgver}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/clang-${pkgver}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/clang-tools-extra-${pkgver}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${pkgver}/compiler-rt-${pkgver}.src.tar.xz toolchain.cmake) sha256sums=(ad1a3b125ff014ded290094088de40efb9193ce81a24278184230b7d401f8a3e 9c7ec82d9a240dc2287b8de89d6881bb64ceea0dcd6ce133c34ef65bda22d99e 0e8048333bab2ba3607910e5d074259f08dccf00615778d03a2a55416718eb45 6358cbb3e14687ca2f3465c61cffc65589b448aaa912ec2c163ef9fc046e8a89 417a7d0048d8eb62dbaa8461f1fd474eb6493b09e14d050b39cc1f051e8b71d1 0d4f312e1419152282c267e6b6a1fa5914a7a0c753a5e926bee1c8c28e614ae4 c33e25cb212475ccebde3aa2a585f9a98b2202a14cdd352389c44b276dbf29ca) prepare() { rename -v -- "-${pkgver}.src" '' {cmake,third-party}-${pkgver}.src cd ${pkgbase}-${pkgver}.src mv ${srcdir}/clang-${pkgver}.src tools/clang mv ${srcdir}/clang-tools-extra-${pkgver}.src tools/clang/tools/extra mv ${srcdir}/compiler-rt-${pkgver}.src projects/compiler-rt grep -rl '#!.*python' | xargs sed -i '1s/python$/python3/' sed 's/utility/tool/' -i utils/FileCheck/CMakeLists.txt } build() { cd ${pkgbase}-${pkgver}.src CFLAGS=${CFLAGS/-g /-g1 } CXXFLAGS=${CXXFLAGS/-g /-g1 } local cmake_args=( -G Ninja -B flarebird-build -D CMAKE_INSTALL_PREFIX=/usr -D LLVM_LIBDIR_SUFFIX=64 -D CMAKE_SKIP_INSTALL_RPATH=ON -D LLVM_ENABLE_FFI=ON -D CMAKE_BUILD_TYPE=Release -D LLVM_BUILD_LLVM_DYLIB=ON -D LLVM_LINK_LLVM_DYLIB=ON -D LLVM_ENABLE_RTTI=ON -D LLVM_TARGETS_TO_BUILD="X86;AMDGPU" -D LLVM_BINUTILS_INCDIR=/usr/include -D LLVM_INCLUDE_BENCHMARKS=OFF -D CLANG_DEFAULT_PIE_ON_LINUX=ON -D CLANG_CONFIG_FILE_SYSTEM_DIR=/etc/clang -D LLVM_HOST_TRIPLE=${CHOST} -W no-dev ) cmake ${cmake_args[@]} cmake --build flarebird-build } _python_optimize() { python3 -m compileall "$@" python3 -O -m compileall "$@" python3 -OO -m compileall "$@" } package_llvm() { pkgdesc="Compiler infrastructure" depends=('llvm-libs' 'curl' 'perl') cd ${pkgbase}-${pkgver}.src DESTDIR=${pkgdir} cmake --install flarebird-build pushd utils/lit python3 setup.py install --root="$pkgdir" -O1 popd local site_packages=$(python3 -c "import site; print(site.getsitepackages()[0])") mv ${pkgdir}/usr/lib/{libear,libscanbuild} ${pkgdir}/${site_packages} cp -a tools/clang/bindings/python/clang ${pkgdir}/${site_packages} _python_optimize ${pkgdir}/usr/share ${pkgdir}/${site_packages} # The runtime libraries go into llvm-libs _pick llvmlibs ${pkgdir}/usr/lib64/lib{LLVM,LTO,Remarks}*.so* _pick llvmlibs ${pkgdir}/usr/lib64/LLVMgold.so _pick CLANG ${pkgdir}/usr/bin/{amdgpu-arch,analyze-build,c-index-test,clang*,diagtool} _pick CLANG ${pkgdir}/usr/bin/{git-clang-format,hmaptool,intercept-build,nvptx-arch} _pick CLANG ${pkgdir}/usr/include/{clang,clang-c,clang-tidy} _pick CLANG ${pkgdir}/usr/lib64/{libclang.so,libclang.so.19.1,libclang.so.19.1.6} _pick CLANG ${pkgdir}/usr/lib64/{libclang-cpp.so,libclang-cpp.so.19.1,libclang*.a} _pick CLANG ${pkgdir}/usr/lib64/{clang,cmake/clang} _pick CLANG ${pkgdir}/${site_packages}/{clang,libear,libscanbuild} _pick CLANG ${pkgdir}/usr/share/{clang,clang-doc,scan-build,scan-view} } package_llvm-libs() { pkgdesc="LLVM runtime libraries" depends=('gcc-libs' 'zlib' 'zstd' 'libffi' 'ncurses' 'libxml2') mv llvmlibs/* ${pkgdir} install -d ${pkgdir}/usr/lib64/bfd-plugins ln -s ../LLVMgold.so ${pkgdir}/usr/lib64/bfd-plugins/LLVMgold.so } package_clang() { pkgdesc="C language family frontend for LLVM" depends=('llvm' 'gcc') mv CLANG/* ${pkgdir} ln -sv clang ${pkgdir}/usr/bin/${CHOST}-clang ln -sv clang++ ${pkgdir}/usr/bin/${CHOST}-clang++ install -vdm755 ${pkgdir}/etc/clang for i in clang clang++; do echo -fstack-protector-strong > ${pkgdir}/etc/clang/${i}.cfg done install -vdm755 ${pkgdir}/usr/share/doc mv ${pkgdir}/usr/share/clang-doc ${pkgdir}/usr/share/doc/clang }