915d6e2fc0
This reverts commit ebd8f5c2c5
.
312 lines
9.2 KiB
Bash
312 lines
9.2 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
|
|
pkgname=rust
|
|
version=1.46.0
|
|
revision=1
|
|
_rust_dist_version=1.45.2
|
|
_cargo_dist_version=0.46.1
|
|
# 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 tar"
|
|
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel llvm10"
|
|
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="2d6a3b7196db474ba3f37b8f5d50a1ecedff00738d7846840605b42bfc922728"
|
|
lib32disabled=yes
|
|
patch_args="-Np1"
|
|
|
|
build_options="bindist"
|
|
desc_option_bindist="Generate tarballs for bootstrap"
|
|
|
|
_bootstrap_dir="stage0-bootstrap"
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
hostmakedepends+=" cargo llvm10"
|
|
# 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+="
|
|
72676b7bb6a6ad056af2ad5459b1ac3992b7a65b823ed7f00d4af72266e0f1ad
|
|
05474dbec0385c8dcfd940e6f8954d4f8284745a4fbcf57932022b1593829463
|
|
8931dba1c23405fe630aa4ca2aceaba7de74c21cc03947c757b349d004d6a4d6"
|
|
;;
|
|
x86_64)
|
|
checksum+="
|
|
0be5c8506fd9317c7d0dc8044b5fef8501caa74f88a9a22be795d68362dc57f6
|
|
02309322467af8e37256ccf1f064f5233c7fca4423dffde0bd5eb32cde46942a
|
|
a27eb5d47b520ef2c554605bf789f80652af63531b4f6a1195d61b3dfd0f6e9c"
|
|
;;
|
|
x86_64-musl)
|
|
checksum+="
|
|
9a971ff29e01243b08f6f3c220ab5d608489637a6b5d81ba2e8a78007901ced0
|
|
e8081032d53baa129c41c4c2bfb025648ac321c9c809f377110f8a26f7ce1cdb
|
|
895a3b6928a5bf7b1ac28c339a85ddd078dd719f54245b8d845370baf8255368"
|
|
;;
|
|
ppc64le)
|
|
checksum+="
|
|
68af3485558636be870a067d0e1196ee34664de1b6e5e6f68aed926c0906574d
|
|
0a000c2e047c675bee27c2287b2e03fe21148ead95c35b884846a8dc7c3c162d
|
|
93354ae5cedaa75d44928d5e232cd9a57a9164cadf47d4a30493c05e60b59b7f"
|
|
;;
|
|
ppc64le-musl)
|
|
checksum+="
|
|
158338268de72108b35ea7b018d99f08be8e7340996a12dc2f4682e06f148fc5
|
|
5c1225e6fb029008584f4d1813ddcd1bccce2c329b398a02b3bd6ea4e6d9e128
|
|
12da677338f860362e00089fe5b67ecd619c0ae4a4ca2bd14e500df32f598f49"
|
|
;;
|
|
ppc64)
|
|
checksum+="
|
|
d474ecedc0783081fa025742b92c459a12f97d2ffc87a83c143df0fa9f4d7212
|
|
60e32e91c9da0263f69c2b41ba5aa0953b2026fb11118bd1595db062a8c5fa62
|
|
eab0c2d96f863e3c87afc46d43c54df6614af333b98ee881278acf56d9bf3fe8"
|
|
;;
|
|
ppc64-musl)
|
|
checksum+="
|
|
1eecbc8f719a41c905b85dd3723f09e2999cc468deaf4f127614310f0634931f
|
|
8abdd395a4448c96e64b881921fc0bba0fdb5da133b1973962018316e8fb5cfa
|
|
48770d0f7941005c87c0ddf303a7eca2fcff4c56cfdaaf60b5d862dfeee2a59d"
|
|
;;
|
|
ppc)
|
|
checksum+="
|
|
772db024e310835f3a967f6e5a147564f3633c8173e88516f2484d9f1d914f6b
|
|
e2c0e48421b0e6da709686e8d2a94852821ad483f1f74f27c48c08d012c917ad
|
|
034af894e980f642e31d35978d8cbb8839fe9c8f1119083a720a58f7ad7fb881"
|
|
;;
|
|
ppc-musl)
|
|
checksum+="
|
|
11d34ff8cca6e76e2b307898bc11858f70e5bdadd2746506aa92923d19e03358
|
|
5c5c3e917339084230ee56b47a9a51fd4e89c5d7227b32f0636b92edd9031980
|
|
aac08878b9ce3bf7dff4247e988fdaddeaa410cccc8559f8e7e0fd45d8f2ece5"
|
|
;;
|
|
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_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
|
|
_clear_vendor_checksums backtrace-sys
|
|
_clear_vendor_checksums lzma-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
|
|
if [ "$build_option_bindist" ]; then
|
|
_use_rpath="true"
|
|
else
|
|
_use_rpath="false"
|
|
fi
|
|
|
|
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_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
|
|
|
|
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"
|
|
archs=noarch
|
|
pkg_install() {
|
|
vmove usr/share/doc
|
|
}
|
|
}
|
|
|
|
rust-std_package() {
|
|
short_desc+=" - standard library"
|
|
pkg_install() {
|
|
vmove usr/lib/rustlib
|
|
}
|
|
}
|