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 {...@@ -197,12 +197,6 @@ pub fn build(b: *std.Build) !void {
197 exe.pie = pie;197 exe.pie = pie;
198 exe.entitlements = entitlements;198 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
206 if (no_bin) {200 if (no_bin) {
207 b.getInstallStep().dependOn(&exe.step);201 b.getInstallStep().dependOn(&exe.step);
208 } else {202 } else {
lib/compiler/build_runner.zig+13
...@@ -202,6 +202,15 @@ pub fn main() !void {...@@ -202,6 +202,15 @@ pub fn main() !void {
202 next_arg, @errorName(err),202 next_arg, @errorName(err),
203 });203 });
204 };204 };
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 };
205 } else if (mem.eql(u8, arg, "--debounce")) {214 } else if (mem.eql(u8, arg, "--debounce")) {
206 const next_arg = nextArg(args, &arg_idx) orelse215 const next_arg = nextArg(args, &arg_idx) orelse
207 fatalWithHint("expected u16 after '{s}'", .{arg});216 fatalWithHint("expected u16 after '{s}'", .{arg});
...@@ -1364,6 +1373,10 @@ fn usage(b: *std.Build, out_stream: anytype) !void {...@@ -1364,6 +1373,10 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
1364 \\ --zig-lib-dir [arg] Override path to Zig lib directory1373 \\ --zig-lib-dir [arg] Override path to Zig lib directory
1365 \\ --build-runner [file] Override path to build runner1374 \\ --build-runner [file] Override path to build runner
1366 \\ --seed [integer] For shuffling dependency traversal order (default: random)1375 \\ --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
1367 \\ --debug-log [scope] Enable debugging the compiler1380 \\ --debug-log [scope] Enable debugging the compiler
1368 \\ --debug-pkg-config Fail if unknown pkg-config flags encountered1381 \\ --debug-pkg-config Fail if unknown pkg-config flags encountered
1369 \\ --debug-rt Debug compiler runtime libraries1382 \\ --debug-rt Debug compiler runtime libraries
lib/std/Build.zig+2
...@@ -94,6 +94,8 @@ available_deps: AvailableDeps,...@@ -94,6 +94,8 @@ available_deps: AvailableDeps,
9494
95release_mode: ReleaseMode,95release_mode: ReleaseMode,
9696
97build_id: ?std.zig.BuildId = null,
98
97pub const ReleaseMode = enum {99pub const ReleaseMode = enum {
98 off,100 off,
99 any,101 any,
lib/std/Build/Step/Compile.zig+1-1
...@@ -1681,7 +1681,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {...@@ -1681,7 +1681,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
16811681
1682 try addFlag(&zig_args, "each-lib-rpath", compile.each_lib_rpath);1682 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| {
1685 try zig_args.append(switch (build_id) {1685 try zig_args.append(switch (build_id) {
1686 .hexstring => |hs| b.fmt("--build-id=0x{s}", .{1686 .hexstring => |hs| b.fmt("--build-id=0x{s}", .{
1687 std.fmt.fmtSliceHexLower(hs.toSlice()),1687 std.fmt.fmtSliceHexLower(hs.toSlice()),