void-packages/srcpkgs/rust/template
Johannes bf995fb765 rust: update to 1.34.2.
[ci skip]
2019-05-15 08:12:56 +02:00

243 lines
8.2 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.34.2
revision=1
_rust_dist_version=1.33.0
_cargo_dist_version=0.33.0
# NB. if you push any(!) new version, don't forget to put a build
# output of musl to https://alpha.de.repo.voidlinux.org/distfiles/
wrksrc="rustc-${version}-src"
build_style=configure
make_build_args="dist VERBOSE=1"
hostmakedepends="cmake curl pkg-config python"
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel
$(vopt_if internal_llvm python-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=c69a4a85a1c464368597df8878cb9e1121aae93e215616d45ad7d23af3052f56
lib32disabled=yes
patch_args="-Np1"
build_options="internal_llvm"
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo $(vopt_if internal_llvm '' llvm)"
# These are required for building the buildhost's stage0/1
hostmakedepends+=" libffi-devel libxml2-devel
ncurses-devel zlib-devel"
else
case "$XBPS_MACHINE" in
x86_64-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
checksum+="
27133fe50d7f43009b802d608654c828e4589cf27810fd7151b67de7de3706e0
6971b0b9147371eaf81ece7ac6ee91d2f7adbbd3129b9a80170f394c9a35636a
7d3e669dc5ddde7529ab0df2d0397648a679426fc56dd4c93d94f84fd68366d5"
;;
x86_64)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
checksum+="
54a342f718b712d8a17fd7878ebd37d22a82ebc70b59c421168cd4153fd04c2b
661c2ba717ae1502f002b4c6e7aeb8941685c7ea8fe7ac26ed9ede26f615b7af
c2c31db68c4dcb50ad856a19e6f11489a0d4df1212f31bd068dfbb73c5425761"
;;
i686)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
checksum+="
be4cdc82b511b0f2499fc9b7048b01069257ca2dedb270a7938e1846beb5a349
f4bba5b77c61a30f0a4c83e152f216c62f974185c4c012c295a5d19d44381a62
13acdb3c9f2505805ceed8a696f5f62ab8cd73e443cd43d6edd588aad88e1c32"
;;
ppc64le)
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
checksum+="
75ef3992b3de501f0b3442315e6ddef9d6f10070174fdd0f3d62e87534fddbc5
984d3ca2a47db04345a2bddd657761f66d209ef95a02097ad4bd549f45a0dc9f
03ece4d677ad59f08a514eb90dd3bd6cad4399fbbaf3d0e916323fbce38e25d1"
;;
ppc64le-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
checksum+="
f3a493414b07e9b1b535269cd39552ece586ccad3bfadddd92a952e08179844d
698dbec4d359bb4a378eef807035c9b0b4fffe478e50af044ae47b485b9b6f8e
801490f04eac96e883f56434747042c375aa3d210b224c2735e02a3a1eab95a0"
;;
ppc64-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
checksum+="
56805b5a8a7a2d07937ab12a00154a64bf756d0c85d0d69573bc27365fc3157b
e9e15702928f2633b1b971911c992c5ed5c552cf4a05f40bc177e53daa05a764
ae90844974681c3ee85a855ae0ed27f06d22215e40f825f3b7ca705d8a7cfe7b"
;;
esac
fi
post_extract() {
if [ -z "$CROSS_BUILD" ]; then
mkdir -p stage0
rm ../rustc-*/rustc/manifest.in
cp -bflr ../rustc-*/rustc/* stage0
rm ../rust-std-*/rust-std-*/manifest.in
cp -bflr ../rust-std-*/rust-std-*/* stage0
case "$XBPS_MACHINE" in
*-musl|ppc64*) cp -bflr ../cargo stage0/bin;;
*)
rm ../cargo-*/cargo/manifest.in
cp -flr ../cargo-*/cargo/* stage0
;;
esac
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() {
if [ "$build_option_internal_llvm" ]; then
# patches for Rust's bundled LLVM
pushd src/llvm-project/llvm
for x in ${FILESDIR}/patches/internal-llvm/llvm-*.patch; do
msg_normal "Applying $x to llvm\n"
patch -sNp1 -i ${x}
done
popd
else
rm -rf src/llvm-project
# patches for system LLVM
for x in ${FILESDIR}/patches/sys-llvm/*.patch; do
msg_normal "Applying patch $x\n"
patch -sNp1 -i ${x}
done
fi
sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
# clear out all the checksum nonsense of patched vendor crates
_clear_vendor_checksums libc
_clear_vendor_checksums lzma-sys
}
do_configure() {
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
configure_args="
--prefix=/usr
--host=${RUST_TARGET}
--target=${RUST_TARGET}
--build=${RUST_BUILD}
--disable-full-bootstrap
--release-channel=stable
--disable-rpath
--disable-docs
--disable-codegen-tests
--enable-vendor
"
if ! [ "$build_option_internal_llvm" ]; then
configure_args+="
--llvm-root=/usr
--set=target.${RUST_BUILD}.llvm-config=/usr/bin/llvm-config
--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
--enable-llvm-link-shared
"
fi
if [ "$CROSS_BUILD" ]; then
configure_args+="
--local-rust-root=/usr
--enable-local-rebuild
"
# Set the appropriate values for the native compilation tools
configure_args+="
--set=target.${RUST_BUILD}.cc=${CC_host}
--set=target.${RUST_BUILD}.cxx=${CXX_host}
--set=target.${RUST_BUILD}.ar=${AR_host}
--set=target.${RUST_BUILD}.linker=${CC_host}
"
else
configure_args+=" --local-rust-root=$wrksrc/stage0"
fi
case "$XBPS_TARGET_MACHINE" in
*-musl)
configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
;;
esac
./configure $configure_args
}
pre_build() {
export CARGO_HOME="$wrksrc/.cargo"
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
export PATH="$wrksrc/stage0/bin:$PATH"
export MUSL_ROOT=/usr
export RUST_BACKTRACE=1
export RUSTFLAGS="-C linker=${CC}"
}
# 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.
# Unset LDFLAGS, otherwise cross builds to the same arch will fail
do_build() {
env CFLAGS_${RUST_BUILD}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
}
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
}
}