aports/testing/rust/APKBUILD

199 lines
7.8 KiB
Plaintext

# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Contributor: Shiz <hi@shiz.me>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=rust
pkgver=1.16.0
# Git revision of prebuilt Cargo to use for bootstrapping, from src/stage0.txt.
_cargo_gitrev=6e0c18cccc8b0c06fba8a8d76486f81a792fb420
_llvmver=3.9
pkgrel=4
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"
# libffi-dev is needed just because we compile llvm with LLVM_ENABLE_FFI.
makedepends="cmake file libffi-dev llvm$_llvmver-dev python2 tar zlib-dev"
subpackages="$pkgname-dbg $pkgname-stdlib
$pkgname-gdb::noarch $pkgname-lldb::noarch $pkgname-doc"
# XXX: Rust is self-hosted, so you need rustc to build rustc... The problem is
# that Rust doesn't provide prebuilt rustc for musl yet. Thus we use binaries
# from VoidLinux for now.
# Follow https://github.com/rust-lang/rust/issues/31322.
source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz
https://repo.voidlinux.eu/distfiles/rustc-$pkgver-x86_64-unknown-linux-musl.tar.gz
https://repo.voidlinux.eu/distfiles/rust-std-$pkgver-x86_64-unknown-linux-musl.tar.gz
cargo-$_cargo_gitrev-x86_64-unknown-linux-musl.tar.gz::https://s3.amazonaws.com/rust-lang-ci/cargo-builds/$_cargo_gitrev/cargo-nightly-x86_64-unknown-linux-musl.tar.gz
dont-require-filecheck.patch
support-dynamically-linked-musl.patch
allow-crt-static-on-stable.patch
static-pie.patch
fix-linux_musl_base.patch
musl-dynamic-linking-by-default.patch
llvm-with-ffi.patch
move-py-scripts-to-share.patch
change-rpath-to-rustlib.patch
force-rpath-on-prefer-dynamic.patch
fix-jemalloc-musl.patch
check-rustc
"
builddir="$srcdir/rustc-$pkgver-src"
_ctarget="$CARCH-unknown-linux-musl"
_rlibdir="usr/lib/rustlib/$_ctarget/lib"
_sharedir="usr/share/rust"
_stage0dir="$srcdir/stage0"
ldpath="/$_rlibdir"
prepare() {
default_prepare
cd "$builddir"
local stage0_cargo=$(sed -En 's/^cargo:\s*(\S+)$/\1/p' src/stage0.txt)
if [ "$_cargo_gitrev" != "$stage0_cargo" ]; then
error "Update Cargo revision to: $stage0_cargo"; return 1
fi
# Don't set wrong LD_LIBRARY_PATH, we will rather set it manually when
# invoking make.
sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
# Remove bundled dependencies.
rm -Rf src/llvm/ src/jemalloc/
# Prepare our stage0 for bootstrapping.
mkdir -p "$_stage0dir"
cp -flr "$srcdir"/rustc-*$_ctarget/rustc/* \
"$srcdir"/rust-std-*$_ctarget/rust-std-*/* \
"$srcdir"/cargo-*$_ctarget/cargo/* \
"$_stage0dir"/
}
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 \
--enable-rustbuild \
--build="$_ctarget" \
--host="$_ctarget" \
--target="$_ctarget" \
--prefix="/usr" \
--release-channel="stable" \
--enable-local-rust \
--local-rust-root="$_stage0dir" \
--llvm-root="/usr/lib/llvm$_llvmver" \
--musl-root="/usr" \
--enable-vendor \
--enable-llvm-link-shared \
--disable-jemalloc \
--disable-docs
# Set LD_LIBRARY_PATH, so rustc in stage0 can find correct libs.
make \
LD_LIBRARY_PATH="$_stage0dir/lib" \
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 \
# VERBOSE=1
}
package() {
cd "$builddir"
make install \
LD_LIBRARY_PATH="$_stage0dir/lib" \
DESTDIR="$pkgdir"
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="096b1b7406be9bc61161bb7cdd2061f2bc2174c161a31f4ed6ceecf7fc379f315fc2f7cb9f6c134ea4f8519c27bf6e5a3f712cf1e56d5785831d8c8374eb0ba5 rustc-1.16.0-src.tar.gz
e9b10d58ae5b51b09dd31a1dbf7367917bd40a05ecb4ba3e0e7ac229a0352d3ceb77de80f7c0120f553bd7904644da6bf973dbc32850b12dc91f3974846d4164 rustc-1.16.0-x86_64-unknown-linux-musl.tar.gz
54467213b2824112dec6d5a132ab01d69617a5ccaa9db15e5c8fad55dea5eb31b1b7c9ca07878901d75edd45dc84c726913bf651f3435c480a79703c074b5d90 rust-std-1.16.0-x86_64-unknown-linux-musl.tar.gz
4df33353b6be1af822220ca03f9ec5a3b6421c9b10ec17b864be586ba495c6210bac70d904b0e0b35eff62ef2c9a681ded526e5cbd37e326dc3146742aa659de cargo-6e0c18cccc8b0c06fba8a8d76486f81a792fb420-x86_64-unknown-linux-musl.tar.gz
2002faf08cca3be702f25618bc17453c5e76644a6ff6b0739b642c2c0f8536ec7f09c98182aff6b2dcc87c77b0929f2f8f732b8242a8f80d94b3824c8cd0d0fe dont-require-filecheck.patch
b0a8883e4469b60edd150c84486ab950396d757220f97bd271529576614c6c3b49456098507503832c20619d4bd74246dbc99c78116634a68a6df994793e9a94 support-dynamically-linked-musl.patch
b00997c65d1a451fafae8b547893c5cbf03f028d2d70f6971aa670f34c2d6fc82728c740ac4a9909fc1999925ff300e4525cfec745cb9c9521e564eb166872a2 allow-crt-static-on-stable.patch
81fe34aa8e2edacacef63c6a0105da05205b86ae76535f8f9359607f10f6de96c48dc8e160cc8f96dc4a4291f1172290cb11ea5993eba023eb393d8fad6fe0c7 static-pie.patch
f436fddf7ab70ca5f1424081f5b75450270b200b3d997231323863e11addf76e1d65831a7ca09e3a5b7904ce828766c1f70b08326a175890298f28e5bc8646ef fix-linux_musl_base.patch
44f3104f506531778fede64034ff5b86f782744d7fed26b393cd88590c22b7fd1df441e2c14bb44c660c54140a4093686aa35f53357f9cd795af6cfa6df1cec4 musl-dynamic-linking-by-default.patch
37416e1fa0bc0c8651cd060a645d6245ff7e2082279ab5e13495c5ee412c71915469019cfbec95a0fd9a7fc144475079a3ad16f0eba7a2f5c8dd99e0002f3225 llvm-with-ffi.patch
19cc2725d68db3e359e0e3016028374e5818a97fdba24d0103f7d1706601c8b17c4dd95a3152e64f982f98e95ad3e949acddbea8a39ed0ba8dd4f702acc2704d move-py-scripts-to-share.patch
8d6206f8c50856724cf7b4c1854ec82547f040358a1c7d44abeacc27a5c205a963b1fec51e58ec06c68d85bd2f68a9e6e27ebe457f39e8dd043de17758f5063f change-rpath-to-rustlib.patch
f230239d8de1b69536353e5735d3bf32f42a2715aefe4863622d9ab2b25d010209ed0bb38976eaa9302bce2eca6bd162abc8cefd71f689b65b3800920a50967b force-rpath-on-prefer-dynamic.patch
a330fa913faeadb98cb95e644f434ddef4fbbea32bcd11b6621fb9e08f7b0d8c71fae702207465489af3cf793eade0af694a8c515fc1bed49624da25103a4862 fix-jemalloc-musl.patch
79549055dea81379c890b495c82456ab497a9179ec6702c59e11d0748bc668f47fc3d6a69c27a0545bb87c01318631dffc69260bf2d4badc75f53cbf7fad7528 check-rustc"