From b16e61969141b68919df7f828dc69a78fabb3a12 Mon Sep 17 00:00:00 2001 From: Red Bear CI Date: Mon, 8 Jun 2026 21:04:36 +0300 Subject: [PATCH] =?UTF-8?q?rebuild-cascade:=20T1.3=20=E2=80=94=20Cargo-awa?= =?UTF-8?q?re=20cascade=20with=20O(1)=20graph=20lookup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace text-grep cascade detection with a precomputed in-memory graph: - Build a recipe_index of pkg_name → deps_csv (extracted from [package]/[build] sections of recipe.toml). - find_reverse_deps() queries the index in O(1) per package. - Precompute once, query BFS in O(N) instead of O(N²). Also fix a bug where empty target string would match every empty-deps recipe, causing runaway BFS to all 3055 packages (was: 2m40s; now: 6s). The script now correctly identifies which packages explicitly declare a target as a [package] or [build] dependency. Implicit cross-compile toolchain dependencies (relibc, base) are NOT tracked here — they participate in build via the redoxer/cross setup, not via recipe declarations. Tracking those requires a different mechanism. Plan: local/docs/BUILD-SYSTEM-ROBUSTNESS-PLAN.md --- local/scripts/rebuild-cascade.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/local/scripts/rebuild-cascade.sh b/local/scripts/rebuild-cascade.sh index 73f68d4395..dd16f1999b 100755 --- a/local/scripts/rebuild-cascade.sh +++ b/local/scripts/rebuild-cascade.sh @@ -146,6 +146,11 @@ find_reverse_deps() { local target="$1" local result=() + # Empty target would match every empty-deps entry — reject early. + if [ -z "${target}" ]; then + return 0 + fi + local pkg_name entry for pkg_name in "${!recipe_index[@]}"; do if [ "${pkg_name}" = "${target}" ]; then @@ -159,7 +164,9 @@ find_reverse_deps() { fi done - printf '%s\n' "${result[@]}" | sort -u + if [ ${#result[@]} -gt 0 ]; then + printf '%s\n' "${result[@]}" | sort -u + fi } # Validate that the requested package names exist in the index