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 {
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+9-9
......@@ -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
10021002pub const StandardOptimizeOptionOptions = struct {
1003 preferred_optimize_mode: ?std.builtin.Mode = null,
1003 preferred_optimize_mode: ?std.builtin.OptimizeMode = null,
10041004};
10051005
1006pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.Mode {
1006pub 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+2-2
......@@ -27,7 +27,7 @@ step: Step,
2727name: []const u8,
2828target: CrossTarget,
2929target_info: NativeTargetInfo,
30optimize: std.builtin.Mode,
30optimize: std.builtin.OptimizeMode,
3131linker_script: ?LazyPath = null,
3232version_script: ?[]const u8 = null,
3333out_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+1-1
......@@ -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+3-3
......@@ -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.
5634pub fn compilerRtOptMode(comp: Compilation) std.builtin.Mode {
5634pub 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+1-1
......@@ -5640,7 +5640,7 @@ pub fn getTarget(mod: Module) Target {
56405640 return mod.comp.bin_file.options.target;
56415641}
56425642
5643pub fn optimizeMode(mod: Module) std.builtin.Mode {
5643pub fn optimizeMode(mod: Module) std.builtin.OptimizeMode {
56445644 return mod.comp.bin_file.options.optimize_mode;
56455645}
56465646
src/link.zig+1-1
......@@ -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+2-2
......@@ -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+1-1
......@@ -441,7 +441,7 @@ pub fn hasDebugInfo(target: std.Target) bool {
441441 return true;
442442}
443443
444pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {
444pub 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+1-1
......@@ -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,
tools/docgen.zig+2-2
......@@ -323,7 +323,7 @@ const Code = struct {
323323 name: []const u8,
324324 source_token: Token,
325325 just_check_syntax: bool,
326 mode: std.builtin.Mode,
326 mode: std.builtin.OptimizeMode,
327327 link_objects: []const []const u8,
328328 target_str: ?[]const u8,
329329 link_libc: bool,
......@@ -589,7 +589,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
589589 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});
590590 }
591591
592 var mode: std.builtin.Mode = .Debug;
592 var mode: std.builtin.OptimizeMode = .Debug;
593593 var link_objects = std.ArrayList([]const u8).init(allocator);
594594 defer link_objects.deinit();
595595 var target_str: ?[]const u8 = null;