| author | |
| committer | |
| log | 0df28f9d45105c44fa28a86a880272acb9ccf630 |
| tree | 1387a31e3717e802d103dbff4a3302942f9bd9d0 |
| parent | ac1aaec9c38eb44b93099ff18579a9401f107100 |
| parent | efeb031b7917f552ea73ee59c086e3d75c87cbaf |
| signature |
CI: add non-LLVM backends to the test matrix10 files changed, 348 insertions(+), 91 deletions(-)
build.zig+12| ... | ... | @@ -445,6 +445,9 @@ pub fn build(b: *Builder) !void { |
| 445 | 445 | false, // skip_single_threaded |
| 446 | 446 | skip_non_native, |
| 447 | 447 | skip_libc, |
| 448 | skip_stage1, | |
| 449 | omit_stage2, | |
| 450 | is_stage1, | |
| 448 | 451 | )); |
| 449 | 452 | |
| 450 | 453 | toolchain_step.dependOn(tests.addPkgTests( |
| ... | ... | @@ -457,6 +460,9 @@ pub fn build(b: *Builder) !void { |
| 457 | 460 | true, // skip_single_threaded |
| 458 | 461 | skip_non_native, |
| 459 | 462 | true, // skip_libc |
| 463 | skip_stage1, | |
| 464 | omit_stage2 or true, // TODO get these all passing | |
| 465 | is_stage1, | |
| 460 | 466 | )); |
| 461 | 467 | |
| 462 | 468 | toolchain_step.dependOn(tests.addPkgTests( |
| ... | ... | @@ -469,6 +475,9 @@ pub fn build(b: *Builder) !void { |
| 469 | 475 | true, // skip_single_threaded |
| 470 | 476 | skip_non_native, |
| 471 | 477 | true, // skip_libc |
| 478 | skip_stage1, | |
| 479 | omit_stage2 or true, // TODO get these all passing | |
| 480 | is_stage1, | |
| 472 | 481 | )); |
| 473 | 482 | |
| 474 | 483 | toolchain_step.dependOn(tests.addCompareOutputTests(b, test_filter, modes)); |
| ... | ... | @@ -494,6 +503,9 @@ pub fn build(b: *Builder) !void { |
| 494 | 503 | false, |
| 495 | 504 | skip_non_native, |
| 496 | 505 | skip_libc, |
| 506 | skip_stage1, | |
| 507 | omit_stage2 or true, // TODO get these all passing | |
| 508 | is_stage1, | |
| 497 | 509 | ); |
| 498 | 510 | |
| 499 | 511 | const test_step = b.step("test", "Run all the tests"); |
ci/azure/macos_script+19-6| ... | ... | @@ -58,12 +58,25 @@ make $JOBS install |
| 58 | 58 | # Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. |
| 59 | 59 | release/bin/zig build -p stage2 -Denable-llvm |
| 60 | 60 | |
| 61 | stage2/bin/zig test ../test/behavior.zig -I../test -fLLVM | |
| 62 | stage2/bin/zig test ../test/behavior.zig -I../test -fno-LLVM | |
| 63 | ||
| 64 | release/bin/zig build test-toolchain -Denable-macos-sdk | |
| 65 | release/bin/zig build test-std | |
| 66 | release/bin/zig build docs | |
| 61 | stage2/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 | |
| 65 | release/bin/zig build test-behavior -Denable-macos-sdk -Domit-stage2 | |
| 66 | release/bin/zig build test-compiler-rt -Denable-macos-sdk | |
| 67 | release/bin/zig build test-std -Denable-macos-sdk | |
| 68 | release/bin/zig build test-minilibc -Denable-macos-sdk | |
| 69 | release/bin/zig build test-compare-output -Denable-macos-sdk | |
| 70 | release/bin/zig build test-standalone -Denable-macos-sdk | |
| 71 | release/bin/zig build test-stack-traces -Denable-macos-sdk | |
| 72 | release/bin/zig build test-cli -Denable-macos-sdk | |
| 73 | release/bin/zig build test-asm-link -Denable-macos-sdk | |
| 74 | release/bin/zig build test-runtime-safety -Denable-macos-sdk | |
| 75 | release/bin/zig build test-translate-c -Denable-macos-sdk | |
| 76 | release/bin/zig build test-run-translated-c -Denable-macos-sdk | |
| 77 | release/bin/zig build docs -Denable-macos-sdk | |
| 78 | release/bin/zig build test-fmt -Denable-macos-sdk | |
| 79 | release/bin/zig build test-stage2 -Denable-macos-sdk | |
| 67 | 80 | |
| 68 | 81 | if [ "${BUILD_REASON}" != "PullRequest" ]; then |
| 69 | 82 | mv ../LICENSE release/ |
ci/zinc/linux_test.sh+11-19| ... | ... | @@ -48,25 +48,19 @@ cd $WORKSPACE |
| 48 | 48 | $ZIG fmt --check . --exclude test/cases/ |
| 49 | 49 | |
| 50 | 50 | # 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" | |
| 52 | 52 | |
| 53 | 53 | # Ensure that stage2 can build itself. |
| 54 | ./stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 55 | ||
| 56 | stage2/bin/zig test test/behavior.zig -I test -fLLVM | |
| 57 | stage2/bin/zig test test/behavior.zig -I test -fno-LLVM | |
| 58 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 59 | stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-linux --test-cmd qemu-aarch64 --test-cmd-bin | |
| 60 | stage2/bin/zig test test/behavior.zig -I test -ofmt=c | |
| 61 | stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin | |
| 62 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target wasm32-wasi --test-cmd wasmtime --test-cmd-bin | |
| 63 | stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target arm-linux --test-cmd qemu-arm --test-cmd-bin | |
| 64 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target aarch64-macos --test-no-exec | |
| 65 | stage2/bin/zig test test/behavior.zig -I test -fno-LLVM -target aarch64-macos --test-no-exec | |
| 66 | stage2/bin/zig test test/behavior.zig -I test -fLLVM -target x86_64-macos --test-no-exec | |
| 67 | stage2/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 | |
| 54 | stage2/bin/zig build -p stage3 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL" | |
| 55 | stage2/bin/zig build # test building self-hosted without LLVM | |
| 56 | stage2/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 | |
| 61 | stage2/bin/zig build test-behavior -fqemu -fwasmtime | |
| 62 | ||
| 63 | $ZIG build test-behavior -fqemu -fwasmtime -Domit-stage2 | |
| 70 | 64 | $ZIG build test-compiler-rt -fqemu -fwasmtime |
| 71 | 65 | $ZIG build test-std -fqemu -fwasmtime |
| 72 | 66 | $ZIG build test-minilibc -fqemu -fwasmtime |
| ... | ... | @@ -79,8 +73,6 @@ $ZIG build test-runtime-safety -fqemu -fwasmtime |
| 79 | 73 | $ZIG build test-translate-c -fqemu -fwasmtime |
| 80 | 74 | $ZIG build test-run-translated-c -fqemu -fwasmtime |
| 81 | 75 | $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 | |
| 84 | 76 | $ZIG build test-fmt -fqemu -fwasmtime |
| 85 | 77 | $ZIG build test-stage2 -fqemu -fwasmtime |
| 86 | 78 |
lib/std/build.zig+14| ... | ... | @@ -1590,6 +1590,8 @@ pub const LibExeObjStep = struct { |
| 1590 | 1590 | |
| 1591 | 1591 | want_lto: ?bool = null, |
| 1592 | 1592 | use_stage1: ?bool = null, |
| 1593 | use_llvm: ?bool = null, | |
| 1594 | ofmt: ?std.Target.ObjectFormat = null, | |
| 1593 | 1595 | |
| 1594 | 1596 | output_path_source: GeneratedFile, |
| 1595 | 1597 | output_lib_path_source: GeneratedFile, |
| ... | ... | @@ -2351,6 +2353,18 @@ pub const LibExeObjStep = struct { |
| 2351 | 2353 | } |
| 2352 | 2354 | } |
| 2353 | 2355 | |
| 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 | ||
| 2354 | 2368 | if (self.entry_symbol_name) |entry| { |
| 2355 | 2369 | try zig_args.append("--entry"); |
| 2356 | 2370 | try zig_args.append(entry); |
lib/std/os/linux/arm-eabi.zig+4-1| ... | ... | @@ -99,7 +99,10 @@ pub fn syscall6( |
| 99 | 99 | |
| 100 | 100 | /// This matches the libc clone function. |
| 101 | 101 | pub 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 | }, | |
| 103 | 106 | stack: usize, |
| 104 | 107 | flags: u32, |
| 105 | 108 | arg: usize, |
src/codegen/llvm.zig+95-9| ... | ... | @@ -4234,36 +4234,103 @@ pub const FuncGen = struct { |
| 4234 | 4234 | return null; |
| 4235 | 4235 | |
| 4236 | 4236 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 4237 | ||
| 4237 | 4238 | const operand = try self.resolveInst(ty_op.operand); |
| 4238 | 4239 | const operand_ty = self.air.typeOf(ty_op.operand); |
| 4239 | 4240 | const operand_scalar_ty = operand_ty.scalarType(); |
| 4241 | ||
| 4240 | 4242 | const dest_ty = self.air.typeOfIndex(inst); |
| 4243 | const dest_scalar_ty = dest_ty.scalarType(); | |
| 4241 | 4244 | const dest_llvm_ty = try self.dg.llvmType(dest_ty); |
| 4245 | const target = self.dg.module.getTarget(); | |
| 4242 | 4246 | |
| 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 | } | |
| 4247 | 4253 | } |
| 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, ""); | |
| 4248 | 4280 | } |
| 4249 | 4281 | |
| 4250 | 4282 | fn airFloatToInt(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |
| 4251 | 4283 | if (self.liveness.isUnused(inst)) |
| 4252 | 4284 | return null; |
| 4253 | 4285 | |
| 4286 | const target = self.dg.module.getTarget(); | |
| 4254 | 4287 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 4288 | ||
| 4255 | 4289 | 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 | ||
| 4256 | 4293 | const dest_ty = self.air.typeOfIndex(inst); |
| 4257 | 4294 | const dest_scalar_ty = dest_ty.scalarType(); |
| 4258 | 4295 | const dest_llvm_ty = try self.dg.llvmType(dest_ty); |
| 4259 | 4296 | |
| 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 | } | |
| 4261 | 4305 | |
| 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; | |
| 4266 | 4331 | } |
| 4332 | ||
| 4333 | return self.builder.buildTrunc(result, dest_llvm_ty, ""); | |
| 4267 | 4334 | } |
| 4268 | 4335 | |
| 4269 | 4336 | fn airSliceField(self: *FuncGen, inst: Air.Inst.Index, index: c_uint) !?*const llvm.Value { |
| ... | ... | @@ -5615,6 +5682,16 @@ pub const FuncGen = struct { |
| 5615 | 5682 | }; |
| 5616 | 5683 | } |
| 5617 | 5684 | |
| 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 | ||
| 5618 | 5695 | /// Creates a floating point comparison by lowering to the appropriate |
| 5619 | 5696 | /// hardware instruction or softfloat routine for the target |
| 5620 | 5697 | fn buildFloatCmp( |
| ... | ... | @@ -8313,3 +8390,12 @@ fn needDbgVarWorkaround(dg: *DeclGen, ty: Type) bool { |
| 8313 | 8390 | } |
| 8314 | 8391 | return false; |
| 8315 | 8392 | } |
| 8393 | ||
| 8394 | fn 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 { |
| 476 | 476 | Name: [*:0]const u8, |
| 477 | 477 | ) *const Value; |
| 478 | 478 | |
| 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 | ||
| 479 | 487 | pub const buildCall = ZigLLVMBuildCall; |
| 480 | 488 | extern fn ZigLLVMBuildCall( |
| 481 | 489 | *const Builder, |
src/link/MachO.zig+16-10| ... | ... | @@ -392,8 +392,9 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 392 | 392 | // Adhoc code signature is required when targeting aarch64-macos either directly or indirectly via the simulator |
| 393 | 393 | // ABI such as aarch64-ios-simulator, etc. |
| 394 | 394 | 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; | |
| 395 | 396 | 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); | |
| 397 | 398 | |
| 398 | 399 | const self = try gpa.create(MachO); |
| 399 | 400 | errdefer gpa.destroy(self); |
| ... | ... | @@ -410,7 +411,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*MachO { |
| 410 | 411 | .needs_prealloc = needs_prealloc, |
| 411 | 412 | }; |
| 412 | 413 | |
| 413 | const use_llvm = build_options.have_llvm and options.use_llvm; | |
| 414 | 414 | if (use_llvm and !use_stage1) { |
| 415 | 415 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 416 | 416 | } |
| ... | ... | @@ -519,7 +519,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 519 | 519 | var needs_full_relink = true; |
| 520 | 520 | |
| 521 | 521 | 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; | |
| 523 | 524 | |
| 524 | 525 | man = comp.cache_parent.obtain(); |
| 525 | 526 | |
| ... | ... | @@ -571,7 +572,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 571 | 572 | if (mem.eql(u8, prev_digest, &digest)) { |
| 572 | 573 | // Hot diggity dog! The output binary is already there. |
| 573 | 574 | |
| 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) { | |
| 575 | 577 | log.debug("MachO Zld digest={s} match - skipping invocation", .{std.fmt.fmtSliceHexLower(&digest)}); |
| 576 | 578 | self.base.lock = man.toOwnedLock(); |
| 577 | 579 | return; |
| ... | ... | @@ -1025,7 +1027,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 1025 | 1027 | try self.createTentativeDefAtoms(); |
| 1026 | 1028 | try self.parseObjectsIntoAtoms(); |
| 1027 | 1029 | |
| 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) { | |
| 1029 | 1032 | try self.sortSections(); |
| 1030 | 1033 | try self.allocateTextSegment(); |
| 1031 | 1034 | try self.allocateDataConstSegment(); |
| ... | ... | @@ -1041,7 +1044,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 1041 | 1044 | self.logSectionOrdinals(); |
| 1042 | 1045 | } |
| 1043 | 1046 | |
| 1044 | if (use_stage1) { | |
| 1047 | if (use_llvm or use_stage1) { | |
| 1045 | 1048 | try self.writeAllAtoms(); |
| 1046 | 1049 | } else { |
| 1047 | 1050 | try self.writeAtoms(); |
| ... | ... | @@ -1097,7 +1100,8 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 1097 | 1100 | } |
| 1098 | 1101 | |
| 1099 | 1102 | 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; | |
| 1101 | 1105 | // Update the file with the digest. If it fails we can continue; it only |
| 1102 | 1106 | // means that the next invocation will have an unnecessary cache miss. |
| 1103 | 1107 | Cache.writeSmallFile(cache_dir_handle, id_symlink_basename, &digest) catch |err| { |
| ... | ... | @@ -4930,12 +4934,13 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void { |
| 4930 | 4934 | var start: u64 = offset; |
| 4931 | 4935 | for (seg.sections.items) |*sect, sect_id| { |
| 4932 | 4936 | 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; | |
| 4933 | 4938 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; |
| 4934 | 4939 | const alignment = try math.powi(u32, 2, sect.@"align"); |
| 4935 | 4940 | const start_aligned = mem.alignForwardGeneric(u64, start, alignment); |
| 4936 | 4941 | |
| 4937 | 4942 | // 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); | |
| 4939 | 4944 | sect.addr = seg.inner.vmaddr + start_aligned; |
| 4940 | 4945 | |
| 4941 | 4946 | // Recalculate section size given the allocated start address |
| ... | ... | @@ -4963,7 +4968,7 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void { |
| 4963 | 4968 | |
| 4964 | 4969 | start = start_aligned + sect.size; |
| 4965 | 4970 | |
| 4966 | if (!(is_zerofill and use_stage1)) { | |
| 4971 | if (!(is_zerofill and (use_stage1 or use_llvm))) { | |
| 4967 | 4972 | seg.inner.filesize = start; |
| 4968 | 4973 | } |
| 4969 | 4974 | seg.inner.vmsize = start; |
| ... | ... | @@ -5012,10 +5017,11 @@ fn initSection( |
| 5012 | 5017 | sect.addr = seg.inner.vmaddr + off - seg.inner.fileoff; |
| 5013 | 5018 | |
| 5014 | 5019 | 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; | |
| 5015 | 5021 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; |
| 5016 | 5022 | |
| 5017 | 5023 | // TODO handle zerofill in stage2 |
| 5018 | if (!(is_zerofill and use_stage1)) { | |
| 5024 | if (!(is_zerofill and (use_stage1 or use_llvm))) { | |
| 5019 | 5025 | sect.offset = @intCast(u32, off); |
| 5020 | 5026 | } |
| 5021 | 5027 | } |
test/behavior/cast.zig+36| ... | ... | @@ -112,6 +112,42 @@ test "@intToFloat" { |
| 112 | 112 | comptime try S.doTheTest(); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | test "@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 | ||
| 115 | 151 | test "@floatToInt" { |
| 116 | 152 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 117 | 153 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
test/tests.zig+133-46| ... | ... | @@ -34,6 +34,7 @@ const TestTarget = struct { |
| 34 | 34 | link_libc: bool = false, |
| 35 | 35 | single_threaded: bool = false, |
| 36 | 36 | disable_native: bool = false, |
| 37 | backend: ?std.builtin.CompilerBackend = null, | |
| 37 | 38 | }; |
| 38 | 39 | |
| 39 | 40 | const test_targets = blk: { |
| ... | ... | @@ -42,15 +43,73 @@ const test_targets = blk: { |
| 42 | 43 | // lot of branches) |
| 43 | 44 | @setEvalBranchQuota(50000); |
| 44 | 45 | break :blk [_]TestTarget{ |
| 45 | TestTarget{}, | |
| 46 | TestTarget{ | |
| 46 | .{}, | |
| 47 | .{ | |
| 47 | 48 | .link_libc = true, |
| 48 | 49 | }, |
| 49 | TestTarget{ | |
| 50 | .{ | |
| 50 | 51 | .single_threaded = true, |
| 51 | 52 | }, |
| 52 | 53 | |
| 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 | .{ | |
| 54 | 113 | .target = .{ |
| 55 | 114 | .cpu_arch = .wasm32, |
| 56 | 115 | .os_tag = .wasi, |
| ... | ... | @@ -58,7 +117,7 @@ const test_targets = blk: { |
| 58 | 117 | .link_libc = false, |
| 59 | 118 | .single_threaded = true, |
| 60 | 119 | }, |
| 61 | TestTarget{ | |
| 120 | .{ | |
| 62 | 121 | .target = .{ |
| 63 | 122 | .cpu_arch = .wasm32, |
| 64 | 123 | .os_tag = .wasi, |
| ... | ... | @@ -67,14 +126,14 @@ const test_targets = blk: { |
| 67 | 126 | .single_threaded = true, |
| 68 | 127 | }, |
| 69 | 128 | |
| 70 | TestTarget{ | |
| 129 | .{ | |
| 71 | 130 | .target = .{ |
| 72 | 131 | .cpu_arch = .x86_64, |
| 73 | 132 | .os_tag = .linux, |
| 74 | 133 | .abi = .none, |
| 75 | 134 | }, |
| 76 | 135 | }, |
| 77 | TestTarget{ | |
| 136 | .{ | |
| 78 | 137 | .target = .{ |
| 79 | 138 | .cpu_arch = .x86_64, |
| 80 | 139 | .os_tag = .linux, |
| ... | ... | @@ -82,7 +141,7 @@ const test_targets = blk: { |
| 82 | 141 | }, |
| 83 | 142 | .link_libc = true, |
| 84 | 143 | }, |
| 85 | TestTarget{ | |
| 144 | .{ | |
| 86 | 145 | .target = .{ |
| 87 | 146 | .cpu_arch = .x86_64, |
| 88 | 147 | .os_tag = .linux, |
| ... | ... | @@ -91,14 +150,14 @@ const test_targets = blk: { |
| 91 | 150 | .link_libc = true, |
| 92 | 151 | }, |
| 93 | 152 | |
| 94 | TestTarget{ | |
| 153 | .{ | |
| 95 | 154 | .target = .{ |
| 96 | 155 | .cpu_arch = .i386, |
| 97 | 156 | .os_tag = .linux, |
| 98 | 157 | .abi = .none, |
| 99 | 158 | }, |
| 100 | 159 | }, |
| 101 | TestTarget{ | |
| 160 | .{ | |
| 102 | 161 | .target = .{ |
| 103 | 162 | .cpu_arch = .i386, |
| 104 | 163 | .os_tag = .linux, |
| ... | ... | @@ -106,7 +165,7 @@ const test_targets = blk: { |
| 106 | 165 | }, |
| 107 | 166 | .link_libc = true, |
| 108 | 167 | }, |
| 109 | TestTarget{ | |
| 168 | .{ | |
| 110 | 169 | .target = .{ |
| 111 | 170 | .cpu_arch = .i386, |
| 112 | 171 | .os_tag = .linux, |
| ... | ... | @@ -115,14 +174,14 @@ const test_targets = blk: { |
| 115 | 174 | .link_libc = true, |
| 116 | 175 | }, |
| 117 | 176 | |
| 118 | TestTarget{ | |
| 177 | .{ | |
| 119 | 178 | .target = .{ |
| 120 | 179 | .cpu_arch = .aarch64, |
| 121 | 180 | .os_tag = .linux, |
| 122 | 181 | .abi = .none, |
| 123 | 182 | }, |
| 124 | 183 | }, |
| 125 | TestTarget{ | |
| 184 | .{ | |
| 126 | 185 | .target = .{ |
| 127 | 186 | .cpu_arch = .aarch64, |
| 128 | 187 | .os_tag = .linux, |
| ... | ... | @@ -130,7 +189,7 @@ const test_targets = blk: { |
| 130 | 189 | }, |
| 131 | 190 | .link_libc = true, |
| 132 | 191 | }, |
| 133 | TestTarget{ | |
| 192 | .{ | |
| 134 | 193 | .target = .{ |
| 135 | 194 | .cpu_arch = .aarch64, |
| 136 | 195 | .os_tag = .linux, |
| ... | ... | @@ -138,7 +197,7 @@ const test_targets = blk: { |
| 138 | 197 | }, |
| 139 | 198 | .link_libc = true, |
| 140 | 199 | }, |
| 141 | TestTarget{ | |
| 200 | .{ | |
| 142 | 201 | .target = .{ |
| 143 | 202 | .cpu_arch = .aarch64, |
| 144 | 203 | .os_tag = .windows, |
| ... | ... | @@ -147,13 +206,13 @@ const test_targets = blk: { |
| 147 | 206 | .link_libc = true, |
| 148 | 207 | }, |
| 149 | 208 | |
| 150 | TestTarget{ | |
| 209 | .{ | |
| 151 | 210 | .target = CrossTarget.parse(.{ |
| 152 | 211 | .arch_os_abi = "arm-linux-none", |
| 153 | 212 | .cpu_features = "generic+v8a", |
| 154 | 213 | }) catch unreachable, |
| 155 | 214 | }, |
| 156 | TestTarget{ | |
| 215 | .{ | |
| 157 | 216 | .target = CrossTarget.parse(.{ |
| 158 | 217 | .arch_os_abi = "arm-linux-musleabihf", |
| 159 | 218 | .cpu_features = "generic+v8a", |
| ... | ... | @@ -161,7 +220,7 @@ const test_targets = blk: { |
| 161 | 220 | .link_libc = true, |
| 162 | 221 | }, |
| 163 | 222 | // https://github.com/ziglang/zig/issues/3287 |
| 164 | //TestTarget{ | |
| 223 | //.{ | |
| 165 | 224 | // .target = CrossTarget.parse(.{ |
| 166 | 225 | // .arch_os_abi = "arm-linux-gnueabihf", |
| 167 | 226 | // .cpu_features = "generic+v8a", |
| ... | ... | @@ -169,7 +228,7 @@ const test_targets = blk: { |
| 169 | 228 | // .link_libc = true, |
| 170 | 229 | //}, |
| 171 | 230 | |
| 172 | TestTarget{ | |
| 231 | .{ | |
| 173 | 232 | .target = .{ |
| 174 | 233 | .cpu_arch = .mips, |
| 175 | 234 | .os_tag = .linux, |
| ... | ... | @@ -177,7 +236,7 @@ const test_targets = blk: { |
| 177 | 236 | }, |
| 178 | 237 | }, |
| 179 | 238 | |
| 180 | TestTarget{ | |
| 239 | .{ | |
| 181 | 240 | .target = .{ |
| 182 | 241 | .cpu_arch = .mips, |
| 183 | 242 | .os_tag = .linux, |
| ... | ... | @@ -187,7 +246,7 @@ const test_targets = blk: { |
| 187 | 246 | }, |
| 188 | 247 | |
| 189 | 248 | // https://github.com/ziglang/zig/issues/4927 |
| 190 | //TestTarget{ | |
| 249 | //.{ | |
| 191 | 250 | // .target = .{ |
| 192 | 251 | // .cpu_arch = .mips, |
| 193 | 252 | // .os_tag = .linux, |
| ... | ... | @@ -196,7 +255,7 @@ const test_targets = blk: { |
| 196 | 255 | // .link_libc = true, |
| 197 | 256 | //}, |
| 198 | 257 | |
| 199 | TestTarget{ | |
| 258 | .{ | |
| 200 | 259 | .target = .{ |
| 201 | 260 | .cpu_arch = .mipsel, |
| 202 | 261 | .os_tag = .linux, |
| ... | ... | @@ -204,7 +263,7 @@ const test_targets = blk: { |
| 204 | 263 | }, |
| 205 | 264 | }, |
| 206 | 265 | |
| 207 | TestTarget{ | |
| 266 | .{ | |
| 208 | 267 | .target = .{ |
| 209 | 268 | .cpu_arch = .mipsel, |
| 210 | 269 | .os_tag = .linux, |
| ... | ... | @@ -214,7 +273,7 @@ const test_targets = blk: { |
| 214 | 273 | }, |
| 215 | 274 | |
| 216 | 275 | // https://github.com/ziglang/zig/issues/4927 |
| 217 | //TestTarget{ | |
| 276 | //.{ | |
| 218 | 277 | // .target = .{ |
| 219 | 278 | // .cpu_arch = .mipsel, |
| 220 | 279 | // .os_tag = .linux, |
| ... | ... | @@ -223,14 +282,14 @@ const test_targets = blk: { |
| 223 | 282 | // .link_libc = true, |
| 224 | 283 | //}, |
| 225 | 284 | |
| 226 | TestTarget{ | |
| 285 | .{ | |
| 227 | 286 | .target = .{ |
| 228 | 287 | .cpu_arch = .powerpc, |
| 229 | 288 | .os_tag = .linux, |
| 230 | 289 | .abi = .none, |
| 231 | 290 | }, |
| 232 | 291 | }, |
| 233 | TestTarget{ | |
| 292 | .{ | |
| 234 | 293 | .target = .{ |
| 235 | 294 | .cpu_arch = .powerpc, |
| 236 | 295 | .os_tag = .linux, |
| ... | ... | @@ -239,7 +298,7 @@ const test_targets = blk: { |
| 239 | 298 | .link_libc = true, |
| 240 | 299 | }, |
| 241 | 300 | // https://github.com/ziglang/zig/issues/2256 |
| 242 | //TestTarget{ | |
| 301 | //.{ | |
| 243 | 302 | // .target = .{ |
| 244 | 303 | // .cpu_arch = .powerpc, |
| 245 | 304 | // .os_tag = .linux, |
| ... | ... | @@ -248,7 +307,7 @@ const test_targets = blk: { |
| 248 | 307 | // .link_libc = true, |
| 249 | 308 | //}, |
| 250 | 309 | |
| 251 | TestTarget{ | |
| 310 | .{ | |
| 252 | 311 | .target = .{ |
| 253 | 312 | .cpu_arch = .riscv64, |
| 254 | 313 | .os_tag = .linux, |
| ... | ... | @@ -256,7 +315,7 @@ const test_targets = blk: { |
| 256 | 315 | }, |
| 257 | 316 | }, |
| 258 | 317 | |
| 259 | TestTarget{ | |
| 318 | .{ | |
| 260 | 319 | .target = .{ |
| 261 | 320 | .cpu_arch = .riscv64, |
| 262 | 321 | .os_tag = .linux, |
| ... | ... | @@ -266,7 +325,7 @@ const test_targets = blk: { |
| 266 | 325 | }, |
| 267 | 326 | |
| 268 | 327 | // https://github.com/ziglang/zig/issues/3340 |
| 269 | //TestTarget{ | |
| 328 | //.{ | |
| 270 | 329 | // .target = .{ |
| 271 | 330 | // .cpu_arch = .riscv64, |
| 272 | 331 | // .os = .linux, |
| ... | ... | @@ -275,7 +334,7 @@ const test_targets = blk: { |
| 275 | 334 | // .link_libc = true, |
| 276 | 335 | //}, |
| 277 | 336 | |
| 278 | TestTarget{ | |
| 337 | .{ | |
| 279 | 338 | .target = .{ |
| 280 | 339 | .cpu_arch = .x86_64, |
| 281 | 340 | .os_tag = .macos, |
| ... | ... | @@ -283,7 +342,7 @@ const test_targets = blk: { |
| 283 | 342 | }, |
| 284 | 343 | }, |
| 285 | 344 | |
| 286 | TestTarget{ | |
| 345 | .{ | |
| 287 | 346 | .target = .{ |
| 288 | 347 | .cpu_arch = .aarch64, |
| 289 | 348 | .os_tag = .macos, |
| ... | ... | @@ -291,7 +350,7 @@ const test_targets = blk: { |
| 291 | 350 | }, |
| 292 | 351 | }, |
| 293 | 352 | |
| 294 | TestTarget{ | |
| 353 | .{ | |
| 295 | 354 | .target = .{ |
| 296 | 355 | .cpu_arch = .i386, |
| 297 | 356 | .os_tag = .windows, |
| ... | ... | @@ -299,7 +358,7 @@ const test_targets = blk: { |
| 299 | 358 | }, |
| 300 | 359 | }, |
| 301 | 360 | |
| 302 | TestTarget{ | |
| 361 | .{ | |
| 303 | 362 | .target = .{ |
| 304 | 363 | .cpu_arch = .x86_64, |
| 305 | 364 | .os_tag = .windows, |
| ... | ... | @@ -307,7 +366,7 @@ const test_targets = blk: { |
| 307 | 366 | }, |
| 308 | 367 | }, |
| 309 | 368 | |
| 310 | TestTarget{ | |
| 369 | .{ | |
| 311 | 370 | .target = .{ |
| 312 | 371 | .cpu_arch = .i386, |
| 313 | 372 | .os_tag = .windows, |
| ... | ... | @@ -316,7 +375,7 @@ const test_targets = blk: { |
| 316 | 375 | .link_libc = true, |
| 317 | 376 | }, |
| 318 | 377 | |
| 319 | TestTarget{ | |
| 378 | .{ | |
| 320 | 379 | .target = .{ |
| 321 | 380 | .cpu_arch = .x86_64, |
| 322 | 381 | .os_tag = .windows, |
| ... | ... | @@ -326,38 +385,38 @@ const test_targets = blk: { |
| 326 | 385 | }, |
| 327 | 386 | |
| 328 | 387 | // Do the release tests last because they take a long time |
| 329 | TestTarget{ | |
| 388 | .{ | |
| 330 | 389 | .mode = .ReleaseFast, |
| 331 | 390 | }, |
| 332 | TestTarget{ | |
| 391 | .{ | |
| 333 | 392 | .link_libc = true, |
| 334 | 393 | .mode = .ReleaseFast, |
| 335 | 394 | }, |
| 336 | TestTarget{ | |
| 395 | .{ | |
| 337 | 396 | .mode = .ReleaseFast, |
| 338 | 397 | .single_threaded = true, |
| 339 | 398 | }, |
| 340 | 399 | |
| 341 | TestTarget{ | |
| 400 | .{ | |
| 342 | 401 | .mode = .ReleaseSafe, |
| 343 | 402 | }, |
| 344 | TestTarget{ | |
| 403 | .{ | |
| 345 | 404 | .link_libc = true, |
| 346 | 405 | .mode = .ReleaseSafe, |
| 347 | 406 | }, |
| 348 | TestTarget{ | |
| 407 | .{ | |
| 349 | 408 | .mode = .ReleaseSafe, |
| 350 | 409 | .single_threaded = true, |
| 351 | 410 | }, |
| 352 | 411 | |
| 353 | TestTarget{ | |
| 412 | .{ | |
| 354 | 413 | .mode = .ReleaseSmall, |
| 355 | 414 | }, |
| 356 | TestTarget{ | |
| 415 | .{ | |
| 357 | 416 | .link_libc = true, |
| 358 | 417 | .mode = .ReleaseSmall, |
| 359 | 418 | }, |
| 360 | TestTarget{ | |
| 419 | .{ | |
| 361 | 420 | .mode = .ReleaseSmall, |
| 362 | 421 | .single_threaded = true, |
| 363 | 422 | }, |
| ... | ... | @@ -524,6 +583,9 @@ pub fn addPkgTests( |
| 524 | 583 | skip_single_threaded: bool, |
| 525 | 584 | skip_non_native: bool, |
| 526 | 585 | skip_libc: bool, |
| 586 | skip_stage1: bool, | |
| 587 | skip_stage2: bool, | |
| 588 | is_stage1: bool, | |
| 527 | 589 | ) *build.Step { |
| 528 | 590 | const step = b.step(b.fmt("test-{s}", .{name}), desc); |
| 529 | 591 | |
| ... | ... | @@ -549,6 +611,11 @@ pub fn addPkgTests( |
| 549 | 611 | continue; |
| 550 | 612 | } |
| 551 | 613 | |
| 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 | ||
| 552 | 619 | const want_this_mode = for (modes) |m| { |
| 553 | 620 | if (m == test_target.mode) break true; |
| 554 | 621 | } else false; |
| ... | ... | @@ -565,12 +632,14 @@ pub fn addPkgTests( |
| 565 | 632 | |
| 566 | 633 | const these_tests = b.addTest(root_src); |
| 567 | 634 | 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} ", .{ | |
| 569 | 637 | name, |
| 570 | 638 | triple_prefix, |
| 571 | 639 | @tagName(test_target.mode), |
| 572 | 640 | libc_prefix, |
| 573 | 641 | single_threaded_txt, |
| 642 | backend_txt, | |
| 574 | 643 | })); |
| 575 | 644 | these_tests.single_threaded = test_target.single_threaded; |
| 576 | 645 | these_tests.setFilter(test_filter); |
| ... | ... | @@ -581,6 +650,24 @@ pub fn addPkgTests( |
| 581 | 650 | } |
| 582 | 651 | these_tests.overrideZigLibDir("lib"); |
| 583 | 652 | 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 | }; | |
| 584 | 671 | |
| 585 | 672 | step.dependOn(&these_tests.step); |
| 586 | 673 | } |