| author | |
| committer | |
| log | 4e700fdf8ed01e7fc856e631ceffd6006e6f48df |
| tree | 98a476316d9427be65779edaf6c27468f0e12ccc |
| parent | 65bd8d52c8260ad8b5d37285b1d29c1516676c01 |
| parent | 1a5dcff8e440fab2d7e9bdefe646ba3943fc122a |
| signature |
std.Build: add build-id option5 files changed, 26 insertions(+), 11 deletions(-)
build.zig-6| ... | ... | @@ -197,12 +197,6 @@ pub fn build(b: *std.Build) !void { |
| 197 | 197 | exe.pie = pie; |
| 198 | 198 | exe.entitlements = entitlements; |
| 199 | 199 | |
| 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 | 200 | if (no_bin) { |
| 207 | 201 | b.getInstallStep().dependOn(&exe.step); |
| 208 | 202 | } else { |
lib/compiler/build_runner.zig+16| ... | ... | @@ -202,6 +202,15 @@ pub fn main() !void { |
| 202 | 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 | 214 | } else if (mem.eql(u8, arg, "--debounce")) { |
| 206 | 215 | const next_arg = nextArg(args, &arg_idx) orelse |
| 207 | 216 | fatalWithHint("expected u16 after '{s}'", .{arg}); |
| ... | ... | @@ -1366,6 +1375,13 @@ fn usage(b: *std.Build, out_stream: anytype) !void { |
| 1366 | 1375 | \\ --zig-lib-dir [arg] Override path to Zig lib directory |
| 1367 | 1376 | \\ --build-runner [file] Override path to build runner |
| 1368 | 1377 | \\ --seed [integer] For shuffling dependency traversal order (default: random) |
| 1378 | \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries | |
| 1379 | \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) | |
| 1380 | \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) | |
| 1381 | \\ md5 16-byte cryptographic hash (ELF) | |
| 1382 | \\ uuid 16-byte random UUID (ELF, WASM) | |
| 1383 | \\ 0x[hexstring] Constant ID, maximum 32 bytes (ELF, WASM) | |
| 1384 | \\ none (default) No build ID | |
| 1369 | 1385 | \\ --debug-log [scope] Enable debugging the compiler |
| 1370 | 1386 | \\ --debug-pkg-config Fail if unknown pkg-config flags encountered |
| 1371 | 1387 | \\ --debug-rt Debug compiler runtime libraries |
lib/std/Build.zig+2| ... | ... | @@ -94,6 +94,8 @@ available_deps: AvailableDeps, |
| 94 | 94 | |
| 95 | 95 | release_mode: ReleaseMode, |
| 96 | 96 | |
| 97 | build_id: ?std.zig.BuildId = null, | |
| 98 | ||
| 97 | 99 | pub const ReleaseMode = enum { |
| 98 | 100 | off, |
| 99 | 101 | any, |
lib/std/Build/Step/Compile.zig+1-1| ... | ... | @@ -1694,7 +1694,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1694 | 1694 | |
| 1695 | 1695 | try addFlag(&zig_args, "each-lib-rpath", compile.each_lib_rpath); |
| 1696 | 1696 | |
| 1697 | if (compile.build_id) |build_id| { | |
| 1697 | if (compile.build_id orelse b.build_id) |build_id| { | |
| 1698 | 1698 | try zig_args.append(switch (build_id) { |
| 1699 | 1699 | .hexstring => |hs| b.fmt("--build-id=0x{s}", .{ |
| 1700 | 1700 | std.fmt.fmtSliceHexLower(hs.toSlice()), |
src/main.zig+7-4| ... | ... | @@ -580,10 +580,13 @@ const usage_build_generic = |
| 580 | 580 | \\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries |
| 581 | 581 | \\ -fallow-so-scripts Allows .so files to be GNU ld scripts |
| 582 | 582 | \\ -fno-allow-so-scripts (default) .so files must be ELF files |
| 583 | \\ --build-id[=style] At a minor link-time expense, coordinates stripped binaries | |
| 584 | \\ fast, uuid, sha1, md5 with debug symbols via a '.note.gnu.build-id' section | |
| 585 | \\ 0x[hexstring] Maximum 32 bytes | |
| 586 | \\ none (default) Disable build-id | |
| 583 | \\ --build-id[=style] At a minor link-time expense, embeds a build ID in binaries | |
| 584 | \\ fast 8-byte non-cryptographic hash (COFF, ELF, WASM) | |
| 585 | \\ sha1, tree 20-byte cryptographic hash (ELF, WASM) | |
| 586 | \\ md5 16-byte cryptographic hash (ELF) | |
| 587 | \\ uuid 16-byte random UUID (ELF, WASM) | |
| 588 | \\ 0x[hexstring] Constant ID, maximum 32 bytes (ELF, WASM) | |
| 589 | \\ none (default) No build ID | |
| 587 | 590 | \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker |
| 588 | 591 | \\ --no-eh-frame-hdr Disable C++ exception handling by passing --no-eh-frame-hdr to linker |
| 589 | 592 | \\ --emit-relocs Enable output of relocation sections for post build tools |