Remix.run Logo
AndyKelley 2 days ago

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!