1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm' 'llvm-libs')
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}
18 sha256sums=('4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4'
20 '8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea'
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() {
30 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
32 llvm-libraries|distribution)
38 # libraries needed for clang-tblgen
39 LLVMDemangle|LLVMSupport|LLVMTableGen)
41 # exclude static libraries
45 # exclude llvm-exegesis (doesn't seem useful without libpfm)
55 mv cmake{-$pkgver.src,}
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 }
69 -DCMAKE_BUILD_TYPE=Release
70 -DCMAKE_INSTALL_DOCDIR=share/doc
71 -DCMAKE_INSTALL_PREFIX=/usr
73 -DLLVM_BINUTILS_INCDIR=/usr/include
75 -DLLVM_BUILD_LLVM_DYLIB=ON
77 -DLLVM_ENABLE_BINDINGS=OFF
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
86 -DSPHINX_WARNINGS_AS_ERRORS=OFF
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 llvm-$pkgver.src/build
100 LD_LIBRARY_PATH=$PWD/lib ninja check
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
113 python3 setup.py install --root="$pkgdir" -O1
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"
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"
139 "$srcdir"/lib{LLVM,LTO,Remarks}*.so* \
140 "$srcdir"/LLVMgold.so \
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: