| author | |
| committer | |
| log | c7f98332383d71a57699426027e82c435e91addc |
| tree | b6a97bb72808d47a001085403254c0fc9d75b82b |
| parent | cb0e22db4e18dd803e1edd681c836fadbae0ea6f |
* `--verbose-llvm-ir` should trigger analysis and codegen
* `-femit-asm` etc should trigger codegen even with `-fno-emit-bin`
Closes #125884 files changed, 36 insertions(+), 7 deletions(-)
src/Module.zig+11-7| ... | ... | @@ -4319,10 +4319,9 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { |
| 4319 | 4319 | comp.emit_llvm_bc == null); |
| 4320 | 4320 | |
| 4321 | 4321 | const dump_air = builtin.mode == .Debug and comp.verbose_air; |
| 4322 | const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir; | |
| 4322 | 4323 | |
| 4323 | if (no_bin_file and !dump_air) { | |
| 4324 | return; | |
| 4325 | } | |
| 4324 | if (no_bin_file and !dump_air and !dump_llvm_ir) return; | |
| 4326 | 4325 | |
| 4327 | 4326 | log.debug("analyze liveness of {s}", .{decl.name}); |
| 4328 | 4327 | var liveness = try Liveness.analyze(gpa, air); |
| ... | ... | @@ -4337,9 +4336,7 @@ pub fn ensureFuncBodyAnalyzed(mod: *Module, func: *Fn) SemaError!void { |
| 4337 | 4336 | std.debug.print("# End Function AIR: {s}\n\n", .{fqn}); |
| 4338 | 4337 | } |
| 4339 | 4338 | |
| 4340 | if (no_bin_file) { | |
| 4341 | return; | |
| 4342 | } | |
| 4339 | if (no_bin_file and !dump_llvm_ir) return; | |
| 4343 | 4340 | |
| 4344 | 4341 | comp.bin_file.updateFunc(mod, func, air, liveness) catch |err| switch (err) { |
| 4345 | 4342 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -6484,7 +6481,14 @@ pub fn populateTestFunctions(mod: *Module) !void { |
| 6484 | 6481 | pub fn linkerUpdateDecl(mod: *Module, decl_index: Decl.Index) !void { |
| 6485 | 6482 | const comp = mod.comp; |
| 6486 | 6483 | |
| 6487 | if (comp.bin_file.options.emit == null) return; | |
| 6484 | const no_bin_file = (comp.bin_file.options.emit == null and | |
| 6485 | comp.emit_asm == null and | |
| 6486 | comp.emit_llvm_ir == null and | |
| 6487 | comp.emit_llvm_bc == null); | |
| 6488 | ||
| 6489 | const dump_llvm_ir = builtin.mode == .Debug and comp.verbose_llvm_ir; | |
| 6490 | ||
| 6491 | if (no_bin_file and !dump_llvm_ir) return; | |
| 6488 | 6492 | |
| 6489 | 6493 | const decl = mod.declPtr(decl_index); |
| 6490 | 6494 |
test/standalone.zig+1| ... | ... | @@ -103,4 +103,5 @@ pub fn addCases(cases: *tests.StandaloneContext) void { |
| 103 | 103 | |
| 104 | 104 | cases.addBuildFile("test/standalone/issue_13030/build.zig", .{ .build_modes = true }); |
| 105 | 105 | cases.addBuildFile("test/standalone/emit_asm_and_bin/build.zig", .{}); |
| 106 | cases.addBuildFile("test/standalone/issue_12588/build.zig", .{}); | |
| 106 | 107 | } |
test/standalone/issue_12588/build.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | const std = @import("std"); | |
| 2 | const Builder = std.build.Builder; | |
| 3 | ||
| 4 | pub fn build(b: *Builder) void { | |
| 5 | const mode = b.standardReleaseOptions(); | |
| 6 | const target = b.standardTargetOptions(.{}); | |
| 7 | ||
| 8 | const obj = b.addObject("main", "main.zig"); | |
| 9 | obj.setBuildMode(mode); | |
| 10 | obj.setTarget(target); | |
| 11 | obj.emit_llvm_ir = .{ .emit_to = b.pathFromRoot("main.ll") }; | |
| 12 | obj.emit_llvm_bc = .{ .emit_to = b.pathFromRoot("main.bc") }; | |
| 13 | obj.emit_bin = .no_emit; | |
| 14 | b.default_step.dependOn(&obj.step); | |
| 15 | ||
| 16 | const test_step = b.step("test", "Test the program"); | |
| 17 | test_step.dependOn(&obj.step); | |
| 18 | } |
test/standalone/issue_12588/main.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | export fn strFromFloatHelp(float: f64) void { | |
| 4 | var buf: [400]u8 = undefined; | |
| 5 | _ = std.fmt.bufPrint(&buf, "{d}", .{float}) catch unreachable; | |
| 6 | } |