8

Zig self hosted compiler is now capable of building itself

 2 years ago
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.
neoserver,ios ssh client

New issue

Make self hosted compiler capable of building itself #11442

Merged

Conversation

Copy link

Member

@Vexu Vexu commented 21 hours ago

$ 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

chwayne, Avokadoen, viriuwu, moosichu, seandewar, iddev5, lukechampine, langbamit, jibal, tinchoz49, and 25 more reacted with hooray emoji thejoshwolfe, haze, cvoges12, nektro, kubkon, Snektron, ethernetsellout, zeroZshadow, msfjarvis, doppioandante, and 56 more reacted with rocket emoji

Copy link

Member

Author

Vexu commented 19 hours ago

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
$ 
SuperAuguste, g-w1, Snektron, leecannon, squeek502, andrewrk, yaymalaga, illfygli, kassane, Avokadoen, and 13 more reacted with rocket emoji

Copy link

Contributor

Snektron commented 19 hours ago

Whats the time difference between the stage 2 and stage 3 build?

illfygli, zeroZshadow, Avokadoen, bradms, McSinyx, matu3ba, and Ristovski reacted with eyes emoji

Copy link

Member

andrewrk commented 6 hours ago

edited

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

kristoff-it, watsy0007, PrajwalCH, adelarsq, mandaputtra, nikitavoloboev, and anders-n08 reacted with thumbs up emoji kristoff-it, PrajwalCH, adelarsq, and anders-n08 reacted with laugh emoji kristoff-it, Ristovski, 0xcodeboi, PrajwalCH, adelarsq, kipcole9, and anders-n08 reacted with hooray emoji thejoshwolfe, sardaukar, tinchoz49, kristoff-it, s0LA1337, Ristovski, PrajwalCH, adelarsq, nikitavoloboev, and anders-n08 reacted with heart emoji McSinyx, dtzWill, kristoff-it, Ristovski, jayschwa, ypyf, PrajwalCH, adelarsq, acdenisSK, rottencandy, and anders-n08 reacted with rocket emoji

andrewrk

merged commit 578a792 into

ziglang:master 6 hours ago

4 checks passed

Vexu

deleted the stage3 branch

5 hours ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels
None yet
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK