361 lines
10 KiB
Bash
361 lines
10 KiB
Bash
# Template file for 'rust'
|
|
# partially adapted from Alpine/Adélie's Rust APKBUILD
|
|
#
|
|
# Permission to use rust and cargo trademark is granted.
|
|
# See: https://github.com/rust-lang/core-team/issues/4
|
|
#
|
|
# Always make sure custom distfiles used for bootstrap are
|
|
# uploaded to https://alpha.de.repo.voidlinux.org/distfiles/
|
|
#
|
|
pkgname=rust
|
|
version=1.48.0
|
|
revision=1
|
|
_rust_dist_version=1.48.0
|
|
wrksrc="rustc-${version}-src"
|
|
hostmakedepends="cmake curl pkg-config python3 tar"
|
|
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm11"
|
|
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="0e763e6db47d5d6f91583284d2f989eacc49b84794d1443355b85c58d67ae43b"
|
|
lib32disabled=yes
|
|
patch_args="-Np1"
|
|
|
|
build_options="bindist"
|
|
desc_option_bindist="Generate tarballs for bootstrap"
|
|
|
|
# rust upstream no longer ships cargo-versioned tarballs
|
|
# need to use the corresponding rust version instead
|
|
_bootstrap_url="https://static.rust-lang.org/dist"
|
|
_cargo_dist_version="${_rust_dist_version}"
|
|
|
|
# 32-bit gnu ppc needs custom bootstrap because of patches
|
|
case "$XBPS_MACHINE" in
|
|
x86_64*|i686|ppc64le) ;;
|
|
ppc*)
|
|
# custom bootstrap tarballs still use cargo versioning, so override
|
|
_bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles"
|
|
_cargo_dist_version="0.49.0"
|
|
;;
|
|
esac
|
|
|
|
# always use external binary cargo; this allows us to break
|
|
# the cargo<->rust cycle that appears when cross-compiling
|
|
distfiles+=" ${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
|
|
|
|
case "$XBPS_MACHINE" in
|
|
i686)
|
|
checksum+="
|
|
1eab76df91e87198632605752d0dd66f3d84b502cbd1f982f6db3d0d8d943cdb"
|
|
;;
|
|
x86_64)
|
|
checksum+="
|
|
b11d595581e2580c069b5039214e1031a0e4f87ff6490ac39f92f77857e37055"
|
|
;;
|
|
x86_64-musl)
|
|
checksum+="
|
|
8728cb7515e593f6fcf3c7afba826a92cd227a35b8e936bae892b95482d4fb90"
|
|
;;
|
|
ppc64le)
|
|
checksum+="
|
|
675321cf812a132ce707261d03aab2f5ff64788ae66b45d03bc281514f5d53ec"
|
|
;;
|
|
ppc64le-musl)
|
|
checksum+="
|
|
cf02e057f04e40458b63326e443c48924c78fc33dcb6b892643d47feb1496b09"
|
|
;;
|
|
ppc64)
|
|
checksum+="
|
|
1e7612ea1900b76924429fa04fa2c194f4213167933b481001290dd4fef27939"
|
|
;;
|
|
ppc64-musl)
|
|
checksum+="
|
|
88ffadd53e79055ba266f1303d502bcf1ef863783b121aa017930cadcd0e398d"
|
|
;;
|
|
ppc)
|
|
checksum+="
|
|
cacacdec7bfd24345804efdd1bd1682084880c3c6a086bcab85cd1186b6cd230"
|
|
;;
|
|
ppc-musl)
|
|
checksum+="
|
|
bad4a5d22da3c7548fd440d0d5a0b98e4de9894dedb35bfb58aaa5f141c23adb"
|
|
;;
|
|
*) broken="cargo bootstrap binary unavailable for ${XBPS_MACHINE}";;
|
|
esac
|
|
|
|
_bootstrap_dir="stage0-bootstrap"
|
|
|
|
# as for the rust compiler, just depend on self when crosscompiling...
|
|
# this is because if we do that, we can skip stage0 build and considerably
|
|
# cut down the build time (the local-rebuild property is enabled for cross)
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
hostmakedepends+=" rust llvm11"
|
|
# These are required for building the buildhost's stage0/1
|
|
hostmakedepends+=" libffi-devel libxml2-devel ncurses-devel zlib-devel"
|
|
else
|
|
distfiles+="
|
|
${_bootstrap_url}/rustc-${_rust_dist_version}-${RUST_BUILD}.tar.xz
|
|
${_bootstrap_url}/rust-std-${_rust_dist_version}-${RUST_BUILD}.tar.xz"
|
|
|
|
case "$XBPS_MACHINE" in
|
|
i686)
|
|
checksum+="
|
|
c241405350bf6f88224db7040012ce25351b332d6deffec07a9b5a958ab19a28
|
|
d4ea5ca6f9c8f9092b50c879f1d9a2620486f08020fa4cac227743a19f6e8cdf"
|
|
;;
|
|
x86_64)
|
|
checksum+="
|
|
fc4d292a52cbb6b84fb9f065d0d7596064a9b957381d639d5a750d6e2bf02483
|
|
1c00a6a0dabbf6290728b09f9307d9fa6cc985487f727075c68acd4a600ef3f8"
|
|
;;
|
|
x86_64-musl)
|
|
checksum+="
|
|
50c2904db7794400987487ea364392714830f287f3e596a9f8ea9df748dfa8a3
|
|
4f485d8800f90898705686b873765a4c0fe909d1127d5b091a01979bc32f01c0"
|
|
;;
|
|
ppc64le)
|
|
checksum+="
|
|
bf06c20e09c66391c19de4319de64621c82787e5e44a40ec25fb565a4c6caf28
|
|
e42b64c5710d3982f22ed744ea21ef2f0196df908c6a673b6df550904583b1c3"
|
|
;;
|
|
ppc64le-musl)
|
|
checksum+="
|
|
f6967f8afe25f6beff65f2e139babc253de2c40edf556f615e380f50b4a31da8
|
|
96311452bb46a855b7afe5883f619d4b768f14c7a5d5de01e15e146fb05d6d59"
|
|
;;
|
|
ppc64)
|
|
checksum+="
|
|
13764a670b15480d1d850cc8ae3576536265e1fcac869c1a8fa72a8ebd059193
|
|
5ce4b14e8895d995c24d3f8706ea9bb6a3ee153bd8d8cec8d808ad66e62162bc"
|
|
;;
|
|
ppc64-musl)
|
|
checksum+="
|
|
6b2485c27be4a3d390e8dd4153381304ec3883eb0d9543835b29e0a471e9d4f0
|
|
e5e513fe1e660856b4a7b133c99c23468bf781b93c69e7a098f600bcb91ce9bb"
|
|
;;
|
|
ppc)
|
|
checksum+="
|
|
4ea76c15c7225ab113c391fb7640786decf706e256fb9338e5b0c2763286777c
|
|
5682d27ffc6f6c1655987e154f5425f9114516e22b7797c9e81bf038ffffad21"
|
|
;;
|
|
ppc-musl)
|
|
checksum+="
|
|
4147cae868df4e936409331ee9e2d81d47529d05a7a2e045d7f566e09eb4f302
|
|
20132e5c67a67399e7945ba17d698a6aa1833f87b89bfc8a5a1678d75cfc637d"
|
|
;;
|
|
*) broken="rust bootstrap binaries unavailable for ${XBPS_MACHINE}";;
|
|
esac
|
|
fi
|
|
|
|
post_extract() {
|
|
mkdir -p "${wrksrc}/${_bootstrap_dir}/bin"
|
|
if [ -z "$CROSS_BUILD" ]; then
|
|
../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
|
|
fi
|
|
# cargo may not be packaged like the rest
|
|
cp ../cargo-${_cargo_dist_version}-${RUST_BUILD}/cargo/bin/cargo \
|
|
"${wrksrc}/${_bootstrap_dir}/bin"
|
|
}
|
|
|
|
# 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_bindist" ]; 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
|
|
}
|
|
|
|
do_configure() {
|
|
local _cargo_root _rust_root _local_rebuild _use_debug _use_debug_rustc _use_rpath _use_docs
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
_rust_root="/usr"
|
|
_local_rebuild="true"
|
|
else
|
|
_rust_root="${wrksrc}/${_bootstrap_dir}"
|
|
_local_rebuild="false"
|
|
fi
|
|
|
|
_cargo_root="${wrksrc}/${_bootstrap_dir}"
|
|
|
|
# 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
|
|
if [ "$build_option_bindist" ]; then
|
|
_use_rpath="true"
|
|
_use_docs="false"
|
|
else
|
|
_use_rpath="false"
|
|
_use_docs="true"
|
|
fi
|
|
|
|
cat > config.toml <<- EOF
|
|
[build]
|
|
build = "${RUST_BUILD}"
|
|
host = [ "${RUST_TARGET}" ]
|
|
target = [ "${RUST_TARGET}" ]
|
|
cargo = "${_cargo_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 = ${_use_docs}
|
|
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_bindist" ]; 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/ui \
|
|
src/test/ui-fulldeps
|
|
}
|
|
|
|
do_install() {
|
|
if [ "$build_option_bindist" ]; then
|
|
mkdir -p ${XBPS_SRCDISTDIR}/distfiles
|
|
install -m 0644 \
|
|
build/dist/rustc-${version}-${RUST_TARGET}.tar.xz \
|
|
build/dist/rust-std-${version}-${RUST_TARGET}.tar.xz \
|
|
${XBPS_SRCDISTDIR}/distfiles
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
tar xf build/dist/rustc-dev-${version}-${RUST_TARGET}.tar.gz \
|
|
-C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
|
|
tar xf build/dist/rust-docs-${version}-${RUST_TARGET}.tar.gz \
|
|
-C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
|
|
|
|
vlicense COPYRIGHT
|
|
vlicense LICENSE-APACHE
|
|
vlicense LICENSE-MIT
|
|
|
|
cd ${DESTDIR}/usr/lib
|
|
# symlinks instead of copies
|
|
mv *.so rustlib/${RUST_TARGET}/lib
|
|
ln -sf rustlib/${RUST_TARGET}/lib/*.so .
|
|
}
|
|
|
|
rust-doc_package() {
|
|
short_desc+=" - documentation"
|
|
pkg_install() {
|
|
vmove usr/share/doc
|
|
}
|
|
}
|
|
|
|
rust-std_package() {
|
|
short_desc+=" - standard library"
|
|
pkg_install() {
|
|
vmove usr/lib/rustlib
|
|
}
|
|
}
|