From e9030563eab915af4a1f04b1aebdb2a74c224c92 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 25 Jun 2026 23:15:57 +0100 Subject: [PATCH] fix(bootstrap): smoke_test provides RTL source for source-built-RTL commits The rolling-bootstrap smoke probe ran `$cc --source s.pas --output s` with no unit-path, relying on the binary finding the RTL beside itself. That worked while the RTL was an archive (FindRTL looks beside the binary), but once a commit makes the compiler source-build the RTL, the boot/carried binary is not beside its compiler/ source tree, so RTLSourceDir (binary-relative, then CWD-relative) misses and the probe fails with "RTL source directory not found". Point the probe at the worktree's RTL source via $BLAISE_RTL_SRC and the unit path. Backward-compatible: pre-source-build commits ignore $BLAISE_RTL_SRC and still link the archive copied beside the binary; the extra unit paths are harmless for a program that uses no units. --- scripts/rolling-bootstrap.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/rolling-bootstrap.sh b/scripts/rolling-bootstrap.sh index 651bccc..dc40d8f 100755 --- a/scripts/rolling-bootstrap.sh +++ b/scripts/rolling-bootstrap.sh @@ -202,7 +202,7 @@ build_step() { } # --------------------------------------------------------------------------- -# smoke_test +# smoke_test # Compiles + runs a trivial program to prove the freshly-built binary is # functional (source -> native backend -> internal assembler + linker -> # runs -> correct stdout). Kept deliberately feature-agnostic: it must pass @@ -210,7 +210,7 @@ build_step() { # not any specific later feature. # --------------------------------------------------------------------------- smoke_test() { - local cc="$1" rtl="$2" + local cc="$1" rtl="$2" wt="$3" local d; d="$(mktemp -d)" cat > "$d/s.pas" <<'PAS' program P; @@ -220,11 +220,19 @@ begin WriteLn(X) end. PAS - # FindRTL looks beside the compiler binary; ensure the matching archive is - # there so the internal linker finds it. + # Pre-source-build commits link the RTL archive (FindRTL beside the binary); + # later commits source-build the RTL. Provide BOTH so this probe works across + # the whole range: copy the archive beside the binary AND point the source + # build at the RTL source in the worktree ($BLAISE_RTL_SRC short-circuits + # RTLSourceDir, which is binary-relative and would otherwise miss because the + # carried binary is not beside its compiler/ tree). cp "$rtl" "$(dirname "$cc")/blaise_rtl.a" 2>/dev/null || true local ok=1 - if "$cc" --source "$d/s.pas" --output "$d/s" 2>"$d/s.err"; then + if BLAISE_RTL_SRC="$wt/compiler/src/main/pascal" \ + "$cc" --source "$d/s.pas" \ + --unit-path "$wt/compiler/src/main/pascal" \ + --unit-path "$wt/stdlib/src/main/pascal" \ + --output "$d/s" 2>"$d/s.err"; then [ "$("$d/s" 2>/dev/null)" = "42" ] && ok=0 fi rm -rf "$d" @@ -255,7 +263,7 @@ for sha in "${COMMITS[@]}"; do exit 2 fi - if ! smoke_test "$WT/_boot/blaise" "$WT/_boot/blaise_rtl.a"; then + if ! smoke_test "$WT/_boot/blaise" "$WT/_boot/blaise_rtl.a" "$WT"; then echo echo "SMOKE_FAILED at $short ($subj)" echo " The binary built but produced wrong output for the local-const-array"