authorgravatar for sentrycraft123@gmail.comJan200101 <sentrycraft123@gmail.com> 2025-01-17 20:53:30+01:00
committergravatar for sentrycraft123@gmail.comJan <sentrycraft123@gmail.com> 2025-03-07 10:59:02+01:00
log013a22896015619e23858ae3fbfc92317af574eb
tree7da642ccb6458600005f63ce234ffb533a0739e2
parent4cefd1bd1bac7059f7e00162a579f659e5f59412

std.Build: add build-id option


4 files changed, 16 insertions(+), 7 deletions(-)

build.zig-6
......@@ -197,12 +197,6 @@ pub fn build(b: *std.Build) !void {
197197 exe.pie = pie;
198198 exe.entitlements = entitlements;
199199
200 exe.build_id = b.option(
201 std.zig.BuildId,
202 "build-id",
203 "Request creation of '.note.gnu.build-id' section",
204 );
205
206200 if (no_bin) {
207201 b.getInstallStep().dependOn(&exe.step);
208202 } else {
lib/compiler/build_runner.zig+13
......@@ -202,6 +202,15 @@ pub fn main() !void {
202202 next_arg, @errorName(err),
203203 });
204204 };
205 } else if (mem.eql(u8, arg, "--build-id")) {
206 builder.build_id = .fast;
207 } else if (mem.startsWith(u8, arg, "--build-id=")) {
208 const style = arg["--build-id=".len..];
209 builder.build_id = std.zig.BuildId.parse(style) catch |err| {
210 fatal("unable to parse --build-id style '{s}': {s}", .{
211 style, @errorName(err),
212 });
213 };
205214 } else if (mem.eql(u8, arg, "--debounce")) {
206215 const next_arg = nextArg(args, &arg_idx) orelse
207216 fatalWithHint("expected u16 after '{s}'", .{arg});
......@@ -1364,6 +1373,10 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
13641373 \\ --zig-lib-dir [arg] Override path to Zig lib directory
13651374 \\ --build-runner [file] Override path to build runner
13661375 \\ --seed [integer] For shuffling dependency traversal order (default: random)
1376 \\ --build-id[=style] At a minor link-time expense, coordinates stripped binaries
1377 \\ fast, uuid, sha1, md5 with debug symbols via a '.note.gnu.build-id' section
1378 \\ 0x[hexstring] Maximum 32 bytes
1379 \\ none (default) Disable build-id
13671380 \\ --debug-log [scope] Enable debugging the compiler
13681381 \\ --debug-pkg-config Fail if unknown pkg-config flags encountered
13691382 \\ --debug-rt Debug compiler runtime libraries
lib/std/Build.zig+2
......@@ -94,6 +94,8 @@ available_deps: AvailableDeps,
9494
9595release_mode: ReleaseMode,
9696
97build_id: ?std.zig.BuildId = null,
98
9799pub const ReleaseMode = enum {
98100 off,
99101 any,
lib/std/Build/Step/Compile.zig+1-1
......@@ -1681,7 +1681,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
16811681
16821682 try addFlag(&zig_args, "each-lib-rpath", compile.each_lib_rpath);
16831683
1684 if (compile.build_id) |build_id| {
1684 if (compile.build_id orelse b.build_id) |build_id| {
16851685 try zig_args.append(switch (build_id) {
16861686 .hexstring => |hs| b.fmt("--build-id=0x{s}", .{
16871687 std.fmt.fmtSliceHexLower(hs.toSlice()),