#Get assembly output of binary or full build
1 messages · Page 1 of 1 (latest)
Nm figured it out!
Updated my build to have the following:
exe.emit_asm = .emit;
ie. My full config
const std = @import("std");
const Sdk = @import("deps/SDL.zig/Sdk.zig"); // Import the Sdk at build time
pub fn build(b: *std.Build.Builder) !void {
// Determine compilation target
const target = b.standardTargetOptions(.{});
// Create a new instance of the SDL2 Sdk
const sdk = Sdk.init(b, null);
// Create executable for our example
const exe = b.addExecutable(.{
.name = "game",
.root_source_file = .{ .path = "src/main.zig" },
.target = target, // must be done before calling sdk.link
// .use_llvm = false,
// .use_lld = false,
});
sdk.link(exe, .dynamic); // link SDL2 as a shared library
// Add "sdl2" package that exposes the SDL2 api (like SDL_Init or SDL_CreateWindow)
exe.addModule("sdl2", sdk.getNativeModule());
// Add stb_image
exe.addCSourceFile("deps/stb_image/stb_image_impl.c", &[_][]const u8{"-std=c99"});
exe.addIncludePath("deps/stb_image");
exe.addModule("stb_image", b.createModule(.{
.source_file = .{ .path = "deps/stb_image/stb_image.zig" },
}));
// Install the executable into the prefix when invoking "zig build"
b.installArtifact(exe);
// const run_cmd = b.addRunArtifact(exe);
// run_cmd.step.dependOn(b.getInstallStep());
// const run_step = b.step("run", "Run the app");
// run_step.dependOn(&run_cmd.step);
exe.emit_asm = .emit;
}
If anyone has further insight into getting a bit more details out of it like mapping the assembly to the source file and line number like the aforementioned objdump example with Go code, that'd be great though.
I don't think there's currently a way of doing that unfortunately, not directly with build.zig or the command line directly anyway
though somehow godbolt.org manages to do it
so taking a look at that might be worthwhile
hm. This actually doesn't do lines/files unless theres a different Zig page...
https://godbolt.org/noscript/zig
So maybe just not possible for now
objdump -S -l file