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 in overlay profiles.

Based on commit ec8e7e8f87108f9b6a7a47dc2f66844e172280ba
This commit is contained in:
Dongsu Park 2023-12-12 10:19:34 +01:00
parent 75c670ec27
commit 0cbb08719b
2 changed files with 37 additions and 6 deletions

View File

@ -22,6 +22,8 @@ else
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
fi 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" RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
DESCRIPTION="Systems programming language from Mozilla" 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} RDEPEND="${DEPEND}
app-eselect/eselect-rust 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[*]} ) REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
miri? ( nightly ) miri? ( nightly )
parallel-compiler? ( nightly ) parallel-compiler? ( nightly )
rust-analyzer? ( rust-src )
test? ( ${ALL_LLVM_TARGETS[*]} ) test? ( ${ALL_LLVM_TARGETS[*]} )
wasm? ( llvm_targets_WebAssembly ) wasm? ( llvm_targets_WebAssembly )
x86? ( cpu_flags_x86_sse2 ) x86? ( cpu_flags_x86_sse2 )
@ -324,10 +327,14 @@ src_configure() {
sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die
fi fi
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#,}" rust_targets="${rust_targets#,}"
# cargo and rustdoc are mandatory and should always be included # Flatcar: Remove rustdoc to keep the SDK size minimal.
local tools='"cargo","rustdoc"' local tools='"cargo"'
use clippy && tools+=',"clippy"' use clippy && tools+=',"clippy"'
use miri && tools+=',"miri"' use miri && tools+=',"miri"'
use profiler && tools+=',"rust-demangler"' use profiler && tools+=',"rust-demangler"'
@ -478,6 +485,30 @@ src_configure() {
_EOF_ _EOF_
fi fi
done 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 if use wasm; then
cat <<- _EOF_ >> "${S}"/config.toml cat <<- _EOF_ >> "${S}"/config.toml
[target.wasm32-unknown-unknown] [target.wasm32-unknown-unknown]

View File

@ -45,7 +45,7 @@
=dev-lang/python-3.11.6 ~amd64 =dev-lang/python-3.11.6 ~amd64
# Accept unstable host Rust compilers. # Accept unstable host Rust compilers.
=dev-lang/rust-1.73.0 ~amd64 ~arm64 =dev-lang/rust-1.74.1 ~amd64 ~arm64
# Needed by arm64-native SDK. # Needed by arm64-native SDK.
=dev-lang/yasm-1.3.0-r1 ~arm64 =dev-lang/yasm-1.3.0-r1 ~arm64
@ -102,4 +102,4 @@
=sys-process/procps-4.0.4 ~amd64 ~arm64 =sys-process/procps-4.0.4 ~amd64 ~arm64
# Accept unstable host Rust compilers. # Accept unstable host Rust compilers.
=virtual/rust-1.73.0 ~amd64 ~arm64 =virtual/rust-1.74.1 ~amd64 ~arm64