authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-02 15:42:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-02 15:46:22-07:00
logb24cbecdb2abb4399d65553ebade318263cd57d3
treebb56e8effbdef5ec7f4ebb48e635ca9d71f14c42
parentcbd653e1d678f0560f5ed3e93a41caa512d93443

zig build: promote qemu, wine, wasmtime, darling, and rosetta

from zig-specific options to generally recognized zig build options that any project can take advantage of. See the updated usage text for more details.

7 files changed, 86 insertions(+), 235 deletions(-)

build.zig+6-37
...@@ -296,13 +296,6 @@ pub fn build(b: *Builder) !void {...@@ -296,13 +296,6 @@ pub fn build(b: *Builder) !void {
296296
297 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");297 const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
298298
299 const is_wine_enabled = b.option(bool, "enable-wine", "Use Wine to run cross compiled Windows tests") orelse false;
300 const is_qemu_enabled = b.option(bool, "enable-qemu", "Use QEMU to run cross compiled foreign architecture tests") orelse false;
301 const is_wasmtime_enabled = b.option(bool, "enable-wasmtime", "Use Wasmtime to enable and run WASI libstd tests") orelse false;
302 const is_darling_enabled = b.option(bool, "enable-darling", "[Experimental] Use Darling to run cross compiled macOS tests") orelse false;
303 const is_rosetta_enabled = b.option(bool, "enable-rosetta", "(Darwin) Use Rosetta to run x86_64 macOS tests on arm64 macOS") orelse false;
304 const glibc_multi_dir = b.option([]const u8, "enable-foreign-glibc", "Provide directory with glibc installations to run cross compiled tests that link glibc");
305
306 const test_stage2_options = b.addOptions();299 const test_stage2_options = b.addOptions();
307 test_stage2.addOptions("build_options", test_stage2_options);300 test_stage2.addOptions("build_options", test_stage2_options);
308301
...@@ -317,13 +310,13 @@ pub fn build(b: *Builder) !void {...@@ -317,13 +310,13 @@ pub fn build(b: *Builder) !void {
317 test_stage2_options.addOption(bool, "llvm_has_csky", llvm_has_csky);310 test_stage2_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
318 test_stage2_options.addOption(bool, "llvm_has_ve", llvm_has_ve);311 test_stage2_options.addOption(bool, "llvm_has_ve", llvm_has_ve);
319 test_stage2_options.addOption(bool, "llvm_has_arc", llvm_has_arc);312 test_stage2_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
320 test_stage2_options.addOption(bool, "enable_qemu", is_qemu_enabled);313 test_stage2_options.addOption(bool, "enable_qemu", b.enable_qemu);
321 test_stage2_options.addOption(bool, "enable_wine", is_wine_enabled);314 test_stage2_options.addOption(bool, "enable_wine", b.enable_wine);
322 test_stage2_options.addOption(bool, "enable_wasmtime", is_wasmtime_enabled);315 test_stage2_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime);
323 test_stage2_options.addOption(bool, "enable_rosetta", is_rosetta_enabled);316 test_stage2_options.addOption(bool, "enable_rosetta", b.enable_rosetta);
317 test_stage2_options.addOption(bool, "enable_darling", b.enable_darling);
324 test_stage2_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2);318 test_stage2_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2);
325 test_stage2_options.addOption(bool, "enable_darling", is_darling_enabled);319 test_stage2_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir);
326 test_stage2_options.addOption(?[]const u8, "glibc_multi_install_dir", glibc_multi_dir);
327 test_stage2_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));320 test_stage2_options.addOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version));
328 test_stage2_options.addOption(std.SemanticVersion, "semver", semver);321 test_stage2_options.addOption(std.SemanticVersion, "semver", semver);
329322
...@@ -368,12 +361,6 @@ pub fn build(b: *Builder) !void {...@@ -368,12 +361,6 @@ pub fn build(b: *Builder) !void {
368 false, // skip_single_threaded361 false, // skip_single_threaded
369 skip_non_native,362 skip_non_native,
370 skip_libc,363 skip_libc,
371 is_wine_enabled,
372 is_qemu_enabled,
373 is_wasmtime_enabled,
374 is_darling_enabled,
375 is_rosetta_enabled,
376 glibc_multi_dir,
377 ));364 ));
378365
379 toolchain_step.dependOn(tests.addPkgTests(366 toolchain_step.dependOn(tests.addPkgTests(
...@@ -386,12 +373,6 @@ pub fn build(b: *Builder) !void {...@@ -386,12 +373,6 @@ pub fn build(b: *Builder) !void {
386 true, // skip_single_threaded373 true, // skip_single_threaded
387 skip_non_native,374 skip_non_native,
388 true, // skip_libc375 true, // skip_libc
389 is_wine_enabled,
390 is_qemu_enabled,
391 is_wasmtime_enabled,
392 is_darling_enabled,
393 is_rosetta_enabled,
394 glibc_multi_dir,
395 ));376 ));
396377
397 toolchain_step.dependOn(tests.addPkgTests(378 toolchain_step.dependOn(tests.addPkgTests(
...@@ -404,12 +385,6 @@ pub fn build(b: *Builder) !void {...@@ -404,12 +385,6 @@ pub fn build(b: *Builder) !void {
404 true, // skip_single_threaded385 true, // skip_single_threaded
405 skip_non_native,386 skip_non_native,
406 true, // skip_libc387 true, // skip_libc
407 is_wine_enabled,
408 is_qemu_enabled,
409 is_wasmtime_enabled,
410 is_darling_enabled,
411 is_rosetta_enabled,
412 glibc_multi_dir,
413 ));388 ));
414389
415 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));390 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
...@@ -435,12 +410,6 @@ pub fn build(b: *Builder) !void {...@@ -435,12 +410,6 @@ pub fn build(b: *Builder) !void {
435 false,410 false,
436 skip_non_native,411 skip_non_native,
437 skip_libc,412 skip_libc,
438 is_wine_enabled,
439 is_qemu_enabled,
440 is_wasmtime_enabled,
441 is_darling_enabled,
442 is_rosetta_enabled,
443 glibc_multi_dir,
444 );413 );
445414
446 const test_step = b.step("test", "Run all the tests");415 const test_step = b.step("test", "Run all the tests");
ci/azure/linux_script deleted-142
...@@ -1,142 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6sudo apt-get update -q
7sudo apt-get install -y cmake s3cmd tidy
8
9ZIGDIR="$(pwd)"
10ARCH="$(uname -m)"
11TARGET="$ARCH-linux-musl"
12CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.9.0-dev.1243+456d7e5f5"
13PREFIX="$HOME/$CACHE_BASENAME"
14MCPU="baseline"
15JOBS="-j$(nproc)"
16
17rm -rf $PREFIX
18cd $HOME
19
20wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
21tar xf "$CACHE_BASENAME.tar.xz"
22
23QEMUBASE="qemu-linux-x86_64-6.1.0.1"
24wget -nv "https://ziglang.org/deps/$QEMUBASE.tar.xz"
25tar xf "$QEMUBASE.tar.xz"
26export PATH="$(pwd)/$QEMUBASE/bin:$PATH"
27
28WASMTIME="wasmtime-v0.26.1-x86_64-linux"
29wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/v0.26.1/$WASMTIME.tar.xz"
30tar xf "$WASMTIME.tar.xz"
31export PATH="$(pwd)/$WASMTIME:$PATH"
32
33ZIG="$PREFIX/bin/zig"
34export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
35export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
36
37cd $ZIGDIR
38
39# Make the `zig version` number consistent.
40# This will affect the cmake command below.
41git config core.abbrev 9
42git fetch --unshallow || true
43git fetch --tags
44
45mkdir build
46cd build
47cmake .. \
48 -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
49 -DCMAKE_PREFIX_PATH="$PREFIX" \
50 -DCMAKE_BUILD_TYPE=Release \
51 -DZIG_TARGET_TRIPLE="$TARGET" \
52 -DZIG_TARGET_MCPU="$MCPU" \
53 -DZIG_STATIC=ON
54
55# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
56# so that installation and testing do not get affected by them.
57unset CC
58unset CXX
59
60make $JOBS install
61
62# Look for non-conforming code formatting.
63# Formatting errors can be fixed by running `zig fmt` on the files printed here.
64release/bin/zig fmt --check ..
65
66# Here we rebuild zig but this time using the Zig binary we just now produced to
67# build zig1.o rather than relying on the one built with stage0. See
68# https://github.com/ziglang/zig/issues/6830 for more details.
69cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig"
70make $JOBS install
71
72release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test
73
74release/bin/zig build test-behavior -Denable-qemu -Denable-wasmtime
75release/bin/zig build test-compiler-rt -Denable-qemu -Denable-wasmtime
76release/bin/zig build test-std -Denable-qemu -Denable-wasmtime
77release/bin/zig build test-minilibc -Denable-qemu -Denable-wasmtime
78release/bin/zig build test-compare-output -Denable-qemu -Denable-wasmtime
79release/bin/zig build test-standalone -Denable-qemu -Denable-wasmtime
80release/bin/zig build test-stack-traces -Denable-qemu -Denable-wasmtime
81release/bin/zig build test-cli -Denable-qemu -Denable-wasmtime
82release/bin/zig build test-asm-link -Denable-qemu -Denable-wasmtime
83release/bin/zig build test-runtime-safety -Denable-qemu -Denable-wasmtime
84release/bin/zig build test-translate-c -Denable-qemu -Denable-wasmtime
85release/bin/zig build test-run-translated-c -Denable-qemu -Denable-wasmtime
86release/bin/zig build docs -Denable-qemu -Denable-wasmtime
87release/bin/zig build # test building self-hosted without LLVM
88release/bin/zig build test-fmt -Denable-qemu -Denable-wasmtime
89release/bin/zig build test-stage2 -Denable-qemu -Denable-wasmtime
90
91# Look for HTML errors.
92tidy --drop-empty-elements no -qe ../zig-cache/langref.html
93
94if [ "${BUILD_REASON}" != "PullRequest" ]; then
95 # Produce the experimental std lib documentation.
96 mkdir -p release/docs/std
97 release/bin/zig test ../lib/std/std.zig \
98 --zig-lib-dir ../lib \
99 -femit-docs=release/docs/std \
100 -fno-emit-bin
101
102 mv ../LICENSE release/
103 mv ../zig-cache/langref.html release/docs/
104
105 # Remove the unnecessary bin dir in $prefix/bin/zig
106 mv release/bin/zig release/
107 rmdir release/bin
108
109 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
110 mv release/lib/zig release/lib2
111 rmdir release/lib
112 mv release/lib2 release/lib
113
114 VERSION=$(release/zig version)
115 DIRNAME="zig-linux-$ARCH-$VERSION"
116 TARBALL="$DIRNAME.tar.xz"
117 mv release "$DIRNAME"
118 tar cfJ "$TARBALL" "$DIRNAME"
119
120 mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
121 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
122
123 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
124 BYTESIZE=$(wc -c < $TARBALL)
125
126 JSONFILE="linux-$GITBRANCH.json"
127 touch $JSONFILE
128 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
129 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
130 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
131
132 s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
133 s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
134
135 # `set -x` causes these variables to be mangled.
136 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
137 set +x
138 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
139 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
140 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
141 echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
142fi
ci/zinc/linux_test.sh+15-15
...@@ -7,23 +7,23 @@ ZIG=$DEBUG_STAGING/bin/zig...@@ -7,23 +7,23 @@ ZIG=$DEBUG_STAGING/bin/zig
7$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test7$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test
8$ZIG test test/behavior.zig -fno-stage1 -ofmt=c -I test8$ZIG test test/behavior.zig -fno-stage1 -ofmt=c -I test
99
10$ZIG build test-behavior -Denable-qemu -Denable-wasmtime10$ZIG build test-behavior -fqemu -fwasmtime
11$ZIG build test-compiler-rt -Denable-qemu -Denable-wasmtime11$ZIG build test-compiler-rt -fqemu -fwasmtime
12$ZIG build test-std -Denable-qemu -Denable-wasmtime12$ZIG build test-std -fqemu -fwasmtime
13$ZIG build test-minilibc -Denable-qemu -Denable-wasmtime13$ZIG build test-minilibc -fqemu -fwasmtime
14$ZIG build test-compare-output -Denable-qemu -Denable-wasmtime14$ZIG build test-compare-output -fqemu -fwasmtime
15$ZIG build test-standalone -Denable-qemu -Denable-wasmtime15$ZIG build test-standalone -fqemu -fwasmtime
16$ZIG build test-stack-traces -Denable-qemu -Denable-wasmtime16$ZIG build test-stack-traces -fqemu -fwasmtime
17$ZIG build test-cli -Denable-qemu -Denable-wasmtime17$ZIG build test-cli -fqemu -fwasmtime
18$ZIG build test-asm-link -Denable-qemu -Denable-wasmtime18$ZIG build test-asm-link -fqemu -fwasmtime
19$ZIG build test-runtime-safety -Denable-qemu -Denable-wasmtime19$ZIG build test-runtime-safety -fqemu -fwasmtime
20$ZIG build test-translate-c -Denable-qemu -Denable-wasmtime20$ZIG build test-translate-c -fqemu -fwasmtime
21$ZIG build test-run-translated-c -Denable-qemu -Denable-wasmtime21$ZIG build test-run-translated-c -fqemu -fwasmtime
22$ZIG build docs -Denable-qemu -Denable-wasmtime22$ZIG build docs -fqemu -fwasmtime
23$ZIG build # test building self-hosted without LLVM23$ZIG build # test building self-hosted without LLVM
24$ZIG build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm24$ZIG build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
25$ZIG build test-fmt -Denable-qemu -Denable-wasmtime25$ZIG build test-fmt -fqemu -fwasmtime
26$ZIG build test-stage2 -Denable-qemu -Denable-wasmtime26$ZIG build test-stage2 -fqemu -fwasmtime
2727
28# Produce the experimental std lib documentation.28# Produce the experimental std lib documentation.
29mkdir -p $RELEASE_STAGING/docs/std29mkdir -p $RELEASE_STAGING/docs/std
lib/std/build.zig+22-27
...@@ -70,6 +70,22 @@ pub const Builder = struct {...@@ -70,6 +70,22 @@ pub const Builder = struct {
70 args: ?[][]const u8 = null,70 args: ?[][]const u8 = null,
71 debug_log_scopes: []const []const u8 = &.{},71 debug_log_scopes: []const []const u8 = &.{},
7272
73 /// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
74 enable_darling: bool = false,
75 /// Use system QEMU installation to run cross compiled foreign architecture build artifacts.
76 enable_qemu: bool = false,
77 /// Darwin. Use Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
78 enable_rosetta: bool = false,
79 /// Use system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
80 enable_wasmtime: bool = false,
81 /// Use system Wine installation to run cross compiled Windows build artifacts.
82 enable_wine: bool = false,
83 /// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
84 /// this will be the directory $glibc-build-dir/install/glibcs
85 /// Given the example of the aarch64 target, this is the directory
86 /// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
87 glibc_runtimes_dir: ?[]const u8 = null,
88
73 const PkgConfigError = error{89 const PkgConfigError = error{
74 PkgConfigCrashed,90 PkgConfigCrashed,
75 PkgConfigFailed,91 PkgConfigFailed,
...@@ -1504,27 +1520,6 @@ pub const LibExeObjStep = struct {...@@ -1504,27 +1520,6 @@ pub const LibExeObjStep = struct {
1504 /// Permit read-only relocations in read-only segments. Disallowed by default.1520 /// Permit read-only relocations in read-only segments. Disallowed by default.
1505 link_z_notext: bool = false,1521 link_z_notext: bool = false,
15061522
1507 /// Uses system Wine installation to run cross compiled Windows build artifacts.
1508 enable_wine: bool = false,
1509
1510 /// Uses system QEMU installation to run cross compiled foreign architecture build artifacts.
1511 enable_qemu: bool = false,
1512
1513 /// Uses system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
1514 enable_wasmtime: bool = false,
1515
1516 /// Experimental. Uses system Darling installation to run cross compiled macOS build artifacts.
1517 enable_darling: bool = false,
1518
1519 /// Darwin. Uses Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
1520 enable_rosetta: bool = false,
1521
1522 /// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
1523 /// this will be the directory $glibc-build-dir/install/glibcs
1524 /// Given the example of the aarch64 target, this is the directory
1525 /// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
1526 glibc_multi_install_dir: ?[]const u8 = null,
1527
1528 /// Position Independent Code1523 /// Position Independent Code
1529 force_pic: ?bool = null,1524 force_pic: ?bool = null,
15301525
...@@ -2533,13 +2528,13 @@ pub const LibExeObjStep = struct {...@@ -2533,13 +2528,13 @@ pub const LibExeObjStep = struct {
2533 }2528 }
2534 } else switch (self.target.getExternalExecutor()) {2529 } else switch (self.target.getExternalExecutor()) {
2535 .native, .unavailable => {},2530 .native, .unavailable => {},
2536 .rosetta => if (self.enable_rosetta) {2531 .rosetta => if (builder.enable_rosetta) {
2537 try zig_args.append("--test-cmd-bin");2532 try zig_args.append("--test-cmd-bin");
2538 },2533 },
2539 .qemu => |bin_name| if (self.enable_qemu) qemu: {2534 .qemu => |bin_name| if (builder.enable_qemu) qemu: {
2540 const need_cross_glibc = self.target.isGnuLibC() and self.is_linking_libc;2535 const need_cross_glibc = self.target.isGnuLibC() and self.is_linking_libc;
2541 const glibc_dir_arg = if (need_cross_glibc)2536 const glibc_dir_arg = if (need_cross_glibc)
2542 self.glibc_multi_install_dir orelse break :qemu2537 builder.glibc_runtimes_dir orelse break :qemu
2543 else2538 else
2544 null;2539 null;
2545 try zig_args.append("--test-cmd");2540 try zig_args.append("--test-cmd");
...@@ -2567,19 +2562,19 @@ pub const LibExeObjStep = struct {...@@ -2567,19 +2562,19 @@ pub const LibExeObjStep = struct {
2567 }2562 }
2568 try zig_args.append("--test-cmd-bin");2563 try zig_args.append("--test-cmd-bin");
2569 },2564 },
2570 .wine => |bin_name| if (self.enable_wine) {2565 .wine => |bin_name| if (builder.enable_wine) {
2571 try zig_args.append("--test-cmd");2566 try zig_args.append("--test-cmd");
2572 try zig_args.append(bin_name);2567 try zig_args.append(bin_name);
2573 try zig_args.append("--test-cmd-bin");2568 try zig_args.append("--test-cmd-bin");
2574 },2569 },
2575 .wasmtime => |bin_name| if (self.enable_wasmtime) {2570 .wasmtime => |bin_name| if (builder.enable_wasmtime) {
2576 try zig_args.append("--test-cmd");2571 try zig_args.append("--test-cmd");
2577 try zig_args.append(bin_name);2572 try zig_args.append(bin_name);
2578 try zig_args.append("--test-cmd");2573 try zig_args.append("--test-cmd");
2579 try zig_args.append("--dir=.");2574 try zig_args.append("--dir=.");
2580 try zig_args.append("--test-cmd-bin");2575 try zig_args.append("--test-cmd-bin");
2581 },2576 },
2582 .darling => |bin_name| if (self.enable_darling) {2577 .darling => |bin_name| if (builder.enable_darling) {
2583 try zig_args.append("--test-cmd");2578 try zig_args.append("--test-cmd");
2584 try zig_args.append(bin_name);2579 try zig_args.append(bin_name);
2585 try zig_args.append("--test-cmd-bin");2580 try zig_args.append("--test-cmd-bin");
lib/std/special/build_runner.zig+41
...@@ -142,6 +142,11 @@ pub fn main() !void {...@@ -142,6 +142,11 @@ pub fn main() !void {
142 return usageAndErr(builder, false, stderr_stream);142 return usageAndErr(builder, false, stderr_stream);
143 };143 };
144 try debug_log_scopes.append(next_arg);144 try debug_log_scopes.append(next_arg);
145 } else if (mem.eql(u8, arg, "--glibc-runtimes")) {
146 builder.glibc_runtimes_dir = nextArg(args, &arg_idx) orelse {
147 std.debug.print("Expected argument after --glibc-runtimes\n\n", .{});
148 return usageAndErr(builder, false, stderr_stream);
149 };
145 } else if (mem.eql(u8, arg, "--verbose-tokenize")) {150 } else if (mem.eql(u8, arg, "--verbose-tokenize")) {
146 builder.verbose_tokenize = true;151 builder.verbose_tokenize = true;
147 } else if (mem.eql(u8, arg, "--verbose-ast")) {152 } else if (mem.eql(u8, arg, "--verbose-ast")) {
...@@ -160,6 +165,26 @@ pub fn main() !void {...@@ -160,6 +165,26 @@ pub fn main() !void {
160 builder.verbose_llvm_cpu_features = true;165 builder.verbose_llvm_cpu_features = true;
161 } else if (mem.eql(u8, arg, "--prominent-compile-errors")) {166 } else if (mem.eql(u8, arg, "--prominent-compile-errors")) {
162 builder.prominent_compile_errors = true;167 builder.prominent_compile_errors = true;
168 } else if (mem.eql(u8, arg, "-fwine")) {
169 builder.enable_wine = true;
170 } else if (mem.eql(u8, arg, "-fno-wine")) {
171 builder.enable_wine = false;
172 } else if (mem.eql(u8, arg, "-fqemu")) {
173 builder.enable_qemu = true;
174 } else if (mem.eql(u8, arg, "-fno-qemu")) {
175 builder.enable_qemu = false;
176 } else if (mem.eql(u8, arg, "-fwasmtime")) {
177 builder.enable_wasmtime = true;
178 } else if (mem.eql(u8, arg, "-fno-wasmtime")) {
179 builder.enable_wasmtime = false;
180 } else if (mem.eql(u8, arg, "-frosetta")) {
181 builder.enable_rosetta = true;
182 } else if (mem.eql(u8, arg, "-fno-rosetta")) {
183 builder.enable_rosetta = false;
184 } else if (mem.eql(u8, arg, "-fdarling")) {
185 builder.enable_darling = true;
186 } else if (mem.eql(u8, arg, "-fno-darling")) {
187 builder.enable_darling = false;
163 } else if (mem.eql(u8, arg, "--")) {188 } else if (mem.eql(u8, arg, "--")) {
164 builder.args = argsRest(args, arg_idx);189 builder.args = argsRest(args, arg_idx);
165 break;190 break;
...@@ -233,6 +258,22 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void...@@ -233,6 +258,22 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
233 \\ --search-prefix [path] Add a path to look for binaries, libraries, headers258 \\ --search-prefix [path] Add a path to look for binaries, libraries, headers
234 \\ --libc [file] Provide a file which specifies libc paths259 \\ --libc [file] Provide a file which specifies libc paths
235 \\260 \\
261 \\ -fdarling, -fno-darling Integration with system-installed Darling to
262 \\ execute macOS programs on Linux hosts
263 \\ (default: no)
264 \\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute
265 \\ foreign-architecture programs on Linux hosts
266 \\ (default: no)
267 \\ --glibc-runtimes [path] Enhances QEMU integration by providing glibc built
268 \\ for multiple foreign architectures, allowing
269 \\ execution of non-native programs that link with glibc.
270 \\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on
271 \\ ARM64 macOS hosts. (default: no)
272 \\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to
273 \\ execute WASI binaries. (default: no)
274 \\ -fwine, -fno-wine Integration with system-installed Wine to execute
275 \\ Windows programs on Linux hosts. (default: no)
276 \\
236 \\ -h, --help Print this help and exit277 \\ -h, --help Print this help and exit
237 \\ --verbose Print commands before executing them278 \\ --verbose Print commands before executing them
238 \\ --color [auto|off|on] Enable or disable colored error messages279 \\ --color [auto|off|on] Enable or disable colored error messages
src/test.zig+2-2
...@@ -11,7 +11,7 @@ const enable_wine: bool = build_options.enable_wine;...@@ -11,7 +11,7 @@ const enable_wine: bool = build_options.enable_wine;
11const enable_wasmtime: bool = build_options.enable_wasmtime;11const enable_wasmtime: bool = build_options.enable_wasmtime;
12const enable_darling: bool = build_options.enable_darling;12const enable_darling: bool = build_options.enable_darling;
13const enable_rosetta: bool = build_options.enable_rosetta;13const enable_rosetta: bool = build_options.enable_rosetta;
14const glibc_multi_install_dir: ?[]const u8 = build_options.glibc_multi_install_dir;14const glibc_runtimes_dir: ?[]const u8 = build_options.glibc_runtimes_dir;
15const skip_compile_errors = build_options.skip_compile_errors;15const skip_compile_errors = build_options.skip_compile_errors;
16const ThreadPool = @import("ThreadPool.zig");16const ThreadPool = @import("ThreadPool.zig");
17const CrossTarget = std.zig.CrossTarget;17const CrossTarget = std.zig.CrossTarget;
...@@ -1143,7 +1143,7 @@ pub const TestContext = struct {...@@ -1143,7 +1143,7 @@ pub const TestContext = struct {
1143 // TODO Ability for test cases to specify whether to link libc.1143 // TODO Ability for test cases to specify whether to link libc.
1144 const need_cross_glibc = false; // target.isGnuLibC() and self.is_linking_libc;1144 const need_cross_glibc = false; // target.isGnuLibC() and self.is_linking_libc;
1145 const glibc_dir_arg = if (need_cross_glibc)1145 const glibc_dir_arg = if (need_cross_glibc)
1146 glibc_multi_install_dir orelse return // glibc dir not available; pass test1146 glibc_runtimes_dir orelse return // glibc dir not available; pass test
1147 else1147 else
1148 null;1148 null;
1149 try argv.append(qemu_bin_name);1149 try argv.append(qemu_bin_name);
test/tests.zig-12
...@@ -513,12 +513,6 @@ pub fn addPkgTests(...@@ -513,12 +513,6 @@ pub fn addPkgTests(
513 skip_single_threaded: bool,513 skip_single_threaded: bool,
514 skip_non_native: bool,514 skip_non_native: bool,
515 skip_libc: bool,515 skip_libc: bool,
516 is_wine_enabled: bool,
517 is_qemu_enabled: bool,
518 is_wasmtime_enabled: bool,
519 is_darling_enabled: bool,
520 is_rosetta_enabled: bool,
521 glibc_dir: ?[]const u8,
522) *build.Step {516) *build.Step {
523 const step = b.step(b.fmt("test-{s}", .{name}), desc);517 const step = b.step(b.fmt("test-{s}", .{name}), desc);
524518
...@@ -575,12 +569,6 @@ pub fn addPkgTests(...@@ -575,12 +569,6 @@ pub fn addPkgTests(
575 these_tests.linkSystemLibrary("c");569 these_tests.linkSystemLibrary("c");
576 }570 }
577 these_tests.overrideZigLibDir("lib");571 these_tests.overrideZigLibDir("lib");
578 these_tests.enable_wine = is_wine_enabled;
579 these_tests.enable_qemu = is_qemu_enabled;
580 these_tests.enable_wasmtime = is_wasmtime_enabled;
581 these_tests.enable_darling = is_darling_enabled;
582 these_tests.enable_rosetta = is_rosetta_enabled;
583 these_tests.glibc_multi_install_dir = glibc_dir;
584 these_tests.addIncludeDir("test");572 these_tests.addIncludeDir("test");
585573
586 step.dependOn(&these_tests.step);574 step.dependOn(&these_tests.step);