overlay dev-lang/rust: Apply Flatcar modifications

- Apply cross-compiling changes.
- Remove dependency on sys-apps/lsb-release, which conflicts with
  sys-apps/baselayout of Flatcar.
- Remove rust-src to keep the SDK size minimal.
- Add a comment about keeping the patchlevel 0 of stage0.
- Update Rust version from 1.72.1 to 1.73.0 in profiles.

Based on commit 82f9e1b8dbbb667f49982e695104f26ea322756f
This commit is contained in:
Dongsu Park 2023-10-17 17:49:41 +02:00
parent 5d12e8e118
commit ec8e7e8f87
2 changed files with 38 additions and 7 deletions

View File

@ -22,6 +22,8 @@ else
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi
# Flatcar: keep the patchlevel "0", no matter what it changes from Gentoo.
# That is necessary for automatic package updates of Flatcar to work correctly.
RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
DESCRIPTION="Systems programming language from Mozilla"
@ -117,15 +119,16 @@ DEPEND="
)
"
# Flatcar: lsb-release must be removed, as it conflicts with baselayout
# of Flatcar.
RDEPEND="${DEPEND}
app-eselect/eselect-rust
sys-apps/lsb-release
"
# Flatcar: rust-src must be removed for keeping the SDK size minimal.
REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
miri? ( nightly )
parallel-compiler? ( nightly )
rust-analyzer? ( rust-src )
test? ( ${ALL_LLVM_TARGETS[*]} )
wasm? ( llvm_targets_WebAssembly )
x86? ( cpu_flags_x86_sse2 )
@ -323,10 +326,14 @@ src_configure() {
sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die
fi
fi
# Flatcar: Auto-enable cross-building only if the cross-compiler is available
if [ "${CBUILD}" != "aarch64-unknown-linux-gnu" ] && [ -f /usr/bin/aarch64-cros-linux-gnu-gcc ]; then
rust_targets="${rust_targets},\"aarch64-unknown-linux-gnu\""
fi
rust_targets="${rust_targets#,}"
# cargo and rustdoc are mandatory and should always be included
local tools='"cargo","rustdoc"'
# Flatcar: Remove rustdoc to keep the SDK size minimal.
local tools='"cargo"'
use clippy && tools+=',"clippy"'
use miri && tools+=',"miri"'
use profiler && tools+=',"rust-demangler"'
@ -477,6 +484,30 @@ src_configure() {
_EOF_
fi
done
# Flatcar: workaround for cross-compile. Could soon be replaced
# by the "experimental cross support" below
if [ "${CBUILD}" != "aarch64-unknown-linux-gnu" ] && [ -f /usr/bin/aarch64-cros-linux-gnu-gcc ]; then
cat <<- 'EOF' > "${S}/cc.sh"
#!/bin/bash
args=("$@")
filtered=()
for i in "${args[@]}"; do
if [ "$i" != "-mindirect-branch-register" ] && [ "$i" != "-mindirect-branch=thunk" ]; then
filtered+=("$i")
fi
done
aarch64-cros-linux-gnu-gcc --sysroot=/usr/aarch64-cros-linux-gnu "${filtered[@]}"
EOF
sed 's/gcc/g++/g' "${S}/cc.sh" > "${S}/cxx.sh"
chmod +x "${S}/cc.sh" "${S}/cxx.sh"
cat <<- EOF >> "${S}"/config.toml
[target.aarch64-unknown-linux-gnu]
cc = "${S}/cc.sh"
cxx = "${S}/cxx.sh"
linker = "${S}/cc.sh"
ar = "aarch64-cros-linux-gnu-ar"
EOF
fi
if use wasm; then
cat <<- _EOF_ >> "${S}"/config.toml
[target.wasm32-unknown-unknown]

View File

@ -36,8 +36,8 @@
=dev-embedded/u-boot-tools-2021.04_rc2 ~arm64
=dev-lang/nasm-2.15.05 ~arm64
# Accept unstable host Rust compilers
=dev-lang/rust-1.72.1 ~amd64 ~arm64
# Accept unstable host Rust compilers.
=dev-lang/rust-1.73.0 ~amd64 ~arm64
# Needed by arm64-native SDK.
=dev-lang/yasm-1.3.0-r1 ~arm64
@ -95,4 +95,4 @@
=sys-process/procps-4.0.4 ~amd64 ~arm64
# Accept unstable host Rust compilers.
=virtual/rust-1.72.1 ~amd64 ~arm64
=virtual/rust-1.73.0 ~amd64 ~arm64