2.42.9-1
[arch-packages.git] / llvm11 / trunk / PKGBUILD
blob17230818d87449d26fadad2f0b07e4fe005920c2
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm11' 'llvm11-libs')
5 pkgver=11.1.0
6 pkgrel=6
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-setuptools')
12 options=('staticlibs')
13 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
14 source=($_source_base/llvm-$pkgver.src.tar.xz{,.sig}
15         utils-benchmark-fix-missing-include.patch
16         amdgpu-avoid-an-illegal-operand-in-si-shrink-instr.patch
17         no-strict-aliasing-DwarfCompileUnit.patch)
18 sha256sums=('ce8508e318a01a63d4e8b3090ab2ded3c598a50258cc49e2625b9120d4c03ea5'
19             'SKIP'
20             '5f666675fd45848e4c4b0f94068f7648dd9ff88df4a7b19d2a9f2b83ee358a7e'
21             '85b6977005899bc76fcc548e0b6501cae5f50a8ad03060b9f58d03d775323327'
22             'd1eff24508e35aae6c26a943dbaa3ef5acb60a145b008fd1ef9ac6f6c4faa662')
23 validpgpkeys=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
25 # Utilizing LLVM_DISTRIBUTION_COMPONENTS to avoid
26 # CMake reference to LLVMgold; inspired by Gentoo
27 _get_distribution_components() {
28   local target
29   ninja -t targets | grep -Po 'install-\K.*(?=-stripped:)' | while read -r target; do
30     case $target in
31       llvm-libraries|distribution)
32         continue
33         ;;
34       LLVMgold)
35         continue
36         ;;
37     esac
38     echo $target
39   done
42 prepare() {
43   cd "$srcdir/llvm-$pkgver.src"
44   mkdir build
46   patch -Np2 -i ../utils-benchmark-fix-missing-include.patch
48   # https://gitlab.freedesktop.org/mesa/mesa/-/issues/4107
49   # https://bugs.llvm.org/show_bug.cgi?id=48921#c2
50   patch -Np2 -i ../amdgpu-avoid-an-illegal-operand-in-si-shrink-instr.patch
52   # https://bugs.llvm.org/show_bug.cgi?id=50611#c3
53   patch -Np2 -i ../no-strict-aliasing-DwarfCompileUnit.patch
56 build() {
57   cd "$srcdir/llvm-$pkgver.src/build"
59   CFLAGS+=' -ffat-lto-objects'
60   CXXFLAGS+=' -ffat-lto-objects'
62   local cmake_args=(
63     -G Ninja
64     -DCMAKE_BUILD_TYPE=Release
65     -DCMAKE_INSTALL_PREFIX=/usr
66     -DLLVM_HOST_TRIPLE=$CHOST
67     -DLLVM_BUILD_LLVM_DYLIB=ON
68     -DLLVM_LINK_LLVM_DYLIB=ON
69     -DLLVM_INSTALL_UTILS=ON
70     -DLLVM_ENABLE_RTTI=ON
71     -DLLVM_ENABLE_FFI=ON
72     -DLLVM_BUILD_TESTS=ON
73     -DLLVM_BINUTILS_INCDIR=/usr/include
74   )
76   cmake .. "${cmake_args[@]}"
77   local distribution_components=$(_get_distribution_components | paste -sd\;)
78   test -n "$distribution_components"
79   cmake_args+=(-DLLVM_DISTRIBUTION_COMPONENTS="$distribution_components")
81   cmake .. "${cmake_args[@]}"
82   ninja
85 check() {
86   cd "$srcdir/llvm-$pkgver.src/build"
87   ninja check
90 package_llvm11() {
91   pkgdesc="Collection of modular and reusable compiler and toolchain technologies"
92   depends=('llvm11-libs' 'perl')
93   conflicts=('llvm')
95   cd "$srcdir/llvm-$pkgver.src/build"
97   DESTDIR="$pkgdir" ninja install-distribution
99   # Include lit for running lit-based tests in other projects
100   pushd ../utils/lit
101   python3 setup.py install --root="$pkgdir" -O1
102   popd
104   # The runtime libraries go into llvm11-libs
105   mv -f "$pkgdir"/usr/lib/lib{LLVM-*.so,{LTO,Remarks}.so.*} "$srcdir"
107   # Remove files which conflict with llvm-libs
108   rm "$pkgdir"/usr/lib/lib{LLVM,LTO,Remarks}.so
110   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
113 package_llvm11-libs() {
114   pkgdesc="LLVM 11 runtime libraries"
115   depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
117   install -d "$pkgdir/usr/lib"
118   cp -P "$srcdir"/lib{LLVM-*.so,{LTO,Remarks}.so.*} "$pkgdir/usr/lib/"
120   install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
121     "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
124 # vim:set ts=2 sw=2 et: