2018-12-26 09:59:18 +01:00
|
|
|
# Description: The Rust language with Cargo included.
|
2020-06-21 12:21:42 +02:00
|
|
|
# URL: https://www.rust-lang.org/
|
2018-12-26 09:59:18 +01:00
|
|
|
# Maintainer: Danny Rawlins, crux at romster dot me
|
2021-05-08 05:29:36 +02:00
|
|
|
# Depends on: compiler-rt
|
2021-10-01 10:54:29 +02:00
|
|
|
# Optional: sccache ccache libgit2 lld polly
|
2018-12-26 09:59:18 +01:00
|
|
|
|
|
|
|
name=rust
|
2021-11-01 16:40:01 +01:00
|
|
|
version=1.56.1
|
2021-10-26 13:30:28 +02:00
|
|
|
_date=2021-09-09
|
|
|
|
_rustc=1.55.0
|
2021-03-27 07:50:54 +01:00
|
|
|
_cargo=$_rustc
|
|
|
|
release=1
|
2021-01-02 11:52:18 +01:00
|
|
|
source=(https://static.rust-lang.org/dist/${name}c-$version-src.tar.xz
|
2020-03-27 13:32:48 +01: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 07:50:54 +01:00
|
|
|
https://static.rust-lang.org/dist/$_date/cargo-$_cargo-x86_64-unknown-linux-gnu.tar.xz
|
2021-06-18 14:47:56 +02:00
|
|
|
libexec.patch
|
2021-08-30 13:00:09 +02:00
|
|
|
0002-compiler-Change-LLVM-targets.patch)
|
2020-03-27 13:32:48 +01:00
|
|
|
|
|
|
|
unpack_source() {
|
|
|
|
for file in ${source[@]}; do
|
|
|
|
case ${file##*/} in
|
2021-05-08 05:29:36 +02:00
|
|
|
rustc-${version}-src.tar.xz)
|
2020-03-27 13:32:48 +01:00
|
|
|
echo "Unpacking $(get_filename $file)";
|
2020-08-29 16:17:08 +02:00
|
|
|
bsdtar -p -o -C ${SRC} -xf $(get_filename $file) ;;
|
2020-03-27 13:32:48 +01:00
|
|
|
*.tar.xz)
|
|
|
|
echo "Copying $(get_filename $file)";
|
2020-08-29 16:17:08 +02: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 13:32:48 +01:00
|
|
|
*)
|
2020-08-29 16:17:08 +02:00
|
|
|
cp $(get_filename $file) ${SRC} ;;
|
2020-03-27 13:32:48 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-12-26 09:59:18 +01:00
|
|
|
build() {
|
|
|
|
cd "${name}c-$version-src"
|
|
|
|
|
2021-02-13 14:28:47 +01:00
|
|
|
# Patch cargo so credential helpers are in /usr/lib instead of /usr/libexec
|
|
|
|
patch -p1 -i $SRC/libexec.patch
|
|
|
|
|
2021-08-30 13:00:09 +02:00
|
|
|
# Use our *-pc-linux-gnu targets, making LTO with clang simpler
|
|
|
|
patch -p1 -i $SRC/0002-compiler-Change-LLVM-targets.patch
|
2021-06-18 14:47:56 +02:00
|
|
|
|
2019-10-11 11:37:45 +02:00
|
|
|
local ERROR
|
|
|
|
local DATE="$(awk '/^date: / { print $2 }' src/stage0.txt)"
|
|
|
|
local RUSTC="$(awk '/^rustc: / { print $2 }' src/stage0.txt)"
|
|
|
|
if [ "$DATE" != "$_date" ]; then
|
|
|
|
printf "\e[031mError: _date $_date != $DATE\033[0m\n"
|
|
|
|
ERROR=1
|
|
|
|
fi
|
|
|
|
if [ "$RUSTC" != "$_rustc" ]; then
|
|
|
|
printf "\e[031mError: _rustc $_rustc != $RUSTC\033[0m\n"
|
|
|
|
ERROR=1
|
|
|
|
fi
|
|
|
|
[ $ERROR ] && exit 1
|
2021-01-02 11:52:18 +01:00
|
|
|
unset DATE RUSTC ERROR
|
2019-10-11 11:37:45 +02:00
|
|
|
|
2018-12-26 09:59:18 +01:00
|
|
|
cat <<- EOF > $SRC/config.toml
|
2021-09-25 15:59:34 +02:00
|
|
|
changelog-seen = 2
|
|
|
|
|
2018-12-26 09:59:18 +01:00
|
|
|
[llvm]
|
2019-02-15 11:00:35 +01:00
|
|
|
ninja = true
|
2019-04-16 17:24:08 +02:00
|
|
|
link-shared = true
|
2021-10-01 10:54:29 +02:00
|
|
|
@POLLY@
|
2021-01-02 11:52:18 +01:00
|
|
|
@CCACHE@
|
2018-12-26 09:59:18 +01:00
|
|
|
|
|
|
|
[install]
|
|
|
|
prefix = "/usr"
|
|
|
|
|
|
|
|
[rust]
|
2021-08-30 13:00:09 +02: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 09:59:18 +01:00
|
|
|
channel = "stable"
|
2021-09-25 15:59:34 +02:00
|
|
|
parallel-compiler = true
|
2018-12-26 09:59:18 +01:00
|
|
|
rpath = false
|
2021-10-01 10:54:29 +02:00
|
|
|
optimize = true
|
|
|
|
@LLD@
|
2018-12-26 09:59:18 +01:00
|
|
|
|
|
|
|
[build]
|
2020-08-29 16:17:08 +02:00
|
|
|
target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
|
2021-10-01 10:54:29 +02:00
|
|
|
tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src", "rust-demangler"]
|
2019-02-15 11:00:35 +01:00
|
|
|
docs = false
|
2018-12-26 09:59:18 +01:00
|
|
|
extended = true
|
2021-10-01 10:54:29 +02:00
|
|
|
sanitizers = true
|
2020-08-29 16:17:08 +02:00
|
|
|
profiler = true
|
|
|
|
vendor = true
|
|
|
|
python = "/usr/bin/python3"
|
|
|
|
@CARGO@
|
|
|
|
@RUST@
|
2021-08-30 13:00:09 +02:00
|
|
|
@RUSTFMT@
|
2020-08-29 16:17:08 +02:00
|
|
|
|
|
|
|
[target.x86_64-unknown-linux-gnu]
|
|
|
|
llvm-config = "/usr/bin/llvm-config"
|
2021-08-30 13:00:09 +02:00
|
|
|
llvm-filecheck = "/usr/bin/FileCheck"
|
2018-12-26 09:59:18 +01:00
|
|
|
EOF
|
2020-08-29 16:17:08 +02:00
|
|
|
|
2020-04-26 10:59:40 +02:00
|
|
|
if [ -e '/usr/bin/rustc' ]; then
|
2021-10-01 10:54:29 +02: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-29 16:17:08 +02:00
|
|
|
sed -e 's|@CARGO@|cargo = "/usr/bin/cargo"|' \
|
|
|
|
-e 's|@RUST@|rustc = "/usr/bin/rustc"|' \
|
2021-08-30 13:00:09 +02:00
|
|
|
-e 's|@RUSTFMT@|rustfmt = "/usr/bin/rustfmt"|' \
|
2020-08-29 16:17:08 +02:00
|
|
|
-i $SRC/config.toml
|
2019-06-03 16:20:39 +02:00
|
|
|
else
|
2021-08-30 13:00:09 +02:00
|
|
|
sed -e 's|@CARGO@||' -e 's|@RUST@||' -e 's|@RUSTFMT@||' -i $SRC/config.toml
|
2021-10-01 10:54:29 +02:00
|
|
|
printf "\e[031mShared library missing, not using system rust to bootstrap.\033[0m\n"
|
2019-06-03 16:20:39 +02:00
|
|
|
fi
|
2020-08-29 16:17:08 +02:00
|
|
|
else
|
2021-08-30 13:00:09 +02:00
|
|
|
sed -e 's|@CARGO@||' -e 's|@RUST@||' -e 's|@RUSTFMT@||' -i $SRC/config.toml
|
2018-12-26 09:59:18 +01:00
|
|
|
fi
|
|
|
|
|
2021-01-02 11:52:18 +01: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 10:54:29 +02: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 09:59:18 +01:00
|
|
|
cat $SRC/config.toml
|
|
|
|
|
2019-05-18 13:19:04 +02:00
|
|
|
mkdir "$PKGMK_SOURCE_DIR/rust" || true
|
|
|
|
export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
|
2018-12-26 09:59:18 +01: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 11:00:35 +01:00
|
|
|
|
2021-10-03 15:57:36 +02:00
|
|
|
export LIBGIT2_NO_PKG_CONFIG=1
|
2021-06-18 14:47:56 +02:00
|
|
|
export RUST_BACKTRACE=full
|
2021-05-08 05:29:36 +02:00
|
|
|
/usr/bin/python3 ./x.py build --config="${SRC}"/config.toml -j ${JOBS-1}
|
2018-12-26 09:59:18 +01:00
|
|
|
DESTDIR=$PKG /usr/bin/python3 ./x.py --config="${SRC}"/config.toml install
|
|
|
|
|
2020-03-27 13:32:48 +01:00
|
|
|
[ -e '/usr/bin/zsh' ] || rm -r $PKG/usr/share/zsh
|
|
|
|
|
|
|
|
# cleanup
|
2018-12-26 09:59:18 +01: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 09:33:25 +02: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 13:21:47 +02:00
|
|
|
|
|
|
|
install -d $PKG/etc/revdep.d
|
2021-01-02 11:52:18 +01:00
|
|
|
echo "/usr/lib/rustlib/i686-unknown-linux-gnu/lib" > $PKG/etc/revdep.d/$name
|
2018-12-26 09:59:18 +01:00
|
|
|
}
|