Skip to content

Commit 0cbb087

Browse files
committed
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 ec8e7e8
1 parent 75c670e commit 0cbb087

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

sdk_container/src/third_party/coreos-overlay/dev-lang/rust/rust-1.74.1.ebuild

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ else
2222
KEYWORDS="~amd64 ~arm ~arm64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86"
2323
fi
2424

25+
# Flatcar: keep the patchlevel "0", no matter what it changes from Gentoo.
26+
# That is necessary for automatic package updates of Flatcar to work correctly.
2527
RUST_STAGE0_VERSION="1.$(($(ver_cut 2) - 1)).0"
2628

2729
DESCRIPTION="Systems programming language from Mozilla"
@@ -117,15 +119,16 @@ DEPEND="
117119
)
118120
"
119121

122+
# Flatcar: lsb-release must be removed, as it conflicts with baselayout
123+
# of Flatcar.
120124
RDEPEND="${DEPEND}
121125
app-eselect/eselect-rust
122-
sys-apps/lsb-release
123126
"
124127

128+
# Flatcar: rust-src must be removed for keeping the SDK size minimal.
125129
REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
126130
miri? ( nightly )
127131
parallel-compiler? ( nightly )
128-
rust-analyzer? ( rust-src )
129132
test? ( ${ALL_LLVM_TARGETS[*]} )
130133
wasm? ( llvm_targets_WebAssembly )
131134
x86? ( cpu_flags_x86_sse2 )
@@ -324,10 +327,14 @@ src_configure() {
324327
sed -i '/linker:/ s/rust-lld/wasm-ld/' compiler/rustc_target/src/spec/wasm_base.rs || die
325328
fi
326329
fi
330+
# Flatcar: Auto-enable cross-building only if the cross-compiler is available
331+
if [ "${CBUILD}" != "aarch64-unknown-linux-gnu" ] && [ -f /usr/bin/aarch64-cros-linux-gnu-gcc ]; then
332+
rust_targets="${rust_targets},\"aarch64-unknown-linux-gnu\""
333+
fi
327334
rust_targets="${rust_targets#,}"
328335

329-
# cargo and rustdoc are mandatory and should always be included
330-
local tools='"cargo","rustdoc"'
336+
# Flatcar: Remove rustdoc to keep the SDK size minimal.
337+
local tools='"cargo"'
331338
use clippy && tools+=',"clippy"'
332339
use miri && tools+=',"miri"'
333340
use profiler && tools+=',"rust-demangler"'
@@ -478,6 +485,30 @@ src_configure() {
478485
_EOF_
479486
fi
480487
done
488+
# Flatcar: workaround for cross-compile. Could soon be replaced
489+
# by the "experimental cross support" below
490+
if [ "${CBUILD}" != "aarch64-unknown-linux-gnu" ] && [ -f /usr/bin/aarch64-cros-linux-gnu-gcc ]; then
491+
cat <<- 'EOF' > "${S}/cc.sh"
492+
#!/bin/bash
493+
args=("$@")
494+
filtered=()
495+
for i in "${args[@]}"; do
496+
if [ "$i" != "-mindirect-branch-register" ] && [ "$i" != "-mindirect-branch=thunk" ]; then
497+
filtered+=("$i")
498+
fi
499+
done
500+
aarch64-cros-linux-gnu-gcc --sysroot=/usr/aarch64-cros-linux-gnu "${filtered[@]}"
501+
EOF
502+
sed 's/gcc/g++/g' "${S}/cc.sh" > "${S}/cxx.sh"
503+
chmod +x "${S}/cc.sh" "${S}/cxx.sh"
504+
cat <<- EOF >> "${S}"/config.toml
505+
[target.aarch64-unknown-linux-gnu]
506+
cc = "${S}/cc.sh"
507+
cxx = "${S}/cxx.sh"
508+
linker = "${S}/cc.sh"
509+
ar = "aarch64-cros-linux-gnu-ar"
510+
EOF
511+
fi
481512
if use wasm; then
482513
cat <<- _EOF_ >> "${S}"/config.toml
483514
[target.wasm32-unknown-unknown]

sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.accept_keywords

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
=dev-lang/python-3.11.6 ~amd64
4646

4747
# Accept unstable host Rust compilers.
48-
=dev-lang/rust-1.73.0 ~amd64 ~arm64
48+
=dev-lang/rust-1.74.1 ~amd64 ~arm64
4949

5050
# Needed by arm64-native SDK.
5151
=dev-lang/yasm-1.3.0-r1 ~arm64
@@ -102,4 +102,4 @@
102102
=sys-process/procps-4.0.4 ~amd64 ~arm64
103103

104104
# Accept unstable host Rust compilers.
105-
=virtual/rust-1.73.0 ~amd64 ~arm64
105+
=virtual/rust-1.74.1 ~amd64 ~arm64

0 commit comments

Comments
 (0)