Remix.run Logo
donio 2 days ago

The Go toolchain is a nice illustration of this approach working in practice. It fully bootstraps in 90 seconds on my aging laptop and since it's fully self-hosted it doesn't even need a C compiler unless you want cgo support.

LLVM takes 2 hours to build on the same host and zig (with the LLVM backend) is another 20 minutes. It will be awesome if that can be brought down to 2 minutes or less.

AndyKelley 2 days ago | parent | next [-]

Is that building Go with Go? Or actual bootstrapping? Check this out...

Building Zig with Zig:

    andy@bark ~/s/zig (master)> time zig build
    
    ________________________________________________________
    Executed in   11.67 secs    fish           external
Bootstrapping with only a C compiler dependency (not even make or shell!):

    andy@bark ~/s/zig (master)> time cc -o bootstrap bootstrap.c; and time ./bootstrap
    
    ________________________________________________________
    Executed in   55.10 millis    fish           external
    
    gcc -o zig-wasm2c stage1/wasm2c.c -O2 -std=c99
    ./zig-wasm2c stage1/zig1.wasm zig1.c
    gcc -o zig1 zig1.c stage1/wasi.c -std=c99 -Os -lm
    ./zig1 lib build-exe -ofmt=c -lc -OReleaseSmall --name zig2 -femit-bin=zig2.c -target x86_64-linux --dep build_options --dep aro -Mroot=src/main.zig -Mbuild_options=config.zig -Maro=lib/compiler/aro/aro.zig
    ./zig1 lib build-obj -ofmt=c -OReleaseSmall --name compiler_rt -femit-bin=compiler_rt.c -target x86_64-linux -Mroot=lib/compiler_rt.zig
    gcc -o zig2 zig2.c compiler_rt.c -std=c99 -O2 -fno-stack-protector -Istage1 -Wl,-z,stack-size=0x10000000 -pthread
    
    ________________________________________________________
    Executed in  305.06 secs    fish           external
donio 2 days ago | parent [-]

> Is that building Go with Go? Or actual bootstrapping?

Normally it's just Go with Go. Besides the Go compiler you need bash if you want to use the normal bootstrap script but not much else. You can build your way up from C by building an old enough version of Go that was still C based but that's not usually done these days.

> Executed in 11.67 secs

Nice!

cxr 2 days ago | parent | prev [-]

Sometime after Minix 3 but before it had attained the critical mass for a self-sustaining community, compilation times went from 10 minutes on low-end hardware to ~3 hours, and the answer to the question "Why?" was "LLVM/clang".