|
| 1 | +#!/usr/bin/env bash |
| 2 | +# requires: gcc |
| 3 | +# 1022 -- a build directory taken over keeps no compiler record of another |
| 4 | +# directory (2026.11.7.1). A split compile (`bmi_schedule`, GCC's detach-codegen) |
| 5 | +# keeps its slot's records beside each object (`<object>.sched.*`), and the |
| 6 | +# completion certificate names the object by its absolute path. A new |
| 7 | +# fingerprint of a configuration's lineage takes its predecessor's directory |
| 8 | +# over (design 2026-10-31 §8), and the certificates there named the |
| 9 | +# predecessor's objects: the next build refused them at admission ("cached |
| 10 | +# compiler certificate does not name its own object"), and every build of the |
| 11 | +# configuration after an mcpp upgrade failed so, until `mcpp clean`. |
| 12 | +# |
| 13 | +# The predecessor is made with plain files: a dev build's directory, renamed, |
| 14 | +# whose `lineage` is the release configuration's, so the release build takes it |
| 15 | +# over while its certificates name the dev build's objects. |
| 16 | +# |
| 17 | +# Criteria: |
| 18 | +# A. The release build takes the predecessor over and builds. |
| 19 | +# B. No record of the predecessor is left beside the objects. |
| 20 | +# C. A certificate of another directory found at admission -- the directory |
| 21 | +# moved, or restored elsewhere -- is no record: the build compiles the |
| 22 | +# object again rather than failing. |
| 23 | +set -e |
| 24 | + |
| 25 | +TMP=$(mktemp -d) |
| 26 | +trap "rm -rf $TMP" EXIT |
| 27 | +export MCPP_HOME="$TMP/mcpp-home" |
| 28 | +source "$(dirname "$0")/_inherit_toolchain.sh" |
| 29 | +fail() { echo "FAIL: $1"; shift; for f in "$@"; do echo "--- $f ---"; cat "$f" 2>/dev/null; done; exit 1; } |
| 30 | + |
| 31 | +cd "$TMP" |
| 32 | +mkdir -p app/src && cd app |
| 33 | +printf '[package]\nname = "app"\nversion = "0.1.0"\n\n[build]\nbmi_schedule = "on"\n' > mcpp.toml |
| 34 | +printf 'export module greet;\nexport int answer() { return 42; }\n' > src/greet.cppm |
| 35 | +printf 'import greet;\nint main() { return answer() == 42 ? 0 : 1; }\n' > src/main.cpp |
| 36 | +config() { ls -d target/*/*/ | grep -E '/[0-9a-f]{16}/$' | head -1 | sed 's#/$##'; } |
| 37 | + |
| 38 | +"$MCPP" build --release > r0.log 2>&1 || fail "the first release build failed" r0.log |
| 39 | +release=$(config); cp "$release/lineage" release.lineage; rm -rf "$release" |
| 40 | +"$MCPP" build > d0.log 2>&1 || fail "the dev build failed" d0.log |
| 41 | +dev=$(config) |
| 42 | +ls "$dev"/obj/*.sched.completed > /dev/null 2>&1 || fail "the split compile left no certificate" <(find "$dev/obj") |
| 43 | +pred="$(dirname "$dev")/0000000000000000" |
| 44 | +mv "$dev" "$pred"; cp release.lineage "$pred/lineage" |
| 45 | + |
| 46 | +# A |
| 47 | +printf 'import greet;\nint main() { return answer() == 42 ? 0 : 2; }\n' > src/main.cpp |
| 48 | +"$MCPP" build --release > a.log 2>&1 || fail "the build that took the predecessor over failed" a.log |
| 49 | +[ ! -d "$pred" ] || fail "the predecessor was not taken over" <(ls "$(dirname "$pred")") |
| 50 | +taken=$(config) |
| 51 | +echo "ok: the release build took the predecessor over and built" |
| 52 | + |
| 53 | +# B |
| 54 | +if grep -rl "/0000000000000000/" "$taken"/obj --include='*.sched*' > /dev/null 2>&1; then |
| 55 | + fail "a record of the predecessor was left beside the objects" <(grep -rl "/0000000000000000/" "$taken"/obj) |
| 56 | +fi |
| 57 | +echo "ok: no record of the predecessor is left" |
| 58 | + |
| 59 | +# C |
| 60 | +moved="$TMP/moved-app"; cp -a "$TMP/app" "$moved"; cd "$moved" |
| 61 | +printf 'export module greet;\nexport int answer() { return 41 + 1; }\n' > src/greet.cppm |
| 62 | +"$MCPP" build --release > c.log 2>&1 || fail "the build of a moved directory failed" c.log |
| 63 | +echo "ok: a certificate of another directory is no record" |
| 64 | + |
| 65 | +echo "PASS: 1022 a taken over directory keeps no compiler record of another" |
0 commit comments