Repository navigation
selfhost: the flow command is a Flow program (tools/flow_cli) - #1095
Merged
Merged
Conversation
tests/cli/run.sh runs 121 invocations of ./flow (every subcommand with a representative input, plus the error paths) and compares stdout, stderr, the exit code and the files written against tests/cli/goldens. The goldens record the bash driver, so they are the parity gate for a Flow CLI.
./flow is now a POSIX sh stub that builds tools/flow_cli from the checked-in bootstrap C with cc on first use (cached in build/cli, or the user cache dir for a read-only install) and execs it. The CLI ports every subcommand, flag and environment variable of flow-driver: argument parsing, dispatch, the flowc and tool builds, C flags and sanitizers, the runtime archive, the C and MLIR link steps, the test tiers, packages, docs and proofs. External programs run through std.process with argument vectors. tests/cli/run.sh: 121 of 121 goldens match the bash driver.
sync_version mirrors the version strings in tools/flow_cli/help.flow and doc_coverage reads the command table from tools/flow_cli/main.flow (help and know are now listed and documented). The scripts that ran flow-driver directly run ./flow. The Homebrew formula builds the CLI at install time and still accepts a release tarball that ships flow-driver. tests/cli: 149 of 149 goldens match the bash driver, including the MLIR pipeline, jit, proofs, shaders, the recorder, the REPL, packages and the GPU and interop test tiers.
The bash driver (4,311 lines) is gone: the stub and tools/flow_cli cover every command, with 149 of 149 goldens matching it. The goldens move to tests/cli/goldens/darwin, since clang, ld and the tools on PATH print differently per OS.
tests/cli/fixtures/bad_syntax.flow does not parse on purpose; tests/cli/run.sh checks the fixtures. The tier-2 sweep output of the Flow CLI was byte for byte the bash driver's over 861 files before this change.
native-tools runs tests/cli/run.sh. tests/cli/goldens/linux was recorded on Ubuntu 24.04 (clang 18) from the bash driver; the Flow CLI matched 148 of 149 there, the miss being a random clang temp object name in a linker warning, which the normalisation now rewrites. flow-driver leaves the paths filters and chmod lines.
…-driver flowc_link_c asks the package manager (native-link) for the objects and flags of the project's and installed packages' [native] sources when a flow.toml declares [native], and links them ahead of the runtime archive. check_run_without_python.sh: 31 of 31, including sqlite_demo and app_cache.
The emitter writes a newline in an MLIR string constant as \0A since #1093. mlir_hello and mlir_run_hello were recorded before it.
…n load Nine programs time out or exit differently from run to run: concurrency examples and nbody under seven parallel jobs with a 10s limit, and three whose Python golden run timed out. They moved the count across the floor (1031 to 1038 on one tree). compiler/corpus_parity/timing.txt lists them and corpus_parity.sh compares their build only, as nondet.txt already does for stdout. The floor stays 1033; this tree scores 1038.
godofecht
force-pushed
the
selfhost/native-cli
branch
from
October 1, 2026 06:30
e223eeb to
d98f298
Compare
The Linux goldens held exit codes and stderr from the bash driver but no stdout, so every case failed on Linux with a missing golden. These were recorded on ubuntu-latest with the native CLI. The same run found no .code or .err that differs from the bash driver's recordings. The temporary workflow that recorded them is removed here.
godofecht
added a commit
that referenced
this pull request
Oct 1, 2026
flow-driver was deleted in #1095. The ./flow stub builds tools/flow_cli from compiler/bootstrap, so tools/ is always installed beside it.
godofecht
added a commit
that referenced
this pull request
Oct 1, 2026
* cli, process: drop the #1078 and #1089 workarounds Both bugs are fixed on main (#1082, #1102). Read SINK fields straight off the module static, and spell the C strings in the sys.flow and std.process shims as quoted literals instead of char arrays. * packaging: drop flow-driver from the Homebrew formula flow-driver was deleted in #1095. The ./flow stub builds tools/flow_cli from compiler/bootstrap, so tools/ is always installed beside it. * parity_typecheck: read logs as text with grep -a Some frontend logs echo source bytes that are not valid UTF-8. GNU grep then printed "binary file matches" on stderr 151 times per CI run and left the message empty. The verdicts and the class table are unchanged. * cli: keep the toolchain state in string statics #1103 allows module-level strings (#1086), so the Toolchain struct behind a pointer static and its tc() accessor (a #1078 workaround) go. * parity_typecheck: keep the shell line count flat The shell ratchet counts lines; the rationale for grep -a lives in the previous commit message.
godofecht
added a commit
that referenced
this pull request
Oct 1, 2026
flow-driver was deleted in #1095. The ./flow stub builds tools/flow_cli from compiler/bootstrap, so tools/ is always installed beside it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #695 (Self-Hosting Phase 5): the native driver executable. The
flowcommand is now a Flow program.What changed
tools/flow_cli/*.flow(about 6,600 lines of Flow) ports every subcommand, flag and environment variable of the bashflow-driver: argument parsing, the command table, flowc resolution and the Flow tool builds, C flags and sanitizers (FLOW_PROFILE,FLOW_SANITIZE,FLOW_UBSAN/ASAN/TSAN,FLOW_CFLAGS,FLOW_LDFLAGS,FLOW_OPT_LEVEL), the runtime archive, the C and MLIR link steps, jit, the test tiers, packages (including the[native]link from Tooling: link [native] package sources on flow run, gate proof doc drift, build benchmarks on macOS #1085), docs, proofs, wasm, python and the demo launchers.FLOW_HOST,FLOWC_*,FLOW_BUILD_ROOTand the rest keep their behaviour.std.process(stdlib: process API, regular expressions, extern const with errno and signals, shared byte buffer #1083) with argument vectors. No shell parses anything; the mlir-opt, mlir-translate and llc pipeline is three processes fed in turn../flowis a 31-line POSIX sh stub. On first use it builds flowc fromcompiler/bootstrap/flowc_stage_a.cwithcc, compilestools/flow_cliintobuild/cli/flow(or~/.cache/flowfor a read-only install) and execs it. It rebuilds when a CLI source or the bootstrap C changes. A clean clone still needs only a C compiler. Startup is about 10 ms.flow-driver(4,311 lines of bash) is deleted, as is the 53-line bash wrapper.flow-lspstays a 15-line launcher.flow-drivercall./flow.sync_versionmirrors the version strings intools/flow_cli/help.flow, anddoc_coveragereads the command table fromtools/flow_cli/main.flow, which now listshelpandknowas well (both documented indocs/coverage.json). The Homebrew formula builds the CLI at install time and still accepts a tarball that shipsflow-driver.Parity
tests/cli/run.shruns 149 invocations: every subcommand with a representative input, plus the error paths (unknown command, missing file, bad flags). For each it compares stdout, stderr, the exit code and the files written against goldens recorded from the bash driver, one set per OS../flow test --tier2 --strictover 861 files printed byte for byte what the bash driver printed../flow test-langgave the same results with both drivers.line 3048: PID Abort trap: 6). The CLI does not. The compiler sweep now skipstests/cli/, whose fixtures include a file that does not parse, on purpose.Gates run on this branch (macOS, rebased on main)
All pass: bootstrap_from_c.sh --verify, self_host_full.sh, roundtrip.sh, parse_coverage.sh --check, fmt_check.sh --check, tests/cgen (107), test-lang (239), test-scripts, corpus_parity.sh --check, parity_typecheck.sh --check, typecheck_rules.sh, parity_lowering/field_dsl/dynamics_dsl/flow_blocks/effects/proofs/mlir/dap/project_test, tests/mlir_commands (72), check_run_without_python.sh (31, sqlite and app_cache included), tests/tools, tests/check, pywheel, fir, flow_run, gpu, check_pkg_commands, check_bench_publish, makefile contract, doc coverage, sync_version, python ratchet, tier 2 strict (870), tests/cli (149).
parity_shader_dsl fails only at its
xcrun metalstep (no Metal Toolchain on this machine), the step excepted. parity_project_test'sconfig_cli_timeoutcase once hit its 2.5 s compile limit while every gate ran at once. It passed 32 of 32 when run alone.On Linux, test-lang has two failures with either driver:
test_dlopenopenslibm.dylib, andtest_c_import_dirsexits 3. These are existing test issues and are unrelated to the CLI.What stays shell
./flow: it has to build the Flow CLI before any Flow program can run.flow-lsp: a 15-line launcher for editors that need a dedicated executable.compiler/scripts/*.sh,scripts/wasm_build.sh,scripts/bpf_target.shand the rest). Most are thin shims over Flow tools, and CI and other gates call them directly.FLOWC_*variables and exits when it is done, and linking it into the CLI would mean building the whole compiler twice on first use.