diff options
| author | bfredl <bjorn.linse@gmail.com> | 2022-09-06 13:28:31 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-09-07 14:53:31 +0300 |
| commit | e02b9f458dd7e48bef5b436242ba0ab3550224da (patch) | |
| tree | 3ecdae366d30b13abc950b552f1393bcf467abce /src/Module.zig | |
| parent | e283a40d17bbbeeafda84fad9b75bbc458950934 (diff) | |
| download | zig-e02b9f458dd7e48bef5b436242ba0ab3550224da.tar.gz zig-e02b9f458dd7e48bef5b436242ba0ab3550224da.zip | |
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
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Module.zig b/src/Module.zig index c63fe43158..3ae6c48edd 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4274,11 +4274,14 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { const comp = mod.comp; - if (comp.bin_file.options.emit == null and + const no_bin_file = (comp.bin_file.options.emit == null and comp.emit_asm == null and comp.emit_llvm_ir == null and - comp.emit_llvm_bc == null) - { + comp.emit_llvm_bc == null); + + const dump_air = builtin.mode == .Debug and comp.verbose_air; + + if (no_bin_file and !dump_air) { return; } @@ -4286,7 +4289,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { var liveness = try Liveness.analyze(gpa, air); defer liveness.deinit(gpa); - if (builtin.mode == .Debug and comp.verbose_air) { + if (dump_air) { const fqn = try decl.getFullyQualifiedName(mod); defer mod.gpa.free(fqn); @@ -4295,6 +4298,10 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { std.debug.print("# End Function AIR: {s}\n\n", .{fqn}); } + if (no_bin_file) { + return; + } + comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, error.AnalysisFail => { |
