| author | |
| committer | |
| log | 90f23e131eadae427c4253fb658002633263b82e |
| tree | 805c150d374a3fcacefa7d910a65d1e10a1c2755 |
| parent | 0527b441ae0e90e0b97052594cabb78129a02782 |
| parent | 20c230cda955936a04af952f9773c0cdda10d9f4 |
| signature |
CI: run test-cases with stage37 files changed, 85 insertions(+), 87 deletions(-)
ci/zinc/linux_test.sh+3-2| ... | ... | @@ -62,12 +62,13 @@ stage3/bin/zig build test-fmt -fqemu -fwasmtime -Denable-llvm |
| 62 | 62 | stage3/bin/zig build test-translate-c -fqemu -fwasmtime -Denable-llvm |
| 63 | 63 | stage3/bin/zig build test-standalone -fqemu -fwasmtime -Denable-llvm |
| 64 | 64 | stage3/bin/zig build test-cli -fqemu -fwasmtime -Denable-llvm |
| 65 | # https://github.com/ziglang/zig/issues/12144 | |
| 66 | stage3/bin/zig build test-cases -fqemu -fwasmtime | |
| 67 | stage3/bin/zig build test-link -fqemu -fwasmtime -Denable-llvm | |
| 65 | 68 | |
| 66 | 69 | $STAGE1_ZIG build test-stack-traces -fqemu -fwasmtime |
| 67 | 70 | $STAGE1_ZIG build test-run-translated-c -fqemu -fwasmtime |
| 68 | 71 | $STAGE1_ZIG build docs -fqemu -fwasmtime |
| 69 | $STAGE1_ZIG build test-cases -fqemu -fwasmtime | |
| 70 | $STAGE1_ZIG build test-link -fqemu -fwasmtime | |
| 71 | 72 | |
| 72 | 73 | # Produce the experimental std lib documentation. |
| 73 | 74 | mkdir -p "$RELEASE_STAGING/docs/std" |
lib/std/start.zig-4| ... | ... | @@ -455,10 +455,6 @@ fn callMainWithArgs(argc: usize, argv: [*][*:0]u8, envp: [][*:0]u8) u8 { |
| 455 | 455 | std.os.argv = argv[0..argc]; |
| 456 | 456 | std.os.environ = envp; |
| 457 | 457 | |
| 458 | if (builtin.zig_backend == .stage2_llvm) { | |
| 459 | return @call(.{ .modifier = .always_inline }, callMain, .{}); | |
| 460 | } | |
| 461 | ||
| 462 | 458 | std.debug.maybeEnableSegfaultHandler(); |
| 463 | 459 | |
| 464 | 460 | return initEventLoopAndCallMain(); |
src/codegen/llvm.zig+15-4| ... | ... | @@ -673,6 +673,7 @@ pub const Object = struct { |
| 673 | 673 | ) !void { |
| 674 | 674 | const decl_index = func.owner_decl; |
| 675 | 675 | const decl = module.declPtr(decl_index); |
| 676 | const target = module.getTarget(); | |
| 676 | 677 | |
| 677 | 678 | var dg: DeclGen = .{ |
| 678 | 679 | .context = o.context, |
| ... | ... | @@ -706,6 +707,17 @@ pub const Object = struct { |
| 706 | 707 | DeclGen.removeFnAttr(llvm_func, "noinline"); |
| 707 | 708 | } |
| 708 | 709 | |
| 710 | // TODO: port these over from stage1 | |
| 711 | // addLLVMFnAttr(llvm_fn, "sspstrong"); | |
| 712 | // addLLVMFnAttrStr(llvm_fn, "stack-protector-buffer-size", "4"); | |
| 713 | ||
| 714 | // TODO: disable this if safety is off for the function scope | |
| 715 | if (module.comp.bin_file.options.stack_check) { | |
| 716 | dg.addFnAttrString(llvm_func, "probe-stack", "__zig_probe_stack"); | |
| 717 | } else if (target.os.tag == .uefi) { | |
| 718 | dg.addFnAttrString(llvm_func, "no-stack-arg-probe", ""); | |
| 719 | } | |
| 720 | ||
| 709 | 721 | // Remove all the basic blocks of a function in order to start over, generating |
| 710 | 722 | // LLVM IR from an empty function body. |
| 711 | 723 | while (llvm_func.getFirstBasicBlock()) |bb| { |
| ... | ... | @@ -719,7 +731,6 @@ pub const Object = struct { |
| 719 | 731 | |
| 720 | 732 | // This gets the LLVM values from the function and stores them in `dg.args`. |
| 721 | 733 | const fn_info = decl.ty.fnInfo(); |
| 722 | const target = dg.module.getTarget(); | |
| 723 | 734 | const sret = firstParamSRet(fn_info, target); |
| 724 | 735 | const ret_ptr = if (sret) llvm_func.getParam(0) else null; |
| 725 | 736 | const gpa = dg.gpa; |
| ... | ... | @@ -730,7 +741,7 @@ pub const Object = struct { |
| 730 | 741 | }; |
| 731 | 742 | |
| 732 | 743 | const err_return_tracing = fn_info.return_type.isError() and |
| 733 | dg.module.comp.bin_file.options.error_return_tracing; | |
| 744 | module.comp.bin_file.options.error_return_tracing; | |
| 734 | 745 | |
| 735 | 746 | const err_ret_trace = if (err_return_tracing) |
| 736 | 747 | llvm_func.getParam(@boolToInt(ret_ptr != null)) |
| ... | ... | @@ -920,7 +931,7 @@ pub const Object = struct { |
| 920 | 931 | |
| 921 | 932 | const line_number = decl.src_line + 1; |
| 922 | 933 | const is_internal_linkage = decl.val.tag() != .extern_fn and |
| 923 | !dg.module.decl_exports.contains(decl_index); | |
| 934 | !module.decl_exports.contains(decl_index); | |
| 924 | 935 | const noret_bit: c_uint = if (fn_info.return_type.isNoReturn()) |
| 925 | 936 | llvm.DIFlags.NoReturn |
| 926 | 937 | else |
| ... | ... | @@ -936,7 +947,7 @@ pub const Object = struct { |
| 936 | 947 | true, // is definition |
| 937 | 948 | line_number + func.lbrace_line, // scope line |
| 938 | 949 | llvm.DIFlags.StaticMember | noret_bit, |
| 939 | dg.module.comp.bin_file.options.optimize_mode != .Debug, | |
| 950 | module.comp.bin_file.options.optimize_mode != .Debug, | |
| 940 | 951 | null, // decl_subprogram |
| 941 | 952 | ); |
| 942 | 953 | try dg.object.di_map.put(gpa, decl, subprogram.toNode()); |
src/link/C.zig+46-29| ... | ... | @@ -263,11 +263,13 @@ pub fn flushModule(self: *C, comp: *Compilation, prog_node: *std.Progress.Node) |
| 263 | 263 | // Covers zig.h and err_typedef_item. |
| 264 | 264 | try f.all_buffers.ensureUnusedCapacity(gpa, 2); |
| 265 | 265 | |
| 266 | f.all_buffers.appendAssumeCapacity(.{ | |
| 267 | .iov_base = zig_h, | |
| 268 | .iov_len = zig_h.len, | |
| 269 | }); | |
| 270 | f.file_size += zig_h.len; | |
| 266 | if (zig_h.len != 0) { | |
| 267 | f.all_buffers.appendAssumeCapacity(.{ | |
| 268 | .iov_base = zig_h, | |
| 269 | .iov_len = zig_h.len, | |
| 270 | }); | |
| 271 | f.file_size += zig_h.len; | |
| 272 | } | |
| 271 | 273 | |
| 272 | 274 | const err_typedef_writer = f.err_typedef_buf.writer(gpa); |
| 273 | 275 | const err_typedef_index = f.all_buffers.items.len; |
| ... | ... | @@ -301,11 +303,18 @@ pub fn flushModule(self: *C, comp: *Compilation, prog_node: *std.Progress.Node) |
| 301 | 303 | try flushDecl(self, &f, decl_index); |
| 302 | 304 | } |
| 303 | 305 | |
| 304 | f.all_buffers.items[err_typedef_index] = .{ | |
| 305 | .iov_base = f.err_typedef_buf.items.ptr, | |
| 306 | .iov_len = f.err_typedef_buf.items.len, | |
| 307 | }; | |
| 308 | f.file_size += f.err_typedef_buf.items.len; | |
| 306 | if (f.err_typedef_buf.items.len == 0) { | |
| 307 | f.all_buffers.items[err_typedef_index] = .{ | |
| 308 | .iov_base = "", | |
| 309 | .iov_len = 0, | |
| 310 | }; | |
| 311 | } else { | |
| 312 | f.all_buffers.items[err_typedef_index] = .{ | |
| 313 | .iov_base = f.err_typedef_buf.items.ptr, | |
| 314 | .iov_len = f.err_typedef_buf.items.len, | |
| 315 | }; | |
| 316 | f.file_size += f.err_typedef_buf.items.len; | |
| 317 | } | |
| 309 | 318 | |
| 310 | 319 | // Now the function bodies. |
| 311 | 320 | try f.all_buffers.ensureUnusedCapacity(gpa, f.fn_count); |
| ... | ... | @@ -391,21 +400,25 @@ fn flushDecl(self: *C, f: *Flush, decl_index: Module.Decl.Index) FlushDeclError! |
| 391 | 400 | |
| 392 | 401 | if (decl_block.fwd_decl.items.len != 0) { |
| 393 | 402 | const buf = decl_block.fwd_decl.items; |
| 394 | try f.all_buffers.append(gpa, .{ | |
| 395 | .iov_base = buf.ptr, | |
| 396 | .iov_len = buf.len, | |
| 397 | }); | |
| 398 | f.file_size += buf.len; | |
| 403 | if (buf.len != 0) { | |
| 404 | try f.all_buffers.append(gpa, .{ | |
| 405 | .iov_base = buf.ptr, | |
| 406 | .iov_len = buf.len, | |
| 407 | }); | |
| 408 | f.file_size += buf.len; | |
| 409 | } | |
| 399 | 410 | } |
| 400 | 411 | if (decl.getFunction() != null) { |
| 401 | 412 | f.fn_count += 1; |
| 402 | 413 | } else if (decl_block.code.items.len != 0) { |
| 403 | 414 | const buf = decl_block.code.items; |
| 404 | try f.all_buffers.append(gpa, .{ | |
| 405 | .iov_base = buf.ptr, | |
| 406 | .iov_len = buf.len, | |
| 407 | }); | |
| 408 | f.file_size += buf.len; | |
| 415 | if (buf.len != 0) { | |
| 416 | try f.all_buffers.append(gpa, .{ | |
| 417 | .iov_base = buf.ptr, | |
| 418 | .iov_len = buf.len, | |
| 419 | }); | |
| 420 | f.file_size += buf.len; | |
| 421 | } | |
| 409 | 422 | } |
| 410 | 423 | } |
| 411 | 424 | |
| ... | ... | @@ -421,19 +434,23 @@ pub fn flushEmitH(module: *Module) !void { |
| 421 | 434 | defer all_buffers.deinit(); |
| 422 | 435 | |
| 423 | 436 | var file_size: u64 = zig_h.len; |
| 424 | all_buffers.appendAssumeCapacity(.{ | |
| 425 | .iov_base = zig_h, | |
| 426 | .iov_len = zig_h.len, | |
| 427 | }); | |
| 437 | if (zig_h.len != 0) { | |
| 438 | all_buffers.appendAssumeCapacity(.{ | |
| 439 | .iov_base = zig_h, | |
| 440 | .iov_len = zig_h.len, | |
| 441 | }); | |
| 442 | } | |
| 428 | 443 | |
| 429 | 444 | for (emit_h.decl_table.keys()) |decl_index| { |
| 430 | 445 | const decl_emit_h = emit_h.declPtr(decl_index); |
| 431 | 446 | const buf = decl_emit_h.fwd_decl.items; |
| 432 | all_buffers.appendAssumeCapacity(.{ | |
| 433 | .iov_base = buf.ptr, | |
| 434 | .iov_len = buf.len, | |
| 435 | }); | |
| 436 | file_size += buf.len; | |
| 447 | if (buf.len != 0) { | |
| 448 | all_buffers.appendAssumeCapacity(.{ | |
| 449 | .iov_base = buf.ptr, | |
| 450 | .iov_len = buf.len, | |
| 451 | }); | |
| 452 | file_size += buf.len; | |
| 453 | } | |
| 437 | 454 | } |
| 438 | 455 | |
| 439 | 456 | const directory = emit_h.loc.directory orelse module.comp.local_cache_directory; |
src/link/Dwarf.zig+2-2| ... | ... | @@ -1752,7 +1752,7 @@ fn pwriteDbgLineNops( |
| 1752 | 1752 | .iov_base = buf.ptr, |
| 1753 | 1753 | .iov_len = buf.len, |
| 1754 | 1754 | }; |
| 1755 | vec_index += 1; | |
| 1755 | if (buf.len > 0) vec_index += 1; | |
| 1756 | 1756 | |
| 1757 | 1757 | { |
| 1758 | 1758 | var padding_left = next_padding_size; |
| ... | ... | @@ -1861,7 +1861,7 @@ fn pwriteDbgInfoNops( |
| 1861 | 1861 | .iov_base = buf.ptr, |
| 1862 | 1862 | .iov_len = buf.len, |
| 1863 | 1863 | }; |
| 1864 | vec_index += 1; | |
| 1864 | if (buf.len > 0) vec_index += 1; | |
| 1865 | 1865 | |
| 1866 | 1866 | { |
| 1867 | 1867 | var padding_left = next_padding_size; |
src/test.zig+19-31| ... | ... | @@ -20,7 +20,7 @@ const enable_wasmtime: bool = build_options.enable_wasmtime; |
| 20 | 20 | const enable_darling: bool = build_options.enable_darling; |
| 21 | 21 | const enable_rosetta: bool = build_options.enable_rosetta; |
| 22 | 22 | const glibc_runtimes_dir: ?[]const u8 = build_options.glibc_runtimes_dir; |
| 23 | const skip_stage1 = build_options.skip_stage1; | |
| 23 | const skip_stage1 = builtin.zig_backend != .stage1 or build_options.skip_stage1; | |
| 24 | 24 | |
| 25 | 25 | const hr = "=" ** 80; |
| 26 | 26 | |
| ... | ... | @@ -233,11 +233,11 @@ const TestManifest = struct { |
| 233 | 233 | fn ConfigValueIterator(comptime T: type) type { |
| 234 | 234 | return struct { |
| 235 | 235 | inner: std.mem.SplitIterator(u8), |
| 236 | parse_fn: ParseFn(T), | |
| 237 | 236 | |
| 238 | 237 | fn next(self: *@This()) !?T { |
| 239 | 238 | const next_raw = self.inner.next() orelse return null; |
| 240 | return try self.parse_fn(next_raw); | |
| 239 | const parseFn = getDefaultParser(T); | |
| 240 | return try parseFn(next_raw); | |
| 241 | 241 | } |
| 242 | 242 | }; |
| 243 | 243 | } |
| ... | ... | @@ -313,27 +313,17 @@ const TestManifest = struct { |
| 313 | 313 | return manifest; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | fn getConfigForKeyCustomParser( | |
| 316 | fn getConfigForKey( | |
| 317 | 317 | self: TestManifest, |
| 318 | 318 | key: []const u8, |
| 319 | 319 | comptime T: type, |
| 320 | parse_fn: ParseFn(T), | |
| 321 | 320 | ) ConfigValueIterator(T) { |
| 322 | 321 | const bytes = self.config_map.get(key) orelse TestManifestConfigDefaults.get(self.@"type", key); |
| 323 | 322 | return ConfigValueIterator(T){ |
| 324 | 323 | .inner = std.mem.split(u8, bytes, ","), |
| 325 | .parse_fn = parse_fn, | |
| 326 | 324 | }; |
| 327 | 325 | } |
| 328 | 326 | |
| 329 | fn getConfigForKey( | |
| 330 | self: TestManifest, | |
| 331 | key: []const u8, | |
| 332 | comptime T: type, | |
| 333 | ) ConfigValueIterator(T) { | |
| 334 | return self.getConfigForKeyCustomParser(key, T, getDefaultParser(T)); | |
| 335 | } | |
| 336 | ||
| 337 | 327 | fn getConfigForKeyAlloc( |
| 338 | 328 | self: TestManifest, |
| 339 | 329 | allocator: Allocator, |
| ... | ... | @@ -377,6 +367,15 @@ const TestManifest = struct { |
| 377 | 367 | } |
| 378 | 368 | |
| 379 | 369 | fn getDefaultParser(comptime T: type) ParseFn(T) { |
| 370 | if (T == CrossTarget) return struct { | |
| 371 | fn parse(str: []const u8) anyerror!T { | |
| 372 | var opts = CrossTarget.ParseOptions{ | |
| 373 | .arch_os_abi = str, | |
| 374 | }; | |
| 375 | return try CrossTarget.parse(opts); | |
| 376 | } | |
| 377 | }.parse; | |
| 378 | ||
| 380 | 379 | switch (@typeInfo(T)) { |
| 381 | 380 | .Int => return struct { |
| 382 | 381 | fn parse(str: []const u8) anyerror!T { |
| ... | ... | @@ -397,14 +396,7 @@ const TestManifest = struct { |
| 397 | 396 | }; |
| 398 | 397 | } |
| 399 | 398 | }.parse, |
| 400 | .Struct => if (comptime std.mem.eql(u8, @typeName(T), "CrossTarget")) return struct { | |
| 401 | fn parse(str: []const u8) anyerror!T { | |
| 402 | var opts = CrossTarget.ParseOptions{ | |
| 403 | .arch_os_abi = str, | |
| 404 | }; | |
| 405 | return try CrossTarget.parse(opts); | |
| 406 | } | |
| 407 | }.parse else @compileError("no default parser for " ++ @typeName(T)), | |
| 399 | .Struct => @compileError("no default parser for " ++ @typeName(T)), | |
| 408 | 400 | else => @compileError("no default parser for " ++ @typeName(T)), |
| 409 | 401 | } |
| 410 | 402 | } |
| ... | ... | @@ -884,8 +876,6 @@ pub const TestContext = struct { |
| 884 | 876 | src: [:0]const u8, |
| 885 | 877 | expected_errors: []const []const u8, |
| 886 | 878 | ) void { |
| 887 | if (skip_stage1) return; | |
| 888 | ||
| 889 | 879 | const case = ctx.addObj(name, .{}); |
| 890 | 880 | case.backend = .stage1; |
| 891 | 881 | case.addError(src, expected_errors); |
| ... | ... | @@ -897,8 +887,6 @@ pub const TestContext = struct { |
| 897 | 887 | src: [:0]const u8, |
| 898 | 888 | expected_errors: []const []const u8, |
| 899 | 889 | ) void { |
| 900 | if (skip_stage1) return; | |
| 901 | ||
| 902 | 890 | const case = ctx.addTest(name, .{}); |
| 903 | 891 | case.backend = .stage1; |
| 904 | 892 | case.addError(src, expected_errors); |
| ... | ... | @@ -910,8 +898,6 @@ pub const TestContext = struct { |
| 910 | 898 | src: [:0]const u8, |
| 911 | 899 | expected_errors: []const []const u8, |
| 912 | 900 | ) void { |
| 913 | if (skip_stage1) return; | |
| 914 | ||
| 915 | 901 | const case = ctx.addExe(name, .{}); |
| 916 | 902 | case.backend = .stage1; |
| 917 | 903 | case.addError(src, expected_errors); |
| ... | ... | @@ -1143,8 +1129,6 @@ pub const TestContext = struct { |
| 1143 | 1129 | |
| 1144 | 1130 | // Cross-product to get all possible test combinations |
| 1145 | 1131 | for (backends) |backend| { |
| 1146 | if (backend == .stage1 and skip_stage1) continue; | |
| 1147 | ||
| 1148 | 1132 | for (targets) |target| { |
| 1149 | 1133 | const name = try std.fmt.allocPrint(ctx.arena, "{s} ({s}, {s})", .{ |
| 1150 | 1134 | name_prefix, |
| ... | ... | @@ -1276,6 +1260,9 @@ pub const TestContext = struct { |
| 1276 | 1260 | if (!build_options.have_llvm and case.backend == .llvm) |
| 1277 | 1261 | continue; |
| 1278 | 1262 | |
| 1263 | if (skip_stage1 and case.backend == .stage1) | |
| 1264 | continue; | |
| 1265 | ||
| 1279 | 1266 | if (build_options.test_filter) |test_filter| { |
| 1280 | 1267 | if (std.mem.indexOf(u8, case.name, test_filter) == null) continue; |
| 1281 | 1268 | } |
| ... | ... | @@ -1607,6 +1594,7 @@ pub const TestContext = struct { |
| 1607 | 1594 | |
| 1608 | 1595 | var module_node = update_node.start("parse/analysis/codegen", 0); |
| 1609 | 1596 | module_node.activate(); |
| 1597 | module_node.context.refresh(); | |
| 1610 | 1598 | try comp.makeBinFileWritable(); |
| 1611 | 1599 | try comp.update(); |
| 1612 | 1600 | module_node.end(); |
| ... | ... | @@ -1855,7 +1843,7 @@ pub const TestContext = struct { |
| 1855 | 1843 | |
| 1856 | 1844 | .qemu => |qemu_bin_name| if (enable_qemu) { |
| 1857 | 1845 | const need_cross_glibc = target.isGnuLibC() and case.link_libc; |
| 1858 | const glibc_dir_arg = if (need_cross_glibc) | |
| 1846 | const glibc_dir_arg: ?[]const u8 = if (need_cross_glibc) | |
| 1859 | 1847 | glibc_runtimes_dir orelse continue :update // glibc dir not available; pass test |
| 1860 | 1848 | else |
| 1861 | 1849 | null; |
test/cases/compile_errors/endless_loop_in_function_evaluation.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const seventh_fib_number = fibonacci(7); | |
| 2 | fn fibonacci(x: i32) i32 { | |
| 3 | return fibonacci(x - 1) + fibonacci(x - 2); | |
| 4 | } | |
| 5 | ||
| 6 | export fn entry() usize { return @sizeOf(@TypeOf(&seventh_fib_number)); } | |
| 7 | ||
| 8 | // error | |
| 9 | // backend=stage2 | |
| 10 | // target=native | |
| 11 | // | |
| 12 | // :3:21: error: evaluation exceeded 1000 backwards branches | |
| 13 | // :3:21: note: use @setEvalBranchQuota() to raise the branch limit from 1000 | |
| 14 | // :3:21: note: called from here (999 times) | |
| 15 | // :1:37: note: called from here |