Compare commits

...

2 Commits

Author SHA1 Message Date
dave caruso
9af70c69c0 Merge branch 'main' into dave/error-return-trace 2024-07-11 14:06:58 -07:00
dave caruso
ee4a617dff experiment with enabling error return traces 2024-06-20 18:31:41 -07:00
3 changed files with 12 additions and 28 deletions

View File

@@ -321,27 +321,6 @@ pub fn build(b: *Build) !void {
}
}
}
// Running `zig build` with no arguments is almost always a mistake.
// TODO: revive this error. cannot right now since ZLS runs zig build without arguments
{
// const mistake_message = b.addSystemCommand(&.{
// "echo",
// \\
// \\To build Bun from source, please use `bun run setup` instead of `zig build`"
// \\For more info, see https://bun.sh/docs/project/contributing
// \\
// \\If you want to build the zig code in isolation, run:
// \\ 'zig build obj -Dgenerated-code=./build/codegen [...opts]'
// \\
// \\If you want to test a compile without emitting an object:
// \\ 'zig build check'
// \\ 'zig build check-all' (run linux+mac+windows)
// \\
// });
// b.default_step.dependOn(&mistake_message.step);
}
}
pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile {
@@ -355,6 +334,13 @@ pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile {
.optimize = opts.optimize,
.pic = true,
.strip = false, // stripped at the end
// Enable error tracing for all targets so that end users can use bun
// --verbose-error-trace in order to print extra error information.
//
// For performance, see https://ziglang.org/documentation/0.13.0/#toc-Implementation-Details
// When this was added to Bun, no large performance impacts were observed,
.error_tracing = true,
});
obj.bundle_compiler_rt = false;
@@ -382,6 +368,7 @@ pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile {
obj.root_module.valgrind = true;
}
}
addInternalPackages(b, obj, opts);
obj.root_module.addImport("build_options", opts.buildOptionsModule(b));
return obj;

View File

@@ -149,13 +149,11 @@ pub const Arguments = struct {
const base_params_ = [_]ParamType{
clap.parseParam("--env-file <STR>... Load environment variables from the specified file(s)") catch unreachable,
clap.parseParam("--cwd <STR> Absolute path to resolve files & entry points from. This just changes the process' cwd.") catch unreachable,
clap.parseParam("--verbose-error-trace Print internal error trace information. Useful for debugging crashes.") catch unreachable,
clap.parseParam("-c, --config <PATH>? Specify path to Bun config file. Default <d>$cwd<r>/bunfig.toml") catch unreachable,
clap.parseParam("-h, --help Display this menu and exit") catch unreachable,
clap.parseParam("<POS>...") catch unreachable,
} ++ if (builtin.have_error_return_tracing) [_]ParamType{
// This will print more error return traces, as a debug aid
clap.parseParam("--verbose-error-trace") catch unreachable,
} else [_]ParamType{};
};
const transpiler_params_ = [_]ParamType{
clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --target dependent") catch unreachable,

View File

@@ -1374,9 +1374,8 @@ fn handleErrorReturnTraceExtra(err: anyerror, maybe_trace: ?*std.builtin.StackTr
/// single line (the error name) is printed. When this is set, we will print
/// trace strings for those errors (or full stacks in debug builds).
///
/// This can be enabled by passing `--verbose-error-trace` to the CLI.
/// In release builds with error return tracing enabled, this is also exposed.
/// You can test if this feature is available by checking `bun --help` for the flag.
/// This can be enabled by passing `--verbose-error-trace` to the CLI, which
/// is enabled in release mode to aid debugging.
pub inline fn handleErrorReturnTrace(err: anyerror, maybe_trace: ?*std.builtin.StackTrace) void {
handleErrorReturnTraceExtra(err, maybe_trace, false);
}