1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm14' 'llvm14-libs')
8 url="https://llvm.org/"
9 license=('custom:Apache 2.0 with LLVM Exception')
10 makedepends=('cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2'
12 checkdepends=('python-psutil')
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 llvm-coroutines-ubsan.patch)
17 sha256sums=('050922ecaaca5781fdf6631ea92bc715183f202f9d2f15147226f023414f619a'
19 'ee9baf6df05474083857044d92f26f59d3ee709cdf82ba3bdb2792e6645f71d9')
20 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
22 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
23 # installing static libraries; inspired by Gentoo
24 _get_distribution_components() {
26 ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
28 llvm-libraries|distribution)
34 # libraries needed for clang-tblgen
35 LLVMDemangle|LLVMSupport|LLVMTableGen)
37 # exclude static libraries
41 # exclude llvm-exegesis (doesn't seem useful without libpfm)
54 # https://github.com/llvm/llvm-project/issues/49689
55 patch -Np2 -i ../llvm-coroutines-ubsan.patch
59 cd llvm-$pkgver.src/build
61 # Build only minimal debug info to reduce size
67 -DCMAKE_BUILD_TYPE=Release
68 -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
70 -DLLVM_BINUTILS_INCDIR=/usr/include
71 -DLLVM_BUILD_LLVM_DYLIB=ON
73 -DLLVM_ENABLE_BINDINGS=OFF
76 -DLLVM_HOST_TRIPLE=$CHOST
77 -DLLVM_INCLUDE_BENCHMARKS=OFF
78 -DLLVM_INSTALL_UTILS=ON
79 -DLLVM_LINK_LLVM_DYLIB=ON
83 cmake .. "${cmake_args[@]}"
84 local distribution_components=$(_get_distribution_components | paste -sd\;)
85 test -n "$distribution_components"
86 cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
88 cmake .. "${cmake_args[@]}"
93 cd llvm-$pkgver.src/build
94 LD_LIBRARY_PATH=$PWD/lib ninja check
98 pkgdesc="Compiler infrastructure (LLVM 14)"
99 depends=('llvm14-libs' 'perl')
101 cd llvm-$pkgver.src/build
103 DESTDIR="$pkgdir" ninja install-distribution
105 # The runtime libraries go into llvm14-libs
106 mv -f "$pkgdir"/usr/lib/llvm14/lib/libLLVM-{14,$pkgver}.so "$srcdir/"
107 mv -f "$pkgdir"/usr/lib/llvm14/lib/LLVMgold.so "$srcdir/"
109 # Create versioned symlinks from /usr/bin/ to /usr/lib/llvm14/bin/
110 install -d "$pkgdir/usr/bin"
112 for _binary in "$pkgdir"/usr/lib/llvm14/bin/*; do
113 local _basename=${_binary##*/}
114 ln -s ../lib/llvm14/bin/$_basename "$pkgdir/usr/bin/$_basename-14"
117 install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
120 package_llvm14-libs() {
121 pkgdesc="LLVM 14 runtime libraries"
122 depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
124 install -d "$pkgdir/usr/lib/llvm14/lib"
125 cp -P "$srcdir"/libLLVM-{14,$pkgver}.so "$pkgdir/usr/lib/"
126 ln -s ../../libLLVM-14.so "$pkgdir/usr/lib/llvm14/lib/libLLVM-14.so"
127 ln -s ../../libLLVM-14.so "$pkgdir/usr/lib/llvm14/lib/libLLVM-$pkgver.so"
128 cp -P "$srcdir"/LLVMgold.so "$pkgdir/usr/lib/llvm14/lib/"
130 install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
131 "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
134 # vim:set ts=2 sw=2 et: