-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error traces in custom steps no longer print in zig build #15014
Comments
Same issue with 0.11.0-dev.2154+2089b3f19. Wow, this issue is fixed in 49d37e2. @RossComputerGuy Would you mind give another try? |
That's unrelated to this issue and I've tried several times to rebuild but I get the same issue. |
Could you provide a minimal example to reproduce this issue? |
This should work and should print out only a const std = @import("std");
fn make_step(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
_ = step;
_ = prog_node;
return error.FileNotFound;
}
pub fn build(b: *std.Build) void {
var step = std.Build.Step.init(.{
.id = .custom,
.name = "Failure",
.owner = b,
.makeFn = make_step,
});
b.default_step.dependOn(&step);
} |
I try your
0.11.0-dev.2168+322ace70f |
Yeah, I have the same segfault. Code wise, it should work but it doesn't. |
@jiacai2050 I decided to take a look at why the example wouldn't work and I just had to allocate step: const std = @import("std");
fn make_step(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
_ = step;
_ = prog_node;
return error.FileNotFound;
}
pub fn build(b: *std.Build) !void {
var step = try b.allocator.create(std.Build.Step);
step.* = std.Build.Step.init(.{
.id = .custom,
.name = "Failure",
.owner = b,
.makeFn = make_step,
});
b.default_step.dependOn(step);
} Log:
And it happens as expected of the issue, it prints |
This is not confirmed to be a bug yet. Can I see your custom build step logic? Also could you perhaps not use a custom step? |
I saw this originally here but I don't have an exact point of failure due to the stack trace not being printed. Also, what would be the alternative to a custom step if a custom step isn't supposed to be used? |
Whatever needs being done, it can be done by one of these:
If all else fails, a RunStep allows for arbitrary code execution - and such code will be done in a sub-process, so you have no chance of accidentally misusing the build system custom step API. |
It looks like
const std = @import("std");
const Build = std.Build;
pub fn build(b: *Build) !void {
const exec = b.addSystemCommand(&.{
"ls",
"--broken-arg",
});
b.default_step.dependOn(&exec.step);
} Not sure why custom steps don't print error traces. It really should be printed because there's cases where just from error names, not enough information is provided. There's always a proposal like #2647 but imo, it probably would be best to have at the very least error traces printed when a function fails in |
Zig Version
0.11.0-dev.2160+49d37e2d1
Steps to Reproduce and Observed Behavior
With the introduction of #14647, I've noticed that custom steps made in
build.zig
will no longer show an error trace. Because of this, it is difficult to debug certain issues even with-freference-trace
set.Example:
As you can see, an error occurred in a step called "Scan Protocols" but it is difficult to understand where the error is coming from.
Expected Behavior
Either
-freference-trace
should at least be able to show the trace or when an error is thrown in a custom step, the trace is shown automatically.The text was updated successfully, but these errors were encountered: