Skip to content
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

add option to strip build regardless of optimization #3945

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ pub fn build(b: *std.Build) !void {
"Build a Position Independent Executable. Default true for system packages.",
) orelse system_package;

const strip = b.option(
bool,
"strip",
"Strip the final executable. Default true for fast and small releases",
) orelse switch (optimize) {
.Debug => false,
.ReleaseSafe => false,
.ReleaseFast, .ReleaseSmall => true,
};

const conformance = b.option(
[]const u8,
"conformance",
Expand Down Expand Up @@ -342,11 +352,7 @@ pub fn build(b: *std.Build) !void {
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = switch (optimize) {
.Debug => false,
.ReleaseSafe => false,
.ReleaseFast, .ReleaseSmall => true,
},
.strip = strip,
}) else null;

// Exe
Expand Down Expand Up @@ -684,6 +690,7 @@ pub fn build(b: *std.Build) !void {
.root_source_file = b.path("src/main_c.zig"),
.optimize = optimize,
.target = target,
.strip = strip,
});
_ = try addDeps(b, lib, config);

Expand All @@ -701,6 +708,7 @@ pub fn build(b: *std.Build) !void {
.root_source_file = b.path("src/main_c.zig"),
.optimize = optimize,
.target = target,
.strip = strip,
});
_ = try addDeps(b, lib, config);

Expand Down