1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
7 pkgdesc="C language family frontend for LLVM"
9 url="https://clang.llvm.org/"
10 license=('custom:Apache 2.0 with LLVM Exception')
11 depends=('llvm-libs' 'gcc' 'compiler-rt')
12 makedepends=('llvm' 'cmake' 'ninja' 'python-sphinx' 'python-recommonmark')
13 optdepends=('openmp: OpenMP support in clang with -fopenmp'
14 'python: for scan-view and git-clang-format'
15 'llvm: referenced by some clang headers')
16 provides=("clang-analyzer=$pkgver" "clang-tools-extra=$pkgver")
17 conflicts=('clang-analyzer' 'clang-tools-extra')
18 replaces=('clang-analyzer' 'clang-tools-extra')
19 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
20 source=($_source_base/clang-$pkgver.src.tar.xz{,.sig}
21 $_source_base/clang-tools-extra-$pkgver.src.tar.xz{,.sig}
22 $_source_base/llvm-$pkgver.src.tar.xz{,.sig}
23 clang-coroutines-ubsan.patch
24 clang-tidy-fix-standalone-build.patch
25 enable-fstack-protector-strong-by-default.patch)
26 sha256sums=('2b5847b6a63118b9efe5c85548363c81ffe096b66c3b3675e953e26342ae4031'
28 '7cf3b8ff56c65c4d1eae3c56883fc4a6cbc3ff9f3a1530a74d66e45d27271866'
30 '050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
32 '2c25ddf0ba6be01949842873fef4d285456321aaccd4ba95db61b69a4c580106'
33 '081a7ebc1ae524b13fc6be3dc73feb2c9eb7cf4b99f7f13d9ed37a688311f58a'
34 '7a9ce949579a3b02d4b91b6835c4fb45adc5f743007572fb0e28e6433e48f3a5')
35 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
37 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
38 # installing static libraries; inspired by Gentoo
39 _get_distribution_components() {
41 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
43 clang-libraries|distribution)
51 clang*|findAllSymbols)
62 mv "$srcdir/clang-tools-extra-$pkgver.src" tools/extra
63 patch -Np2 -i ../enable-fstack-protector-strong-by-default.patch
65 # https://github.com/llvm/llvm-project/issues/49689
66 patch -Np2 -i ../clang-coroutines-ubsan.patch
68 # https://github.com/llvm/llvm-project/issues/54116
69 patch -Np0 -i ../clang-tidy-fix-standalone-build.patch
71 # Attempt to convert script to Python 3
73 tools/extra/clang-include-fixer/find-all-symbols/tool/run-find-all-symbols.py
77 cd clang-$pkgver.src/build
81 -DCMAKE_BUILD_TYPE=Release
82 -DCMAKE_INSTALL_PREFIX=/usr
83 -DCMAKE_INSTALL_DOCDIR=share/doc
85 -DCLANG_DEFAULT_PIE_ON_LINUX=ON
86 -DCLANG_LINK_CLANG_DYLIB=ON
90 -DLLVM_ENABLE_SPHINX=ON
91 -DLLVM_EXTERNAL_LIT=/usr/bin/lit
92 -DLLVM_INCLUDE_DOCS=ON
93 -DLLVM_LINK_LLVM_DYLIB=ON
94 -DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"
95 -DSPHINX_WARNINGS_AS_ERRORS=OFF
98 cmake .. "${cmake_args[@]}"
99 local distribution_components=$(_get_distribution_components | paste -sd\;)
100 test -n "$distribution_components"
101 cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
103 cmake .. "${cmake_args[@]}"
108 cd clang-$pkgver.src/build
109 LD_LIBRARY_PATH=$PWD/lib ninja check-clang{,-tools}
113 python -m compileall "$@"
114 python -O -m compileall "$@"
115 python -OO -m compileall "$@"
119 cd clang-$pkgver.src/build
121 DESTDIR="$pkgdir" ninja install-distribution
122 install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
124 # Remove documentation sources
125 rm -r "$pkgdir"/usr/share/doc/clang{,-tools}/html/{_sources,.buildinfo}
127 # Move scanbuild-py into site-packages and install Python bindings
128 local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
129 install -d "$pkgdir/$site_packages"
130 mv "$pkgdir"/usr/lib/{libear,libscanbuild} "$pkgdir/$site_packages/"
131 cp -a ../bindings/python/clang "$pkgdir/$site_packages/"
133 # Move analyzer scripts out of /usr/libexec
134 mv "$pkgdir"/usr/libexec/* "$pkgdir/usr/lib/clang/"
135 rmdir "$pkgdir/usr/libexec"
136 sed -i 's|libexec|lib/clang|' \
137 "$pkgdir/usr/bin/scan-build" \
138 "$pkgdir/$site_packages/libscanbuild/analyze.py"
140 # Compile Python scripts
141 _python_optimize "$pkgdir/usr/share" "$pkgdir/$site_packages"
144 # vim:set ts=2 sw=2 et: