zig-repro/README.md

36 lines
1.1 KiB
Markdown
Raw Normal View History

2024-11-05 06:15:27 +02:00
Building modern Zig from the original C++ implementation
--------------------------------------------------------
This repository explores building Zig from the C++ implementation without using
binary blobs. [Forum post goes with this][1].
2024-11-06 14:53:09 +02:00
Clone zig and prune binary files from history:
```
2024-11-08 16:47:27 +02:00
$ git clone https://github.com/ziglang/zig zig2
$ cd zig2
2024-11-09 23:17:04 +02:00
$ git config user.name "$(git config --get user.name)"
$ git config user.email "$(git config --get user.email)"
2024-11-06 14:53:09 +02:00
$ git filter-repo --prune-empty=never --prune-degenerate never --invert-paths --path-glob 'stage1/zig1.wasm*' --path stage1/zig1.c
```
Now build an isolated container with a bunch of zig historic dependencies:
2024-11-05 06:15:27 +02:00
```
$ docker build -t zig-repro .
2024-11-09 23:17:04 +02:00
$ docker run -ti --rm --name zig-repro \
2024-11-05 06:15:27 +02:00
-v ~/code:/x \
-v /home/$USER/.cache/zig:/home/$USER/.cache/zig \
2024-11-08 16:47:27 +02:00
-w /x/zig2 \
2024-11-05 06:18:08 +02:00
zig-repro \
2024-11-06 14:53:09 +02:00
sh -c "useradd -s /bin/bash -u $UID $USER && su $USER; bash"
```
And run the thing in the container:
```
2024-11-05 06:15:27 +02:00
$ ../zig-repro/run
```
[1]: https://ziggit.dev/t/building-self-hosted-from-the-original-c-implementation/6607/11