1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
7 pkgdesc="C language family frontend for LLVM 14"
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')
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'
25 '050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
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() {
36 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
38 clang-libraries|distribution)
41 # trim static analyzer and other bits
42 bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
47 clang*|findAllSymbols)
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
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 }
76 -DCMAKE_BUILD_TYPE=Release
77 -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
79 -DCLANG_DEFAULT_PIE_ON_LINUX=ON
80 -DCLANG_LINK_CLANG_DYLIB=ON
81 -DENABLE_LINKER_BUILD_ID=ON
83 -DLLVM_CONFIG=/usr/lib/llvm14/bin/llvm-config
85 -DLLVM_EXTERNAL_LIT=/usr/bin/lit
86 -DLLVM_LINK_LLVM_DYLIB=ON
87 -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
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[@]}"
100 cd clang-$pkgver.src/build
101 LD_LIBRARY_PATH=$PWD/lib ninja check-clang
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: