| Filename | Latest commit message | Latest commit date |
|---|---|---|
src/embedded.fch (made by tools/pack.fch, checked by tests/run.sh) holds runtime/finch_rt.c and std/; when they aren't beside the binary they're written to the cache folder once. All the sh/cmd specifics of the driver (quoting, temp dir, mkdir, rm, mv, null device, path separator, cache dir, binary stdio) moved into host.fch / host_windows.fch. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015f73FesGZGYPkmDvUcj6QX |
||
| .. | ||
| build.sh | ||
| install.sh | ||
| linux-aarch64.ll | ||
| linux-x86_64.ll | ||
| pack.sh | ||
| README.md | ||
The seed
Finch's compiler is written in Finch. To build it you need something that already runs Finch: the seed, which is the compiler's own LLVM IR, one file per system:
| File | System | Checked |
|---|---|---|
linux-x86_64.ll |
Linux x86-64 | built and tested here and in CI |
linux-aarch64.ll |
Linux ARM64 | made with the ARM64 cross compiler; CI builds and tests it on an ARM64 runner |
bootstrap/build.sh compiles the seed with clang (and the runtime, and libclang) into build/finch0; finch0 builds
src/ into finch1; finch1 builds src/ again into build/finch; the two must make the same IR, or the script stops.
Why one per system
The seed includes how this system's C compiler passes structs by value, because the compiler calls libclang with
CXCursor, CXType and CXString (the calling convention is different on x86-64, on ARM64 and on Windows). So a seed
made for one system doesn't run on another, and a seed needs the target system's C headers to be made.
When to make a new one
When the compiler's own source starts to use a feature that the committed seed doesn't have, build.sh fails at the first
step. Make the seed from a working compiler:
bootstrap/build.sh seed # writes bootstrap/<this system>.ll
For another system, from a machine that has that system's headers and a cross compiler (what tests/cross.sh uses):
FINCH_CC=aarch64-linux-gnu-gcc build/finch ir src/main.fch --target arm64 > bootstrap/linux-aarch64.ll
macOS and Windows
There is no seed for them yet: it needs Apple's or Microsoft's headers, which can't be had on Linux. Until there is one,
programs for macOS and Windows are built from Linux with --target macos|windows, and the compiler's older C++ version
(branch before-bootstrap) is the way to get a compiler that runs there.