mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
zig build: change "-Drelease" to "-Doptimize"
I find myself quite often creating ReleaseSafe builds and putting them to production for certain experiments: - Debug info are for stack traces. An ongoing example where those would help is #14815. - Safety checks would have saved a couple of mine and @kubkon's hours in #15098. This is a breaking change for scripts that make Zig releases -- I will submit another PR to zig-bootstrap and release-cutter after this is merged.
This commit is contained in:
parent
7fad555e5e
commit
7abc3738a2
5 changed files with 9 additions and 10 deletions
|
|
@ -813,9 +813,9 @@ endif()
|
||||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||||
set(ZIG_RELEASE_ARG "")
|
set(ZIG_RELEASE_ARG "")
|
||||||
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||||
set(ZIG_RELEASE_ARG -Drelease)
|
set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast)
|
||||||
else()
|
else()
|
||||||
set(ZIG_RELEASE_ARG -Drelease -Dstrip)
|
set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast -Dstrip)
|
||||||
endif()
|
endif()
|
||||||
if(ZIG_NO_LIB)
|
if(ZIG_NO_LIB)
|
||||||
set(ZIG_NO_LIB_ARG "-Dno-lib")
|
set(ZIG_NO_LIB_ARG "-Dno-lib")
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ const zig_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };
|
||||||
const stack_size = 32 * 1024 * 1024;
|
const stack_size = 32 * 1024 * 1024;
|
||||||
|
|
||||||
pub fn build(b: *std.Build) !void {
|
pub fn build(b: *std.Build) !void {
|
||||||
const release = b.option(bool, "release", "Build in release mode") orelse false;
|
|
||||||
const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;
|
const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;
|
||||||
const target = t: {
|
const target = t: {
|
||||||
var default_target: std.zig.CrossTarget = .{};
|
var default_target: std.zig.CrossTarget = .{};
|
||||||
|
|
@ -22,10 +21,10 @@ pub fn build(b: *std.Build) !void {
|
||||||
}
|
}
|
||||||
break :t b.standardTargetOptions(.{ .default_target = default_target });
|
break :t b.standardTargetOptions(.{ .default_target = default_target });
|
||||||
};
|
};
|
||||||
const optimize: std.builtin.OptimizeMode = if (release) switch (target.getCpuArch()) {
|
|
||||||
.wasm32 => .ReleaseSmall,
|
// TODO remove type annotation with ziglang/zig#13749
|
||||||
else => .ReleaseFast,
|
const optimize: std.builtin.Mode = b.option(std.builtin.Mode, "optimize", "Prioritize performance, safety, or binary size (-O flag)") orelse
|
||||||
} else .Debug;
|
if (target.getCpuArch() == .wasm32) .ReleaseSmall else .Debug;
|
||||||
|
|
||||||
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
|
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
|
||||||
const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
|
const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ stage3-release/bin/zig build \
|
||||||
--prefix stage4-release \
|
--prefix stage4-release \
|
||||||
-Denable-llvm \
|
-Denable-llvm \
|
||||||
-Dno-lib \
|
-Dno-lib \
|
||||||
-Drelease \
|
-Doptimize=ReleaseFast \
|
||||||
-Dstrip \
|
-Dstrip \
|
||||||
-Dtarget=$TARGET \
|
-Dtarget=$TARGET \
|
||||||
-Duse-zig-libcxx \
|
-Duse-zig-libcxx \
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ stage3-release/bin/zig build \
|
||||||
--prefix stage4-release \
|
--prefix stage4-release \
|
||||||
-Denable-llvm \
|
-Denable-llvm \
|
||||||
-Dno-lib \
|
-Dno-lib \
|
||||||
-Drelease \
|
-Doptimize=ReleaseFast \
|
||||||
-Dstrip \
|
-Dstrip \
|
||||||
-Dtarget=$TARGET \
|
-Dtarget=$TARGET \
|
||||||
-Duse-zig-libcxx \
|
-Duse-zig-libcxx \
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ stage3/bin/zig build \
|
||||||
--prefix stage4 \
|
--prefix stage4 \
|
||||||
-Denable-llvm \
|
-Denable-llvm \
|
||||||
-Dno-lib \
|
-Dno-lib \
|
||||||
-Drelease \
|
-Doptimize=ReleaseFast \
|
||||||
-Dstrip \
|
-Dstrip \
|
||||||
-Dtarget=$TARGET \
|
-Dtarget=$TARGET \
|
||||||
-Duse-zig-libcxx \
|
-Duse-zig-libcxx \
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue