authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-23 02:08:18-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-01-23 02:08:18-05:00
logd395127552ab6f04b7b044b2a309e0d1e8977775
treea4ceb1d7b27cae61fb196f14d58e3c473ce69fdf
parent05c7f7abf1730a54568cd9dc7c8fa22102cd0f28
parent4592ee77c0770c60ec573e561a474e2ab9cf9b84
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #14389 from ziglang/ci-macos-debug

CI: additionally test x86_64-macos with a debug build of the zig compiler

5 files changed, 151 insertions(+), 81 deletions(-)

.github/workflows/ci.yaml+11-2
...@@ -38,7 +38,7 @@ jobs:...@@ -38,7 +38,7 @@ jobs:
38 uses: actions/checkout@v338 uses: actions/checkout@v3
39 - name: Build and Test39 - name: Build and Test
40 run: sh ci/aarch64-linux-release.sh40 run: sh ci/aarch64-linux-release.sh
41 x86_64-macos:41 x86_64-macos-debug:
42 runs-on: "macos-11"42 runs-on: "macos-11"
43 env:43 env:
44 ARCH: "x86_64"44 ARCH: "x86_64"
...@@ -46,7 +46,16 @@ jobs:...@@ -46,7 +46,16 @@ jobs:
46 - name: Checkout46 - name: Checkout
47 uses: actions/checkout@v347 uses: actions/checkout@v3
48 - name: Build and Test48 - name: Build and Test
49 run: ci/x86_64-macos.sh49 run: ci/x86_64-macos-debug.sh
50 x86_64-macos-release:
51 runs-on: "macos-11"
52 env:
53 ARCH: "x86_64"
54 steps:
55 - name: Checkout
56 uses: actions/checkout@v3
57 - name: Build and Test
58 run: ci/x86_64-macos-release.sh
50 aarch64-macos:59 aarch64-macos:
51 runs-on: [self-hosted, macOS, aarch64]60 runs-on: [self-hosted, macOS, aarch64]
52 env:61 env:
ci/x86_64-macos-debug.sh created+58
...@@ -0,0 +1,58 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ZIGDIR="$(pwd)"
7TARGET="$ARCH-macos-none"
8MCPU="baseline"
9CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.1416+8484df5bd"
10PREFIX="$HOME/$CACHE_BASENAME"
11JOBS="-j3"
12
13rm -rf $PREFIX
14cd $HOME
15
16curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
17tar xf "$CACHE_BASENAME.tar.xz"
18
19ZIG="$PREFIX/bin/zig"
20
21cd $ZIGDIR
22
23# Make the `zig version` number consistent.
24# This will affect the cmake command below.
25git config core.abbrev 9
26git fetch --unshallow || true
27git fetch --tags
28
29rm -rf build
30mkdir build
31cd build
32
33# Override the cache directories because they won't actually help other CI runs
34# which will be testing alternate versions of zig, and ultimately would just
35# fill up space on the hard drive for no reason.
36export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
37export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
38
39cmake .. \
40 -DCMAKE_PREFIX_PATH="$PREFIX" \
41 -DCMAKE_BUILD_TYPE=Debug \
42 -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
43 -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
44 -DZIG_TARGET_TRIPLE="$TARGET" \
45 -DZIG_TARGET_MCPU="$MCPU" \
46 -DZIG_STATIC=ON
47
48make $JOBS install
49
50stage3/bin/zig build test docs \
51 --zig-lib-dir "$(pwd)/../lib" \
52 -Denable-macos-sdk \
53 -Dstatic-llvm \
54 -Dskip-non-native \
55 --search-prefix "$PREFIX"
56
57# Produce the experimental std lib documentation.
58stage3/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
ci/x86_64-macos-release.sh created+74
...@@ -0,0 +1,74 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ZIGDIR="$(pwd)"
7TARGET="$ARCH-macos-none"
8MCPU="baseline"
9CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.1416+8484df5bd"
10PREFIX="$HOME/$CACHE_BASENAME"
11JOBS="-j3"
12
13rm -rf $PREFIX
14cd $HOME
15
16curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
17tar xf "$CACHE_BASENAME.tar.xz"
18
19ZIG="$PREFIX/bin/zig"
20
21cd $ZIGDIR
22
23# Make the `zig version` number consistent.
24# This will affect the cmake command below.
25git config core.abbrev 9
26git fetch --unshallow || true
27git fetch --tags
28
29rm -rf build
30mkdir build
31cd build
32
33# Override the cache directories because they won't actually help other CI runs
34# which will be testing alternate versions of zig, and ultimately would just
35# fill up space on the hard drive for no reason.
36export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
37export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
38
39cmake .. \
40 -DCMAKE_PREFIX_PATH="$PREFIX" \
41 -DCMAKE_BUILD_TYPE=Release \
42 -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
43 -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
44 -DZIG_TARGET_TRIPLE="$TARGET" \
45 -DZIG_TARGET_MCPU="$MCPU" \
46 -DZIG_STATIC=ON
47
48make $JOBS install
49
50stage3/bin/zig build test docs \
51 --zig-lib-dir "$(pwd)/../lib" \
52 -Denable-macos-sdk \
53 -Dstatic-llvm \
54 -Dskip-non-native \
55 --search-prefix "$PREFIX"
56
57# Produce the experimental std lib documentation.
58stage3/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
59
60# Ensure that stage3 and stage4 are byte-for-byte identical.
61stage3/bin/zig build \
62 --prefix stage4 \
63 -Denable-llvm \
64 -Dno-lib \
65 -Drelease \
66 -Dstrip \
67 -Dtarget=$TARGET \
68 -Duse-zig-libcxx \
69 -Dversion-string="$(stage3/bin/zig version)"
70
71# diff returns an error code if the files differ.
72echo "If the following command fails, it means nondeterminism has been"
73echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
74diff stage3/bin/zig stage4/bin/zig
ci/x86_64-macos.sh deleted-78
...@@ -1,78 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6# Script assumes the presence of the following:
7# s3cmd
8
9ZIGDIR="$(pwd)"
10TARGET="$ARCH-macos-none"
11MCPU="baseline"
12CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.534+b0b1cc356"
13PREFIX="$HOME/$CACHE_BASENAME"
14JOBS="-j3"
15
16rm -rf $PREFIX
17cd $HOME
18
19curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
20tar xf "$CACHE_BASENAME.tar.xz"
21
22ZIG="$PREFIX/bin/zig"
23
24cd $ZIGDIR
25
26# Make the `zig version` number consistent.
27# This will affect the cmake command below.
28git config core.abbrev 9
29git fetch --unshallow || true
30git fetch --tags
31
32rm -rf build
33mkdir build
34cd build
35
36# Override the cache directories because they won't actually help other CI runs
37# which will be testing alternate versions of zig, and ultimately would just
38# fill up space on the hard drive for no reason.
39export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
40export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
41
42cmake .. \
43 -DCMAKE_INSTALL_PREFIX="stage3-release" \
44 -DCMAKE_PREFIX_PATH="$PREFIX" \
45 -DCMAKE_BUILD_TYPE=Release \
46 -DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
47 -DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
48 -DZIG_TARGET_TRIPLE="$TARGET" \
49 -DZIG_TARGET_MCPU="$MCPU" \
50 -DZIG_STATIC=ON
51
52make $JOBS install
53
54stage3-release/bin/zig build test docs \
55 --zig-lib-dir "$(pwd)/../lib" \
56 -Denable-macos-sdk \
57 -Dstatic-llvm \
58 -Dskip-non-native \
59 --search-prefix "$PREFIX"
60
61# Produce the experimental std lib documentation.
62stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
63
64# Ensure that stage3 and stage4 are byte-for-byte identical.
65stage3-release/bin/zig build \
66 --prefix stage4-release \
67 -Denable-llvm \
68 -Dno-lib \
69 -Drelease \
70 -Dstrip \
71 -Dtarget=$TARGET \
72 -Duse-zig-libcxx \
73 -Dversion-string="$(stage3-release/bin/zig version)"
74
75# diff returns an error code if the files differ.
76echo "If the following command fails, it means nondeterminism has been"
77echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
78diff stage3-release/bin/zig stage4-release/bin/zig
src/Compilation.zig+8-1
...@@ -4319,11 +4319,18 @@ pub fn addCCArgs(...@@ -4319,11 +4319,18 @@ pub fn addCCArgs(
4319 }4319 }
4320 },4320 },
4321 .macos => {4321 .macos => {
4322 try argv.ensureUnusedCapacity(2);
4322 // Pass the proper -m<os>-version-min argument for darwin.4323 // Pass the proper -m<os>-version-min argument for darwin.
4323 const ver = target.os.version_range.semver.min;4324 const ver = target.os.version_range.semver.min;
4324 try argv.append(try std.fmt.allocPrint(arena, "-mmacos-version-min={d}.{d}.{d}", .{4325 argv.appendAssumeCapacity(try std.fmt.allocPrint(arena, "-mmacos-version-min={d}.{d}.{d}", .{
4325 ver.major, ver.minor, ver.patch,4326 ver.major, ver.minor, ver.patch,
4326 }));4327 }));
4328 // This avoids a warning that sometimes occurs when
4329 // providing both a -target argument that contains a
4330 // version as well as the -mmacosx-version-min argument.
4331 // Zig provides the correct value in both places, so it
4332 // doesn't matter which one gets overridden.
4333 argv.appendAssumeCapacity("-Wno-overriding-t-option");
4327 },4334 },
4328 .ios, .tvos, .watchos => switch (target.cpu.arch) {4335 .ios, .tvos, .watchos => switch (target.cpu.arch) {
4329 // Pass the proper -m<os>-version-min argument for darwin.4336 // Pass the proper -m<os>-version-min argument for darwin.