Skip to content

Commit 0461a64

Browse files
authored
change uses of std.builtin.Mode to OptimizeMode (#16745)
std.builtin.Mode is deprecated.
1 parent 72c68f6 commit 0461a64

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

build.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,22 +400,22 @@ pub fn build(b: *std.Build) !void {
400400
test_cases_options.addOption(std.SemanticVersion, "semver", semver);
401401
test_cases_options.addOption(?[]const u8, "test_filter", test_filter);
402402

403-
var chosen_opt_modes_buf: [4]builtin.Mode = undefined;
403+
var chosen_opt_modes_buf: [4]builtin.OptimizeMode = undefined;
404404
var chosen_mode_index: usize = 0;
405405
if (!skip_debug) {
406-
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.Debug;
406+
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.Debug;
407407
chosen_mode_index += 1;
408408
}
409409
if (!skip_release_safe) {
410-
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseSafe;
410+
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSafe;
411411
chosen_mode_index += 1;
412412
}
413413
if (!skip_release_fast) {
414-
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseFast;
414+
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseFast;
415415
chosen_mode_index += 1;
416416
}
417417
if (!skip_release_small) {
418-
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseSmall;
418+
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;
419419
chosen_mode_index += 1;
420420
}
421421
const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];

lib/std/Build.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ pub const ExecutableOptions = struct {
475475
root_source_file: ?LazyPath = null,
476476
version: ?std.SemanticVersion = null,
477477
target: CrossTarget = .{},
478-
optimize: std.builtin.Mode = .Debug,
478+
optimize: std.builtin.OptimizeMode = .Debug,
479479
linkage: ?Step.Compile.Linkage = null,
480480
max_rss: usize = 0,
481481
link_libc: ?bool = null,
@@ -509,7 +509,7 @@ pub const ObjectOptions = struct {
509509
name: []const u8,
510510
root_source_file: ?LazyPath = null,
511511
target: CrossTarget,
512-
optimize: std.builtin.Mode,
512+
optimize: std.builtin.OptimizeMode,
513513
max_rss: usize = 0,
514514
link_libc: ?bool = null,
515515
single_threaded: ?bool = null,
@@ -541,7 +541,7 @@ pub const SharedLibraryOptions = struct {
541541
root_source_file: ?LazyPath = null,
542542
version: ?std.SemanticVersion = null,
543543
target: CrossTarget,
544-
optimize: std.builtin.Mode,
544+
optimize: std.builtin.OptimizeMode,
545545
max_rss: usize = 0,
546546
link_libc: ?bool = null,
547547
single_threaded: ?bool = null,
@@ -574,7 +574,7 @@ pub const StaticLibraryOptions = struct {
574574
name: []const u8,
575575
root_source_file: ?LazyPath = null,
576576
target: CrossTarget,
577-
optimize: std.builtin.Mode,
577+
optimize: std.builtin.OptimizeMode,
578578
version: ?std.SemanticVersion = null,
579579
max_rss: usize = 0,
580580
link_libc: ?bool = null,
@@ -608,7 +608,7 @@ pub const TestOptions = struct {
608608
name: []const u8 = "test",
609609
root_source_file: LazyPath,
610610
target: CrossTarget = .{},
611-
optimize: std.builtin.Mode = .Debug,
611+
optimize: std.builtin.OptimizeMode = .Debug,
612612
version: ?std.SemanticVersion = null,
613613
max_rss: usize = 0,
614614
filter: ?[]const u8 = null,
@@ -644,7 +644,7 @@ pub const AssemblyOptions = struct {
644644
name: []const u8,
645645
source_file: LazyPath,
646646
target: CrossTarget,
647-
optimize: std.builtin.Mode,
647+
optimize: std.builtin.OptimizeMode,
648648
max_rss: usize = 0,
649649
zig_lib_dir: ?LazyPath = null,
650650
};
@@ -1000,10 +1000,10 @@ pub fn step(self: *Build, name: []const u8, description: []const u8) *Step {
10001000
}
10011001

10021002
pub const StandardOptimizeOptionOptions = struct {
1003-
preferred_optimize_mode: ?std.builtin.Mode = null,
1003+
preferred_optimize_mode: ?std.builtin.OptimizeMode = null,
10041004
};
10051005

1006-
pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.Mode {
1006+
pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.OptimizeMode {
10071007
if (options.preferred_optimize_mode) |mode| {
10081008
if (self.option(bool, "release", "optimize for end users") orelse false) {
10091009
return mode;
@@ -1012,7 +1012,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio
10121012
}
10131013
} else {
10141014
return self.option(
1015-
std.builtin.Mode,
1015+
std.builtin.OptimizeMode,
10161016
"optimize",
10171017
"Prioritize performance, safety, or binary size (-O flag)",
10181018
) orelse .Debug;

lib/std/Build/Step/Compile.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ step: Step,
2727
name: []const u8,
2828
target: CrossTarget,
2929
target_info: NativeTargetInfo,
30-
optimize: std.builtin.Mode,
30+
optimize: std.builtin.OptimizeMode,
3131
linker_script: ?LazyPath = null,
3232
version_script: ?[]const u8 = null,
3333
out_filename: []const u8,
@@ -269,7 +269,7 @@ pub const Options = struct {
269269
name: []const u8,
270270
root_source_file: ?LazyPath = null,
271271
target: CrossTarget,
272-
optimize: std.builtin.Mode,
272+
optimize: std.builtin.OptimizeMode,
273273
kind: Kind,
274274
linkage: ?Linkage = null,
275275
version: ?std.SemanticVersion = null,

lib/std/Build/Step/TranslateC.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub const AddExecutableOptions = struct {
4949
name: ?[]const u8 = null,
5050
version: ?std.SemanticVersion = null,
5151
target: ?CrossTarget = null,
52-
optimize: ?std.builtin.Mode = null,
52+
optimize: ?std.builtin.OptimizeMode = null,
5353
linkage: ?Step.Compile.Linkage = null,
5454
};
5555

src/Compilation.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub const InitOptions = struct {
498498
/// this flag would be set to disable this machinery to avoid false positives.
499499
disable_lld_caching: bool = false,
500500
cache_mode: CacheMode = .incremental,
501-
optimize_mode: std.builtin.Mode = .Debug,
501+
optimize_mode: std.builtin.OptimizeMode = .Debug,
502502
keep_source_files_loaded: bool = false,
503503
clang_argv: []const []const u8 = &[0][]const u8{},
504504
lib_dirs: []const []const u8 = &[0][]const u8{},
@@ -5348,7 +5348,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
53485348
\\ .ofmt = object_format,
53495349
\\}};
53505350
\\pub const object_format = std.Target.ObjectFormat.{};
5351-
\\pub const mode = std.builtin.Mode.{};
5351+
\\pub const mode = std.builtin.OptimizeMode.{};
53525352
\\pub const link_libc = {};
53535353
\\pub const link_libcpp = {};
53545354
\\pub const have_error_return_tracing = {};
@@ -5631,7 +5631,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
56315631

56325632
/// This decides the optimization mode for all zig-provided libraries, including
56335633
/// compiler-rt, libcxx, libc, libunwind, etc.
5634-
pub fn compilerRtOptMode(comp: Compilation) std.builtin.Mode {
5634+
pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
56355635
if (comp.debug_compiler_runtime_libs) {
56365636
return comp.bin_file.options.optimize_mode;
56375637
}

src/Module.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5640,7 +5640,7 @@ pub fn getTarget(mod: Module) Target {
56405640
return mod.comp.bin_file.options.target;
56415641
}
56425642

5643-
pub fn optimizeMode(mod: Module) std.builtin.Mode {
5643+
pub fn optimizeMode(mod: Module) std.builtin.OptimizeMode {
56445644
return mod.comp.bin_file.options.optimize_mode;
56455645
}
56465646

src/link.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub const Options = struct {
102102
target: std.Target,
103103
output_mode: std.builtin.OutputMode,
104104
link_mode: std.builtin.LinkMode,
105-
optimize_mode: std.builtin.Mode,
105+
optimize_mode: std.builtin.OptimizeMode,
106106
machine_code_model: std.builtin.CodeModel,
107107
root_name: [:0]const u8,
108108
/// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.

src/main.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ fn buildOutputType(
765765
arg_mode: ArgMode,
766766
) !void {
767767
var color: Color = .auto;
768-
var optimize_mode: std.builtin.Mode = .Debug;
768+
var optimize_mode: std.builtin.OptimizeMode = .Debug;
769769
var provided_name: ?[]const u8 = null;
770770
var link_mode: ?std.builtin.LinkMode = null;
771771
var dll_export_fns: ?bool = null;
@@ -1595,7 +1595,7 @@ fn buildOutputType(
15951595
}
15961596
}
15971597
if (optimize_mode_string) |s| {
1598-
optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse
1598+
optimize_mode = std.meta.stringToEnum(std.builtin.OptimizeMode, s) orelse
15991599
fatal("unrecognized optimization mode: '{s}'", .{s});
16001600
}
16011601
},

src/target.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub fn hasDebugInfo(target: std.Target) bool {
441441
return true;
442442
}
443443

444-
pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {
444+
pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.OptimizeMode {
445445
if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) {
446446
return .ReleaseSmall;
447447
} else {

test/src/Cases.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub const Case = struct {
7474
/// In order to be able to run e.g. Execution updates, this must be set
7575
/// to Executable.
7676
output_mode: std.builtin.OutputMode,
77-
optimize_mode: std.builtin.Mode = .Debug,
77+
optimize_mode: std.builtin.OptimizeMode = .Debug,
7878
updates: std.ArrayList(Update),
7979
emit_bin: bool = true,
8080
emit_h: bool = false,

0 commit comments

Comments
 (0)