7.3.0-1
[arch-packages.git] / llvm14 / trunk / PKGBUILD
blobbffe9c9563d43294ad8d7ddf4acd5f1ab68059d5
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm14' 'llvm14-libs')
5 pkgver=14.0.6
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' 'libffi' 'libedit' 'ncurses' 'libxml2'
11              'python')
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'
18             'SKIP'
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() {
25   local target
26   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
27     case $target in
28       llvm-libraries|distribution)
29         continue
30         ;;
31       # shared libraries
32       LLVM|LLVMgold)
33         ;;
34       # libraries needed for clang-tblgen
35       LLVMDemangle|LLVMSupport|LLVMTableGen)
36         ;;
37       # exclude static libraries
38       LLVM*)
39         continue
40         ;;
41       # exclude llvm-exegesis (doesn't seem useful without libpfm)
42       llvm-exegesis)
43         continue
44         ;;
45     esac
46     echo $target
47   done
50 prepare() {
51   cd llvm-$pkgver.src
52   mkdir build
54   # https://github.com/llvm/llvm-project/issues/49689
55   patch -Np2 -i ../llvm-coroutines-ubsan.patch
58 build() {
59   cd llvm-$pkgver.src/build
61   # Build only minimal debug info to reduce size
62   CFLAGS+=' -g1'
63   CXXFLAGS+=' -g1'
65   local cmake_args=(
66     -G Ninja
67     -DCMAKE_BUILD_TYPE=Release
68     -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm14
69     -DCMAKE_SKIP_RPATH=ON
70     -DLLVM_BINUTILS_INCDIR=/usr/include
71     -DLLVM_BUILD_LLVM_DYLIB=ON
72     -DLLVM_BUILD_TESTS=ON
73     -DLLVM_ENABLE_BINDINGS=OFF
74     -DLLVM_ENABLE_FFI=ON
75     -DLLVM_ENABLE_RTTI=ON
76     -DLLVM_HOST_TRIPLE=$CHOST
77     -DLLVM_INCLUDE_BENCHMARKS=OFF
78     -DLLVM_INSTALL_UTILS=ON
79     -DLLVM_LINK_LLVM_DYLIB=ON
80     -DLLVM_USE_PERF=ON
81   )
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[@]}"
89   ninja
92 check() {
93   cd llvm-$pkgver.src/build
94   LD_LIBRARY_PATH=$PWD/lib ninja check
97 package_llvm14() {
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"
111   local _binary
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"
115   done
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: