Zig self hosted compiler is now capable of building itself
source link: https://github.com/ziglang/zig/pull/11442
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
New issue
Make self hosted compiler capable of building itself #11442
Merged
Conversation
$ zig build -Denable-llvm $ zig2 build -p build-stage3 $ cat a.zig const std = @import("std"); pub fn main() void { const stderr = std.io.getStdErr(); stderr.writeAll("Hello, world!\n") catch {}; } $ build-stage3/bin/zig run a.zig Hello, world!
LLVM backend needs some adjustments still.
Closes #11375
Recursion:
$ cd build $ cmake .. -DZIG_PREFER_CLANG_CPP_DYLIB=ON -DZIG_OMIT_STAGE2=on -DCMAKE_BUILD_TYPE=Release -- Configuring zig version 0.10.0-dev.1825+101aac92c -- Configuring done -- Generating done -- Build files have been written to: /home/vexu/Documents/zig/zig/build $ make -s -j 12 Consolidate compiler generated dependencies of target opt_c_util Consolidate compiler generated dependencies of target zigcpp Consolidate compiler generated dependencies of target embedded_softfloat [ 1%] Built target opt_c_util [ 5%] Built target zigcpp [ 86%] Built target embedded_softfloat Consolidate compiler generated dependencies of target zigstage1 [ 98%] Built target zigstage1 Consolidate compiler generated dependencies of target zig0 [ 99%] Building CXX object CMakeFiles/zig0.dir/src/stage1/zig0.cpp.o [ 99%] Linking CXX executable zig0 [ 99%] Built target zig0 [ 99%] Building self-hosted component /home/vexu/Documents/zig/zig/build/zig1.o Consolidate compiler generated dependencies of target zig [ 99%] Linking CXX executable zig [100%] Built target zig $ cd .. $ build/zig build -p build-stage2 -Denable-llvm -Dconfig_h=build/config.h $ build-stage2/bin/zig build -p build-stage3 -Denable-llvm -Dconfig_h=build/config.h $ build-stage3/bin/zig build -p build-stage4 -Denable-llvm -Dconfig_h=build/config.h $
Whats the time difference between the stage 2 and stage 3 build?
Whats the time difference between the stage 2 and stage 3 build?
I took one measurement on my computer:
stage1 (release) build stage2 (debug) (LLVM backend):
* wall clock: 47.80 seconds
* peak rss: 8.6 GiB
stage2 (release) build stage3 (debug) (LLVM backend):
* wall clock: 43.26 seconds
* peak rss: 2.3 GiB
While a 10% speedup is no joke, keep in mind this is only the beginning of a set of upcoming compiler milestones, each successively improving compilation speed. I talked about this at the Milan meetup last weekend and @kristoff-it will be posting the recordings soon.
Edit: here it is! https://www.youtube.com/watch?v=AqDdWEiSwMM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
No reviews
No one assigned
None yet
No milestone
Successfully merging this pull request may close these issues.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK