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/
|
2023-03-10 11:58:29 +01:00
|
|
|
# Maintainer: CRUX System Team, core-ports at crux dot nu
|
2021-05-08 13:29:36 +10:00
|
|
|
# Depends on: compiler-rt
|
2023-10-06 14:29:02 +02:00
|
|
|
# Optional: ccache clang libgit2 lld polly sccache
|
2018-12-26 19:59:18 +11:00
|
|
|
|
|
|
|
name=rust
|
2024-05-04 19:14:35 +02:00
|
|
|
version=1.78.0
|
|
|
|
_date=2024-03-21
|
|
|
|
_rustc=1.77.0
|
2021-03-27 17:50:54 +11:00
|
|
|
_cargo=$_rustc
|
2024-03-22 01:39:07 +01:00
|
|
|
release=1
|
2022-02-05 16:00:17 +01:00
|
|
|
|
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
|
2022-05-21 12:20:18 +02:00
|
|
|
0001-bootstrap-Change-libexec-dir.patch
|
2024-03-22 01:39:07 +01:00
|
|
|
0002-bootstrap-Change-bash-completion-dir.patch
|
|
|
|
0003-compiler-Change-LLVM-targets.patch
|
2023-10-06 14:29:02 +02:00
|
|
|
0004-compiler-Use-wasm-ld-for-wasm-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)
|
2022-12-17 11:40:44 +00:00
|
|
|
echo "Unpacking $(get_filename $file)";
|
|
|
|
bsdtar -p -o -C ${SRC} -xf $(get_filename $file) ;;
|
|
|
|
*.tar.xz)
|
|
|
|
echo "Copying $(get_filename $file)";
|
|
|
|
mkdir -p ${SRC}/${name}c-$version-src/build/cache/${_date} || true
|
|
|
|
cp $(get_filename $file) ${SRC}/${name}c-$version-src/build/cache/${_date} ;;
|
|
|
|
*)
|
|
|
|
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"
|
|
|
|
|
2022-05-21 12:20:18 +02:00
|
|
|
patch -p1 -i $SRC/0001-bootstrap-Change-libexec-dir.patch
|
2024-03-22 01:39:07 +01:00
|
|
|
patch -p1 -i $SRC/0002-bootstrap-Change-bash-completion-dir.patch
|
|
|
|
patch -p1 -i $SRC/0003-compiler-Change-LLVM-targets.patch
|
2023-11-18 23:44:00 +01:00
|
|
|
patch -p1 -i $SRC/0004-compiler-Use-wasm-ld-for-wasm-targets.patch
|
2023-09-22 19:23:20 +02:00
|
|
|
|
2018-12-26 19:59:18 +11:00
|
|
|
cat <<- EOF > $SRC/config.toml
|
2024-05-04 19:14:35 +02:00
|
|
|
change-id = 121754
|
2021-09-25 23:59:34 +10:00
|
|
|
|
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
|
2024-05-04 19:14:35 +02:00
|
|
|
debuginfo-level = 1
|
2021-08-30 21:00:09 +10:00
|
|
|
debuginfo-level-std = 2
|
2021-10-03 15:57:36 +02:00
|
|
|
codegen-tests = false
|
2023-02-10 15:07:53 +01:00
|
|
|
backtrace-on-ice = true
|
|
|
|
jemalloc = true
|
2023-12-30 01:17:18 +01:00
|
|
|
remap-debuginfo = false
|
2021-10-03 15:57:36 +02:00
|
|
|
|
|
|
|
description = "CRUX"
|
2018-12-26 19:59:18 +11:00
|
|
|
channel = "stable"
|
2023-02-10 15:07:53 +01:00
|
|
|
parallel-compiler = false
|
2018-12-26 19:59:18 +11:00
|
|
|
rpath = false
|
2024-05-04 19:14:35 +02:00
|
|
|
frame-pointers = true
|
|
|
|
deny-warnings = false
|
2021-10-01 18:54:29 +10:00
|
|
|
optimize = true
|
2024-03-28 20:57:29 +01:00
|
|
|
codegen-backends = ["llvm"]
|
2021-10-01 18:54:29 +10:00
|
|
|
@LLD@
|
2018-12-26 19:59:18 +11:00
|
|
|
|
|
|
|
[build]
|
2023-06-01 22:48:10 +02:00
|
|
|
target = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
|
2023-07-14 18:18:07 +02:00
|
|
|
tools = ["cargo",
|
|
|
|
"clippy",
|
|
|
|
"rustfmt",
|
|
|
|
"analysis",
|
|
|
|
"src",
|
|
|
|
"rust-demangler",
|
|
|
|
"rust-analyzer",
|
|
|
|
"rust-analyzer-proc-macro-srv",
|
|
|
|
"rustdoc"]
|
2019-02-15 21:00:35 +11:00
|
|
|
docs = false
|
2018-12-26 19:59:18 +11:00
|
|
|
extended = true
|
2023-06-01 22:48:10 +02:00
|
|
|
sanitizers = true
|
2020-08-30 00:17:08 +10:00
|
|
|
profiler = true
|
|
|
|
vendor = true
|
2023-02-10 15:07:53 +01:00
|
|
|
locked-deps = true
|
2020-08-30 00:17:08 +10:00
|
|
|
python = "/usr/bin/python3"
|
2024-03-28 20:57:29 +01:00
|
|
|
optimized-compiler-builtins = true
|
2020-08-30 00:17:08 +10:00
|
|
|
@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"
|
2023-10-06 14:29:02 +02:00
|
|
|
cc = @TARGETCC@
|
|
|
|
cxx = @TARGETCXX@
|
|
|
|
ar = @TARGETAR@
|
|
|
|
ranlib = @TARGETRANLIB@
|
2022-09-23 07:54:51 +02:00
|
|
|
|
|
|
|
[target.i686-unknown-linux-gnu]
|
2023-05-21 10:15:13 +02:00
|
|
|
llvm-config = "/usr/bin/llvm-config"
|
|
|
|
llvm-filecheck = "/usr/bin/FileCheck"
|
2023-10-06 14:29:02 +02:00
|
|
|
cc = @TARGETCC@
|
|
|
|
cxx = @TARGETCXX@
|
|
|
|
ar = @TARGETAR@
|
|
|
|
ranlib = @TARGETRANLIB@
|
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
|
2024-03-09 11:22:01 +01:00
|
|
|
if ! /usr/bin/ldd /usr/bin/rustc | grep -q -E '.*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
|
2022-01-22 09:51:50 +01:00
|
|
|
PATH=$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')
|
2021-01-02 21:52:18 +11:00
|
|
|
else
|
|
|
|
sed -e 's|@CCACHE@||' -i $SRC/config.toml
|
|
|
|
fi
|
2024-03-22 12:39:15 +01:00
|
|
|
|
2023-10-06 14:29:02 +02:00
|
|
|
if prt-get isinst clang lld; then
|
|
|
|
sed -e 's|@TARGETCC@|"clang"|g' -e 's|@TARGETCXX@|"clang++"|g' -e 's|@TARGETAR@|"llvm-ar"|g' -e 's|@TARGETRANLIB@|"llvm-ranlib"|g' -i $SRC/config.toml
|
|
|
|
else
|
|
|
|
sed -e 's|@TARGETCC@|"gcc"|g' -e 's|@TARGETCXX@|"g++"|g' -e 's|@TARGETAR@|"gcc-ar"|g' -e 's|@TARGETRANLIB@|"gcc-ranlib"|g' -i $SRC/config.toml
|
|
|
|
fi
|
2023-09-20 17:51:44 +02:00
|
|
|
prt-get isinst lld && sed -e 's|@LLD@|use-lld = true\nlld = true|' -i $SRC/config.toml || sed -e 's|@LLD@||' -i $SRC/config.toml
|
2021-10-01 18:54:29 +10:00
|
|
|
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
|
|
|
|
2023-11-18 23:44:00 +01:00
|
|
|
## sccache currently leads to errors
|
|
|
|
#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
|
|
|
|
2024-05-04 19:14:35 +02:00
|
|
|
unset CFLAGS CXXFLAGS
|
|
|
|
|
2023-09-22 19:23:20 +02:00
|
|
|
{ [ ! -e /usr/include/libssh2.h ] ||
|
|
|
|
export LIBSSH2_SYS_USE_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
|
|
|
|
|
2024-03-22 01:39:07 +01:00
|
|
|
prt-get isinst bash-completion || rm -r $PKG/usr/share/bash-completion
|
2023-07-14 18:18:07 +02:00
|
|
|
prt-get isinst zsh || rm -r $PKG/usr/share/zsh
|
|
|
|
|
|
|
|
install -d $PKG/etc/revdep.d
|
|
|
|
echo "/usr/lib/rustlib/i686-unknown-linux-gnu/lib" > $PKG/etc/revdep.d/$name
|
2020-03-27 23:32:48 +11:00
|
|
|
|
|
|
|
# cleanup
|
2023-08-05 13:54:10 +02:00
|
|
|
rm -r $PKG/usr/share/doc
|
2018-12-26 19:59:18 +11:00
|
|
|
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
|
|
|
|
2023-09-22 19:23:20 +02:00
|
|
|
find $PKG/usr -name "*.old" -delete
|
2023-07-14 18:18:07 +02:00
|
|
|
rm $PKG/usr/lib/rustlib/{install.log,manifest-*}
|
2018-12-26 19:59:18 +11:00
|
|
|
}
|