Commit 9bf8f486
9bf8f4862012Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
build: split bootstrap AST/IR/C1 into proper Make targets
The spinel_{analyze,codegen}$(EXE) recipes produced build/.ast, build/.ir, and build/*1.c as side effects, leaving those files without their own Make rules. Under default-parallel make, the verification round-2 targets that depend on build/codegen.ast could be scheduled before the spinel_codegen recipe had finished refreshing the AST, so they read a stale AST while later steps used the freshly rebuilt one.
That race only manifested when spinel_codegen.rb actually changed: any node-count shift in the rebuilt AST landed in build/codegen.ast while build/codegen2.ir still encoded the previous numbering. codegen then looked up per-method scope tables at bids that no longer pointed at the right method, producing build/codegen2.c where adjacent methods borrowed each other's locals (push_redo_label returning lv_old, emit_setjmp_depth_unwind returning lv_saved_setjmp_depth, etc.) and string-returning calls got wrapped with sp_int_to_s. The same probe under -j1 always passed.
Give every produced file its own rule: build/{analyze,codegen}.ast, build/{analyze,codegen}.ir, build/{analyze,codegen}1.c. Each spinel_$(EXE) now only links its build/1.c. No side-effect outputs remain, so the dependency DAG matches what parallel make actually schedules.
Fixes #620
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 9bf8f4862012
- Parent
- 12838d1f308a
MakefilemodifiedView file
codegen: spinel_analyze$(EXE) spinel_codegen$(EXE)spinel_analyze$(EXE): $(ANALYZE_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) spinel_parse$(EXE)# Round 1 pipeline split into per-stage rules. Previously the# `spinel_<phase>$(EXE)` recipe produced its AST/IR/C1 outputs as# side effects, which left those files without proper Make rules.# Under parallel make that races: `build/codegen2.ir` (declared to# depend on `build/codegen.ast`) could be scheduled before the# spinel_codegen recipe had refreshed the AST, so it read a stale# AST while later steps used the fresh one. The bid mismatch then# corrupted scope tables in the bootstrap fixpoint output. See #620.build/analyze.ast: $(ANALYZE_STAMP) spinel_parse$(EXE) ./spinel_parse$(EXE) spinel_analyze.rb build/analyze.ast ruby spinel_analyze.rb build/analyze.ast build/analyze.ir ruby spinel_codegen.rb build/analyze.ast build/analyze.ir build/analyze1.c $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze1.c $(LDFLAGS) -lm -o spinel_analyze$(EXE)spinel_codegen$(EXE): $(CODEGEN_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) spinel_parse$(EXE)build/codegen.ast: $(CODEGEN_STAMP) spinel_parse$(EXE) ./spinel_parse$(EXE) spinel_codegen.rb build/codegen.astbuild/analyze.ir: build/analyze.ast $(ANALYZE_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) ruby spinel_analyze.rb build/analyze.ast build/analyze.irbuild/codegen.ir: build/codegen.ast $(ANALYZE_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) ruby spinel_analyze.rb build/codegen.ast build/codegen.irbuild/analyze1.c: build/analyze.ast build/analyze.ir $(CODEGEN_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) ruby spinel_codegen.rb build/analyze.ast build/analyze.ir build/analyze1.cbuild/codegen1.c: build/codegen.ast build/codegen.ir $(CODEGEN_STAMP) $(NODE_TABLE_LOADER_STAMP) $(COMPILER_HELPERS_STAMP) ruby spinel_codegen.rb build/codegen.ast build/codegen.ir build/codegen1.cspinel_analyze$(EXE): build/analyze1.c $(SP_RT_LIB) $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/analyze1.c $(LDFLAGS) -lm -o spinel_analyze$(EXE)spinel_codegen$(EXE): build/codegen1.c $(SP_RT_LIB) $(CC) $(BOOTSTRAP_CFLAGS) -Ilib build/codegen1.c $(LDFLAGS) -lm -o spinel_codegen$(EXE)# ---- Self-hosting verification ----