From 25e9d22807dca495bb4bc66391d09a2431fb796f Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Thu, 28 May 2026 14:10:25 -0700 Subject: [PATCH] Fixes the optimization mode passed to translate C --- lib/compiler/Maker/Step/TranslateC.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/compiler/Maker/Step/TranslateC.zig b/lib/compiler/Maker/Step/TranslateC.zig index 4d7df09fe6e0090c24da0c005ec4669c51768510..d9bbd6ad4cb2b20deaf3da3f74cc56409a491598 100644 --- a/lib/compiler/Maker/Step/TranslateC.zig +++ b/lib/compiler/Maker/Step/TranslateC.zig @@ -5,6 +5,7 @@ const Io = std.Io; const Configuration = std.Build.Configuration; const allocPrint = std.fmt.allocPrint; const assert = std.debug.assert; +const OptimizeMode = std.lang.OptimizeMode; const Step = @import("../Step.zig"); const Maker = @import("../../Maker.zig"); @@ -47,10 +48,13 @@ pub fn make( } } - switch (conf_tc.flags.optimize) { - .debug, .default => {}, // Skip since it's the default. - else => argv.appendAssumeCapacity(try allocPrint(arena, "-O{t}", .{conf_tc.flags.optimize})), - } + const opt: ?OptimizeMode = switch (conf_tc.flags.optimize) { + .debug, .default => null, // Skip since it's the default + .safe => .ReleaseSafe, + .fast => .ReleaseFast, + .small => .ReleaseSmall, + }; + if (opt) |o| argv.appendAssumeCapacity(try allocPrint(arena, "-O{t}", .{o})); try argv.ensureUnusedCapacity(arena, conf_tc.include_dirs.len * 2); for (0..conf_tc.include_dirs.len) |i| -- 2.54.0