Skip to content

Commit

Permalink
dev-lang/rust: Drop our custom package in favour of upstream Gentoo's
Browse files Browse the repository at this point in the history
It is not clear why this was forked originally. One reason was to avoid
the sys-apps/lsb-release dependency, but it probably wasn't just that.
It seems likely that the upstream package did not support cross targets
at the time. Now it does.

It appears that LTO was previously enabled by us following Gentoo rather
than through an explicit decision. They now disable it by default, so we
do likewise. It previously used "fat" LTO, which makes Rust especially
slow to build and reportedly made rustc slower than with "thin" LTO!
There seems little benefit in using thin LTO given that we rebuild Rust
almost as much as the packages that use it, plus we don't enable LTO
anywhere else.

We still avoid rustdoc to keep the size down using INSTALL_MASK. This
isn't as good as not building it in the first place, but this alone
isn't worth keeping a fork.

Cross targets are now handled via the admittedly experimental
RUST_CROSS_TARGETS support. This has been in place for a while, and I
think it is fairly widely used now. If it does disappear, it would
almost certainly be for something even better.

This also updates Rust from 1.80.0 to 1.80.1.

Signed-off-by: James Le Cuirot <[email protected]>
  • Loading branch information
chewi committed Aug 15, 2024
1 parent b88b31a commit 3bf7931
Show file tree
Hide file tree
Showing 48 changed files with 7,915 additions and 122 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/portage-stable-packages-list
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ dev-lang/perl
dev-lang/python
dev-lang/python-exec
dev-lang/python-exec-conf
dev-lang/rust
dev-lang/swig
dev-lang/tcl
dev-lang/yasm
Expand Down Expand Up @@ -688,6 +689,7 @@ virtual/perl-Getopt-Long
virtual/perl-IO
virtual/perl-Unicode-Collate
virtual/pkgconfig
virtual/rust
virtual/service-manager
virtual/ssh
virtual/tmpfiles
Expand Down
2 changes: 1 addition & 1 deletion build_library/catalyst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ cat <<EOF
# stage1 packages aren't published, save in tmp
pkgcache_path: ${TEMPDIR}/stage1-${ARCH}-packages
update_seed: yes
update_seed_command: --exclude cross-*-cros-linux-gnu/* --exclude dev-lang/rust --ignore-world y --ignore-built-slot-operator-deps y @changed-subslot
update_seed_command: --exclude cross-*-cros-linux-gnu/* --exclude dev-lang/rust --exclude virtual/rust --ignore-world y --ignore-built-slot-operator-deps y @changed-subslot
EOF
catalyst_stage_default 1
}
Expand Down
4 changes: 2 additions & 2 deletions build_library/catalyst_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ for cross_chost in $(get_chost_list); do
echo "Building cross toolchain for ${cross_chost}"
PKGDIR="$(portageq envvar PKGDIR)/crossdev" \
install_cross_toolchain "${cross_chost}" ${clst_myemergeopts}
PKGDIR="$(portageq envvar PKGDIR)/crossdev" \
install_cross_rust "${cross_chost}" ${clst_myemergeopts}
done

PKGDIR="$(portageq envvar PKGDIR)/crossdev" install_cross_rust ${clst_myemergeopts}
28 changes: 10 additions & 18 deletions build_library/toolchain_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,6 @@ install_cross_toolchain() {
else
echo "Installing existing binaries"
"${sudo[@]}" emerge "${emerge_flags[@]}" "${emerge_atoms[@]}"
if [ "${cbuild}" = "x86_64-pc-linux-gnu" ] && [ "${cross_chost}" = aarch64-cros-linux-gnu ] && \
[ ! -d /usr/lib/rust-*/rustlib/aarch64-unknown-linux-gnu ] && [ ! -d /usr/lib/rustlib/aarch64-unknown-linux-gnu ]; then
# If no aarch64 folder exists, warn about the situation but don't compile Rust here or download it as binary package
echo "WARNING: No aarch64 cross-compilation Rust libraries found!"
echo "In case building fails, make sure the old Rust version is deleted with: sudo emerge --unmerge virtual/rust dev-lang/rust"
echo "Then install it again with: sudo emerge ${emerge_flags[@]} virtual/rust"
echo "This will download the binary package or build from source."
fi
fi

# Setup environment and wrappers for our shiny new toolchain
Expand Down Expand Up @@ -471,22 +463,22 @@ install_cross_libs() {
}

install_cross_rust() {
local cross_chost="$1"; shift
local emerge_flags=( "$@" --binpkg-respect-use=y --update )
local cbuild="$(portageq envvar CBUILD)"

# may be called from either catalyst (root) or upgrade_chroot (user)
local sudo=("env")
if [[ $(id -u) -ne 0 ]]; then
sudo=("sudo" "-E")
fi

if [ "${cbuild}" = "x86_64-pc-linux-gnu" ] && [ "${cross_chost}" = "aarch64-cros-linux-gnu" ]; then
echo "Building Rust for arm64"
# If no aarch64 folder exists, try to remove any existing Rust packages.
[ ! -d /usr/lib/rustlib/aarch64-unknown-linux-gnu ] && ("${sudo[@]}" emerge --unmerge dev-lang/rust || true)
"${sudo[@]}" emerge "${emerge_flags[@]}" dev-lang/rust
fi
echo "Installing dev-lang/rust with (potentially outdated) cross targets."
"${sudo[@]}" emerge "${emerge_flags[@]}" --binpkg-respect-use=y --update dev-lang/rust

[[
-d /usr/lib/rustlib/x86_64-unknown-linux-gnu &&
-d /usr/lib/rustlib/aarch64-unknown-linux-gnu
]] && return

echo "Rebuilding dev-lang/rust with updated cross targets."
"${sudo[@]}" emerge "${emerge_flags[@]}" --usepkg=n dev-lang/rust
}

# Update to the latest binutils profile for a given CHOST if required
Expand Down
1 change: 1 addition & 0 deletions changelog/updates/2024-08-15-rust-1.80.1-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- SDK: Rust ([1.80.1](https://github.com/rust-lang/rust/releases/tag/1.80.1))
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSTALL_MASK+=" *rustdoc*"
I_KNOW_WHAT_I_AM_DOING_CROSS=1

RUST_CROSS_TARGETS=(
$(aarch64-cros-linux-gnu-gcc --version >/dev/null && echo "AArch64:aarch64-unknown-linux-gnu:aarch64-cros-linux-gnu")
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
=dev-lang/python-3.11.9_p1 ~amd64

# Accept unstable host Rust compilers.
=dev-lang/rust-1.80.0 ~amd64 ~arm64
=dev-lang/rust-1.80.1 ~amd64 ~arm64

# Needed by arm64-native SDK.
=dev-lang/yasm-1.3.0-r1 ~arm64
Expand Down Expand Up @@ -106,4 +106,4 @@ dev-util/catalyst ~amd64 ~arm64
=sys-cluster/ipvsadm-1.31-r1 ~arm64

# Accept unstable host Rust compilers.
=virtual/rust-1.80.0 ~amd64 ~arm64
=virtual/rust-1.80.1 ~amd64 ~arm64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Overwrite portage-stable mask. We haven't seen LLVM related problems
# with rust so far, so keep using 1.70.0.
~dev-lang/rust-1.80.0
~virtual/rust-1.80.0
~dev-lang/rust-1.80.1
~virtual/rust-1.80.1

This file was deleted.

Loading

0 comments on commit 3bf7931

Please sign in to comment.