archrelease: copy trunk to extra-x86_64
[arch-packages.git] / clang14 / repos / extra-x86_64 / PKGBUILD
blob9e3f62de29612af4a9a777d4be9b199e6b270cdd
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 options=('debug')
17 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
18 source=($_source_base/clang-$pkgver.src.tar.xz{,.sig}
19         $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
20         enforce-instantiation-of-constexpr-template-functions.patch
21         clang-coroutines-ubsan.patch
22         enable-fstack-protector-strong-by-default.patch)
23 sha256sums=('2b5847b6a63118b9efe5c85548363c81ffe096b66c3b3675e953e26342ae4031'
24             'SKIP'
25             '050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
26             'SKIP'
27             'eb2916131ae63b3bd1689f6a27dc0c2fadad73a5c5f2c828062c8a2c547e4a0d'
28             '2c25ddf0ba6be01949842873fef4d285456321aaccd4ba95db61b69a4c580106'
29             '7a9ce949579a3b02d4b91b6835c4fb45adc5f743007572fb0e28e6433e48f3a5')
30 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
32 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
33 # installing static libraries; inspired by Gentoo
34 _get_distribution_components() {
35   local target
36   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
37     case $target in
38       clang-libraries|distribution)
39         continue
40         ;;
41       # trim static analyzer and other bits
42       bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
43         continue
44         ;;
45       clang|clang-*)
46         ;;
47       clang*|findAllSymbols)
48         continue
49         ;;
50     esac
51     echo $target
52   done
55 prepare() {
56   cd clang-$pkgver.src
57   mkdir build
58   patch -Np2 -i ../enable-fstack-protector-strong-by-default.patch
60   # https://github.com/llvm/llvm-project/issues/55560
61   patch -Np2 -i ../enforce-instantiation-of-constexpr-template-functions.patch
63   # https://github.com/llvm/llvm-project/issues/49689
64   patch -Np2 -i ../clang-coroutines-ubsan.patch
67 build() {
68   cd clang-$pkgver.src/build
70   # Build only minimal debug info to reduce size
71   CFLAGS=${CFLAGS/-g /-g1 }
72   CXXFLAGS=${CXXFLAGS/-g /-g1 }
74   local cmake_args=(
75     -G Ninja
76     -DCMAKE_BUILD_TYPE=Release
77     -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
78     -DCMAKE_SKIP_RPATH=ON
79     -DCLANG_DEFAULT_PIE_ON_LINUX=ON
80     -DCLANG_LINK_CLANG_DYLIB=ON
81     -DENABLE_LINKER_BUILD_ID=ON
82     -DLLVM_BUILD_TESTS=ON
83     -DLLVM_CONFIG=/usr/lib/llvm14/bin/llvm-config
84     -DLLVM_ENABLE_RTTI=ON
85     -DLLVM_EXTERNAL_LIT=/usr/bin/lit
86     -DLLVM_LINK_LLVM_DYLIB=ON
87     -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
88   )
90   cmake .. "${cmake_args[@]}"
91   local distribution_components=$(_get_distribution_components | paste -sd\;)
92   test -n "$distribution_components"
93   cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
95   cmake .. "${cmake_args[@]}"
96   ninja
99 check() {
100   cd clang-$pkgver.src/build
101   LD_LIBRARY_PATH=$PWD/lib ninja check-clang
104 package() {
105   cd clang-$pkgver.src/build
107   DESTDIR="$pkgdir" ninja install-distribution
108   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
110   mv "$pkgdir"/usr/lib/{llvm14/lib/,}libclang-cpp.so.14
111   ln -s ../../libclang-cpp.so.14 "$pkgdir/usr/lib/llvm14/lib/libclang-cpp.so.14"
112   ln -s llvm14/lib/libclang.so.13 "$pkgdir"/usr/lib/libclang.so.13
115 # vim:set ts=2 sw=2 et: