| author | |
| committer | |
| log | 93ae386f560e7a3464df31b7c9bc9acdc231bc3f |
| tree | 4d279258d3812a47b5f5188c9304937c6133fa98 |
| parent | be294e3744b221e7a7aad3ce8fbd1a30148487bc |
Fixes Godbolt's CLI usage of Zig.3 files changed, 29 insertions(+), 12 deletions(-)
ci/zinc/linux_test.sh+1-1| ... | ... | @@ -61,9 +61,9 @@ stage3/bin/zig build test-asm-link -fqemu -fwasmtime -Denable-llvm |
| 61 | 61 | 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 | stage3/bin/zig build test-cli -fqemu -fwasmtime -Denable-llvm | |
| 64 | 65 | |
| 65 | 66 | $STAGE1_ZIG build test-stack-traces -fqemu -fwasmtime |
| 66 | $STAGE1_ZIG build test-cli -fqemu -fwasmtime | |
| 67 | 67 | $STAGE1_ZIG build test-run-translated-c -fqemu -fwasmtime |
| 68 | 68 | $STAGE1_ZIG build docs -fqemu -fwasmtime |
| 69 | 69 | $STAGE1_ZIG build test-cases -fqemu -fwasmtime |
src/Module.zig+11-3| ... | ... | @@ -4122,13 +4122,21 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { |
| 4122 | 4122 | }; |
| 4123 | 4123 | defer air.deinit(gpa); |
| 4124 | 4124 | |
| 4125 | if (mod.comp.bin_file.options.emit == null) return; | |
| 4125 | const comp = mod.comp; | |
| 4126 | ||
| 4127 | if (comp.bin_file.options.emit == null and | |
| 4128 | comp.emit_asm == null and | |
| 4129 | comp.emit_llvm_ir == null and | |
| 4130 | comp.emit_llvm_bc == null) | |
| 4131 | { | |
| 4132 | return; | |
| 4133 | } | |
| 4126 | 4134 | |
| 4127 | 4135 | log.debug("analyze liveness of {s}", .{decl.name}); |
| 4128 | 4136 | var liveness = try Liveness.analyze(gpa, air); |
| 4129 | 4137 | defer liveness.deinit(gpa); |
| 4130 | 4138 | |
| 4131 | if (builtin.mode == .Debug and mod.comp.verbose_air) { | |
| 4139 | if (builtin.mode == .Debug and comp.verbose_air) { | |
| 4132 | 4140 | const fqn = try decl.getFullyQualifiedName(mod); |
| 4133 | 4141 | defer mod.gpa.free(fqn); |
| 4134 | 4142 | |
| ... | ... | @@ -4137,7 +4145,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { |
| 4137 | 4145 | std.debug.print("# End Function AIR: {s}\n\n", .{fqn}); |
| 4138 | 4146 | } |
| 4139 | 4147 | |
| 4140 | mod.comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { | |
| 4148 | comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { | |
| 4141 | 4149 | error.OutOfMemory => return error.OutOfMemory, |
| 4142 | 4150 | error.AnalysisFail => { |
| 4143 | 4151 | decl.analysis = .codegen_failure; |
test/cli.zig+17-8| ... | ... | @@ -33,17 +33,26 @@ pub fn main() !void { |
| 33 | 33 | defer fs.cwd().deleteTree(dir_path) catch {}; |
| 34 | 34 | |
| 35 | 35 | const TestFn = fn ([]const u8, []const u8) anyerror!void; |
| 36 | const test_fns = [_]TestFn{ | |
| 37 | testZigInitLib, | |
| 38 | testZigInitExe, | |
| 39 | testGodboltApi, | |
| 40 | testMissingOutputPath, | |
| 41 | testZigFmt, | |
| 36 | const Test = struct { | |
| 37 | func: TestFn, | |
| 38 | name: []const u8, | |
| 42 | 39 | }; |
| 43 | inline for (test_fns) |testFn| { | |
| 40 | const tests = [_]Test{ | |
| 41 | .{ .func = testZigInitLib, .name = "zig init-lib" }, | |
| 42 | .{ .func = testZigInitExe, .name = "zig init-exe" }, | |
| 43 | .{ .func = testGodboltApi, .name = "godbolt API" }, | |
| 44 | .{ .func = testMissingOutputPath, .name = "missing output path" }, | |
| 45 | .{ .func = testZigFmt, .name = "zig fmt" }, | |
| 46 | }; | |
| 47 | inline for (tests) |t| { | |
| 44 | 48 | try fs.cwd().deleteTree(dir_path); |
| 45 | 49 | try fs.cwd().makeDir(dir_path); |
| 46 | try testFn(zig_exe, dir_path); | |
| 50 | t.func(zig_exe, dir_path) catch |err| { | |
| 51 | std.debug.print("test '{s}' failed: {s}\n", .{ | |
| 52 | t.name, @errorName(err), | |
| 53 | }); | |
| 54 | return err; | |
| 55 | }; | |
| 47 | 56 | } |
| 48 | 57 | } |
| 49 | 58 |