db-move: moved polari from [testing] to [extra] (x86_64)
[arch-packages.git] / clang14 / trunk / PKGBUILD
blob533f49b3da178e877c32a1db3aed0c3f664d2f7a
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=clang14
5 pkgver=14.0.6
6 pkgrel=1
7 pkgdesc="C language family frontend for LLVM 14"
8 arch=('x86_64')
9 url="https://clang.llvm.org/"
10 license=('custom:Apache 2.0 with LLVM Exception')
11 depends=('llvm14-libs' 'gcc' 'compiler-rt14')
12 makedepends=('llvm14' 'cmake' 'ninja' 'python')
13 optdepends=('openmp: OpenMP support in clang with -fopenmp'
14             'llvm14: 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         enforce-instantiation-of-constexpr-template-functions.patch
20         clang-coroutines-ubsan.patch
21         enable-fstack-protector-strong-by-default.patch)
22 sha256sums=('2b5847b6a63118b9efe5c85548363c81ffe096b66c3b3675e953e26342ae4031'
23             'SKIP'
24             '050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
25             'SKIP'
26             'eb2916131ae63b3bd1689f6a27dc0c2fadad73a5c5f2c828062c8a2c547e4a0d'
27             '2c25ddf0ba6be01949842873fef4d285456321aaccd4ba95db61b69a4c580106'
28             '7a9ce949579a3b02d4b91b6835c4fb45adc5f743007572fb0e28e6433e48f3a5')
29 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
31 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
32 # installing static libraries; inspired by Gentoo
33 _get_distribution_components() {
34   local target
35   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
36     case $target in
37       clang-libraries|distribution)
38         continue
39         ;;
40       # trim static analyzer and other bits
41       bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
42         continue
43         ;;
44       clang|clang-*)
45         ;;
46       clang*|findAllSymbols)
47         continue
48         ;;
49     esac
50     echo $target
51   done
54 prepare() {
55   cd clang-$pkgver.src
56   mkdir build
57   patch -Np2 -i ../enable-fstack-protector-strong-by-default.patch
59   # https://github.com/llvm/llvm-project/issues/55560
60   patch -Np2 -i ../enforce-instantiation-of-constexpr-template-functions.patch
62   # https://github.com/llvm/llvm-project/issues/49689
63   patch -Np2 -i ../clang-coroutines-ubsan.patch
66 build() {
67   cd clang-$pkgver.src/build
69   # Build only minimal debug info to reduce size
70   CFLAGS=${CFLAGS/-g /-g1 }
71   CXXFLAGS=${CXXFLAGS/-g /-g1 }
73   local cmake_args=(
74     -G Ninja
75     -DCMAKE_BUILD_TYPE=Release
76     -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
77     -DCMAKE_SKIP_RPATH=ON
78     -DCLANG_DEFAULT_PIE_ON_LINUX=ON
79     -DCLANG_LINK_CLANG_DYLIB=ON
80     -DENABLE_LINKER_BUILD_ID=ON
81     -DLLVM_BUILD_TESTS=ON
82     -DLLVM_CONFIG=/usr/lib/llvm14/bin/llvm-config
83     -DLLVM_ENABLE_RTTI=ON
84     -DLLVM_EXTERNAL_LIT=/usr/bin/lit
85     -DLLVM_LINK_LLVM_DYLIB=ON
86     -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
87   )
89   cmake .. "${cmake_args[@]}"
90   local distribution_components=$(_get_distribution_components | paste -sd\;)
91   test -n "$distribution_components"
92   cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
94   cmake .. "${cmake_args[@]}"
95   ninja
98 check() {
99   cd clang-$pkgver.src/build
100   LD_LIBRARY_PATH=$PWD/lib ninja check-clang
103 package() {
104   cd clang-$pkgver.src/build
106   DESTDIR="$pkgdir" ninja install-distribution
107   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
109   mv "$pkgdir"/usr/lib/{llvm14/lib/,}libclang-cpp.so.14
110   ln -s ../../libclang-cpp.so.14 "$pkgdir/usr/lib/llvm14/lib/libclang-cpp.so.14"
111   ln -s llvm14/lib/libclang.so.13 "$pkgdir"/usr/lib/libclang.so.13
114 # vim:set ts=2 sw=2 et: