-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the feature of O(1) bootstrapping to temporarily regress #6378
Comments
@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. |
Yes and I have that working over in #6250 (with a fat checklist needed to be done before merging) |
So we would have stage1 autotranslated from stage2 after all, for some time at least? |
If instead you took the C output and just copied/pushed that to the |
Assume for this comment that c codegen "just works" and "cleanup can be done": 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.
|
I've also been thinking, on and off, about the feasibility of this proposal. Besides the problem of translating comptime and generics into C, as noted by @matu3ba, there's also the fact that stage2 is a pretty big piece of code. It is a production quality compiler with many features that are extraneous to the task of bootstrapping:
The bootstrap compiler, on the other hand, only needs a minimal parser and comptime system to translate Zig directly to C in some not terribly inefficient fashion. All actual development and debugging can be done with stage2, so the bootstrap compiler could cut a lot of corners: e.g., doc comments can be ignored entirely; some comptime checks and computations can be deferred to runtime; inlining directives can be mostly ignored, along with many error conditions like unused items. And that's just a couple of things off the top of my head. I'm guessing that a dedicated bootstrap compiler/translator focusing on simplicity and maintainablility might be of the order of 10 KLOC, while stage 2 (including the standard library) will be an MLOC project before long. It seems to me that maintaining a separate copy of stage 2 in C will likely create more work in the long run than writing a bootstrap compiler from scratch. |
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.
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 |
Related: #853
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:
The text was updated successfully, but these errors were encountered: