You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow the feature of O(1) bootstrapping to temporarily regress #6378
acceptedThis proposal is planned.frontendTokenization, parsing, AstGen, Sema, and Liveness.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.stage1The process of building from source via WebAssembly and the C backend.
Right now the bootstrap repository can start with cmake, a C++ compiler, bash, and cross compile zig for all supported targets. It does this in a fixed number of steps, because the Zig compiler is currently in c++ code and depends on an LLVM backend.
This proposal is to allow this feature to regress for a period of time between now and 1.0, restoring the feature before 1.0.
What that regression would look like is:
Finish implementing self-hosted (stage2) and pass all the behavior tests, std lib tests, and able to build itself.
Finish the C backend.
Use the C backend to generate a .c implementation of the self-hosted compiler
Delete the stage1 c++ code and check that generated .c code into the zig source repository to make it easy to build zig. This does not count as bootstrapping because the generated .c code is not source code. It's more like committing a multi-target binary into source control.
Exploit the fact that we only have 1 codebase for the zig compiler to iterate faster, solve bugs, finish the language, and approach 1.0. This is the main motivation for this proposal.
If instead you took the C output and just copied/pushed that to the zig-bootstrap repo every so often, then wouldn't that mean you wouldn't have to maintain the stage1 C compiler by hand ever?
Assume for this comment that c codegen "just works" and "cleanup can be done": rg -g '!arch' -g '!codegen' -g '!link' -g '!stage1' -g '!translate_c' -g '*.zig' 'std.ArrayListUnmanaged' | wc -l shows 27 instances of ArrayListUnmanaged inside folder src (the compiler implementation).
Once we touch things inside ArrayListUnmanaged or worse refactor things to a different datastructure, we need to redo the work on cleaning up C files and its unclear how much can be simplified in a maintainable way with macros or combine functions in other ways.
What is the necessary list of .zig files, which require translation to C? They should be listed for planning.
Is there follow-up tooling necessary to get "what stuff was changed" between 2 outputs from translate-c to track bigger refactorings (changes of basic data structures etc)? Synchronizing bigger changes manually sounds like recipe for disaster to me (multiple changes in combinations may introduce bad behavior)
If 2 is not necessary/its too much hassle to update changes of the basic data structures, ie we "freeze" the translated libc+compiler code as its better than current stage1 etc: How are contributors motivated to fix stage1 shenanigans/hacks that are introduced and we do not end up with the same situation as current c++ stage1 in the long run, where people dont want to touch some code?
All actual development and debugging can be done with stage2
On changes (before the release 1.0 spec/fixed semantics) and for basic quality assurance (+ easing development), one wants tests run in CI for the bootstrap compiler for the edge cases on different architectures etc.
Base for the test system could be inspired by tau (MIT licensed) https://github.com/jasmcaus/tau as it unfortunately does only support Mac, Linux, Windows (with the most common compilers).
Though I think dogfeeding might be simpler.
some comptime checks and computations can be deferred to runtime
The Zig compiler has no Zig backend (ie for comptime being resolved) and several comptime things dont exist intentionally at runtime.
order of 10 KLOC
My reference is arocc compiler for C, which is an arguably simpler and comparable language (due to no comptime): 89c6a7a7a6722d3965c1b81dfbab3800c2655cbdtokei . inside src/ shows me 18120 LOC code.
acceptedThis proposal is planned.frontendTokenization, parsing, AstGen, Sema, and Liveness.proposalThis issue suggests language modifications. If it also has the "accepted" label then it is planned.stage1The process of building from source via WebAssembly and the C backend.
Activity
joachimschmidt557 commentedon Sep 19, 2020
@andrewrk Is it planned to have a split between stage0 and stage1 again? As in that stage1 of 1.0 is composed of
This would reduce the amount of C code needed to maintain.
andrewrk commentedon Sep 19, 2020
Yes and I have that working over in #6250 (with a fat checklist needed to be done before merging)
Rocknest commentedon Sep 19, 2020
So we would have stage1 autotranslated from stage2 after all, for some time at least?
marler8997 commentedon Sep 20, 2020
If instead you took the C output and just copied/pushed that to the
zig-bootstraprepo every so often, then wouldn't that mean you wouldn't have to maintain the stage1 C compiler by hand ever?matu3ba commentedon Apr 17, 2022
Assume for this comment that c codegen "just works" and "cleanup can be done":
rg -g '!arch' -g '!codegen' -g '!link' -g '!stage1' -g '!translate_c' -g '*.zig' 'std.ArrayListUnmanaged' | wc -lshows 27 instances of ArrayListUnmanaged inside foldersrc(the compiler implementation).Once we touch things inside ArrayListUnmanaged or worse refactor things to a different datastructure, we need to redo the work on cleaning up C files and its unclear how much can be simplified in a maintainable way with macros or combine functions in other ways.
matu3ba commentedon Apr 18, 2022
On changes (before the release 1.0 spec/fixed semantics) and for basic quality assurance (+ easing development), one wants tests run in CI for the bootstrap compiler for the edge cases on different architectures etc.
Base for the test system could be inspired by tau (MIT licensed) https://github.com/jasmcaus/tau as it unfortunately does only support Mac, Linux, Windows (with the most common compilers).
Though I think dogfeeding might be simpler.
The Zig compiler has no Zig backend (ie for comptime being resolved) and several comptime things dont exist intentionally at runtime.
My reference is arocc compiler for C, which is an arguably simpler and comparable language (due to no comptime): 89c6a7a7a6722d3965c1b81dfbab3800c2655cbd
tokei .insidesrc/shows me 18120 LOC code.