Skip to content

Commit 5fcd021

Browse files
committed
CI: test both stage3-debug and stage3-release on x86-linux
1 parent 7213bd9 commit 5fcd021

File tree

3 files changed

+104
-28
lines changed

3 files changed

+104
-28
lines changed

ci/zinc/drone.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ workspace:
99
path: /workspace
1010

1111
steps:
12-
- name: test
12+
- name: test_stage3_debug
1313
image: ci/debian-amd64:11.1-6
1414
commands:
15-
- ./ci/zinc/linux_test.sh
15+
- ./ci/zinc/linux_test_stage3_debug.sh
16+
17+
- name: test_stage3_release
18+
image: ci/debian-amd64:11.1-6
19+
commands:
20+
- ./ci/zinc/linux_test_stage3_release.sh
1621

1722
- name: package
1823
depends_on:
19-
- test
24+
- test_stage3_debug
25+
- test_stage3_release
2026
when:
2127
branch:
2228
- master

ci/zinc/linux_test.sh renamed to ci/zinc/linux_test_stage3_debug.sh

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ MCPU="baseline"
1010
# This will affect the cmake command below.
1111
git config core.abbrev 9
1212

13-
echo "building debug zig with zig version $($OLD_ZIG version)"
13+
echo "building stage3-debug with zig version $($OLD_ZIG version)"
1414

1515
export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
1616
export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
1717

18-
mkdir _debug
19-
cd _debug
18+
mkdir build-debug
19+
cd build-debug
2020
cmake .. \
2121
-DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
2222
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
@@ -63,29 +63,8 @@ stage3/bin/zig build test-standalone -fqemu -fwasmtime -Dstatic-llvm -Dtar
6363
stage3/bin/zig build test-cli -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
6464
stage3/bin/zig build test-cases -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
6565
stage3/bin/zig build test-link -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
66+
stage3/bin/zig build test-stack-traces -fqemu -fwasmtime -fstage1
6667
stage3/bin/zig build docs -fqemu -fwasmtime -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
6768

68-
stage3/bin/zig build test-stack-traces -fqemu -fwasmtime -fstage1
69-
70-
# Produce the experimental std lib documentation.
71-
mkdir -p "$RELEASE_STAGING/docs/std"
72-
stage3/bin/zig test lib/std/std.zig \
73-
--zig-lib-dir lib \
74-
-femit-docs=$RELEASE_STAGING/docs/std \
75-
-fno-emit-bin
76-
77-
# Look for HTML errors.
78-
tidy --drop-empty-elements no -qe zig-cache/langref.html
79-
80-
# Build release zig.
81-
stage3/bin/zig build \
82-
--prefix "$RELEASE_STAGING" \
83-
--search-prefix "$DEPS_LOCAL" \
84-
-Dstatic-llvm \
85-
-Drelease \
86-
-Dstrip \
87-
-Dtarget="$TARGET" \
88-
-Denable-stage1
89-
9069
# Explicit exit helps show last command duration.
9170
exit

ci/zinc/linux_test_stage3_release.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/sh
2+
3+
. ./ci/zinc/linux_base.sh
4+
5+
OLD_ZIG="$DEPS_LOCAL/bin/zig"
6+
TARGET="${ARCH}-linux-musl"
7+
MCPU="baseline"
8+
9+
# Make the `zig version` number consistent.
10+
# This will affect the cmake command below.
11+
git config core.abbrev 9
12+
13+
echo "building stage3-release with zig version $($OLD_ZIG version)"
14+
15+
export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
16+
export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
17+
18+
mkdir build-release
19+
cd build-release
20+
STAGE2_PREFIX="$(pwd)/stage2"
21+
cmake .. \
22+
-DCMAKE_INSTALL_PREFIX="$STAGE2_PREFIX" \
23+
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
24+
-DCMAKE_BUILD_TYPE=Release \
25+
-DZIG_TARGET_TRIPLE="$TARGET" \
26+
-DZIG_TARGET_MCPU="$MCPU" \
27+
-DZIG_STATIC=ON \
28+
-GNinja
29+
30+
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
31+
# so that installation and testing do not get affected by them.
32+
unset CC
33+
unset CXX
34+
35+
ninja install
36+
37+
# Here we rebuild zig but this time using the Zig binary we just now produced to
38+
# build zig1.o rather than relying on the one built with stage0. See
39+
# https://github.com/ziglang/zig/issues/6830 for more details.
40+
cmake .. -DZIG_EXECUTABLE="$STAGE2_PREFIX/bin/zig"
41+
ninja install
42+
43+
# This is the binary we will distribute. We intentionally test this one in this
44+
# script. If any test failures occur, hopefully they also occur in the debug
45+
# version of this script for easier troubleshooting. This prevents distribution
46+
# of a Zig binary that passes tests in debug mode but has a miscompilation in
47+
# release mode.
48+
"$STAGE2_PREFIX/bin/zig" build \
49+
--prefix "$RELEASE_STAGING" \
50+
--search-prefix "$DEPS_LOCAL" \
51+
-Dstatic-llvm \
52+
-Drelease \
53+
-Dstrip \
54+
-Dtarget="$TARGET" \
55+
-Denable-stage1
56+
57+
cd $WORKSPACE
58+
59+
ZIG="$RELEASE_STAGING/bin/zig"
60+
61+
$ZIG build \
62+
test-compiler-rt \
63+
test-behavior \
64+
test-std \
65+
test-universal-libc \
66+
test-compare-output \
67+
test-asm-link \
68+
test-translate-c \
69+
test-run-translated-c \
70+
test-standalone \
71+
test-cli \
72+
test-cases \
73+
test-link \
74+
-fqemu \
75+
-fwasmtime \
76+
-Dstatic-llvm \
77+
-Dtarget=native-native-musl \
78+
--search-prefix "$DEPS_LOCAL"
79+
80+
# Produce the experimental std lib documentation.
81+
mkdir -p "$RELEASE_STAGING/docs/std"
82+
$ZIG test lib/std/std.zig \
83+
--zig-lib-dir lib \
84+
-femit-docs=$RELEASE_STAGING/docs/std \
85+
-fno-emit-bin
86+
87+
# Look for HTML errors.
88+
tidy --drop-empty-elements no -qe zig-cache/langref.html
89+
90+
# Explicit exit helps show last command duration.
91+
exit

0 commit comments

Comments
 (0)