authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2023-04-06 10:32:05+03:00
committergravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2023-04-16 23:55:51+03:00
log7abc3738a2f0e024bee12e2046054a62fb8aa3e0
tree9a8af11e11e1ba2d31b56239faa23111c07fe171
parent7fad555e5e16e6cb71554981394387a0622093b0

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.

5 files changed, 9 insertions(+), 10 deletions(-)

CMakeLists.txt+2-2
...@@ -813,9 +813,9 @@ endif()...@@ -813,9 +813,9 @@ endif()
813if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")813if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
814 set(ZIG_RELEASE_ARG "")814 set(ZIG_RELEASE_ARG "")
815elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")815elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
816 set(ZIG_RELEASE_ARG -Drelease)816 set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast)
817else()817else()
818 set(ZIG_RELEASE_ARG -Drelease -Dstrip)818 set(ZIG_RELEASE_ARG -Doptimize=ReleaseFast -Dstrip)
819endif()819endif()
820if(ZIG_NO_LIB)820if(ZIG_NO_LIB)
821 set(ZIG_NO_LIB_ARG "-Dno-lib")821 set(ZIG_NO_LIB_ARG "-Dno-lib")
build.zig+4-5
...@@ -13,7 +13,6 @@ const zig_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };...@@ -13,7 +13,6 @@ const zig_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };
13const stack_size = 32 * 1024 * 1024;13const stack_size = 32 * 1024 * 1024;
1414
15pub fn build(b: *std.Build) !void {15pub fn build(b: *std.Build) !void {
16 const release = b.option(bool, "release", "Build in release mode") orelse false;
17 const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;16 const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;
18 const target = t: {17 const target = t: {
19 var default_target: std.zig.CrossTarget = .{};18 var default_target: std.zig.CrossTarget = .{};
...@@ -22,10 +21,10 @@ pub fn build(b: *std.Build) !void {...@@ -22,10 +21,10 @@ pub fn build(b: *std.Build) !void {
22 }21 }
23 break :t b.standardTargetOptions(.{ .default_target = default_target });22 break :t b.standardTargetOptions(.{ .default_target = default_target });
24 };23 };
25 const optimize: std.builtin.OptimizeMode = if (release) switch (target.getCpuArch()) {24
26 .wasm32 => .ReleaseSmall,25 // TODO remove type annotation with ziglang/zig#13749
27 else => .ReleaseFast,26 const optimize: std.builtin.Mode = b.option(std.builtin.Mode, "optimize", "Prioritize performance, safety, or binary size (-O flag)") orelse
28 } else .Debug;27 if (target.getCpuArch() == .wasm32) .ReleaseSmall else .Debug;
2928
30 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");29 const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
31 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;30 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;
ci/aarch64-macos.sh+1-1
...@@ -58,7 +58,7 @@ stage3-release/bin/zig build \...@@ -58,7 +58,7 @@ stage3-release/bin/zig build \
58 --prefix stage4-release \58 --prefix stage4-release \
59 -Denable-llvm \59 -Denable-llvm \
60 -Dno-lib \60 -Dno-lib \
61 -Drelease \61 -Doptimize=ReleaseFast \
62 -Dstrip \62 -Dstrip \
63 -Dtarget=$TARGET \63 -Dtarget=$TARGET \
64 -Duse-zig-libcxx \64 -Duse-zig-libcxx \
ci/x86_64-linux-release.sh+1-1
...@@ -77,7 +77,7 @@ stage3-release/bin/zig build \...@@ -77,7 +77,7 @@ stage3-release/bin/zig build \
77 --prefix stage4-release \77 --prefix stage4-release \
78 -Denable-llvm \78 -Denable-llvm \
79 -Dno-lib \79 -Dno-lib \
80 -Drelease \80 -Doptimize=ReleaseFast \
81 -Dstrip \81 -Dstrip \
82 -Dtarget=$TARGET \82 -Dtarget=$TARGET \
83 -Duse-zig-libcxx \83 -Duse-zig-libcxx \
ci/x86_64-macos-release.sh+1-1
...@@ -61,7 +61,7 @@ stage3/bin/zig build \...@@ -61,7 +61,7 @@ stage3/bin/zig build \
61 --prefix stage4 \61 --prefix stage4 \
62 -Denable-llvm \62 -Denable-llvm \
63 -Dno-lib \63 -Dno-lib \
64 -Drelease \64 -Doptimize=ReleaseFast \
65 -Dstrip \65 -Dstrip \
66 -Dtarget=$TARGET \66 -Dtarget=$TARGET \
67 -Duse-zig-libcxx \67 -Duse-zig-libcxx \