archrelease: copy trunk to extra-x86_64
[arch-packages.git] / llvm / trunk / PKGBUILD
blobb186d12ed87ca3c6d56f420b648aa5494b3d24da
1 # Maintainer: Evangelos Foutras <evangelos@foutrelis.com>
2 # Contributor: Jan "heftig" Steffens <jan.steffens@gmail.com>
4 pkgname=('llvm' 'llvm-libs' 'llvm-ocaml')
5 pkgver=13.0.1
6 pkgrel=1
7 _ocaml_ver=4.13.1
8 arch=('x86_64')
9 url="https://llvm.org/"
10 license=('custom:Apache 2.0 with LLVM Exception')
11 makedepends=('cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2'
12              "ocaml>=$_ocaml_ver" 'ocaml-ctypes' 'ocaml-findlib'
13              'python-setuptools' 'python-psutil' 'python-sphinx'
14              'python-recommonmark')
15 options=('staticlibs' '!lto') # Getting thousands of test failures with LTO
16 _source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
17 source=($_source_base/$pkgname-$pkgver.src.tar.xz{,.sig}
18         don-t-accept-nullptr-as-GEP-element-type.patch
19         no-strict-aliasing-DwarfCompileUnit.patch
20         disable-bswap-for-spir.patch
21         llvm-config.h)
22 sha256sums=('ec6b80d82c384acad2dc192903a6cf2cdbaffb889b84bfb98da9d71e630fc834'
23             'SKIP'
24             'a7e902a7612d0fdabe436a917468b043cc296bc89d8954bfc3126f737beb9ac4'
25             'd1eff24508e35aae6c26a943dbaa3ef5acb60a145b008fd1ef9ac6f6c4faa662'
26             'af163392fbc19d65d11ab4b1510a2eae39b417d6228023b3ba5395b138bb41f5'
27             '597dc5968c695bbdbb0eac9e8eb5117fcd2773bc91edf5ec103ecffffab8bc48')
28 validpgpkeys+=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans@chromium.org>
29 validpgpkeys+=('474E22316ABF4785A88C6E8EA2C794A986419D8A') # Tom Stellard <tstellar@redhat.com>
31 prepare() {
32   cd "$srcdir/llvm-$pkgver.src"
33   mkdir build
35   # https://github.com/intel/intel-graphics-compiler/issues/204
36   patch -Rp2 -i ../don-t-accept-nullptr-as-GEP-element-type.patch
38   # Work around intermittent 'clang -O -g' crashes
39   # https://bugs.llvm.org/show_bug.cgi?id=50611#c3
40   patch -Np2 -i ../no-strict-aliasing-DwarfCompileUnit.patch
42   # Fix an ISPC build failure (https://github.com/ispc/ispc/issues/2189)
43   patch -Np2 -i ../disable-bswap-for-spir.patch
46 build() {
47   cd "$srcdir/llvm-$pkgver.src/build"
49   cmake .. -G Ninja \
50     -DCMAKE_BUILD_TYPE=Release \
51     -DCMAKE_INSTALL_PREFIX=/usr \
52     -DCMAKE_SKIP_RPATH=ON \
53     -DLLVM_HOST_TRIPLE=$CHOST \
54     -DLLVM_BUILD_LLVM_DYLIB=ON \
55     -DLLVM_LINK_LLVM_DYLIB=ON \
56     -DLLVM_INSTALL_UTILS=ON \
57     -DLLVM_ENABLE_RTTI=ON \
58     -DLLVM_ENABLE_FFI=ON \
59     -DLLVM_BUILD_TESTS=ON \
60     -DLLVM_BUILD_DOCS=ON \
61     -DLLVM_ENABLE_SPHINX=ON \
62     -DLLVM_ENABLE_DOXYGEN=OFF \
63     -DSPHINX_WARNINGS_AS_ERRORS=OFF \
64     -DLLVM_BINUTILS_INCDIR=/usr/include
65   ninja all ocaml_doc
68 check() {
69   cd "$srcdir/llvm-$pkgver.src/build"
70   LD_LIBRARY_PATH=$PWD/lib ninja check
73 package_llvm() {
74   pkgdesc="Collection of modular and reusable compiler and toolchain technologies"
75   depends=('llvm-libs' 'perl')
77   cd "$srcdir/llvm-$pkgver.src/build"
79   DESTDIR="$pkgdir" ninja install
81   # Include lit for running lit-based tests in other projects
82   pushd ../utils/lit
83   python3 setup.py install --root="$pkgdir" -O1
84   popd
86   # Remove documentation sources
87   rm -r "$pkgdir"/usr/share/doc/$pkgname/html/{_sources,.buildinfo}
89   # The runtime libraries go into llvm-libs
90   mv -f "$pkgdir"/usr/lib/lib{LLVM,LTO,Remarks}*.so* "$srcdir"
91   mv -f "$pkgdir"/usr/lib/LLVMgold.so "$srcdir"
93   # OCaml bindings go to a separate package
94   rm -rf "$srcdir"/ocaml.{lib,doc}
95   mv "$pkgdir/usr/lib/ocaml" "$srcdir/ocaml.lib"
96   mv "$pkgdir/usr/share/doc/$pkgname/ocaml-html" "$srcdir/ocaml.doc"
98   if [[ $CARCH == x86_64 ]]; then
99     # Needed for multilib (https://bugs.archlinux.org/task/29951)
100     # Header stub is taken from Fedora
101     mv "$pkgdir/usr/include/llvm/Config/llvm-config"{,-64}.h
102     cp "$srcdir/llvm-config.h" "$pkgdir/usr/include/llvm/Config/llvm-config.h"
103   fi
105   install -Dm644 ../LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
108 package_llvm-libs() {
109   pkgdesc="LLVM runtime libraries"
110   depends=('gcc-libs' 'zlib' 'libffi' 'libedit' 'ncurses' 'libxml2')
112   install -d "$pkgdir/usr/lib"
113   cp -P \
114     "$srcdir"/lib{LLVM,LTO,Remarks}*.so* \
115     "$srcdir"/LLVMgold.so \
116     "$pkgdir/usr/lib/"
118   # Symlink LLVMgold.so from /usr/lib/bfd-plugins
119   # https://bugs.archlinux.org/task/28479
120   install -d "$pkgdir/usr/lib/bfd-plugins"
121   ln -s ../LLVMgold.so "$pkgdir/usr/lib/bfd-plugins/LLVMgold.so"
123   install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
124     "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
127 package_llvm-ocaml() {
128   pkgdesc="OCaml bindings for LLVM"
129   depends=('llvm' "ocaml>=$_ocaml_ver" 'ocaml-ctypes')
131   install -d "$pkgdir"/{usr/lib,usr/share/doc/$pkgname}
132   cp -a "$srcdir/ocaml.lib" "$pkgdir/usr/lib/ocaml"
133   cp -a "$srcdir/ocaml.doc" "$pkgdir/usr/share/doc/$pkgname/html"
135   install -Dm644 "$srcdir/llvm-$pkgver.src/LICENSE.TXT" \
136     "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
139 # vim:set ts=2 sw=2 et: