authorgravatar for bjorn.linse@gmail.combfredl <bjorn.linse@gmail.com> 2022-09-06 13:28:31+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-07 14:53:31+03:00
loge02b9f458dd7e48bef5b436242ba0ab3550224da
tree3ecdae366d30b13abc950b552f1393bcf467abce
parente283a40d17bbbeeafda84fad9b75bbc458950934

build-exe: allow combination of -fno-emit-bin and --verbose-air

Currently, `zig build-exe -fno-emit-bin --verbose-air src/main.zig` results in no output at all. With this refactor, it dumps AIR and then exits without invoking LLVM, as expected

1 files changed, 11 insertions(+), 4 deletions(-)

src/Module.zig+11-4
......@@ -4274,11 +4274,14 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
42744274
42754275 const comp = mod.comp;
42764276
4277 if (comp.bin_file.options.emit == null and
4277 const no_bin_file = (comp.bin_file.options.emit == null and
42784278 comp.emit_asm == null and
42794279 comp.emit_llvm_ir == null and
4280 comp.emit_llvm_bc == null)
4281 {
4280 comp.emit_llvm_bc == null);
4281
4282 const dump_air = builtin.mode == .Debug and comp.verbose_air;
4283
4284 if (no_bin_file and !dump_air) {
42824285 return;
42834286 }
42844287
......@@ -4286,7 +4289,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
42864289 var liveness = try Liveness.analyze(gpa, air);
42874290 defer liveness.deinit(gpa);
42884291
4289 if (builtin.mode == .Debug and comp.verbose_air) {
4292 if (dump_air) {
42904293 const fqn = try decl.getFullyQualifiedName(mod);
42914294 defer mod.gpa.free(fqn);
42924295
......@@ -4295,6 +4298,10 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void {
42954298 std.debug.print("# End Function AIR: {s}\n\n", .{fqn});
42964299 }
42974300
4301 if (no_bin_file) {
4302 return;
4303 }
4304
42984305 comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) {
42994306 error.OutOfMemory => return error.OutOfMemory,
43004307 error.AnalysisFail => {