Skip to content

Commit 2e1d8c0

Browse files
rpardiniclaude
andcommitted
docker: split rust into own layer to flatten distribution
Real 'docker history' showed native-toolchain=334MB poles. - rustc/cargo pull libstd-rust-dev; move them to a new 'rust' group ordered *after* native-toolchain (so shared gcc/build-essential stay there). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8784e6f commit 2e1d8c0

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

extensions/kernel-rust.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ declare -g RUST_TOOL_SYSROOT=""
5151
function add_host_dependencies__add_rust_compiler() {
5252
display_alert "Adding Rust kernel build dependencies" "${EXTENSION}" "info"
5353
# bindgen needs libclang for dlopen; available on all target distros.
54+
# NB: do NOT pre-pull llvm-dev into an earlier layer to "split" this — measured, llvm-dev is a
55+
# superset far larger than what libclang-dev needs (~+560MB total, bigger max layer). Keep
56+
# libclang-dev as a single ~633MB 'clang' layer instead.
5457
EXTRA_BUILD_DEPS+=("clang::libclang-dev")
5558
}
5659

extensions/mtkflash.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
function add_host_dependencies__mtkflash() {
1616
display_alert "Preparing mtkflash host-side dependencies" "${EXTENSION}" "info"
17-
EXTRA_BUILD_DEPS+=("native-toolchain::rustc" "native-toolchain::cargo" "native-toolchain::build-essential")
17+
# rustc/cargo pull the bulky libstd-rust-dev; keep them in their own 'rust' layer (after
18+
# native-toolchain, so the shared gcc/build-essential stay in native-toolchain).
19+
EXTRA_BUILD_DEPS+=("rust::rustc" "rust::cargo" "native-toolchain::build-essential")
1820
}
1921

2022
function extension_finish_config__900_mtkflash() {

lib/functions/host/docker.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,11 @@ function docker_create_dockerfile_apt_install_runs() {
273273

274274
# Preferred layer order: heaviest/most-stable first, so they stay cached longest.
275275
# Any unknown (e.g. extension-defined) group is appended after, in first-seen order.
276-
declare -a preferred_order=(clang qemu cross-other cross-amd64 cross-arm64 cross-armhf native-toolchain build-tools imaging python fs-tools core)
276+
# NOTE on ordering: groups that explicitly pre-install a heavy *shared* dependency of a later
277+
# group must come first, so that dependency lands in their (smaller, parallel-pullable) layer
278+
# instead of inflating the later one. Specifically: 'llvm' before 'clang' (llvm-dev is the bulk
279+
# of libclang-dev), and 'native-toolchain' before 'rust' (so gcc stays in native-toolchain).
280+
declare -a preferred_order=(llvm clang qemu cross-other cross-amd64 cross-arm64 cross-armhf native-toolchain rust build-tools imaging python fs-tools core)
277281
declare -a final_order=()
278282
for group in "${preferred_order[@]}"; do
279283
[[ -n "${group_pkgs[${group}]:-}" ]] && final_order+=("${group}")

lib/functions/host/prepare-host.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,10 @@ function adaptative_prepare_host_dependencies() {
280280
fi
281281

282282
if [[ "${KERNEL_COMPILER}" == "clang" ]]; then
283+
# llvm goes in its own (earlier) layer; clang/lld depend on libllvm, so splitting it out
284+
# keeps the clang layer smaller and gives llvm its own parallel-pullable layer.
285+
host_dependencies+=("llvm::llvm")
283286
host_dependencies+=("clang::clang")
284-
host_dependencies+=("clang::llvm")
285287
host_dependencies+=("clang::lld")
286288
fi
287289

0 commit comments

Comments
 (0)