-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPKGBUILD
329 lines (283 loc) · 13.2 KB
/
PKGBUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/usr/bin/bash
# Maintainer: Solomon Choina <shlomochoina@gmail.com>
# Based on LordHeavy's LLVM
pkgbase=llvm-git
pkgname=('lldb-git' 'lld-git' 'polly-git' 'compiler-rt-git' 'clang-git' 'spirv-llvm-translator-git' 'llvm-libs-git' 'llvm-git')
pkgdesc='Low Level Virtual Machine (git version)'
pkgver=19.0.0_r499786.56d319e7e40e
pkgrel=1
epoch=2
groups=('chaotic-mesa-git')
arch=('x86_64' 'armv7h' 'aarch64')
url="https://llvm.org/"
license=('Apache-2.0 WITH LLVM-exception')
makedepends=('git' 'cmake' 'ninja' 'libffi' 'libedit' 'ncurses' 'libxml2'
'python-sphinx' 'lua53' 'python-recommonmark' 'python-setuptools' 'python-six'
'cuda' 'ocl-icd' 'opencl-headers' 'python-yaml' 'python-myst-parser'
'swig' 'python' 'libunwind' 'spirv-headers-git'
'python-sphinx-furo' 'python-sphinx-automodapi' 'python-pexpect'
'python-psutil' 'spirv-tools' 'tensorflow')
source=("llvm-project::git+https://github.com/llvm/llvm-project.git"
"git+https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git"
"llvm-config.h"
)
md5sums=('SKIP'
'SKIP'
'295c343dcd457dc534662f011d7cff1a')
sha512sums=('SKIP'
'SKIP'
'75e743dea28b280943b3cc7f8bbb871b57d110a7f2b9da2e6845c1c36bf170dd883fca54e463f5f49e0c3effe07fbd0db0f8cf5a12a2469d3f792af21a73fcdd')
options=('staticlibs' '!emptydirs') # 'debug' takes way too long to scan for the source files...
# NINJAFLAGS is an env var used to pass commandline options to ninja
# NOTE: It's your responbility to validate the value of $NINJAFLAGS. If unsure, don't set it.
_python_optimize() {
python -m compileall "$@"
python -O -m compileall "$@"
python -OO -m compileall "$@"
}
pkgver() {
cd llvm-project/cmake/Modules
# This will almost match the output of `llvm-config --version` when the
# LLVM_APPEND_VC_REV cmake flag is turned on. The only difference is
# dash being replaced with underscore because of Pacman requirements.
local _pkgver=$(awk -F 'MAJOR |MINOR |PATCH |)' \
'BEGIN { ORS="." ; i=0 } \
/set\(LLVM_VERSION_/ { print $2 ; i++ ; if (i==2) ORS="" } \
END { print "\n" }' \
LLVMVersion.cmake)_r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
echo "$_pkgver"
}
prepare() {
cd llvm-project
# llvm-project contains a lot of stuff, remove parts that aren't used by this package
rm -rf "$srcdir"/fakeinstall
cp -r $srcdir/SPIRV-LLVM-Translator llvm/projects
}
build() {
CFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug} -fno-lto"
CXXFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug} -fno-lto"
CFLAGS+=' -I/usr/include/tensorflow'
CXXFLAGS+=' -I/usr/include/tensorflow'
CFLAGS+=' -fasynchronous-unwind-tables'
CXXFLAGS+=' -fasynchronous-unwind-tables'
LDFLAGS+=' -fasynchronous-unwind-tables'
# export CC="clang -v"
# export CXX="clang++ -v"
cmake \
-B _build \
-S llvm-project/llvm -G Ninja \
-Wno-dev \
-D CMAKE_C_FLAGS="$CFLAGS" \
-D CMAKE_CXX_FLAGS="$CXXFLAGS" \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr \
-D CMAKE_INSTALL_DOCDIR=/usr/share/doc \
-D CMAKE_POSITION_INDEPENDENT_CODE=ON \
-D LLVM_APPEND_VC_REV=ON \
-D LLVM_HOST_TRIPLE="$CHOST" \
-D LLVM_ENABLE_RTTI=ON \
-D LLVM_ENABLE_FFI=ON \
-D LLVM_BINUTILS_INCDIR=/usr/include \
-D FFI_INCLUDE_DIR="$(pkg-config --variable=includedir libffi)" \
-D LLVM_BUILD_LLVM_DYLIB=ON \
-D LLVM_LINK_LLVM_DYLIB=ON \
-D LLVM_ENABLE_BINDINGS=OFF \
-D LLVM_INSTALL_UTILS=ON \
-D LLVM_BUILD_DOCS=ON \
-D LLVM_INCLUDE_DOCS=ON \
-D LLVM_INCLUDE_BENCHMARKS=OFF \
-D LLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR \
-D LLVM_ENABLE_SPHINX=ON \
-D SPHINX_OUTPUT_HTML=ON \
-D SPHINX_OUTPUT_MAN=ON \
-D SPHINX_WARNINGS_AS_ERRORS=OFF \
-D LLVM_VERSION_SUFFIX="" \
-D LLDB_ENABLE_PYTHON=ON \
-D LLVM_ENABLE_PROJECTS="lldb;polly;compiler-rt;lld;clang-tools-extra;clang" \
-D LLVM_ENABLE_DUMP=ON \
-D LLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=/usr/include/spirv/
ninja -C _build LLVMgold all
DESTDIR="$srcdir/fakeinstall" ninja -C _build install
}
_fakeinstall () {
local src f dir
for src; do
f="${src#fakeinstall/}"
dir="$pkgdir/${f%/*}"
install -m755 -d "$dir"
mv -v "$src" "$dir/"
done
}
package_lldb-git() {
_pythonver="$(python -V | sed 's/.* \([0-9]\)\.\([0-9]*\)\..*/\1.\2/')"
pkgdesc="Next generation, high-performance debugger (git version)"
url="https://lldb.llvm.org/"
depends=("clang-git=$epoch:$pkgver-$pkgrel" "llvm-libs-git=$epoch:$pkgver-$pkgrel" "lua53" "zstd" "libxml2" "python")
provides=("lldb=$pkgver")
replaces=('lldb-svn')
optdepends=('lua53: scripting support')
conflicts=('lldb' 'lldb-svn')
_fakeinstall fakeinstall/usr/bin/lldb*
_fakeinstall fakeinstall/usr/include/lldb
_fakeinstall fakeinstall/usr/lib/liblldb*
_fakeinstall fakeinstall/usr/lib/python"$_pythonver"/site-packages/lldb
_fakeinstall fakeinstall/usr/share/man/man1/lldb*
_fakeinstall fakeinstall/usr/share/doc/lldb/*
install -Dm644 "$srcdir"/llvm-project/lldb/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
rm -r "$pkgdir"/usr/share/doc/lldb/html/.buildinfo
}
package_lld-git(){
pkgdesc="Linker from the LLVM project"
url="https://lld.llvm.org"
depends=("llvm-libs-git=$epoch:$pkgver-$pkgrel"
"zstd"
"llvm-git=$epoch:$pkgver-$pkgrel")
provides=("lld=$pkgver")
replaces=('lld-svn')
conflicts=('lld' 'lld-svn')
_fakeinstall fakeinstall/usr/include/lld
_fakeinstall fakeinstall/usr/lib/liblld*
_fakeinstall fakeinstall/usr/lib/cmake/lld/
_fakeinstall fakeinstall/usr/bin/{lld*,*.lld,wasm-ld}
_fakeinstall fakeinstall/usr/share/doc/lld/*
install -Dm644 "$srcdir"/llvm-project/lld/docs/ld.lld.1 "$pkgdir/usr/share/man/man1"
install -Dm644 "$srcdir"/llvm-project/lld/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
rm -r "$pkgdir"/usr/share/doc/lld/html/{_sources,.buildinfo}
}
package_polly-git() {
pkgdesc="Polly is a high-level loop and data-locality optimizer and optimization infrastructure for LLVM"
url="https://polly.llvm.org/"
depends=("llvm-libs-git=$epoch:$pkgver-$pkgrel" 'glibc' 'gcc-libs')
provides=("polly=$pkgver")
replaces=('polly-svn')
conflicts=('polly' 'polly-svn')
_fakeinstall fakeinstall/usr/include/polly
_fakeinstall fakeinstall/usr/lib/cmake/polly/
_fakeinstall fakeinstall/usr/lib/*Polly*
install -Dm644 "$srcdir"/llvm-project/polly/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
_fakeinstall fakeinstall/usr/share/doc/polly/*
_fakeinstall fakeinstall/usr/share/man/man1/polly*
rm -r "$pkgdir"/usr/share/doc/polly/html/{_sources,.buildinfo}
}
package_compiler-rt-git() {
pkgdesc="Compiler runtime libraries for clang (git version)"
url="https://compiler-rt.llvm.org/"
depends=('gcc-libs' "llvm-git=$epoch:$pkgver-$pkgrel")
provides=("compiler-rt=$pkgver")
replaces=('compiler-rt-svn')
conflicts=('compiler-rt' 'compiler-rt-svn')
local _llvmver=$(echo "$pkgver" | grep -Po "(^[\d]+)")
_fakeinstall fakeinstall/usr/lib/clang/"$_llvmver"/lib/"$CHOST"
_fakeinstall fakeinstall/usr/lib/clang/"$_llvmver"/include/{sanitizer,xray}
_fakeinstall fakeinstall/usr/lib/clang/"$_llvmver"/share
install -Dm644 "$srcdir"/llvm-project/clang/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
package_clang-git() {
_pythonver="$(python -V | sed 's/.* \([0-9]\)\.\([0-9]*\)\..*/\1.\2/')"
pkgdesc="C language family frontend for LLVM (git version)"
url="http://clang.llvm.org/"
depends=("llvm-libs-git=$epoch:$pkgver-$pkgrel" 'gcc' "compiler-rt-git=$epoch:$pkgver-$pkgrel" "python-yaml")
optdepends=('llvm-git: refered by some clang-headers'
'python: for scan-view and git-clang-format'
'perl: for scanbuild, c++-analyzer, and ccc-analyzer')
provides=("clang=$pkgver" "clang-analyzer=$pkgver" "clang-tools-extra=$pkgver")
conflicts=('clang' 'clang-svn' 'clang-analyzer' 'clang-analyzer-svn' 'clang-tools-extra' 'clang-tools-extra-svn')
replaces=('clang-svn' 'clang-analyzer-svn' 'clang-tools-extra-svn')
_fakeinstall fakeinstall/usr/bin/*clang*
_fakeinstall fakeinstall/usr/bin/{c-index-test,diagtool,find-all-symbols}
_fakeinstall fakeinstall/usr/bin/{hmaptool,modularize,scan-build,scan-build-py,scan-view,analyze-build,intercept-build}
_fakeinstall fakeinstall/usr/bin/pp-trace
_fakeinstall fakeinstall/usr/include/clang*
_fakeinstall fakeinstall/usr/lib/clang
_fakeinstall fakeinstall/usr/lib/libclang*
_fakeinstall fakeinstall/usr/lib/libfindAllSymbols*
_fakeinstall fakeinstall/usr/lib/cmake/clang
_fakeinstall fakeinstall/usr/libexec
_fakeinstall fakeinstall/usr/share/doc/clang*
_fakeinstall fakeinstall/usr/share/clang
_fakeinstall fakeinstall/usr/share/scan{-build,-view}
_fakeinstall fakeinstall/usr/share/man/man1/{clang,diagtool,extraclangtools,scan-build}*
# Remove documentation sources
rm -rf "$pkgdir"/usr/share/doc/clang{,-tools}/html/{_sources,.buildinfo}
# Move scanbuild-py into site-packages and install Python bindings
local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
install -d "$pkgdir/$site_packages"
_fakeinstall fakeinstall/usr/lib/{libear,libscanbuild}
mv "$pkgdir"/usr/lib/{libear,libscanbuild} "$pkgdir/$site_packages/"
cp -a $srcdir/llvm-project/clang/bindings/python/clang "$pkgdir/$site_packages/"
# Move analyzer scripts out of /usr/libexec
mv "$pkgdir"/usr/libexec/* "$pkgdir/usr/lib/clang/"
rmdir "$pkgdir/usr/libexec"
sed -i 's|libexec|lib/clang|' \
"$pkgdir/usr/bin/scan-build" \
"$pkgdir/$site_packages/libscanbuild/analyze.py"
# Compile Python scripts
_python_optimize "$pkgdir/usr/share" "$pkgdir/$site_packages"
install -Dm644 "$srcdir"/llvm-project/llvm/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
package_llvm-libs-git() {
pkgdesc="LLVM runtime libraries (git version)"
depends=('gcc-libs'
'zlib'
'libffi'
'libedit'
'libxml2'
'ncurses'
'tensorflow'
'zstd'
"llvm-git=$epoch:$pkgver-$pkgrel")
provides=("llvm-libs=$pkgver")
replaces=('llvm-libs-svn')
conflicts=('llvm-libs-svn' 'llvm-libs')
_fakeinstall fakeinstall/usr/lib/libLLVM-*.so*
_fakeinstall fakeinstall/usr/lib/libLTO.so*
_fakeinstall fakeinstall/usr/lib/libRemarks.so.*
_fakeinstall fakeinstall/usr/lib/LLVMgold.so
install -d "$pkgdir/usr/lib/bfd-plugins"
ln -s ../LLVMgold.so "$pkgdir/usr/lib/bfd-plugins/LLVMgold.so"
install -Dm644 "$srcdir"/llvm-project/llvm/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
package_spirv-llvm-translator-git() {
pkgdesc="Tool and a library for bi-directional translation between SPIR-V and LLVM IR"
depends=("llvm-git=$epoch:$pkgver-$pkgrel" 'spirv-tools')
provides=('spirv-llvm-translator')
conflicts=('spirv-llvm-translator')
_fakeinstall fakeinstall/usr/bin/llvm-spirv
_fakeinstall fakeinstall/usr/include/LLVMSPIRVLib
_fakeinstall fakeinstall/usr/lib/libLLVMSPIRVLib.*
_fakeinstall fakeinstall/usr/lib/pkgconfig/LLVMSPIRVLib.pc
sed -i 's/17.0.0/18.0.0/g' $pkgdir/usr/lib/pkgconfig/LLVMSPIRVLib.pc
install -Dm644 "$srcdir"/llvm-project/llvm/projects/SPIRV-LLVM-Translator/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
package_llvm-git() {
pkgdesc="Collection of modular and reusable compiler and toolchain technologies (git version)"
depends=("llvm-libs-git=$epoch:$pkgver-$pkgrel" 'perl' 'python-yaml' 'python-psutil' 'python-pygments' 'libxml2' 'zstd' 'libedit' 'libffi')
optdepends=('python-setuptools: for using lit (LLVM Integrated Tester)')
provides=("llvm=$pkgver")
replaces=('llvm-svn')
conflicts=('llvm' 'llvm-svn')
_fakeinstall fakeinstall/usr/bin
_fakeinstall fakeinstall/usr/include/llvm*
_fakeinstall fakeinstall/usr/lib
_fakeinstall fakeinstall/usr/share
# Include lit for running lit-based tests in other projects
pushd "$srcdir"/llvm-project/llvm/utils/lit
python3 setup.py install --root="$pkgdir" -O1
popd
cp "$pkgdir"/usr/bin/lit "$pkgdir"/usr/bin/llvm-lit
# Remove documentation sources
rm -rf "$pkgdir"/usr/share/doc/llvm/html/{_sources,.buildinfo}
# Remove libs which conflict with llvm-libs
rm -f "$pkgdir"/usr/lib/{libLLVM,libLTO,LLVMgold,libRemarks}.so
rm -f "$pkgdir"/usr/lib/python3.8/site-packages/six.py
# remove spirv-headers files
rm -rf fakeinstall/usr/include/spirv
rm -rf fakeinstall/usr/share/cmake/SPIRV-Headers
if [[ $CARCH == x86_64 ]]; then
# Needed for multilib (https://bugs.archlinux.org/task/29951)
# Header stub is taken from Fedora
mv "$pkgdir/usr/include/llvm/Config/llvm-config"{,-64}.h
cp "$srcdir/llvm-config.h" "$pkgdir/usr/include/llvm/Config/llvm-config.h"
fi
install -Dm644 "$srcdir"/llvm-project/llvm/LICENSE.TXT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}