authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-06 22:51:55-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-05-06 22:51:55-04:00
log0df28f9d45105c44fa28a86a880272acb9ccf630
tree1387a31e3717e802d103dbff4a3302942f9bd9d0
parentac1aaec9c38eb44b93099ff18579a9401f107100
parentefeb031b7917f552ea73ee59c086e3d75c87cbaf
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #11492 from ziglang/ci-stage3-behavior

CI: add non-LLVM backends to the test matrix

10 files changed, 348 insertions(+), 91 deletions(-)

build.zig+12
......@@ -445,6 +445,9 @@ pub fn build(b: *Builder) !void {
445445 false, // skip_single_threaded
446446 skip_non_native,
447447 skip_libc,
448 skip_stage1,
449 omit_stage2,
450 is_stage1,
448451 ));
449452
450453 toolchain_step.dependOn(tests.addPkgTests(
......@@ -457,6 +460,9 @@ pub fn build(b: *Builder) !void {
457460 true, // skip_single_threaded
458461 skip_non_native,
459462 true, // skip_libc
463 skip_stage1,
464 omit_stage2 or true, // TODO get these all passing
465 is_stage1,
460466 ));
461467
462468 toolchain_step.dependOn(tests.addPkgTests(
......@@ -469,6 +475,9 @@ pub fn build(b: *Builder) !void {
469475 true, // skip_single_threaded
470476 skip_non_native,
471477 true, // skip_libc
478 skip_stage1,
479 omit_stage2 or true, // TODO get these all passing
480 is_stage1,
472481 ));
473482
474483 toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes));
......@@ -494,6 +503,9 @@ pub fn build(b: *Builder) !void {
494503 false,
495504 skip_non_native,
496505 skip_libc,
506 skip_stage1,
507 omit_stage2 or true, // TODO get these all passing
508 is_stage1,
497509 );
498510
499511 const test_step = b.step("test", "Run all the tests");
ci/azure/macos_script+19-6
......@@ -58,12 +58,25 @@ make $JOBS install
5858# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt.
5959release/bin/zig build -p stage2 -Denable-llvm
6060
61stage2/bin/zig test ../test/behavior.zig -I../test -fLLVM
62stage2/bin/zig test ../test/behavior.zig -I../test -fno-LLVM
63
64release/bin/zig build test-toolchain -Denable-macos-sdk
65release/bin/zig build test-std
66release/bin/zig build docs
61stage2/bin/zig build test-behavior
62
63# TODO: upgrade these to test stage2 instead of stage1
64# TODO: upgrade these to test stage3 instead of stage2
65release/bin/zig build test-behavior -Denable-macos-sdk -Domit-stage2
66release/bin/zig build test-compiler-rt -Denable-macos-sdk
67release/bin/zig build test-std -Denable-macos-sdk
68release/bin/zig build test-minilibc -Denable-macos-sdk
69release/bin/zig build test-compare-output -Denable-macos-sdk
70release/bin/zig build test-standalone -Denable-macos-sdk
71release/bin/zig build test-stack-traces -Denable-macos-sdk
72release/bin/zig build test-cli -Denable-macos-sdk
73release/bin/zig build test-asm-link -Denable-macos-sdk
74release/bin/zig build test-runtime-safety -Denable-macos-sdk
75release/bin/zig build test-translate-c -Denable-macos-sdk
76release/bin/zig build test-run-translated-c -Denable-macos-sdk
77release/bin/zig build docs -Denable-macos-sdk
78release/bin/zig build test-fmt -Denable-macos-sdk
79release/bin/zig build test-stage2 -Denable-macos-sdk
6780
6881if [ "${BUILD_REASON}" != "PullRequest" ]; then
6982 mv ../LICENSE release/
ci/zinc/linux_test.sh+11-19
......@@ -48,25 +48,19 @@ cd $WORKSPACE
4848$ZIG fmt --check . --exclude test/cases/
4949
5050# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt.
51$ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
51$ZIG build -p stage2 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
5252
5353# Ensure that stage2 can build itself.
54./stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
55
56stage2/bin/zig test test/behavior.zig -I test -fLLVM
57stage2/bin/zig test test/behavior.zig -I test -fno-LLVM
58stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin
59stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin
60stage2/bin/zig test test/behavior.zig -I test -ofmt=c
61stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin
62stage2/bin/zig test test/behavior.zig -I test -fLLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin
63stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target arm-linux --test-cmd qemu-arm --test-cmd-bin
64stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-macos --test-no-exec
65stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-macos --test-no-exec
66stage2/bin/zig test test/behavior.zig -I test -fLLVM -target x86_64-macos --test-no-exec
67stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target x86_64-macos --test-no-exec
68
69$ZIG build test-behavior -fqemu -fwasmtime
54stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
55stage2/bin/zig build # test building self-hosted without LLVM
56stage2/bin/zig build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
57
58# Here we use stage2 instead of stage3 because of two bugs remaining:
59# * https://github.com/ziglang/zig/issues/11367 (and corresponding workaround in compiler source)
60# * https://github.com/ziglang/zig/pull/11492#issuecomment-1112871321
61stage2/bin/zig build test-behavior -fqemu -fwasmtime
62
63$ZIG build test-behavior -fqemu -fwasmtime -Domit-stage2
7064$ZIG build test-compiler-rt -fqemu -fwasmtime
7165$ZIG build test-std -fqemu -fwasmtime
7266$ZIG build test-minilibc -fqemu -fwasmtime
......@@ -79,8 +73,6 @@ $ZIG build test-runtime-safety -fqemu -fwasmtime
7973$ZIG build test-translate-c -fqemu -fwasmtime
8074$ZIG build test-run-translated-c -fqemu -fwasmtime
8175$ZIG build docs -fqemu -fwasmtime
82$ZIG build # test building self-hosted without LLVM
83$ZIG build -Dtarget=arm-linux-musleabihf # test building self-hosted for 32-bit arm
8476$ZIG build test-fmt -fqemu -fwasmtime
8577$ZIG build test-stage2 -fqemu -fwasmtime
8678
lib/std/build.zig+14
......@@ -1590,6 +1590,8 @@ pub const LibExeObjStep = struct {
15901590
15911591 want_lto: ?bool = null,
15921592 use_stage1: ?bool = null,
1593 use_llvm: ?bool = null,
1594 ofmt: ?std.Target.ObjectFormat = null,
15931595
15941596 output_path_source: GeneratedFile,
15951597 output_lib_path_source: GeneratedFile,
......@@ -2351,6 +2353,18 @@ pub const LibExeObjStep = struct {
23512353 }
23522354 }
23532355
2356 if (self.use_llvm) |use_llvm| {
2357 if (use_llvm) {
2358 try zig_args.append("-fLLVM");
2359 } else {
2360 try zig_args.append("-fno-LLVM");
2361 }
2362 }
2363
2364 if (self.ofmt) |ofmt| {
2365 try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
2366 }
2367
23542368 if (self.entry_symbol_name) |entry| {
23552369 try zig_args.append("--entry");
23562370 try zig_args.append(entry);
lib/std/os/linux/arm-eabi.zig+4-1
......@@ -99,7 +99,10 @@ pub fn syscall6(
9999
100100/// This matches the libc clone function.
101101pub extern fn clone(
102 func: fn (arg: usize) callconv(.C) u8,
102 func: switch (@import("builtin").zig_backend) {
103 .stage1 => fn (arg: usize) callconv(.C) u8,
104 else => *const fn (arg: usize) callconv(.C) u8,
105 },
103106 stack: usize,
104107 flags: u32,
105108 arg: usize,
src/codegen/llvm.zig+95-9
......@@ -4234,36 +4234,103 @@ pub const FuncGen = struct {
42344234 return null;
42354235
42364236 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
4237
42374238 const operand = try self.resolveInst(ty_op.operand);
42384239 const operand_ty = self.air.typeOf(ty_op.operand);
42394240 const operand_scalar_ty = operand_ty.scalarType();
4241
42404242 const dest_ty = self.air.typeOfIndex(inst);
4243 const dest_scalar_ty = dest_ty.scalarType();
42414244 const dest_llvm_ty = try self.dg.llvmType(dest_ty);
4245 const target = self.dg.module.getTarget();
42424246
4243 if (operand_scalar_ty.isSignedInt()) {
4244 return self.builder.buildSIToFP(operand, dest_llvm_ty, "");
4245 } else {
4246 return self.builder.buildUIToFP(operand, dest_llvm_ty, "");
4247 if (intrinsicsAllowed(dest_scalar_ty, target)) {
4248 if (operand_scalar_ty.isSignedInt()) {
4249 return self.builder.buildSIToFP(operand, dest_llvm_ty, "");
4250 } else {
4251 return self.builder.buildUIToFP(operand, dest_llvm_ty, "");
4252 }
42474253 }
4254
4255 const operand_bits = @intCast(u16, operand_scalar_ty.bitSize(target));
4256 const rt_int_bits = compilerRtIntBits(operand_bits);
4257 const rt_int_ty = self.context.intType(rt_int_bits);
4258 const extended = e: {
4259 if (operand_scalar_ty.isSignedInt()) {
4260 break :e self.builder.buildSExtOrBitCast(operand, rt_int_ty, "");
4261 } else {
4262 break :e self.builder.buildZExtOrBitCast(operand, rt_int_ty, "");
4263 }
4264 };
4265 const dest_bits = dest_scalar_ty.floatBits(target);
4266 const compiler_rt_operand_abbrev = compilerRtIntAbbrev(rt_int_bits);
4267 const compiler_rt_dest_abbrev = compilerRtFloatAbbrev(dest_bits);
4268 const sign_prefix = if (operand_scalar_ty.isSignedInt()) "" else "un";
4269 var fn_name_buf: [64]u8 = undefined;
4270 const fn_name = std.fmt.bufPrintZ(&fn_name_buf, "__float{s}{s}i{s}f", .{
4271 sign_prefix,
4272 compiler_rt_operand_abbrev,
4273 compiler_rt_dest_abbrev,
4274 }) catch unreachable;
4275 const param_types = [1]*const llvm.Type{rt_int_ty};
4276 const libc_fn = self.getLibcFunction(fn_name, &param_types, dest_llvm_ty);
4277 const params = [1]*const llvm.Value{extended};
4278
4279 return self.builder.buildCall(libc_fn, &params, params.len, .C, .Auto, "");
42484280 }
42494281
42504282 fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {
42514283 if (self.liveness.isUnused(inst))
42524284 return null;
42534285
4286 const target = self.dg.module.getTarget();
42544287 const ty_op = self.air.instructions.items(.data)[inst].ty_op;
4288
42554289 const operand = try self.resolveInst(ty_op.operand);
4290 const operand_ty = self.air.typeOf(ty_op.operand);
4291 const operand_scalar_ty = operand_ty.scalarType();
4292
42564293 const dest_ty = self.air.typeOfIndex(inst);
42574294 const dest_scalar_ty = dest_ty.scalarType();
42584295 const dest_llvm_ty = try self.dg.llvmType(dest_ty);
42594296
4260 // TODO set fast math flag
4297 if (intrinsicsAllowed(operand_scalar_ty, target)) {
4298 // TODO set fast math flag
4299 if (dest_scalar_ty.isSignedInt()) {
4300 return self.builder.buildFPToSI(operand, dest_llvm_ty, "");
4301 } else {
4302 return self.builder.buildFPToUI(operand, dest_llvm_ty, "");
4303 }
4304 }
42614305
4262 if (dest_scalar_ty.isSignedInt()) {
4263 return self.builder.buildFPToSI(operand, dest_llvm_ty, "");
4264 } else {
4265 return self.builder.buildFPToUI(operand, dest_llvm_ty, "");
4306 const rt_int_bits = compilerRtIntBits(@intCast(u16, dest_scalar_ty.bitSize(target)));
4307 const libc_ret_ty = self.context.intType(rt_int_bits);
4308
4309 const operand_bits = operand_scalar_ty.floatBits(target);
4310 const compiler_rt_operand_abbrev = compilerRtFloatAbbrev(operand_bits);
4311
4312 const compiler_rt_dest_abbrev = compilerRtIntAbbrev(rt_int_bits);
4313 const sign_prefix = if (dest_scalar_ty.isSignedInt()) "" else "un";
4314
4315 var fn_name_buf: [64]u8 = undefined;
4316 const fn_name = std.fmt.bufPrintZ(&fn_name_buf, "__fix{s}{s}f{s}i", .{
4317 sign_prefix,
4318 compiler_rt_operand_abbrev,
4319 compiler_rt_dest_abbrev,
4320 }) catch unreachable;
4321
4322 const operand_llvm_ty = try self.dg.llvmType(operand_ty);
4323 const param_types = [1]*const llvm.Type{operand_llvm_ty};
4324 const libc_fn = self.getLibcFunction(fn_name, &param_types, libc_ret_ty);
4325 const params = [1]*const llvm.Value{operand};
4326
4327 const result = self.builder.buildCall(libc_fn, &params, params.len, .C, .Auto, "");
4328
4329 if (libc_ret_ty == dest_llvm_ty) {
4330 return result;
42664331 }
4332
4333 return self.builder.buildTrunc(result, dest_llvm_ty, "");
42674334 }
42684335
42694336 fn airSliceField(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*const llvm.Value {
......@@ -5615,6 +5682,16 @@ pub const FuncGen = struct {
56155682 };
56165683 }
56175684
5685 fn compilerRtIntAbbrev(bits: u16) []const u8 {
5686 return switch (bits) {
5687 16 => "h",
5688 32 => "s",
5689 64 => "d",
5690 128 => "t",
5691 else => "o", // Non-standard
5692 };
5693 }
5694
56185695 /// Creates a floating point comparison by lowering to the appropriate
56195696 /// hardware instruction or softfloat routine for the target
56205697 fn buildFloatCmp(
......@@ -8313,3 +8390,12 @@ fn needDbgVarWorkaround(dg: *DeclGen, ty: Type) bool {
83138390 }
83148391 return false;
83158392}
8393
8394fn compilerRtIntBits(bits: u16) u16 {
8395 inline for (.{ 8, 16, 32, 64, 128 }) |b| {
8396 if (bits <= b) {
8397 return b;
8398 }
8399 }
8400 return bits;
8401}
src/codegen/llvm/bindings.zig+8
......@@ -476,6 +476,14 @@ pub const Builder = opaque {
476476 Name: [*:0]const u8,
477477 ) *const Value;
478478
479 pub const buildSExtOrBitCast = LLVMBuildSExtOrBitCast;
480 extern fn LLVMBuildSExtOrBitCast(
481 *const Builder,
482 Val: *const Value,
483 DestTy: *const Type,
484 Name: [*:0]const u8,
485 ) *const Value;
486
479487 pub const buildCall = ZigLLVMBuildCall;
480488 extern fn ZigLLVMBuildCall(
481489 *const Builder,
src/link/MachO.zig+16-10
......@@ -392,8 +392,9 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO {
392392 // Adhoc code signature is required when targeting aarch64-macos either directly or indirectly via the simulator
393393 // ABI such as aarch64-ios-simulator, etc.
394394 const requires_adhoc_codesig = cpu_arch == .aarch64 and (os_tag == .macos or abi == .simulator);
395 const use_llvm = build_options.have_llvm and options.use_llvm;
395396 const use_stage1 = build_options.is_stage1 and options.use_stage1;
396 const needs_prealloc = !(use_stage1 or options.cache_mode == .whole);
397 const needs_prealloc = !(use_stage1 or use_llvm or options.cache_mode == .whole);
397398
398399 const self = try gpa.create(MachO);
399400 errdefer gpa.destroy(self);
......@@ -410,7 +411,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO {
410411 .needs_prealloc = needs_prealloc,
411412 };
412413
413 const use_llvm = build_options.have_llvm and options.use_llvm;
414414 if (use_llvm and !use_stage1) {
415415 self.llvm_object = try LlvmObject.create(gpa, options);
416416 }
......@@ -519,7 +519,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
519519 var needs_full_relink = true;
520520
521521 cache: {
522 if (use_stage1 and self.base.options.disable_lld_caching) break :cache;
522 if ((use_stage1 and self.base.options.disable_lld_caching) or self.base.options.cache_mode == .whole)
523 break :cache;
523524
524525 man = comp.cache_parent.obtain();
525526
......@@ -571,7 +572,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
571572 if (mem.eql(u8, prev_digest, &digest)) {
572573 // Hot diggity dog! The output binary is already there.
573574
574 if (use_stage1) {
575 const use_llvm = build_options.have_llvm and self.base.options.use_llvm;
576 if (use_llvm or use_stage1) {
575577 log.debug("MachO Zld digest={s} match - skipping invocation", .{std.fmt.fmtSliceHexLower(&digest)});
576578 self.base.lock = man.toOwnedLock();
577579 return;
......@@ -1025,7 +1027,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
10251027 try self.createTentativeDefAtoms();
10261028 try self.parseObjectsIntoAtoms();
10271029
1028 if (use_stage1) {
1030 const use_llvm = build_options.have_llvm and self.base.options.use_llvm;
1031 if (use_llvm or use_stage1) {
10291032 try self.sortSections();
10301033 try self.allocateTextSegment();
10311034 try self.allocateDataConstSegment();
......@@ -1041,7 +1044,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
10411044 self.logSectionOrdinals();
10421045 }
10431046
1044 if (use_stage1) {
1047 if (use_llvm or use_stage1) {
10451048 try self.writeAllAtoms();
10461049 } else {
10471050 try self.writeAtoms();
......@@ -1097,7 +1100,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No
10971100 }
10981101
10991102 cache: {
1100 if (use_stage1 and self.base.options.disable_lld_caching) break :cache;
1103 if ((use_stage1 and self.base.options.disable_lld_caching) or self.base.options.cache_mode == .whole)
1104 break :cache;
11011105 // Update the file with the digest. If it fails we can continue; it only
11021106 // means that the next invocation will have an unnecessary cache miss.
11031107 Cache.writeSmallFile(cache_dir_handle, id_symlink_basename, &digest) catch |err| {
......@@ -4930,12 +4934,13 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void {
49304934 var start: u64 = offset;
49314935 for (seg.sections.items) |*sect, sect_id| {
49324936 const is_zerofill = sect.flags == macho.S_ZEROFILL or sect.flags == macho.S_THREAD_LOCAL_ZEROFILL;
4937 const use_llvm = build_options.have_llvm and self.base.options.use_llvm;
49334938 const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1;
49344939 const alignment = try math.powi(u32, 2, sect.@"align");
49354940 const start_aligned = mem.alignForwardGeneric(u64, start, alignment);
49364941
49374942 // TODO handle zerofill sections in stage2
4938 sect.offset = if (is_zerofill and use_stage1) 0 else @intCast(u32, seg.inner.fileoff + start_aligned);
4943 sect.offset = if (is_zerofill and (use_stage1 or use_llvm)) 0 else @intCast(u32, seg.inner.fileoff + start_aligned);
49394944 sect.addr = seg.inner.vmaddr + start_aligned;
49404945
49414946 // Recalculate section size given the allocated start address
......@@ -4963,7 +4968,7 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void {
49634968
49644969 start = start_aligned + sect.size;
49654970
4966 if (!(is_zerofill and use_stage1)) {
4971 if (!(is_zerofill and (use_stage1 or use_llvm))) {
49674972 seg.inner.filesize = start;
49684973 }
49694974 seg.inner.vmsize = start;
......@@ -5012,10 +5017,11 @@ fn initSection(
50125017 sect.addr = seg.inner.vmaddr + off - seg.inner.fileoff;
50135018
50145019 const is_zerofill = opts.flags == macho.S_ZEROFILL or opts.flags == macho.S_THREAD_LOCAL_ZEROFILL;
5020 const use_llvm = build_options.have_llvm and self.base.options.use_llvm;
50155021 const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1;
50165022
50175023 // TODO handle zerofill in stage2
5018 if (!(is_zerofill and use_stage1)) {
5024 if (!(is_zerofill and (use_stage1 or use_llvm))) {
50195025 sect.offset = @intCast(u32, off);
50205026 }
50215027 }
test/behavior/cast.zig+36
......@@ -112,6 +112,42 @@ test "@intToFloat" {
112112 comptime try S.doTheTest();
113113}
114114
115test "@intToFloat(f80)" {
116 if (builtin.zig_backend == .stage1) return error.SkipZigTest;
117
118 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
119 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
120 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
121 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
122 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
123
124 const S = struct {
125 fn doTheTest(comptime Int: type) !void {
126 try testIntToFloat(Int, -2);
127 }
128
129 fn testIntToFloat(comptime Int: type, k: Int) !void {
130 const f = @intToFloat(f80, k);
131 const i = @floatToInt(Int, f);
132 try expect(i == k);
133 }
134 };
135 try S.doTheTest(i31);
136 try S.doTheTest(i32);
137 try S.doTheTest(i45);
138 try S.doTheTest(i64);
139 try S.doTheTest(i80);
140 try S.doTheTest(i128);
141 // try S.doTheTest(i256); // TODO missing compiler_rt symbols
142 comptime try S.doTheTest(i31);
143 comptime try S.doTheTest(i32);
144 comptime try S.doTheTest(i45);
145 comptime try S.doTheTest(i64);
146 comptime try S.doTheTest(i80);
147 comptime try S.doTheTest(i128);
148 comptime try S.doTheTest(i256);
149}
150
115151test "@floatToInt" {
116152 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
117153 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
test/tests.zig+133-46
......@@ -34,6 +34,7 @@ const TestTarget = struct {
3434 link_libc: bool = false,
3535 single_threaded: bool = false,
3636 disable_native: bool = false,
37 backend: ?std.builtin.CompilerBackend = null,
3738};
3839
3940const test_targets = blk: {
......@@ -42,15 +43,73 @@ const test_targets = blk: {
4243 // lot of branches)
4344 @setEvalBranchQuota(50000);
4445 break :blk [_]TestTarget{
45 TestTarget{},
46 TestTarget{
46 .{},
47 .{
4748 .link_libc = true,
4849 },
49 TestTarget{
50 .{
5051 .single_threaded = true,
5152 },
5253
53 TestTarget{
54 .{
55 .link_libc = true,
56 .backend = .stage2_c,
57 },
58 .{
59 .target = .{
60 .cpu_arch = .x86_64,
61 .os_tag = .linux,
62 .abi = .none,
63 },
64 .backend = .stage2_x86_64,
65 },
66 .{
67 .target = .{
68 .cpu_arch = .aarch64,
69 .os_tag = .linux,
70 },
71 .backend = .stage2_aarch64,
72 },
73 .{
74 .target = .{
75 .cpu_arch = .wasm32,
76 .os_tag = .wasi,
77 },
78 .single_threaded = true,
79 .backend = .stage2_wasm,
80 },
81 .{
82 .target = .{
83 .cpu_arch = .arm,
84 .os_tag = .linux,
85 },
86 .backend = .stage2_wasm,
87 },
88 .{
89 .target = CrossTarget.parse(.{
90 .arch_os_abi = "arm-linux-none",
91 .cpu_features = "generic+v8a",
92 }) catch unreachable,
93 .backend = .stage2_arm,
94 },
95 .{
96 .target = .{
97 .cpu_arch = .aarch64,
98 .os_tag = .macos,
99 .abi = .gnu,
100 },
101 .backend = .stage2_aarch64,
102 },
103 .{
104 .target = .{
105 .cpu_arch = .x86_64,
106 .os_tag = .macos,
107 .abi = .gnu,
108 },
109 .backend = .stage2_x86_64,
110 },
111
112 .{
54113 .target = .{
55114 .cpu_arch = .wasm32,
56115 .os_tag = .wasi,
......@@ -58,7 +117,7 @@ const test_targets = blk: {
58117 .link_libc = false,
59118 .single_threaded = true,
60119 },
61 TestTarget{
120 .{
62121 .target = .{
63122 .cpu_arch = .wasm32,
64123 .os_tag = .wasi,
......@@ -67,14 +126,14 @@ const test_targets = blk: {
67126 .single_threaded = true,
68127 },
69128
70 TestTarget{
129 .{
71130 .target = .{
72131 .cpu_arch = .x86_64,
73132 .os_tag = .linux,
74133 .abi = .none,
75134 },
76135 },
77 TestTarget{
136 .{
78137 .target = .{
79138 .cpu_arch = .x86_64,
80139 .os_tag = .linux,
......@@ -82,7 +141,7 @@ const test_targets = blk: {
82141 },
83142 .link_libc = true,
84143 },
85 TestTarget{
144 .{
86145 .target = .{
87146 .cpu_arch = .x86_64,
88147 .os_tag = .linux,
......@@ -91,14 +150,14 @@ const test_targets = blk: {
91150 .link_libc = true,
92151 },
93152
94 TestTarget{
153 .{
95154 .target = .{
96155 .cpu_arch = .i386,
97156 .os_tag = .linux,
98157 .abi = .none,
99158 },
100159 },
101 TestTarget{
160 .{
102161 .target = .{
103162 .cpu_arch = .i386,
104163 .os_tag = .linux,
......@@ -106,7 +165,7 @@ const test_targets = blk: {
106165 },
107166 .link_libc = true,
108167 },
109 TestTarget{
168 .{
110169 .target = .{
111170 .cpu_arch = .i386,
112171 .os_tag = .linux,
......@@ -115,14 +174,14 @@ const test_targets = blk: {
115174 .link_libc = true,
116175 },
117176
118 TestTarget{
177 .{
119178 .target = .{
120179 .cpu_arch = .aarch64,
121180 .os_tag = .linux,
122181 .abi = .none,
123182 },
124183 },
125 TestTarget{
184 .{
126185 .target = .{
127186 .cpu_arch = .aarch64,
128187 .os_tag = .linux,
......@@ -130,7 +189,7 @@ const test_targets = blk: {
130189 },
131190 .link_libc = true,
132191 },
133 TestTarget{
192 .{
134193 .target = .{
135194 .cpu_arch = .aarch64,
136195 .os_tag = .linux,
......@@ -138,7 +197,7 @@ const test_targets = blk: {
138197 },
139198 .link_libc = true,
140199 },
141 TestTarget{
200 .{
142201 .target = .{
143202 .cpu_arch = .aarch64,
144203 .os_tag = .windows,
......@@ -147,13 +206,13 @@ const test_targets = blk: {
147206 .link_libc = true,
148207 },
149208
150 TestTarget{
209 .{
151210 .target = CrossTarget.parse(.{
152211 .arch_os_abi = "arm-linux-none",
153212 .cpu_features = "generic+v8a",
154213 }) catch unreachable,
155214 },
156 TestTarget{
215 .{
157216 .target = CrossTarget.parse(.{
158217 .arch_os_abi = "arm-linux-musleabihf",
159218 .cpu_features = "generic+v8a",
......@@ -161,7 +220,7 @@ const test_targets = blk: {
161220 .link_libc = true,
162221 },
163222 // https://github.com/ziglang/zig/issues/3287
164 //TestTarget{
223 //.{
165224 // .target = CrossTarget.parse(.{
166225 // .arch_os_abi = "arm-linux-gnueabihf",
167226 // .cpu_features = "generic+v8a",
......@@ -169,7 +228,7 @@ const test_targets = blk: {
169228 // .link_libc = true,
170229 //},
171230
172 TestTarget{
231 .{
173232 .target = .{
174233 .cpu_arch = .mips,
175234 .os_tag = .linux,
......@@ -177,7 +236,7 @@ const test_targets = blk: {
177236 },
178237 },
179238
180 TestTarget{
239 .{
181240 .target = .{
182241 .cpu_arch = .mips,
183242 .os_tag = .linux,
......@@ -187,7 +246,7 @@ const test_targets = blk: {
187246 },
188247
189248 // https://github.com/ziglang/zig/issues/4927
190 //TestTarget{
249 //.{
191250 // .target = .{
192251 // .cpu_arch = .mips,
193252 // .os_tag = .linux,
......@@ -196,7 +255,7 @@ const test_targets = blk: {
196255 // .link_libc = true,
197256 //},
198257
199 TestTarget{
258 .{
200259 .target = .{
201260 .cpu_arch = .mipsel,
202261 .os_tag = .linux,
......@@ -204,7 +263,7 @@ const test_targets = blk: {
204263 },
205264 },
206265
207 TestTarget{
266 .{
208267 .target = .{
209268 .cpu_arch = .mipsel,
210269 .os_tag = .linux,
......@@ -214,7 +273,7 @@ const test_targets = blk: {
214273 },
215274
216275 // https://github.com/ziglang/zig/issues/4927
217 //TestTarget{
276 //.{
218277 // .target = .{
219278 // .cpu_arch = .mipsel,
220279 // .os_tag = .linux,
......@@ -223,14 +282,14 @@ const test_targets = blk: {
223282 // .link_libc = true,
224283 //},
225284
226 TestTarget{
285 .{
227286 .target = .{
228287 .cpu_arch = .powerpc,
229288 .os_tag = .linux,
230289 .abi = .none,
231290 },
232291 },
233 TestTarget{
292 .{
234293 .target = .{
235294 .cpu_arch = .powerpc,
236295 .os_tag = .linux,
......@@ -239,7 +298,7 @@ const test_targets = blk: {
239298 .link_libc = true,
240299 },
241300 // https://github.com/ziglang/zig/issues/2256
242 //TestTarget{
301 //.{
243302 // .target = .{
244303 // .cpu_arch = .powerpc,
245304 // .os_tag = .linux,
......@@ -248,7 +307,7 @@ const test_targets = blk: {
248307 // .link_libc = true,
249308 //},
250309
251 TestTarget{
310 .{
252311 .target = .{
253312 .cpu_arch = .riscv64,
254313 .os_tag = .linux,
......@@ -256,7 +315,7 @@ const test_targets = blk: {
256315 },
257316 },
258317
259 TestTarget{
318 .{
260319 .target = .{
261320 .cpu_arch = .riscv64,
262321 .os_tag = .linux,
......@@ -266,7 +325,7 @@ const test_targets = blk: {
266325 },
267326
268327 // https://github.com/ziglang/zig/issues/3340
269 //TestTarget{
328 //.{
270329 // .target = .{
271330 // .cpu_arch = .riscv64,
272331 // .os = .linux,
......@@ -275,7 +334,7 @@ const test_targets = blk: {
275334 // .link_libc = true,
276335 //},
277336
278 TestTarget{
337 .{
279338 .target = .{
280339 .cpu_arch = .x86_64,
281340 .os_tag = .macos,
......@@ -283,7 +342,7 @@ const test_targets = blk: {
283342 },
284343 },
285344
286 TestTarget{
345 .{
287346 .target = .{
288347 .cpu_arch = .aarch64,
289348 .os_tag = .macos,
......@@ -291,7 +350,7 @@ const test_targets = blk: {
291350 },
292351 },
293352
294 TestTarget{
353 .{
295354 .target = .{
296355 .cpu_arch = .i386,
297356 .os_tag = .windows,
......@@ -299,7 +358,7 @@ const test_targets = blk: {
299358 },
300359 },
301360
302 TestTarget{
361 .{
303362 .target = .{
304363 .cpu_arch = .x86_64,
305364 .os_tag = .windows,
......@@ -307,7 +366,7 @@ const test_targets = blk: {
307366 },
308367 },
309368
310 TestTarget{
369 .{
311370 .target = .{
312371 .cpu_arch = .i386,
313372 .os_tag = .windows,
......@@ -316,7 +375,7 @@ const test_targets = blk: {
316375 .link_libc = true,
317376 },
318377
319 TestTarget{
378 .{
320379 .target = .{
321380 .cpu_arch = .x86_64,
322381 .os_tag = .windows,
......@@ -326,38 +385,38 @@ const test_targets = blk: {
326385 },
327386
328387 // Do the release tests last because they take a long time
329 TestTarget{
388 .{
330389 .mode = .ReleaseFast,
331390 },
332 TestTarget{
391 .{
333392 .link_libc = true,
334393 .mode = .ReleaseFast,
335394 },
336 TestTarget{
395 .{
337396 .mode = .ReleaseFast,
338397 .single_threaded = true,
339398 },
340399
341 TestTarget{
400 .{
342401 .mode = .ReleaseSafe,
343402 },
344 TestTarget{
403 .{
345404 .link_libc = true,
346405 .mode = .ReleaseSafe,
347406 },
348 TestTarget{
407 .{
349408 .mode = .ReleaseSafe,
350409 .single_threaded = true,
351410 },
352411
353 TestTarget{
412 .{
354413 .mode = .ReleaseSmall,
355414 },
356 TestTarget{
415 .{
357416 .link_libc = true,
358417 .mode = .ReleaseSmall,
359418 },
360 TestTarget{
419 .{
361420 .mode = .ReleaseSmall,
362421 .single_threaded = true,
363422 },
......@@ -524,6 +583,9 @@ pub fn addPkgTests(
524583 skip_single_threaded: bool,
525584 skip_non_native: bool,
526585 skip_libc: bool,
586 skip_stage1: bool,
587 skip_stage2: bool,
588 is_stage1: bool,
527589) *build.Step {
528590 const step = b.step(b.fmt("test-{s}", .{name}), desc);
529591
......@@ -549,6 +611,11 @@ pub fn addPkgTests(
549611 continue;
550612 }
551613
614 if (test_target.backend) |backend| switch (backend) {
615 .stage1 => if (skip_stage1) continue,
616 else => if (skip_stage2) continue,
617 } else if (is_stage1 and skip_stage1) continue;
618
552619 const want_this_mode = for (modes) |m| {
553620 if (m == test_target.mode) break true;
554621 } else false;
......@@ -565,12 +632,14 @@ pub fn addPkgTests(
565632
566633 const these_tests = b.addTest(root_src);
567634 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
568 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s} ", .{
635 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
636 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{
569637 name,
570638 triple_prefix,
571639 @tagName(test_target.mode),
572640 libc_prefix,
573641 single_threaded_txt,
642 backend_txt,
574643 }));
575644 these_tests.single_threaded = test_target.single_threaded;
576645 these_tests.setFilter(test_filter);
......@@ -581,6 +650,24 @@ pub fn addPkgTests(
581650 }
582651 these_tests.overrideZigLibDir("lib");
583652 these_tests.addIncludePath("test");
653 if (test_target.backend) |backend| switch (backend) {
654 .stage1 => {
655 these_tests.use_stage1 = true;
656 },
657 .stage2_llvm => {
658 these_tests.use_stage1 = false;
659 these_tests.use_llvm = true;
660 },
661 .stage2_c => {
662 these_tests.use_stage1 = false;
663 these_tests.use_llvm = false;
664 these_tests.ofmt = .c;
665 },
666 else => {
667 these_tests.use_stage1 = false;
668 these_tests.use_llvm = false;
669 },
670 };
584671
585672 step.dependOn(&these_tests.step);
586673 }