1
Fork 0
zig-repro/run

215 lines
5.3 KiB
Plaintext
Raw Normal View History

2024-11-01 09:33:22 +02:00
#!/usr/bin/env bash
2024-11-03 22:20:46 +02:00
HERE=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
2024-11-03 23:21:48 +02:00
# commit e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118
# Merge: 817cf6a82e 20d86d9c63
# Author: Andrew Kelley <andrew@ziglang.org>
# Date: 2022-12-07T01:52:39+02:00
#
# Merge pull request #13560 from ziglang/wasi-bootstrap
#
# Nuke the C++ implementation of Zig from orbit using WASI
MERGE_WASI_BOOTSTRAP=0.10.0-610-ge7d28344fa
# commit 3ba916584db5485c38ebf2390e8d22bc6d81bf8e
# Author: Andrew Kelley <andrew@ziglang.org>
# Date: 2022-11-05T03:47:19+02:00
#
# actually remove stage1
REMOVE_STAGE1=0.10.0-542-g3ba916584d
# commit 28514476ef8c824c3d189d98f23d0f8d23e496ea
# Author: Andrew Kelley <andrew@ziglang.org>
# Date: 2022-11-01T05:29:55+02:00
#
# remove `-fstage1` option
#
# After this commit, the self-hosted compiler does not offer the option to
# use stage1 as a backend anymore.
REMOVE_FSTAGE1=0.10.0-539-g28514476ef
# commit 9d93b2ccf11f584320a2c5209dd2d94705167695
# Author: Veikka Tuominen <git@vexu.eu>
# Date: 2022-12-08T19:52:05+02:00
#
# Eliminate `BoundFn` type from the language
#
# Closes #9484
BOUNDFN=0.10.0-675-g9d93b2ccf1
# commit d10fd78d4615f329141f5c19f893039d56aff425
# Author: Andrew Kelley <andrew@ziglang.org>
# Date: 2022-12-10T21:54:24+02:00
#
# update zig1.wasm
#
# This includes the latest changes from master branch with fixes to the C
# backend that affect aarch64-windows which are necessary to build from
# source on this target.
#
# stage1/zig1.wasm | Bin 2315523 -> 2315899 bytes
# 1 file changed, 0 insertions(+), 0 deletions(-)
C_AARCH64=0.10.0-722-gd10fd78d46
2024-11-06 14:11:10 +02:00
# commit 7b2a936173165002105ba5e76bed69654e132fea
2024-11-03 23:21:48 +02:00
# Author: Veikka Tuominen <git@vexu.eu>
2024-11-06 14:11:10 +02:00
# Date: 2022-12-12T15:32:37+02:00
2024-11-03 23:21:48 +02:00
#
2024-11-06 14:11:10 +02:00
# remove `stack` option from `@call`
CALL_OPTIONS=0.10.0-747-g7b2a936173-CallOptions.patch
# commit 08b2d491bcd8c79c68495267cc71967661caea1e
# Author: Veikka Tuominen <git@vexu.eu>
# Date: 2022-12-12T15:32:37+02:00
#
# update usages of `@call`
CALL_USAGES=0.10.0-748-g08b2d491bc
2024-11-03 23:21:48 +02:00
# commit 2a5e1426aa9469fadb78e837d0100d689213b034
# Author: Veikka Tuominen <git@vexu.eu>
# Date: 2022-12-16T19:44:25+02:00
#
# update zig1.wasm to builtin.Type field changes
BUILTIN_TYPE=0.10.0-853-g2a5e1426aa
2024-11-03 22:20:46 +02:00
step00() {
git checkout $MERGE_WASI_BOOTSTRAP
git revert --no-edit $REMOVE_STAGE1
git revert --no-edit -X theirs $REMOVE_FSTAGE1
git mv stage1/config.zig.in src
# removing the wasi-based stage1 just to be sure
git rm stage1/zig1.wasm.zst
sed -i '/have_stage1/ s/false/true/' src/config.zig.in
git checkout $REMOVE_FSTAGE1~1 build.zig CMakeLists.txt
echo "Building the C++ (stage1) implementation"
mkdir build
{
pushd build
2024-11-03 19:09:11 +02:00
CC=clang-15 CXX=clang++-15 cmake ..
make -j"$(nproc)" install
2024-11-03 22:20:46 +02:00
popd
}
2024-11-03 19:09:11 +02:00
2024-11-03 22:20:46 +02:00
echo "C++ implementation in build/stage3/bin/zig. Will build zig1.wasm.zst."
git reset --hard
git checkout $MERGE_WASI_BOOTSTRAP
rm stage1/zig1.wasm.zst
build/stage3/bin/zig build update-zig1
echo "stage1/zig1.wasm.zst built. Bootstrapping zig with it."
rm -fr build
mkdir build
{
pushd build
CC=clang-15 CXX=clang++-15 cmake ..
make -j"$(nproc)" install
popd
}
echo "Zig bootstrapped from selfhosted."
}
step10() {
2024-11-03 23:21:48 +02:00
echo "Generating zig1.wasm.zst for $BOUNDFN"
2024-11-03 23:44:29 +02:00
rm -fr ../zig-$BOUNDFN
2024-11-03 22:20:46 +02:00
git archive --prefix=zig-$BOUNDFN/ $BOUNDFN | tar -C .. -x --exclude="stage1/zig1.wasm*"
{
2024-11-03 22:25:28 +02:00
pushd "../zig-$BOUNDFN"
2024-11-03 22:20:46 +02:00
cp ../zig/stage1/zig1.wasm.zst stage1/
patch -p1 <"$HERE/0.10.0-675-g9d93b2ccf1-TypeOf-hack.patch"
mkdir build
{
pushd build
CC=clang-15 CXX=clang++-15 cmake ..
make -j"$(nproc)" install
popd
}
build/stage3/bin/zig build update-zig1
popd
}
echo "zig1.wasm.zst was built for BoundFn hack"
}
step20() {
2024-11-03 23:21:48 +02:00
echo "Generating zig1.wasm.zst for $C_AARCH64"
2024-11-03 23:44:29 +02:00
rm -fr ../zig-$BOUNDFN
2024-11-03 23:21:48 +02:00
git archive --prefix=zig-$C_AARCH64/ $C_AARCH64 | tar -C .. -x --exclude="stage1/zig1.wasm*"
{
pushd "../zig-$C_AARCH64"
zstd -cd ../zig-$BOUNDFN/stage1/zig1.wasm.zst >stage1/zig1.wasm
mkdir build
{
pushd build
CC=clang-15 CXX=clang++-15 cmake ..
make -j"$(nproc)" install
popd
}
build/stage3/bin/zig build update-zig1
popd
}
echo "zig1.wasm.zst was built for C-aarch64 backend"
}
2024-11-06 14:11:10 +02:00
step30() {
local FROM="$C_AARCH64"
local TO="$CALL_OPTIONS"
2024-11-03 23:21:48 +02:00
echo "Updating zig1.wasm from $FROM -> $TO in ../zig-$TO"
2024-11-03 23:44:29 +02:00
rm -fr "../zig-$TO"
2024-11-03 23:21:48 +02:00
git archive --prefix="zig-$TO/" "$TO" | tar -C .. -x --exclude="stage1/zig1.wasm"
{
pushd "../zig-$TO"
2024-11-06 14:11:10 +02:00
patch -p1 <"$HERE0.10.0-747-g7b2a936173-CallOptions.patch"
"../zig-$FROM/build/stage3/bin/zig" build --zig-lib-dir lib update-zig1
popd
}
echo "zig1.wasm updated for $TO"
}
step40() {
echo "Updating zig1.wasm from $FROM -> $TO in ../zig-$TO"
local FROM="$CALL_OPTIONS"
local TO="$CALL_USAGES"
rm -fr "../zig-$TO"
git archive --prefix=zig-$TO/ "$TO" | tar -C .. -x --exclude="stage1/zig1.wasm*"
{
pushd "../zig-$TO"
cp ../zig-$FROM/stage1/zig1.wasm stage1/zig1.wasm
2024-11-03 23:21:48 +02:00
mkdir build
{
pushd build
CC=clang-15 CXX=clang++-15 cmake ..
make -j"$(nproc)" install
popd
}
build/stage3/bin/zig build update-zig1
popd
}
echo "zig1.wasm updated for $TO"
2024-11-03 22:20:46 +02:00
}
2024-11-03 23:21:48 +02:00
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
set -xeuo pipefail
step00
step10
step20
2024-11-06 14:11:10 +02:00
step30
step40
2024-11-03 23:21:48 +02:00
fi