db-move: moved firefox-i18n from [testing] to [extra] (any)
[arch-packages.git] / llvm / trunk / PKGBUILD
blob29601d6b632f63d65bd7727cce9d56f897880291
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm' 'llvm-libs')
5 pkgver=15.0.7
6 pkgrel=3
7 arch=('x86_64')
8 url="https://llvm.org/"
9 license=('custom:Apache 2.0 with LLVM Exception')
10 makedepends=('cmake' 'ninja' 'zlib' 'zstd' 'libffi' 'libedit' 'ncurses'
11              'libxml2' 'python-setuptools' 'python-psutil' 'python-sphinx'
12              'python-recommonmark')
13 options=('staticlibs' '!lto') # Getting thousands of test failures with LTO
14 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
15 source=($_source_base/llvm-$pkgver.src.tar.xz{,.sig}
16         $_source_base/cmake-$pkgver.src.tar.xz{,.sig}
17         llvm-config.h)
18 sha256sums=('4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4'
19             'SKIP'
20             '8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea'
21             'SKIP'
22             '597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48')
23 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A'  # Tom Stellard <tstellar@redhat.com>
24               'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta <tobias@hieta.se>
26 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
27 # installing static libraries; inspired by Gentoo
28 _get_distribution_components() {
29   local target
30   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
31     case $target in
32       llvm-libraries|distribution)
33         continue
34         ;;
35       # shared libraries
36       LLVM|LLVMgold)
37         ;;
38       # libraries needed for clang-tblgen
39       LLVMDemangle|LLVMSupport|LLVMTableGen)
40         ;;
41       # exclude static libraries
42       LLVM*)
43         continue
44         ;;
45       # exclude llvm-exegesis (doesn't seem useful without libpfm)
46       llvm-exegesis)
47         continue
48         ;;
49     esac
50     echo $target
51   done
54 prepare() {
55   mv cmake{-$pkgver.src,}
56   cd llvm-$pkgver.src
57   mkdir build
60 build() {
61   cd llvm-$pkgver.src/build
63   # Build only minimal debug info to reduce size
64   CFLAGS=${CFLAGS/-g /-g1 }
65   CXXFLAGS=${CXXFLAGS/-g /-g1 }
67   local cmake_args=(
68     -G Ninja
69     -DCMAKE_BUILD_TYPE=Release
70     -DCMAKE_INSTALL_DOCDIR=share/doc
71     -DCMAKE_INSTALL_PREFIX=/usr
72     -DCMAKE_SKIP_RPATH=ON
73     -DLLVM_BINUTILS_INCDIR=/usr/include
74     -DLLVM_BUILD_DOCS=ON
75     -DLLVM_BUILD_LLVM_DYLIB=ON
76     -DLLVM_BUILD_TESTS=ON
77     -DLLVM_ENABLE_BINDINGS=OFF
78     -DLLVM_ENABLE_FFI=ON
79     -DLLVM_ENABLE_RTTI=ON
80     -DLLVM_ENABLE_SPHINX=ON
81     -DLLVM_HOST_TRIPLE=$CHOST
82     -DLLVM_INCLUDE_BENCHMARKS=OFF
83     -DLLVM_INSTALL_UTILS=ON
84     -DLLVM_LINK_LLVM_DYLIB=ON
85     -DLLVM_USE_PERF=ON
86     -DSPHINX_WARNINGS_AS_ERRORS=OFF
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 llvm-$pkgver.src/build
100   LD_LIBRARY_PATH=$PWD/lib ninja check
103 package_llvm() {
104   pkgdesc="Compiler infrastructure"
105   depends=('llvm-libs' 'perl')
107   cd llvm-$pkgver.src/build
109   DESTDIR="$pkgdir" ninja install-distribution
111   # Include lit for running lit-based tests in other projects
112   pushd ../utils/lit
113   python3 setup.py install --root="$pkgdir" -O1
114   popd
116   # The runtime libraries go into llvm-libs
117   mv -f "$pkgdir"/usr/lib/lib{LLVM,LTO,Remarks}*.so* "$srcdir"
118   mv -f "$pkgdir"/usr/lib/LLVMgold.so "$srcdir"
120   if [[ $CARCH == x86_64 ]]; then
121     # Needed for multilib (https://bugs.archlinux.org/task/29951)
122     # Header stub is taken from Fedora
123     mv "$pkgdir/usr/include/llvm/Config/llvm-config"{,-64}.h
124     cp "$srcdir/llvm-config.h" "$pkgdir/usr/include/llvm/Config/llvm-config.h"
125   fi
127   # Remove documentation sources
128   rm -r "$pkgdir"/usr/share/doc/llvm/html/{_sources,.buildinfo}
130   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
133 package_llvm-libs() {
134   pkgdesc="LLVM runtime libraries"
135   depends=('gcc-libs' 'zlib' 'zstd' 'libffi' 'libedit' 'ncurses' 'libxml2')
137   install -d "$pkgdir/usr/lib"
138   cp -P \
139     "$srcdir"/lib{LLVM,LTO,Remarks}*.so* \
140     "$srcdir"/LLVMgold.so \
141     "$pkgdir/usr/lib/"
143   # Symlink LLVMgold.so from /usr/lib/bfd-plugins
144   # https://bugs.archlinux.org/task/28479
145   install -d "$pkgdir/usr/lib/bfd-plugins"
146   ln -s ../LLVMgold.so "$pkgdir/usr/lib/bfd-plugins/LLVMgold.so"
148   install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
149     "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
152 # vim:set ts=2 sw=2 et: