1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
7 pkgdesc="C language family frontend for LLVM 13"
9 url="https://clang.llvm.org/"
10 license=('custom:Apache 2.0 with LLVM Exception')
11 depends=('llvm13-libs' 'gcc')
12 makedepends=('llvm13' 'cmake' 'ninja' 'python')
13 optdepends=('openmp: OpenMP support in clang with -fopenmp'
14 'llvm13: referenced by some clang headers')
16 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
17 source=($_source_base/clang-$pkgver.src.tar.xz{,.sig}
18 $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
19 strip-exception-specifications-in-CFI-type-names.patch
20 enable-SSP-and-PIE-by-default.patch)
21 sha256sums=('787a9e2d99f5c8720aa1773e4be009461cd30d3bd40fdd24591e473467c917c9'
23 'ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
25 '3f4a2784a4c2b2df13e03beb0b66d5805c520f2b9f16ff76e0557daeb284c8fa'
26 '67706047fc93a2e79185d344bdac48219ce042c55ddb9b9397bc98db2153ba58')
27 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
29 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
30 # installing static libraries; inspired by Gentoo
31 _get_distribution_components() {
33 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
35 clang-libraries|distribution)
38 # trim static analyzer and other bits
39 bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
42 # avoid shadowing libclang.so.13 from clang 14
43 # https://github.com/llvm/llvm-project/issues/53684#issuecomment-1162669770
44 libclang|c-index-test)
49 clang*|findAllSymbols)
60 patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch
61 patch -Np2 -i ../strip-exception-specifications-in-CFI-type-names.patch
65 cd clang-$pkgver.src/build
69 -DCMAKE_BUILD_TYPE=Release
70 -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm13
72 -DCLANG_LINK_CLANG_DYLIB=ON
74 -DLLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config
76 -DLLVM_EXTERNAL_LIT=/usr/bin/lit
77 -DLLVM_LINK_LLVM_DYLIB=ON
78 -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
81 cmake .. "${cmake_args[@]}"
82 local distribution_components=$(_get_distribution_components | paste -sd\;)
83 test -n "$distribution_components"
84 cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
86 cmake .. "${cmake_args[@]}"
91 cd clang-$pkgver.src/build
92 LD_LIBRARY_PATH=$PWD/lib ninja check-clang
96 cd clang-$pkgver.src/build
98 DESTDIR="$pkgdir" ninja install-distribution
99 install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
101 mv "$pkgdir"/usr/lib/{llvm13/lib/,}libclang-cpp.so.13
102 ln -s ../../libclang-cpp.so.13 "$pkgdir/usr/lib/llvm13/lib/libclang-cpp.so.13"
105 # vim:set ts=2 sw=2 et: