void-packages/srcpkgs/rust/template
Duncaen 4fd06c5965
Revert "rust: nocross for now"
This reverts commit 09903dcdf3.
2019-11-10 17:55:43 +01:00

294 lines
8.6 KiB
Bash

# Template file for 'rust'
# partially adapted from Alpine/Adélie's Rust APKBUILD
pkgname=rust
version=1.39.0
revision=1
_rust_dist_version=1.38.0
_cargo_dist_version=0.39.0
# Always make sure custom distfiles used for bootstrap are
# uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
wrksrc="rustc-${version}-src"
hostmakedepends="cmake curl pkg-config python3"
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm"
depends="rust-std"
short_desc="Safe, concurrent, practical systems language"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="MIT, Apache-2.0"
homepage="https://www.rust-lang.org/"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=b4a1f6b6a93931f270691aba4fc85eee032fecda973e6b9c774cd06857609357
lib32disabled=yes
patch_args="-Np1"
build_options="static_llvm"
_bootstrap_dir="stage0-bootstrap"
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo llvm"
# These are required for building the buildhost's stage0/1
hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
else
_bootstrap_url="https://static.rust-lang.org/dist"
# 32-bit ppc needs custom bootstrap for now because of patches
case "$XBPS_MACHINE" in
x86_64*|i686|ppc64le) ;;
ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
*) broken="unsupported host: ${XBPS_MACHINE}" ;;
esac
distfiles+="
${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz
${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
# checksums must be specified per arch
case "$XBPS_MACHINE" in
i686)
checksum+="
183dca6a4d746b833804e658267c1a60cdb446a36d4e4f8d29b04cfd29d886d5
a3248cf8cf7e33afb0a2508c7c204ffe5db2e515c3d3d31ffd9a2146ffa3bad3
2996b0fb41506e87d9b07851f40b41fed94725cf53c3d251e4e1c78eea08df4c"
;;
x86_64)
checksum+="
0fedde3406cf3367ceb00f493698e6bfc3264bd7f7253c85de7a042b45f873fa
51b334337804baeff7524e5496d396f254894d7529860d236975e9ed8fcca371
80bcb1368ce98d13cb371df89cbbed9007fb98843f34d07f2abd2c03b8f2747a"
;;
x86_64-musl)
checksum+="
9bc0b51bdfca3ed7b298021e2ec768bd28ea3af138d9dc1854a70e3866f06c0d
efcc1779f9815c1d99010ef9eb66a2439f3993bc4d5accd7566e669d1b182373
1d7d881a5af73fb7c3f632278d47a7d174f8347673e2263c4cd6a2f7d0278733"
;;
ppc64le)
checksum+="
d7c011dae42ba4498493488385d3ab00d793124866baa8310cc6414b66c9d2d2
937d2ece46539ba149cdce307718dadbc4b038a3c751bd75749430bd421a6249
456d019511cfe015152a7a4c1c2f518fdeb10e0c610c9bc3ef44d73861ca967e"
;;
ppc64le-musl)
checksum+="
37420069fc877a430c32b8b5a533483fdb7cc1a28d0d9e0c1f0579a111aec888
f4b6f37b1f914a2ca086a7e806d7552275a20982b139670ecb2bc1be2d33df2f
5725c42c8356443db15f378d88f2ccb67e363ebf4beacc96ae1eac9ba36f8fe7"
;;
ppc64)
checksum+="
7821de7c49e6c26606f2248f8cd126bef92661e149f0a67cc87f08e359685d4e
b4d2a800fef9ca53208d16c5d5e215b01849d2f34eb476fa9d05457adf1b67ae
73a4f13b8edda6b4c9c1818341c5d936f7b11a04f892358039d072b80ccd41dc"
;;
ppc64-musl)
checksum+="
a607da72ea9ae81149d563e5e07c03bfc9fcf819ad079f5193f86fcab376315c
4f3b8f8d3e07b27096224131816668c7f34a2d80b5f2c0353905dcd878c50f12
ac18707b8df5d1f64b7e15dabd73eb7a3b0f9ef5976ef7c6ceb462b5d3feb9cd"
;;
ppc)
checksum+="
e4f088461db79b75c55210a1c70fd3127675287138196322a8416d078045468d
94a2a2fc17adec46daf913e0c71280f03c12048f5224e39c7a77c533a4582f08
02c07b741062e75556f5993a05eefe6dace70fee4a45542f1c6997fa69624d7e"
;;
ppc-musl)
checksum+="
80428db030216eea9117d131acdb1293404e78b71d26746dceeed3bb30629d32
ca6253605d6eafafa9c2fbf27504b3c5d3f8efcaab69852a22ae080c265f03a9
b06306fc164bffa73afd2d21d96381a28d38446e58cf01a0d1585e92b4656a23"
;;
esac
fi
post_extract() {
if [ -z "$CROSS_BUILD" ]; then
mkdir -p "${wrksrc}/${_bootstrap_dir}"
../rust-std-${_rust_dist_version}-${RUST_BUILD}/install.sh \
--destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
../rustc-${_rust_dist_version}-${RUST_BUILD}/install.sh \
--destdir="${wrksrc}/${_bootstrap_dir}" --prefix=/ --disable-ldconfig
# cargo may not be packaged like the rest
cp ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
"${wrksrc}/${_bootstrap_dir}/bin"
fi
}
# we need this because cargo verifies checksums of all files in vendor
# crates when it builds and gives us no way to override or update the
# file sanely... so just clear out the file list
_clear_vendor_checksums() {
sed -i 's/\("files":{\)[^}]*/\1/' vendor/$1/.cargo-checksum.json
}
post_patch() {
rm -rf src/llvm-project
if [ "$build_option_static_llvm" ]; then
for x in ${FILESDIR}/patches/static-llvm/*.patch; do
msg_normal "Applying patch $x\n"
patch -sNp1 -i ${x}
done
fi
# clear out all the checksum nonsense of patched vendor crates
_clear_vendor_checksums libc
_clear_vendor_checksums typenum
_clear_vendor_checksums backtrace-sys
}
do_configure() {
local _rust_root _local_rebuild _use_debug _use_debug_rustc _use_rpath
if [ "$CROSS_BUILD" ]; then
_rust_root="/usr"
_local_rebuild="true"
else
_rust_root="${wrksrc}/${_bootstrap_dir}"
_local_rebuild="false"
fi
# disable rustc debug info as it bloats up rust-std significantly
# set to 1 or 2 if you wish to have debug info for rustc, it won't
# link on 32-bit platforms though (too big)
_use_debug_rustc="0"
# use stdlib debug level 2 for all platforms when generating debug
if [ -n "$XBPS_DEBUG_PKGS" ]; then
_use_debug="2"
else
_use_debug="0"
fi
# if true, the binaries will be built with rpath, so the binaries will be
# usable directly from the build directory, this is not desirable for
# packaging but is useful when building bootstrap binaries
_use_rpath="false"
cat > config.toml <<- EOF
[build]
build = "${RUST_BUILD}"
host = [ "${RUST_TARGET}" ]
target = [ "${RUST_TARGET}" ]
cargo = "${_rust_root}/bin/cargo"
rustc = "${_rust_root}/bin/rustc"
submodules = false
python = "python3"
locked-deps = true
vendor = true
full-bootstrap = false
local-rebuild = ${_local_rebuild}
extended = false
docs = false
tools = []
[install]
prefix = "/usr"
[rust]
codegen-units = 1
codegen-units-std = 1
debug-assertions = false
debuginfo-level = ${_use_debug}
debuginfo-level-rustc = ${_use_debug_rustc}
debuginfo-level-tests = 0
backtrace = true
incremental = false
parallel-compiler = false
channel = "stable"
rpath = ${_use_rpath}
verbose-tests = true
dist-src = false
jemalloc = false
llvm-libunwind = false
codegen-tests = false
[dist]
src-tarball = false
[target.${RUST_BUILD}]
llvm-config = "/usr/bin/llvm-config"
crt-static = false
cc = "${CC_host:-$CC}"
cxx = "${CXX_host:-$CXX}"
ar = "${AR_host:-$AR}"
linker = "${CC_host:-$CC}"
EOF
if [ "$CROSS_BUILD" ]; then
cat >> config.toml <<- EOF
[target.${RUST_TARGET}]
llvm-config = "/usr/bin/llvm-config"
crt-static = false
cc = "${CC}"
cxx = "${CXX}"
ar = "${AR}"
linker = "${CC}"
EOF
fi
}
# Set the correct CFLAGS for the build host, we have to compile libbacktrace
# for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
# of the cross host.
do_build() {
if [ ! "$build_option_static_llvm" ]; then
export LLVM_LINK_SHARED=1
fi
export RUST_BACKTRACE=1
export CARGO_HOME="$wrksrc/.cargo"
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# prevent sysroot from leaking in
export RUSTFLAGS=""
env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" \
python3 x.py dist --jobs $XBPS_MAKEJOBS
}
do_check() {
export RUST_BACKTRACE=1
python3 x.py test ${makejobs} --no-doc --no-fail-fast \
src/test/codegen \
src/test/codegen-units \
src/test/compile-fail \
src/test/incremental \
src/test/mir-opt \
src/test/pretty \
src/test/run-fail \
src/test/run-fail/pretty \
src/test/run-make \
src/test/run-make-fulldeps \
src/test/run-pass \
src/test/run-pass/pretty \
src/test/run-pass-fulldeps \
src/test/run-pass-fulldeps/pretty \
src/test/ui \
src/test/ui-fulldeps
}
do_install() {
vmkdir usr
tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz \
-C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz \
-C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
vlicense COPYRIGHT
vlicense LICENSE-APACHE
vlicense LICENSE-MIT
cd ${DESTDIR}/usr/lib
ln -sf rustlib/*/lib/*.so . # symlinks instead of copies
}
rust-doc_package() {
short_desc+=" - documentation"
archs=noarch
pkg_install() {
vmove usr/share/doc
}
}
rust-std_package() {
short_desc+=" - standard library"
pkg_install() {
vmove usr/lib/rustlib
}
}