Closed
Description
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Create a hello world file at "hello.zig"
Next to it create the following "build.zig" file.
const std = @import("std");
pub fn build(b: *std.Build) void {
const hello = b.addObject(.{
.name = "hello_world",
.root_source_file = b.path("hello.zig"),
.optimize = .ReleaseFast,
.target = b.standardTargetOptions(.{}),
.use_llvm = true,
});
const install_bc = b.addInstallFile(hello.getEmittedLlvmBc(), "hello.bc");
b.getInstallStep().dependOn(&install_bc.step);
}
// If this two lines are commented out, the bytecode file doesn't get installed (but still emitted).
// const install_bin = b.addInstallFile(zig_kernel.getEmittedBin(), "hello.bin");
// b.getInstallStep().dependOn(&install_bin.step);
}
Then zig build
fails with the following error:
getPath() was called on a GeneratedFile that wasn't built yet.
Is there a missing Step dependency on step 'zig build-obj hello_world ReleaseFast native'?
Expected Behavior
Zig should accept to compile the program and only output llvm bytecode, not the full binary.
Note this is still present on zig_0.14.0-dev.363, and it was also present a few months ago when I wrote this https://gist.github.com/gwenzek/7e77e592320b9b1971b95fb0d6429424 (totally forgot about it in the meantime).
This issue is not only about Llvm bytecode, it's also reproducible with other outputs kind such as -femit-asm
Note that directly calling zig build-obj -fno-emit-bin -femit-llvm-bytecode
works fine it's really an issue with the build system.