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')
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'
24 '050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
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() {
35 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
37 clang-libraries|distribution)
40 # trim static analyzer and other bits
41 bash-autocomplete|clang-format|clang-rename|hmaptool|scan-*)
46 clang*|findAllSymbols)
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
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 }
75 -DCMAKE_BUILD_TYPE=Release
76 -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
78 -DCLANG_DEFAULT_PIE_ON_LINUX=ON
79 -DCLANG_LINK_CLANG_DYLIB=ON
80 -DENABLE_LINKER_BUILD_ID=ON
82 -DLLVM_CONFIG=/usr/lib/llvm14/bin/llvm-config
84 -DLLVM_EXTERNAL_LIT=/usr/bin/lit
85 -DLLVM_LINK_LLVM_DYLIB=ON
86 -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
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[@]}"
99 cd clang-$pkgver.src/build
100 LD_LIBRARY_PATH=$PWD/lib ninja check-clang
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: