Skip to content

[self-hosting D] Retire Python from the compile critical path #153

Closed

Description

@godofecht

Phase D — Retire Python compiler

Plan: docs/project/self-hosting.md

Work

  • DSLs (dynamics/shaders/verify): Flow ports or explicit optional Python plugins
  • LSP: Python server calling flowc diagnostics OK; full rewrite later
  • Archive unused src/flow/*.py compile modules
  • Docs: compile requires cc + Flow binary, not Python

Exit

CI compile jobs have no pip install for the compiler itself.

Activity

  1. added
    enhancement
    self-hosting
    on Aug 5, 2026
  2. godofecht commented on Aug 5, 2026

    @godofecht
    ContributorAuthor

    Started Phase D slice 1 in a separate worktree (feature/flowc-phase-d) to avoid colliding with pattern-adoption work on src/flow/*.py. PR incoming: pip-free flowc-compile CI + docs; no Python module deletions yet.

  3. godofecht commented on Aug 5, 2026

    @godofecht
    ContributorAuthor

    Phase D slice 1 merged (#197):

    • New CI job flowc-compile (no pip): downloads Stage-A driver artifact; compiles Stage-A programs with no pip install
    • Gen0 bootstrap still needs pip (transpiler → numpy); documented
    • Host plugins (dynamics/shader/verify/LSP) stay on FLOW_HOST=python — no src/flow/*.py deletions (coordinated around concurrent pattern-adoption work)

    Remaining for #153 exit: broaden Stage-A surface, move example/tier2 compile off Python pip, optional lazy-import numpy so Gen0 can go bare-python later.

  4. godofecht commented on Aug 6, 2026

    @godofecht
    ContributorAuthor

    Phase D exit reached: no Python anywhere on the compile path

    Branch flowc/self-hosting-chain. Slice 1 (#197) proved the CI compile job needs no pip install. What remained was the Gen0 bootstrap: getting a compiler out of a clean checkout still required the Python host.

    Slice 2

    compiler/bootstrap/flowc_stage_a.c is now checked in — driver.flow plus every module it imports, emitted by flowc as a single 121 KB translation unit. cc on that file is a complete compiler.

    ./compiler/scripts/bootstrap_from_c.sh
    ./flow run examples/basics/fibonacci.flow    # exit 55

    Verified with python and python3 replaced by shims that exit 127 and log any invocation. Nothing logged. The whole three-generation self-host chain (self_host_full.sh) also runs clean under the same shims.

    New CI job flowc self-host (no Python) with no setup-python step: build from the bootstrap C, run the self-compile audit, run the three-generation fixed point, compile and run fibonacci through FLOW_HOST=flowc, then repeat it with python removed from PATH, then package. It is in the ci-ok required set.

    A bootstrap bug this exposed

    ensure_flowc.sh ran its Python fallback with FLOWC_PHASE_A_ONLY=1, which exits roundtrip.sh before any driver is linked. On a clean tree the default FLOW_HOST=flowc path could not bootstrap at all:

    ensure_flowc: bootstrap finished but no stage_a_driver* binary found
    ❌ flowc emit failed (Stage-A subset?)
    

    ensure_flowc.sh now builds the bootstrap C first and drops FLOWC_PHASE_A_ONLY=1 from the fallback.

    Drift protection

    bootstrap_from_c.sh --verify runs in roundtrip.sh and requires the checked-in C to be byte-for-byte what flowc emits from compiler/src today. Regenerate with --regen, which picks the freshest driver so a cgen change lands in one step.

    What still uses Python, and why none of it is the compile path

    Thing Why
    Full language surface (FLOW_HOST=python) Stage-A is a subset — generics, effects, MLIR/GPU, DSLs
    ./flow test, benchmarks, wiki build, LSP glue tooling, not compilation
    compiler/scripts/flowc_c_to_hdr.py roundtrip's per-module .o dogfood only; the bundle path needs no headers
    Re-deriving Gen0 from source without the checked-in C only if you distrust compiler/bootstrap/

    Nothing in src/flow/*.py was deleted. The Python host stays for the language surface Stage-A does not cover; it is no longer required to obtain or use a compiler.

    Gates: roundtrip.sh ALL PASS; ./flow test --strict --tier2 516/516.

  5. added 2 commits that reference this issue on Aug 9, 2026
    9e27d25
    aa21c02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementself-hosting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions