2018-12-26 19:59:18 +11:00
|
|
|
# Description: The Rust language with Cargo included.
|
2020-06-21 20:21:42 +10:00
|
|
|
# URL: https://www.rust-lang.org/
|
2018-12-26 19:59:18 +11:00
|
|
|
# Maintainer: Danny Rawlins, crux at romster dot me
|
2021-05-08 13:29:36 +10:00
|
|
|
# Depends on: compiler-rt
|
2021-10-01 18:54:29 +10:00
|
|
|
# Optional: sccache ccache libgit2 lld polly
|
2018-12-26 19:59:18 +11:00
|
|
|
|
|
|
|
name=rust
|
2022-01-14 23:14:02 +01:00
|
|
|
version=1.58.0
|
|
|
|
_date=2021-12-02
|
|
|
|
_rustc=1.57.0
|
2021-03-27 17:50:54 +11:00
|
|
|
_cargo=$_rustc
|
|
|
|
release=1
|
2021-01-02 21:52:18 +11:00
|
|
|
source=(https://static.rust-lang.org/dist/${name}c-$version-src.tar.xz
|
2020-03-27 23:32:48 +11:00
|
|
|
https://static.rust-lang.org/dist/$_date/rust-std-$_rustc-x86_64-unknown-linux-gnu.tar.xz
|
|
|
|
https://static.rust-lang.org/dist/$_date/rustc-$_rustc-x86_64-unknown-linux-gnu.tar.xz
|
2021-03-27 17:50:54 +11:00
|
|
|
https://static.rust-lang.org/dist/$_date/cargo-$_cargo-x86_64-unknown-linux-gnu.tar.xz
|
2021-06-18 22:47:56 +10:00
|
|
|
libexec.patch
|
2021-08-30 21:00:09 +10:00
|
|
|
0002-compiler-Change-LLVM-targets.patch)
|
2020-03-27 23:32:48 +11:00
|
|
|
|
|
|
|
unpack_source() {
|
|
|
|
for file in ${source[@]}; do
|
|
|
|
case ${file##*/} in
|
2021-05-08 13:29:36 +10:00
|
|
|
rustc-${version}-src.tar.xz)
|
2020-03-27 23:32:48 +11:00
|
|
|
echo "Unpacking $(get_filename $file)";
|
2020-08-30 00:17:08 +10:00
|
|
|
bsdtar -p -o -C ${SRC} -xf $(get_filename $file) ;;
|
2020-03-27 23:32:48 +11:00
|
|
|
*.tar.xz)
|
|
|
|
echo "Copying $(get_filename $file)";
|
2020-08-30 00:17:08 +10:00
|
|
|
mkdir -p ${SRC}/${name}c-$version-src/build/cache/${_date} || true
|
|
|
|
cp $(get_filename $file) ${SRC}/${name}c-$version-src/build/cache/${_date} ;;
|
2020-03-27 23:32:48 +11:00
|
|
|
*)
|
2020-08-30 00:17:08 +10:00
|
|
|
cp $(get_filename $file) ${SRC} ;;
|
2020-03-27 23:32:48 +11:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-12-04 15:16:46 +01:00
|
|
|
_check_version() {
|
|
|
|
local ERROR
|
|
|
|
local DATE="$(awk '/^.*"date": / {gsub(/"|,/, "", $2); print $2 }' $SRC/${name}c-$version-src/src/stage0.json)"
|
|
|
|
local RUSTC="$(awk '/^.*"version": / {gsub(/"|,/, "", $2); print $2 }' $SRC/${name}c-$version-src/src/stage0.json)"
|
2018-12-26 19:59:18 +11:00
|
|
|
|
2021-12-04 15:16:46 +01:00
|
|
|
printf '\033[0;32m%s\033[0m\n' "Checking versions for bootstrap compiler.."
|
|
|
|
printf '\033[0;32m%s\033[0m\n' "Got _date = $_date && _rustc = $_rustc"
|
2021-02-14 00:28:47 +11:00
|
|
|
|
2019-10-11 20:37:45 +11:00
|
|
|
if [ "$DATE" != "$_date" ]; then
|
2021-12-04 15:16:46 +01:00
|
|
|
printf '\e[1;31m%-6s\e[m\n' "Error: _date $_date != $DATE"
|
2019-10-11 20:37:45 +11:00
|
|
|
ERROR=1
|
|
|
|
fi
|
|
|
|
if [ "$RUSTC" != "$_rustc" ]; then
|
2021-12-04 15:16:46 +01:00
|
|
|
printf '\e[1;31m%-6s\e[m\n' "Error: _rustc $_rustc != $RUSTC"
|
2019-10-11 20:37:45 +11:00
|
|
|
ERROR=1
|
|
|
|
fi
|
2021-12-04 15:16:46 +01:00
|
|
|
|
2019-10-11 20:37:45 +11:00
|
|
|
[ $ERROR ] && exit 1
|
2021-12-04 15:16:46 +01:00
|
|
|
printf '\033[0;32m%s\033[0m\n' "Versions check out! Proceeding.."
|
2021-01-02 21:52:18 +11:00
|
|
|
unset DATE RUSTC ERROR
|
2021-12-04 15:16:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
_check_version
|
|
|
|
|
|
|
|
cd "${name}c-$version-src"
|
|
|
|
|
|
|
|
# Patch cargo so credential helpers are in /usr/lib instead of /usr/libexec
|
|
|
|
patch -p1 -i $SRC/libexec.patch
|
|
|
|
|
|
|
|
# Use our *-pc-linux-gnu targets, making LTO with clang simpler
|
|
|
|
patch -p1 -i $SRC/0002-compiler-Change-LLVM-targets.patch
|
2019-10-11 20:37:45 +11:00
|
|
|
|
2018-12-26 19:59:18 +11:00
|
|
|
cat <<- EOF > $SRC/config.toml
|
2021-09-25 23:59:34 +10:00
|
|
|
changelog-seen = 2
|
|
|
|
|
2018-12-26 19:59:18 +11:00
|
|
|
[llvm]
|
2019-02-15 21:00:35 +11:00
|
|
|
ninja = true
|
2019-04-17 01:24:08 +10:00
|
|
|
link-shared = true
|
2021-10-01 18:54:29 +10:00
|
|
|
@POLLY@
|
2021-01-02 21:52:18 +11:00
|
|
|
@CCACHE@
|
2018-12-26 19:59:18 +11:00
|
|
|
|
|
|
|
[install]
|
|
|
|
prefix = "/usr"
|
|
|
|
|
|
|
|
[rust]
|
2021-08-30 21:00:09 +10:00
|
|
|
# LLVM crashes when passing an object through ThinLTO twice. This is triggered
|
|
|
|
# when using rust code in cross-language LTO if libstd was built using ThinLTO.
|
|
|
|
# http://blog.llvm.org/2019/09/closing-gap-cross-language-lto-between.html
|
|
|
|
# https://github.com/rust-lang/rust/issues/54872
|
|
|
|
codegen-units-std = 1
|
|
|
|
debuginfo-level-std = 2
|
2021-10-03 15:57:36 +02:00
|
|
|
codegen-tests = false
|
|
|
|
|
|
|
|
description = "CRUX"
|
2018-12-26 19:59:18 +11:00
|
|
|
channel = "stable"
|
2021-09-25 23:59:34 +10:00
|
|
|
parallel-compiler = true
|
2018-12-26 19:59:18 +11:00
|
|
|
rpath = false
|
2021-10-01 18:54:29 +10:00
|
|
|
optimize = true
|
|
|
|
@LLD@
|
2018-12-26 19:59:18 +11:00
|
|
|
|
|
|
|
[build]
|
2020-08-30 00:17:08 +10:00
|
|
|
target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
|
2021-10-01 18:54:29 +10:00
|
|
|
tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src", "rust-demangler"]
|
2019-02-15 21:00:35 +11:00
|
|
|
docs = false
|
2018-12-26 19:59:18 +11:00
|
|
|
extended = true
|
2021-10-01 18:54:29 +10:00
|
|
|
sanitizers = true
|
2020-08-30 00:17:08 +10:00
|
|
|
profiler = true
|
|
|
|
vendor = true
|
|
|
|
python = "/usr/bin/python3"
|
|
|
|
@CARGO@
|
|
|
|
@RUST@
|
2021-08-30 21:00:09 +10:00
|
|
|
@RUSTFMT@
|
2020-08-30 00:17:08 +10:00
|
|
|
|
|
|
|
[target.x86_64-unknown-linux-gnu]
|
|
|
|
llvm-config = "/usr/bin/llvm-config"
|
2021-08-30 21:00:09 +10:00
|
|
|
llvm-filecheck = "/usr/bin/FileCheck"
|
2018-12-26 19:59:18 +11:00
|
|
|
EOF
|
2020-08-30 00:17:08 +10:00
|
|
|
|
2020-04-26 18:59:40 +10:00
|
|
|
if [ -e '/usr/bin/rustc' ]; then
|
2021-10-01 18:54:29 +10:00
|
|
|
if [[ -z "$(/usr/bin/ldd /usr/bin/rustc | egrep '.*libLLVM.*.so => not found')" && \
|
|
|
|
-z "$(/usr/bin/ldd /usr/bin/cargo | egrep 'libgit2.so.* => not found')" ]]; then
|
|
|
|
|
2020-08-30 00:17:08 +10:00
|
|
|
sed -e 's|@CARGO@|cargo = "/usr/bin/cargo"|' \
|
|
|
|
-e 's|@RUST@|rustc = "/usr/bin/rustc"|' \
|
2021-08-30 21:00:09 +10:00
|
|
|
-e 's|@RUSTFMT@|rustfmt = "/usr/bin/rustfmt"|' \
|
2020-08-30 00:17:08 +10:00
|
|
|
-i $SRC/config.toml
|
2019-06-04 00:20:39 +10:00
|
|
|
else
|
2021-08-30 21:00:09 +10:00
|
|
|
sed -e 's|@CARGO@||' -e 's|@RUST@||' -e 's|@RUSTFMT@||' -i $SRC/config.toml
|
2021-10-01 18:54:29 +10:00
|
|
|
printf "\e[031mShared library missing, not using system rust to bootstrap.\033[0m\n"
|
2019-06-04 00:20:39 +10:00
|
|
|
fi
|
2020-08-30 00:17:08 +10:00
|
|
|
else
|
2021-08-30 21:00:09 +10:00
|
|
|
sed -e 's|@CARGO@||' -e 's|@RUST@||' -e 's|@RUSTFMT@||' -i $SRC/config.toml
|
2018-12-26 19:59:18 +11:00
|
|
|
fi
|
|
|
|
|
2021-01-02 21:52:18 +11:00
|
|
|
if [ -e '/usr/bin/ccache' ]; then
|
|
|
|
sed -e 's|@CCACHE@|ccache = "/usr/bin/ccache"|' -i $SRC/config.toml
|
|
|
|
else
|
|
|
|
sed -e 's|@CCACHE@||' -i $SRC/config.toml
|
|
|
|
fi
|
|
|
|
|
2021-10-01 18:54:29 +10:00
|
|
|
prt-get isinst lld && sed -e 's|@LLD@|use-lld = true|' -i $SRC/config.toml || sed -e 's|@LLD@||' -i $SRC/config.toml
|
|
|
|
prt-get isinst polly && sed -e 's|@POLLY@|polly = true|' -i $SRC/config.toml || sed -e 's|@POLLY@||' -i $SRC/config.toml
|
|
|
|
|
2018-12-26 19:59:18 +11:00
|
|
|
cat $SRC/config.toml
|
|
|
|
|
2019-05-18 21:19:04 +10:00
|
|
|
mkdir "$PKGMK_SOURCE_DIR/rust" || true
|
|
|
|
export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
|
2018-12-26 19:59:18 +11:00
|
|
|
|
2021-10-03 15:57:36 +02:00
|
|
|
if [ -e '/usr/bin/sccache' ]; then
|
|
|
|
export RUSTC_WRAPPER='/usr/bin/sccache'
|
|
|
|
export SCCACHE_IDLE_TIMEOUT='1500'
|
|
|
|
fi
|
2019-02-15 21:00:35 +11:00
|
|
|
|
2021-12-05 14:05:24 +11:00
|
|
|
#error: field is never read: `id`
|
|
|
|
# --> src/bootstrap/lib.rs:280:5
|
|
|
|
# = note: `-D dead-code` implied by `-D warnings`
|
2021-12-05 14:12:09 +11:00
|
|
|
export RUSTFLAGS+=' -A dead_code'
|
2021-12-05 14:05:24 +11:00
|
|
|
|
2021-10-03 15:57:36 +02:00
|
|
|
export LIBGIT2_NO_PKG_CONFIG=1
|
2021-06-18 22:47:56 +10:00
|
|
|
export RUST_BACKTRACE=full
|
2021-05-08 13:29:36 +10:00
|
|
|
/usr/bin/python3 ./x.py build --config="${SRC}"/config.toml -j ${JOBS-1}
|
2018-12-26 19:59:18 +11:00
|
|
|
DESTDIR=$PKG /usr/bin/python3 ./x.py --config="${SRC}"/config.toml install
|
|
|
|
|
2020-03-27 23:32:48 +11:00
|
|
|
[ -e '/usr/bin/zsh' ] || rm -r $PKG/usr/share/zsh
|
|
|
|
|
|
|
|
# cleanup
|
2018-12-26 19:59:18 +11:00
|
|
|
rm -r $PKG/usr/share/doc
|
|
|
|
rm -r $PKG/etc
|
|
|
|
rm $PKG/usr/lib/rustlib/{components,manifest-rustc,rust-installer-version,uninstall.sh}
|
2020-06-20 17:33:25 +10:00
|
|
|
|
|
|
|
# Remove analysis data for libs that weren't installed
|
|
|
|
local file lib
|
|
|
|
while read -rd '' file; do
|
|
|
|
lib="${file%.json}.rlib"
|
|
|
|
lib="${lib/\/analysis\///lib/}"
|
|
|
|
if [[ ! -e $lib ]]; then
|
|
|
|
echo "missing '$lib'"
|
|
|
|
rm -v "$file"
|
|
|
|
fi
|
|
|
|
done < <(find "$PKG/usr/lib/rustlib" -path '*/analysis/*.json' -print0)
|
2020-09-01 21:21:47 +10:00
|
|
|
|
|
|
|
install -d $PKG/etc/revdep.d
|
2021-01-02 21:52:18 +11:00
|
|
|
echo "/usr/lib/rustlib/i686-unknown-linux-gnu/lib" > $PKG/etc/revdep.d/$name
|
2018-12-26 19:59:18 +11:00
|
|
|
}
|