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
Copy file name to clipboardExpand all lines: content/dev-notes/zig/zig-build.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,20 @@ provide compile-time configuration to your code
261
261
* somewhere in its belly invokes your `pub fn build(b: *Builder)` on a `Builder` it created earlier
262
262
* The very last thing it does is hand over to this `Builder` you got to modify using `make()`
263
263
* the main workhorse is `LibExeObjStep.make` which spawns the actual zig compiler (e.g. `zig build-exe/zig build-lib/zig cc`) with the builder/step settings converted as command line args
264
-
* code at [src/main.zig](https://github.com/ziglang/zig/blob/master/src/main.zig),
264
+
* code at [src/main.zig](https://github.com/ziglang/zig/blob/master/src/main.zig)
265
+
266
+
### Compiler Stages
267
+
268
+
Zig uses multiple compiler stages for bootstrapping the compiler:
269
+
270
+
***zig0**: is just the c++ compiler as a static library
271
+
* only implements the backend for build-exe/obj etc
272
+
***stage1**: is the current compiler, written in C++, compiled with Clang
273
+
* uses *zig0* library to build pieces of *stage2* in (subcommands like translate-c etc)
274
+
***stage2**: is the current project, written in Zig, compiled with *stage1*
275
+
***stage3**: is the fully self-hosted, *stage2* code compiled with *stage2*
276
+
**stage1* doesn't implement full optimizations so *stage2* binary is not optimized
277
+
**stage3* binary is optimized b/c *stage2* implements optimizations/much better codegen
0 commit comments