Create new seed from `0ba4857a`

627a5b791ca1f5720a55312a42f73ec4e0457f6b210f22451e38f141d8df81a3
Build the seed from 8e466772 using the seed on master at 026ca4cb.
The compiler accepts derives after positional fields and can build
source that uses that syntax. Self-compilation reaches a byte-identical
fixed point.

Record the full tree of the source commit in the seed metadata.
Compile an archive of the committed tree when updating the seed.

Assisted-by: Codex:gpt-6-astra
Alexis Sellier committed ago 1 parent 446b6f4b
seed/radiance.rv64 +0 -0

Binary file changed.

seed/radiance.rv64.git +1 -1
1 -
1b64151dd6a6ba6ce343705b69f028a1ea8834b388e19bb935fe23b311ed624d
1 +
0ba4857a931e06a3123a41253559cc45976cb4d17a9e46ebc84ccc2e87941daa
seed/update +34 -17
34 34
fail() {
35 35
  printf "!! %s\n" "$*" >&2
36 36
  exit 1
37 37
}
38 38
39 -
# ---------------------------------------------------------------------------
40 -
# Command line flags for Radiance compiler
41 -
# ---------------------------------------------------------------------------
42 -
43 -
STD_MODS="$(sed 's/^/-mod /' std.lib | tr '\n' ' ')"
44 -
OPTS="-pkg std ${STD_MODS} -pkg radiance -mod compiler/radiance.rad -mod compiler/radiance/codegen.rad -entry radiance"
45 -
46 39
# ---------------------------------------------------------------------------
47 40
# Emulator settings
48 41
# ---------------------------------------------------------------------------
49 42
50 43
MEMORY_SIZE="${EMULATOR_MEMORY_SIZE:-385024}"
51 44
DATA_SIZE="${EMULATOR_DATA_SIZE:-348160}"
52 -
EMU="${RAD_EMULATOR:-emulator} -debug -no-validate \
45 +
EMULATOR="${RAD_EMULATOR:-emulator} -debug -no-validate \
53 46
    -memory-size=${MEMORY_SIZE} -data-size=${DATA_SIZE} \
54 47
    -count-instructions -run"
55 48
56 49
# ---------------------------------------------------------------------------
57 50
# Compile one self-hosted stage.
58 51
#   stage <input> <output>
59 52
# ---------------------------------------------------------------------------
60 53
61 54
stage() {
62 -
  time -p $EMU "$1" $OPTS -o "$2"
55 +
  time -p $EMULATOR "$1" $OPTS -o "$2"
63 56
}
64 57
65 58
# ---------------------------------------------------------------------------
66 59
# Compile one stage using a native (s0) binary.
67 60
#   stageS0 <input> <output>
88 81
# ---------------------------------------------------------------------------
89 82
# Copy the fixed-point binary to the seed.
90 83
# ---------------------------------------------------------------------------
91 84
92 85
updateSeed() {
93 -
  [ "$1" != seed/radiance.rv64 ] && cp "$1" seed/radiance.rv64
86 +
  [ "$1" != "$ROOT_DIR/seed/radiance.rv64" ] && cp "$1" "$ROOT_DIR/seed/radiance.rv64"
94 87
95 -
  git rev-parse HEAD > seed/radiance.rv64.git
88 +
  printf '%s\n' "$SOURCE_TREE" > "$ROOT_DIR/seed/radiance.rv64.git"
96 89
97 90
  printf "\n"
98 91
  printf "Fixed point reached at %s\n" "$2"
99 -
  printf "Seed updated (commit $(git rev-parse --short HEAD))\n"
92 +
  printf "Seed updated (tree $SOURCE_TREE)\n"
100 93
}
101 94
102 95
# ---------------------------------------------------------------------------
103 96
# Parse arguments
104 97
# ---------------------------------------------------------------------------
105 98
106 -
SEED="seed/radiance.rv64"
99 +
SEED="$ROOT_DIR/seed/radiance.rv64"
107 100
FROM_S0=0
108 101
109 102
while [ $# -gt 0 ]; do
110 103
  case "$1" in
111 104
    --seed)
125 118
126 119
command -v "${RAD_EMULATOR:-emulator}" >/dev/null 2>&1 \
127 120
  || fail "emulator not found: set RAD_EMULATOR or add 'emulator' to PATH"
128 121
[ -f "${SEED}" ] || fail "seed binary not found: ${SEED}"
129 122
123 +
# ---------------------------------------------------------------------------
124 +
# Compiler source snapshot
125 +
# ---------------------------------------------------------------------------
126 +
127 +
# Compile the complete tree of the current source commit.
128 +
git diff --quiet HEAD -- . ':!seed/radiance.rv64' \
129 +
    ':!seed/radiance.rv64.git' ||
130 +
    fail "commit source changes before updating the seed"
131 +
SOURCE_TREE="$(git rev-parse 'HEAD^{tree}')"
132 +
BUILD_DIR="$(mktemp -d)"
133 +
trap 'rm -rf "$BUILD_DIR"' EXIT
134 +
trap 'exit 1' HUP INT TERM
135 +
git archive "$SOURCE_TREE" > "$BUILD_DIR/source.tar"
136 +
mkdir "$BUILD_DIR/source"
137 +
tar -xf "$BUILD_DIR/source.tar" -C "$BUILD_DIR/source"
138 +
cd "$BUILD_DIR/source"
139 +
140 +
# ---------------------------------------------------------------------------
141 +
# Command line flags for Radiance compiler
142 +
# ---------------------------------------------------------------------------
143 +
144 +
STD_MODS="$(sed 's/^/-mod /' std.lib | tr '\n' ' ')"
145 +
OPTS="-pkg std ${STD_MODS} -pkg radiance -mod compiler/radiance.rad -mod compiler/radiance/codegen.rad -entry radiance"
146 +
130 147
# ---------------------------------------------------------------------------
131 148
# Stage 1: seed compiles source
132 149
# ---------------------------------------------------------------------------
133 150
134 -
S1=seed/radiance.rv64.s1
135 -
S2=seed/radiance.rv64.s2
136 -
S3=seed/radiance.rv64.s3
137 -
S4=seed/radiance.rv64.s4
151 +
S1="$ROOT_DIR/seed/radiance.rv64.s1"
152 +
S2="$ROOT_DIR/seed/radiance.rv64.s2"
153 +
S3="$ROOT_DIR/seed/radiance.rv64.s3"
154 +
S4="$ROOT_DIR/seed/radiance.rv64.s4"
138 155
139 156
step "Stage 1: S0 builds S1"
140 157
if [ "${FROM_S0}" -eq 1 ]; then
141 158
  stageS0 "${SEED}" "${S1}"
142 159
else