upgpkg: sbcl 2.2.9-1
[arch-packages.git] / clang13 / trunk / PKGBUILD
blobce02352e5f631e7d1dd2feb0d8663d4cd884f324
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=clang13
5 pkgver=13.0.1
6 pkgrel=4
7 pkgdesc="C language family frontend for LLVM 13"
8 arch=('x86_64')
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')
15 checkdepends=('llvm')
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'
22             'SKIP'
23             'ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
24             'SKIP'
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() {
32   local target
33   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
34     case $target in
35       clang-libraries|distribution)
36         continue
37         ;;
38       # trim static analyzer and other bits
39       bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
40         continue
41         ;;
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)
45         continue
46         ;;
47       clang|clang-*)
48         ;;
49       clang*|findAllSymbols)
50         continue
51         ;;
52     esac
53     echo $target
54   done
57 prepare() {
58   cd clang-$pkgver.src
59   mkdir build
60   patch -Np2 -i ../enable-SSP-and-PIE-by-default.patch
61   patch -Np2 -i ../strip-exception-specifications-in-CFI-type-names.patch
64 build() {
65   cd clang-$pkgver.src/build
67   local cmake_args=(
68     -G Ninja
69     -DCMAKE_BUILD_TYPE=Release
70     -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm13
71     -DCMAKE_SKIP_RPATH=ON
72     -DCLANG_LINK_CLANG_DYLIB=ON
73     -DENABLE_LINKER_BUILD_ID=ON
74     -DLLVM_BUILD_TESTS=ON
75     -DLLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config
76     -DLLVM_ENABLE_RTTI=ON
77     -DLLVM_EXTERNAL_LIT=/usr/bin/lit
78     -DLLVM_LINK_LLVM_DYLIB=ON
79     -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
80   )
82   cmake .. "${cmake_args[@]}"
83   local distribution_components=$(_get_distribution_components | paste -sd\;)
84   test -n "$distribution_components"
85   cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
87   cmake .. "${cmake_args[@]}"
88   ninja
91 check() {
92   cd clang-$pkgver.src/build
93   LD_LIBRARY_PATH=$PWD/lib ninja check-clang
96 package() {
97   cd clang-$pkgver.src/build
99   DESTDIR="$pkgdir" ninja install-distribution
100   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
102   mv "$pkgdir"/usr/lib/{llvm13/lib/,}libclang-cpp.so.13
103   ln -s ../../libclang-cpp.so.13 "$pkgdir/usr/lib/llvm13/lib/libclang-cpp.so.13"
106 # vim:set ts=2 sw=2 et: