aboutsummaryrefslogtreecommitdiffstats
path: root/community/rust/APKBUILD
blob: 55892cad97ebe18ef2a3ca2c5098b6eef302c30a (plain)
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
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Shiz <hi@shiz.me>
# Contributor: Jeizsm <jeizsm@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=rust
pkgver=1.28.0
# TODO: bump to 6 as soon as we add llvm6
_llvmver=5
_bootver=1.27.0
pkgrel=0
pkgdesc="The Rust Programming Language"
url="http://www.rust-lang.org"
arch="x86_64"
license="Apache-2.0 BSD ISC MIT"

# gcc is needed at runtime just for linking. Someday rustc might invoke
# the linker directly, and then we'll only need binutils.
# See: https://github.com/rust-lang/rust/issues/11937
depends="$pkgname-stdlib=$pkgver-r$pkgrel gcc llvm-libunwind-dev musl-dev"

# * Rust is self-hosted, so you need rustc (and cargo) to build rustc...
#   The last revision of this abuild that does not depend on itself (uses
#   prebuilt rustc and cargo) is 8cb3112594f10a8cee5b5412c28a846acb63167f.
# * libffi-dev is needed just because we compile llvm with LLVM_ENABLE_FFI.
makedepends="
	rust-bootstrap>=$_bootver
	cargo-bootstrap
	cmake
	curl-dev
	file
	libffi-dev
	libgit2-dev
	libressl-dev
	libssh2-dev
	llvm$_llvmver-dev
	llvm$_llvmver-test-utils
	python2
	tar
	zlib-dev
	"
# XXX: This is a hack to allow this abuild to depend on itself. Adding "rust"
# to makedepends would not work, because abuild implicitly removes $pkgname
# and $subpackages from the abuild's dependencies.
provides="rust-bootstrap=$pkgver-r$pkgrel"
# This is needed for -src that contains some testing binaries.
options="!archcheck"
subpackages="
	$pkgname-dbg
	$pkgname-stdlib
	$pkgname-analysis
	$pkgname-gdb::noarch
	$pkgname-lldb::noarch
	$pkgname-doc
	$pkgname-src::noarch
	cargo
	cargo-bash-completions:_cargo_bashcomp:noarch
	cargo-zsh-completion:_cargo_zshcomp:noarch
	cargo-doc:_cargo_doc:noarch
	"
source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz
	musl-fix-static-linking.patch
	musl-fix-linux_musl_base.patch
	llvm-with-ffi.patch
	static-pie.patch
	need-rpath.patch
	minimize-rpath.patch
	alpine-move-py-scripts-to-share.patch
	alpine-change-rpath-to-rustlib.patch
	alpine-target.patch
	install-template-shebang.patch
	bootstrap-tool-respect-tool-config.patch
	cargo-tests-fix-build-auth-http_auth_offered.patch
	cargo-tests-ignore-resolving_minimum_version_with_transitive_deps.patch
	cargo-tests-fix-build-target.patch
	check-rustc
	"
builddir="$srcdir/rustc-$pkgver-src"

_rlibdir="usr/lib/rustlib/$CTARGET/lib"
_sharedir="usr/share/rust"

ldpath="/$_rlibdir"

export RUST_BACKTRACE=1
export RUSTC_CRT_STATIC="false"
# Convince libgit2-sys to use the distro libgit2.
export LIBGIT2_SYS_USE_PKG_CONFIG=1

prepare() {
	default_prepare

	cd "$builddir"

	# Remove bundled dependencies.
	rm -Rf src/llvm/
}

build() {
	cd "$builddir"

	# jemalloc is disabled, because it increases size of statically linked
	# binaries produced by rustc (stripped hello_world 186 kiB vs. 358 kiB)
	# for only tiny performance boost (even negative in some tests).
	./configure \
		--build="$CBUILD" \
		--host="$CTARGET" \
		--target="$CTARGET" \
		--prefix="/usr" \
		--release-channel="stable" \
		--enable-local-rust \
		--local-rust-root="/usr" \
		--llvm-root="/usr/lib/llvm$_llvmver" \
		--musl-root="/usr" \
		--disable-docs \
		--enable-extended \
		--tools="analysis,cargo,src" \
		--enable-llvm-link-shared \
		--enable-option-checking \
		--enable-locked-deps \
		--enable-vendor \
		--disable-jemalloc

	./x.py build -v --jobs ${JOBS:-2}
}

check() {
	cd "$builddir"

	# At this moment lib/rustlib/$CTARGET/lib does not contain a complete
	# copy of the .so libs from lib (they will be copied there during
	# `x.py install`). Thus we must set LD_LIBRARY_PATH for tests to work.
	# This is related to change-rpath-to-rustlib.patch.
	export LD_LIBRARY_PATH="$builddir/build/$CTARGET/stage2/lib"

	"$srcdir"/check-rustc "$builddir"/build/$CTARGET/stage2/bin/rustc

# XXX: There's some problem with these tests, we will figure it out later.
#	cd "$builddir"
#	make check \
#		LD_LIBRARY_PATH="$_stage0dir/lib" \
#		VERBOSE=1

	msg "Running tests for cargo..."
	CFG_DISABLE_CROSS_TESTS=1 ./x.py test --no-fail-fast src/tools/cargo

	unset LD_LIBRARY_PATH
}

package() {
	cd "$builddir"

	DESTDIR="$pkgdir" ./x.py install -v

	cd "$pkgdir"

	# These libraries are identical to those under rustlib/. Since we have
	# linked rustc/rustdoc against those under rustlib/, we can remove
	# them. Read change-rpath-to-rustlib.patch for more info.
	rm -r usr/lib/*.so

	# These objects are for static linking with musl on non-musl systems.
	rm $_rlibdir/crt*.o

	# Shared objects should have executable flag.
	chmod +x $_rlibdir/*.so

	# Python scripts are noarch, so move them to /usr/share.
	# Requires move-py-scripts-to-share.patch to be applied.
	_mv usr/lib/rustlib/etc/*.py $_sharedir/etc/
	rmdir -p usr/lib/rustlib/etc 2>/dev/null || true

	# Remove some clutter.
	cd usr/lib/rustlib
	rm components install.log manifest-* rust-installer-version uninstall.sh
}

stdlib() {
	pkgdesc="Standard library for Rust (static rlibs)"

	_mv "$pkgdir"/$_rlibdir/*.rlib "$subpkgdir"/$_rlibdir/
}

analysis() {
	pkgdesc="Compiler analysis data for the Rust standard library"
	depends="$pkgname-stdlib=$pkgver-r$pkgrel"

	_mv "$pkgdir"/$_rlibdir/../analysis "$subpkgdir"/${_rlibdir%/*}/
}

gdb() {
	pkgdesc="GDB pretty printers for Rust"
	depends="$pkgname gdb"

	mkdir -p "$subpkgdir"
	cd "$subpkgdir"

	_mv "$pkgdir"/usr/bin/rust-gdb usr/bin/
	_mv "$pkgdir"/$_sharedir/etc/gdb_*.py $_sharedir/etc/
}

lldb() {
	pkgdesc="LLDB pretty printers for Rust"
	depends="$pkgname lldb py2-lldb"

	mkdir -p "$subpkgdir"
	cd "$subpkgdir"

	_mv "$pkgdir"/usr/bin/rust-lldb usr/bin/
	_mv "$pkgdir"/$_sharedir/etc/lldb_*.py $_sharedir/etc/
}

src() {
	pkgdesc="$pkgdesc (source code)"
	depends="$pkgname"
	license="$license OFL-1.1 GPL-3.0-or-later GPL-3.0-with-GCC-exception CC-BY-SA-3.0 LGPL-3.0"

	_mv "$pkgdir"/usr/lib/rustlib/src/rust "$subpkgdir"/usr/src/
	rmdir -p "$pkgdir"/usr/lib/rustlib/src 2>/dev/null || true

	mkdir -p "$subpkgdir"/usr/lib/rustlib/src
	ln -s ../../../src/rust "$subpkgdir"/usr/lib/rustlib/src/rust
}

cargo() {
	pkgdesc="The Rust package manager"
	license="Apache-2.0 MIT UNLICENSE"
	depends="$pkgname"
	# XXX: See comment on top-level provides=.
	provides="cargo-bootstrap=$pkgver-r$pkgrel"

	_mv "$pkgdir"/usr/bin/cargo "$subpkgdir"/usr/bin/
}

_cargo_bashcomp() {
	pkgdesc="Bash completions for cargo"
	license="Apache-2.0 MIT"
	depends=""
	install_if="cargo=$pkgver-r$pkgrel bash-completion"

	cd "$pkgdir"
	_mv etc/bash_completion.d/cargo \
		"$subpkgdir"/usr/share/bash-completion/completions/
	rmdir -p etc/bash_completion.d 2>/dev/null || true
}

_cargo_zshcomp() {
	pkgdesc="ZSH completions for cargo"
	license="Apache-2.0 MIT"
	depends=""
	install_if="cargo=$pkgver-r$pkgrel zsh"

	cd "$pkgdir"
	_mv usr/share/zsh/site-functions/_cargo \
		"$subpkgdir"/usr/share/zsh/site-functions/_cargo
	rmdir -p usr/share/zsh/site-functions 2>/dev/null || true
}

_cargo_doc() {
	pkgdesc="The Rust package manager (documentation)"
	license="Apache-2.0 MIT"
	install_if="docs cargo=$pkgver-r$pkgrel"

	# XXX: This is hackish!
	cd "$pkgdir"/../$pkgname-doc
	_mv usr/share/man/man1/cargo* "$subpkgdir"/usr/share/man/man1/
}

_mv() {
	local dest; for dest; do true; done  # get last argument
	mkdir -p "$dest"
	mv $@
}

sha512sums="4e4f121ee5a8a9f8e1ddb6ca5a0c43ba15c1349ecea9478fbcd0b242bf438b498f76bee97d33b9e078a47395e44cdea4c5aa0941e7dd21167abdf94314ef10ce  rustc-1.28.0-src.tar.gz
768f999d88b74c89b595a29028041807b963c72da22cc9d9f96ae3d366a9bcac12ec65520510509560ed0cfa19b6988975e201e9be8349e41192aed82641afba  musl-fix-static-linking.patch
3615b815cfb4eae60f3291dc07a292e1be6048eeddcb21c595bddbe8cca6a622e5b76be72a76f6b65b4d33abdc34a792ce010b024b2818a4d73bce3f85b3eb2b  musl-fix-linux_musl_base.patch
e40d41a6dc5d400d6672f1836cd5b9e00391f7beb52e872d87db76bc95a606ce6aaae737a0256a1e5fba77c83bb223818d214dbe87028d47be65fb43c101595c  llvm-with-ffi.patch
9fe4c230165a29ffc5557952d20e62b42e0c384a874e2584fa227239b44d20079878a740e525a51a1262d5a2194b2efe0b4e2e846fe317ea4c496d5fc1834671  static-pie.patch
487d479a15b43c3e1ee28c111206a4f488be933309f3c6571be7ec33da4e955cc1ee907b7729b4228cb292ca7b3324eb6ba4f32a01abc3d04573a0d96982569a  need-rpath.patch
4362dcc4e9bbe2803337ca39ff97b5206feb42fd86580a108146153f323732e8d1e109edbf6a5d68791975cae7dd185b8220fc8edd62484b8ca31b1d39ab67b8  minimize-rpath.patch
0c0aa7eeddeb578c320a94696a4437fbf083ef4d6f8049512de82548285f37ec4460b5d04f087dc303a5f62a09b5d13b7f0c4fbbdb0b321147ae030e7282ac07  alpine-move-py-scripts-to-share.patch
61aa415d754e9e01236481a1f3c9d5242f2d633e6f11b998e9ffcc07bf5c182d87c0c973dab6f10e4bb3ab4b4a4857bf9ed8dd664c49a65f6175d27db2774db1  alpine-change-rpath-to-rustlib.patch
a688b4bc2420bf05c6ae724c9a4e6821267716032f69a9a44cb395407276df7fb37fc145f8d274b5fa03e7173c338871c9d2294a90726ef16bd087fbe6a77b66  alpine-target.patch
7d59258d4462eba0207739a5c0c8baf1f19d9a396e5547bb4d59d700eb94d50ba6add2e523f3e94e29e993821018594625ea4ac86304fb58f7f8c82622a26ab0  install-template-shebang.patch
c2ccab15d48c11cc3af549a3944ca0d29cb3790345468f4f3779e5ac931554dea603e5523281fc391ba4a555ee468b516961c4cb8ecee007eadacf114f3d8758  bootstrap-tool-respect-tool-config.patch
332a6af59edc507baa73eda1de60591dd4202f540541769ac1bcbc731267f4523ea309d2c3b1f5a9dc3db32831942a5d3d40b81882dad0bf0b5ee7f74f1d6477  cargo-tests-fix-build-auth-http_auth_offered.patch
3d6f027088e1ec189ce864bf5ed150ccad8be5d9fc0973f1b4d202eec6eab865834403335a9f0765bbfa54638aed7f5d5f2183ba9dfeab9f5bc4ef48111a8427  cargo-tests-ignore-resolving_minimum_version_with_transitive_deps.patch
afa9b770c78857612078660966af0d800671b53bb5cfa717e9584efcca55ed3af451f2b05bf2d4168a4f992cdb5e1e21445ce6b1a09830e1bf5edfb5f92ef98c  cargo-tests-fix-build-target.patch
c31fdfe8a9b3411576c75da46645cf0465b9053000a2ab49cf9b2f2733f679d6d33acbf236d67a20e14935d094a685453b7f1840180249f39d610fd0902c3125  check-rustc"