aboutsummaryrefslogtreecommitdiffstats
path: root/community/rust/APKBUILD
blob: 62f9462f9c98f5588793b983207998426a4ba24d (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
# 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.18.0
_llvmver=3.9
_bootver=1.17.0
pkgrel=1
pkgdesc="The Rust Programming Language (compiler)"
url="http://www.rust-lang.org"
arch="x86_64"
license="ASL-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>=$_bootver cargo
	cmake file libffi-dev llvm$_llvmver-dev python2 tar zlib-dev"

subpackages="$pkgname-dbg $pkgname-stdlib
	$pkgname-gdb::noarch $pkgname-lldb::noarch $pkgname-doc"
source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz
	musl-support-dynamic-linking.patch
	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-allow-crt-static.patch
	alpine-move-py-scripts-to-share.patch
	alpine-change-rpath-to-rustlib.patch
	alpine-target.patch
	fix-build.patch
	check-rustc
	"
builddir="$srcdir/rustc-$pkgver-src"

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

ldpath="/$_rlibdir"

prepare() {
	default_prepare

	cd "$builddir"

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

	# Make sure to use the system LLVM.
	printf '[target.%s]\nllvm_config = "/usr/lib/llvm%s/bin/llvm-config"\n' \
		"$CTARGET" "$_llvmver" > config.toml
}

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" \
		--enable-vendor \
		--enable-llvm-link-shared \
		--disable-jemalloc \
		--disable-docs

	make \
		RUST_BACKTRACE=1 \
		RUST_CRT_STATIC="false" \
		VERBOSE=1
}

check() {
	"$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" \
#		RUST_BACKTRACE=1 \
#		RUST_CRT_STATIC="false" \
#		VERBOSE=1
}

package() {
	cd "$builddir"

	make dist \
		RUST_BACKTRACE=1 \
		RUST_CRT_STATIC="false" \
		VERBOSE=1

	local component; for component in rustc rust-std; do
		tar -xf "build/dist/$component-$pkgver-$CTARGET.tar.gz"
		./"$component-$pkgver-$CTARGET"/install.sh --destdir="$pkgdir" --prefix=/usr --disable-ldconfig
	done

	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/
}

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 py-lldb"

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

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

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

sha512sums="eff0460b647dfb3490e28d4dec4f9781d31a942f22de75d9bd1ba31591597226b6862ec5132e8b4fcdbcf6e6ffa085ca5dda7ff8260cd82388fc13e8d3b4a2eb  rustc-1.18.0-src.tar.gz
b5db9ed04eac26c6fc62cde3f19d29837a5feea68e79165c23b5b5cade2e1d193f2399d27f7622b230996da9565f78825be154574f1cd59189ded8a03a766cfb  musl-support-dynamic-linking.patch
d4d39514eca638852307f470250fd12a21781e1e7944377744b7d50290d3a2ab3776fbdfccb7a9221f5da00ca694ac3a5b8c05f72c5e1a0c8711b684b16b1084  musl-fix-static-linking.patch
9ebfb10abb50d74ff08d257d85257ce70ac3ce834aa95a8901808497b14acf3ea898fb197de64d13554eb5feedabe9fd04fec2cc6a7bea9b1335684bfcdcd88b  musl-fix-linux_musl_base.patch
dc6432293bd060d5e3a73f25870867654fae61995dcd919e244a2dc686b6107556deed8c59ca6002182bfeff5ebc1ca2b89c4028ab0fbfb79e65defe47c9b4b0  llvm-with-ffi.patch
5aaf6715b27b8b786740a55b91216d47985fbef3ccb0ef7e6a81696a2823671f8306143f7ecf77e66af91ef1500072524b9b4c7569508922ad5268df6080fda1  static-pie.patch
ff633f2a46c683ad698d1c09c98c06ce9ee9b8d55fa5593cdd485b439ebca3273794d29b5ff32b887be8666f52913a23af6e133c782bd0c4e2c88e306dd3a494  need-rpath.patch
d352614e7c774e181decae210140e789de7fc090327ff371981ad28a11ce51c8c01b27c1101a24bb84d75ed2f706f67868f7dbc52196d4ccdf4ebd2d6d6b6b5e  minimize-rpath.patch
b00997c65d1a451fafae8b547893c5cbf03f028d2d70f6971aa670f34c2d6fc82728c740ac4a9909fc1999925ff300e4525cfec745cb9c9521e564eb166872a2  alpine-allow-crt-static.patch
498f4649163974afc4f042c43cd0c15d36784031514201a2962061f288a9336c2bc9749f8d2308b8ce3656f8097b5fc5bef505f61e2a6ed422ef4153f5339d77  alpine-move-py-scripts-to-share.patch
8d6206f8c50856724cf7b4c1854ec82547f040358a1c7d44abeacc27a5c205a963b1fec51e58ec06c68d85bd2f68a9e6e27ebe457f39e8dd043de17758f5063f  alpine-change-rpath-to-rustlib.patch
e9935f88f959d37da9e696f2722569bc6da6ed17eddc8d496af4a2ee9a561d8e40bd7644089ee26114bb920e04ff05def18d70a6f2347545500d1a23ee96eefa  alpine-target.patch
5c1bcd78d2579e1aeacd4f20d849f75127111fb2f06124531af370c7afdcf9ae78d9e3952911197c02099cdedfeb2335699f98568123bdd83c7acc1ddbae7f54  fix-build.patch
79549055dea81379c890b495c82456ab497a9179ec6702c59e11d0748bc668f47fc3d6a69c27a0545bb87c01318631dffc69260bf2d4badc75f53cbf7fad7528  check-rustc"