authorgravatar for zach@raineri.softwareZachary Raineri <zach@raineri.software> 2023-08-09 13:39:34-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-08-09 14:39:34-04:00
log0461a64a93f0596e98b62d596bb547e5455577d2
treebbf00bc95c15a411c4427e9fbf69d285404bc0d9
parent72c68f698ed2153f2a9e3b2c7166fa03bb03ae1a
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

change uses of std.builtin.Mode to OptimizeMode (#16745)

std.builtin.Mode is deprecated.

11 files changed, 28 insertions(+), 28 deletions(-)

build.zig+5-5
...@@ -400,22 +400,22 @@ pub fn build(b: *std.Build) !void {...@@ -400,22 +400,22 @@ pub fn build(b: *std.Build) !void {
400 test_cases_options.addOption(std.SemanticVersion, "semver", semver);400 test_cases_options.addOption(std.SemanticVersion, "semver", semver);
401 test_cases_options.addOption(?[]const u8, "test_filter", test_filter);401 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;
404 var chosen_mode_index: usize = 0;404 var chosen_mode_index: usize = 0;
405 if (!skip_debug) {405 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;
407 chosen_mode_index += 1;407 chosen_mode_index += 1;
408 }408 }
409 if (!skip_release_safe) {409 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;
411 chosen_mode_index += 1;411 chosen_mode_index += 1;
412 }412 }
413 if (!skip_release_fast) {413 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;
415 chosen_mode_index += 1;415 chosen_mode_index += 1;
416 }416 }
417 if (!skip_release_small) {417 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;
419 chosen_mode_index += 1;419 chosen_mode_index += 1;
420 }420 }
421 const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];421 const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
lib/std/Build.zig+9-9
...@@ -475,7 +475,7 @@ pub const ExecutableOptions = struct {...@@ -475,7 +475,7 @@ pub const ExecutableOptions = struct {
475 root_source_file: ?LazyPath = null,475 root_source_file: ?LazyPath = null,
476 version: ?std.SemanticVersion = null,476 version: ?std.SemanticVersion = null,
477 target: CrossTarget = .{},477 target: CrossTarget = .{},
478 optimize: std.builtin.Mode = .Debug,478 optimize: std.builtin.OptimizeMode = .Debug,
479 linkage: ?Step.Compile.Linkage = null,479 linkage: ?Step.Compile.Linkage = null,
480 max_rss: usize = 0,480 max_rss: usize = 0,
481 link_libc: ?bool = null,481 link_libc: ?bool = null,
...@@ -509,7 +509,7 @@ pub const ObjectOptions = struct {...@@ -509,7 +509,7 @@ pub const ObjectOptions = struct {
509 name: []const u8,509 name: []const u8,
510 root_source_file: ?LazyPath = null,510 root_source_file: ?LazyPath = null,
511 target: CrossTarget,511 target: CrossTarget,
512 optimize: std.builtin.Mode,512 optimize: std.builtin.OptimizeMode,
513 max_rss: usize = 0,513 max_rss: usize = 0,
514 link_libc: ?bool = null,514 link_libc: ?bool = null,
515 single_threaded: ?bool = null,515 single_threaded: ?bool = null,
...@@ -541,7 +541,7 @@ pub const SharedLibraryOptions = struct {...@@ -541,7 +541,7 @@ pub const SharedLibraryOptions = struct {
541 root_source_file: ?LazyPath = null,541 root_source_file: ?LazyPath = null,
542 version: ?std.SemanticVersion = null,542 version: ?std.SemanticVersion = null,
543 target: CrossTarget,543 target: CrossTarget,
544 optimize: std.builtin.Mode,544 optimize: std.builtin.OptimizeMode,
545 max_rss: usize = 0,545 max_rss: usize = 0,
546 link_libc: ?bool = null,546 link_libc: ?bool = null,
547 single_threaded: ?bool = null,547 single_threaded: ?bool = null,
...@@ -574,7 +574,7 @@ pub const StaticLibraryOptions = struct {...@@ -574,7 +574,7 @@ pub const StaticLibraryOptions = struct {
574 name: []const u8,574 name: []const u8,
575 root_source_file: ?LazyPath = null,575 root_source_file: ?LazyPath = null,
576 target: CrossTarget,576 target: CrossTarget,
577 optimize: std.builtin.Mode,577 optimize: std.builtin.OptimizeMode,
578 version: ?std.SemanticVersion = null,578 version: ?std.SemanticVersion = null,
579 max_rss: usize = 0,579 max_rss: usize = 0,
580 link_libc: ?bool = null,580 link_libc: ?bool = null,
...@@ -608,7 +608,7 @@ pub const TestOptions = struct {...@@ -608,7 +608,7 @@ pub const TestOptions = struct {
608 name: []const u8 = "test",608 name: []const u8 = "test",
609 root_source_file: LazyPath,609 root_source_file: LazyPath,
610 target: CrossTarget = .{},610 target: CrossTarget = .{},
611 optimize: std.builtin.Mode = .Debug,611 optimize: std.builtin.OptimizeMode = .Debug,
612 version: ?std.SemanticVersion = null,612 version: ?std.SemanticVersion = null,
613 max_rss: usize = 0,613 max_rss: usize = 0,
614 filter: ?[]const u8 = null,614 filter: ?[]const u8 = null,
...@@ -644,7 +644,7 @@ pub const AssemblyOptions = struct {...@@ -644,7 +644,7 @@ pub const AssemblyOptions = struct {
644 name: []const u8,644 name: []const u8,
645 source_file: LazyPath,645 source_file: LazyPath,
646 target: CrossTarget,646 target: CrossTarget,
647 optimize: std.builtin.Mode,647 optimize: std.builtin.OptimizeMode,
648 max_rss: usize = 0,648 max_rss: usize = 0,
649 zig_lib_dir: ?LazyPath = null,649 zig_lib_dir: ?LazyPath = null,
650};650};
...@@ -1000,10 +1000,10 @@ pub fn step(self: *Build, name: []const u8, description: []const u8) *Step {...@@ -1000,10 +1000,10 @@ pub fn step(self: *Build, name: []const u8, description: []const u8) *Step {
1000}1000}
10011001
1002pub const StandardOptimizeOptionOptions = struct {1002pub const StandardOptimizeOptionOptions = struct {
1003 preferred_optimize_mode: ?std.builtin.Mode = null,1003 preferred_optimize_mode: ?std.builtin.OptimizeMode = null,
1004};1004};
10051005
1006pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.Mode {1006pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.OptimizeMode {
1007 if (options.preferred_optimize_mode) |mode| {1007 if (options.preferred_optimize_mode) |mode| {
1008 if (self.option(bool, "release", "optimize for end users") orelse false) {1008 if (self.option(bool, "release", "optimize for end users") orelse false) {
1009 return mode;1009 return mode;
...@@ -1012,7 +1012,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio...@@ -1012,7 +1012,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio
1012 }1012 }
1013 } else {1013 } else {
1014 return self.option(1014 return self.option(
1015 std.builtin.Mode,1015 std.builtin.OptimizeMode,
1016 "optimize",1016 "optimize",
1017 "Prioritize performance, safety, or binary size (-O flag)",1017 "Prioritize performance, safety, or binary size (-O flag)",
1018 ) orelse .Debug;1018 ) orelse .Debug;
lib/std/Build/Step/Compile.zig+2-2
...@@ -27,7 +27,7 @@ step: Step,...@@ -27,7 +27,7 @@ step: Step,
27name: []const u8,27name: []const u8,
28target: CrossTarget,28target: CrossTarget,
29target_info: NativeTargetInfo,29target_info: NativeTargetInfo,
30optimize: std.builtin.Mode,30optimize: std.builtin.OptimizeMode,
31linker_script: ?LazyPath = null,31linker_script: ?LazyPath = null,
32version_script: ?[]const u8 = null,32version_script: ?[]const u8 = null,
33out_filename: []const u8,33out_filename: []const u8,
...@@ -269,7 +269,7 @@ pub const Options = struct {...@@ -269,7 +269,7 @@ pub const Options = struct {
269 name: []const u8,269 name: []const u8,
270 root_source_file: ?LazyPath = null,270 root_source_file: ?LazyPath = null,
271 target: CrossTarget,271 target: CrossTarget,
272 optimize: std.builtin.Mode,272 optimize: std.builtin.OptimizeMode,
273 kind: Kind,273 kind: Kind,
274 linkage: ?Linkage = null,274 linkage: ?Linkage = null,
275 version: ?std.SemanticVersion = null,275 version: ?std.SemanticVersion = null,
lib/std/Build/Step/TranslateC.zig+1-1
...@@ -49,7 +49,7 @@ pub const AddExecutableOptions = struct {...@@ -49,7 +49,7 @@ pub const AddExecutableOptions = struct {
49 name: ?[]const u8 = null,49 name: ?[]const u8 = null,
50 version: ?std.SemanticVersion = null,50 version: ?std.SemanticVersion = null,
51 target: ?CrossTarget = null,51 target: ?CrossTarget = null,
52 optimize: ?std.builtin.Mode = null,52 optimize: ?std.builtin.OptimizeMode = null,
53 linkage: ?Step.Compile.Linkage = null,53 linkage: ?Step.Compile.Linkage = null,
54};54};
5555
src/Compilation.zig+3-3
...@@ -498,7 +498,7 @@ pub const InitOptions = struct {...@@ -498,7 +498,7 @@ pub const InitOptions = struct {
498 /// this flag would be set to disable this machinery to avoid false positives.498 /// this flag would be set to disable this machinery to avoid false positives.
499 disable_lld_caching: bool = false,499 disable_lld_caching: bool = false,
500 cache_mode: CacheMode = .incremental,500 cache_mode: CacheMode = .incremental,
501 optimize_mode: std.builtin.Mode = .Debug,501 optimize_mode: std.builtin.OptimizeMode = .Debug,
502 keep_source_files_loaded: bool = false,502 keep_source_files_loaded: bool = false,
503 clang_argv: []const []const u8 = &[0][]const u8{},503 clang_argv: []const []const u8 = &[0][]const u8{},
504 lib_dirs: []const []const u8 = &[0][]const u8{},504 lib_dirs: []const []const u8 = &[0][]const u8{},
...@@ -5348,7 +5348,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca...@@ -5348,7 +5348,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
5348 \\ .ofmt = object_format,5348 \\ .ofmt = object_format,
5349 \\}};5349 \\}};
5350 \\pub const object_format = std.Target.ObjectFormat.{};5350 \\pub const object_format = std.Target.ObjectFormat.{};
5351 \\pub const mode = std.builtin.Mode.{};5351 \\pub const mode = std.builtin.OptimizeMode.{};
5352 \\pub const link_libc = {};5352 \\pub const link_libc = {};
5353 \\pub const link_libcpp = {};5353 \\pub const link_libcpp = {};
5354 \\pub const have_error_return_tracing = {};5354 \\pub const have_error_return_tracing = {};
...@@ -5631,7 +5631,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -5631,7 +5631,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
56315631
5632/// This decides the optimization mode for all zig-provided libraries, including5632/// This decides the optimization mode for all zig-provided libraries, including
5633/// compiler-rt, libcxx, libc, libunwind, etc.5633/// compiler-rt, libcxx, libc, libunwind, etc.
5634pub fn compilerRtOptMode(comp: Compilation) std.builtin.Mode {5634pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
5635 if (comp.debug_compiler_runtime_libs) {5635 if (comp.debug_compiler_runtime_libs) {
5636 return comp.bin_file.options.optimize_mode;5636 return comp.bin_file.options.optimize_mode;
5637 }5637 }
src/Module.zig+1-1
...@@ -5640,7 +5640,7 @@ pub fn getTarget(mod: Module) Target {...@@ -5640,7 +5640,7 @@ pub fn getTarget(mod: Module) Target {
5640 return mod.comp.bin_file.options.target;5640 return mod.comp.bin_file.options.target;
5641}5641}
56425642
5643pub fn optimizeMode(mod: Module) std.builtin.Mode {5643pub fn optimizeMode(mod: Module) std.builtin.OptimizeMode {
5644 return mod.comp.bin_file.options.optimize_mode;5644 return mod.comp.bin_file.options.optimize_mode;
5645}5645}
56465646
src/link.zig+1-1
...@@ -102,7 +102,7 @@ pub const Options = struct {...@@ -102,7 +102,7 @@ pub const Options = struct {
102 target: std.Target,102 target: std.Target,
103 output_mode: std.builtin.OutputMode,103 output_mode: std.builtin.OutputMode,
104 link_mode: std.builtin.LinkMode,104 link_mode: std.builtin.LinkMode,
105 optimize_mode: std.builtin.Mode,105 optimize_mode: std.builtin.OptimizeMode,
106 machine_code_model: std.builtin.CodeModel,106 machine_code_model: std.builtin.CodeModel,
107 root_name: [:0]const u8,107 root_name: [:0]const u8,
108 /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.108 /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.
src/main.zig+2-2
...@@ -765,7 +765,7 @@ fn buildOutputType(...@@ -765,7 +765,7 @@ fn buildOutputType(
765 arg_mode: ArgMode,765 arg_mode: ArgMode,
766) !void {766) !void {
767 var color: Color = .auto;767 var color: Color = .auto;
768 var optimize_mode: std.builtin.Mode = .Debug;768 var optimize_mode: std.builtin.OptimizeMode = .Debug;
769 var provided_name: ?[]const u8 = null;769 var provided_name: ?[]const u8 = null;
770 var link_mode: ?std.builtin.LinkMode = null;770 var link_mode: ?std.builtin.LinkMode = null;
771 var dll_export_fns: ?bool = null;771 var dll_export_fns: ?bool = null;
...@@ -1595,7 +1595,7 @@ fn buildOutputType(...@@ -1595,7 +1595,7 @@ fn buildOutputType(
1595 }1595 }
1596 }1596 }
1597 if (optimize_mode_string) |s| {1597 if (optimize_mode_string) |s| {
1598 optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse1598 optimize_mode = std.meta.stringToEnum(std.builtin.OptimizeMode, s) orelse
1599 fatal("unrecognized optimization mode: '{s}'", .{s});1599 fatal("unrecognized optimization mode: '{s}'", .{s});
1600 }1600 }
1601 },1601 },
src/target.zig+1-1
...@@ -441,7 +441,7 @@ pub fn hasDebugInfo(target: std.Target) bool {...@@ -441,7 +441,7 @@ pub fn hasDebugInfo(target: std.Target) bool {
441 return true;441 return true;
442}442}
443443
444pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {444pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.OptimizeMode {
445 if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) {445 if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) {
446 return .ReleaseSmall;446 return .ReleaseSmall;
447 } else {447 } else {
test/src/Cases.zig+1-1
...@@ -74,7 +74,7 @@ pub const Case = struct {...@@ -74,7 +74,7 @@ pub const Case = struct {
74 /// In order to be able to run e.g. Execution updates, this must be set74 /// In order to be able to run e.g. Execution updates, this must be set
75 /// to Executable.75 /// to Executable.
76 output_mode: std.builtin.OutputMode,76 output_mode: std.builtin.OutputMode,
77 optimize_mode: std.builtin.Mode = .Debug,77 optimize_mode: std.builtin.OptimizeMode = .Debug,
78 updates: std.ArrayList(Update),78 updates: std.ArrayList(Update),
79 emit_bin: bool = true,79 emit_bin: bool = true,
80 emit_h: bool = false,80 emit_h: bool = false,
tools/docgen.zig+2-2
...@@ -323,7 +323,7 @@ const Code = struct {...@@ -323,7 +323,7 @@ const Code = struct {
323 name: []const u8,323 name: []const u8,
324 source_token: Token,324 source_token: Token,
325 just_check_syntax: bool,325 just_check_syntax: bool,
326 mode: std.builtin.Mode,326 mode: std.builtin.OptimizeMode,
327 link_objects: []const []const u8,327 link_objects: []const []const u8,
328 target_str: ?[]const u8,328 target_str: ?[]const u8,
329 link_libc: bool,329 link_libc: bool,
...@@ -589,7 +589,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {...@@ -589,7 +589,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
589 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});589 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});
590 }590 }
591591
592 var mode: std.builtin.Mode = .Debug;592 var mode: std.builtin.OptimizeMode = .Debug;
593 var link_objects = std.ArrayList([]const u8).init(allocator);593 var link_objects = std.ArrayList([]const u8).init(allocator);
594 defer link_objects.deinit();594 defer link_objects.deinit();
595 var target_str: ?[]const u8 = null;595 var target_str: ?[]const u8 = null;