docs: Finch builds itself; what is left before main switches
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015f73FesGZGYPkmDvUcj6QX
This commit is contained in:
parent
7d2eca8271
commit
d7ad3d09f7
1 changed files with 26 additions and 30 deletions
|
|
@ -57,36 +57,32 @@ Measured from the repository, not from its README alone:
|
|||
the headers in `include/uapi/`, so they are not hand-written and cannot
|
||||
drift from the kernel.
|
||||
|
||||
## The self-hosting gap
|
||||
## Where self-hosting stands
|
||||
|
||||
"Rewrite it in Finch itself" was mostly done before this was written: `boot/`
|
||||
compiled itself. What it lacked is stated by its own test, `tests/boot.sh`,
|
||||
which skips every test using a feature `boot/` does not have. Measured against
|
||||
that test, on the branch `finish-finch` of the Finch repository (kept in the
|
||||
author's checkout, `Projects/Finch`, as a branch on top of `embed`):
|
||||
The Finch compiler written in Finch (`boot/`) now **builds itself**: stage 2 and
|
||||
stage 3 are byte-identical (58,660 lines of LLVM IR), and it passes all 22 of
|
||||
the repository's run tests (the C++ one passes 77/77). The work is on the
|
||||
`finish-finch` branch of `github.com/Nexoniarz/Finch`; `before-bootstrap` there
|
||||
is the all-C++ compiler, kept as the backup. `main` is untouched.
|
||||
|
||||
| Feature | `boot/` | Notes |
|
||||
|---|---|---|
|
||||
| sized numbers (`i8`..`u64`, `f32`), conversions | **done** | `int` and `float` stay the i64 and f64 defaults |
|
||||
| methods (`fn T.m`), mutation analysis | **done** | |
|
||||
| `defer` | **done** | |
|
||||
| errors as values (`-> T!`, `error`, `try`, `or`) | **done** | including `fn main() -> !` |
|
||||
| maps, `for k, v in`, `for i, x in` | **done** | |
|
||||
| `str(x)` of any value | **done** | |
|
||||
| **C import** (`import "x.h"`, `link`, C structs by value) | **missing** | the one that matters for SchOS: libclang through Finch's own C import, then the System V struct ABI |
|
||||
| target and ABI layer (AArch64, macOS, Windows) | missing | after C import |
|
||||
| language server | missing | `lsp.cpp`, 580 lines |
|
||||
What the self-hosted compiler has: sized numbers, methods, `defer`, errors as
|
||||
values, maps, `for k, v in`, C import through libclang (written in Finch, in
|
||||
`boot/cimport.fch`), C structs by value and `addr(fn)` callbacks (System V
|
||||
x86-64), `run`, `build`, `ir`, `version`, `-O0`, `-l`, `-I`.
|
||||
|
||||
The self-hosted compiler passes 17 of 22 tests and compiles itself to
|
||||
byte-identical output; the five it skips all import C. **C import is the next
|
||||
piece, and the last one before the C++ compiler is only a seed.** It is a few
|
||||
thousand lines of Finch (`cimport.cpp` and `abi.cpp` are 740 in C++), done in two
|
||||
steps so each can be tested: functions, constants, globals and pointers first
|
||||
(`cimport`, `c_pointers`), struct layout and the calling convention second
|
||||
(`c_structs`).
|
||||
What it does **not** have yet, and the C++ compiler does:
|
||||
|
||||
The scratch files `note.txt` and `notatka.txt` in the repository are not
|
||||
Finch's and can go.
|
||||
| | |
|
||||
|---|---|
|
||||
| `-g` debug info | text IR needs the DWARF metadata written by hand |
|
||||
| `--target` (Windows, ARM64, macOS) | their struct-passing rules (`abi.cpp`) and linkers |
|
||||
| `lsp`, the editor language server | `lsp.cpp`, 580 lines |
|
||||
| `export fn`, `build --shared` | on the author's local `embed` branch |
|
||||
|
||||
**`main` becomes the Finch-written compiler when those are in**, so that
|
||||
nothing a user does today stops working; until then it is the seed that builds
|
||||
the first stage. The new language features (enums, `match`, generics, a
|
||||
standard library) come before that switch, as simple as the rest of the language.
|
||||
|
||||
## Rules
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue