mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
change uses of std.builtin.Mode to OptimizeMode (#16745)
std.builtin.Mode is deprecated.
This commit is contained in:
parent
72c68f698e
commit
0461a64a93
11 changed files with 28 additions and 28 deletions
10
build.zig
10
build.zig
|
|
@ -400,22 +400,22 @@ pub fn build(b: *std.Build) !void {
|
|||
test_cases_options.addOption(std.SemanticVersion, "semver", semver);
|
||||
test_cases_options.addOption(?[]const u8, "test_filter", test_filter);
|
||||
|
||||
var chosen_opt_modes_buf: [4]builtin.Mode = undefined;
|
||||
var chosen_opt_modes_buf: [4]builtin.OptimizeMode = undefined;
|
||||
var chosen_mode_index: usize = 0;
|
||||
if (!skip_debug) {
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.Debug;
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.Debug;
|
||||
chosen_mode_index += 1;
|
||||
}
|
||||
if (!skip_release_safe) {
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseSafe;
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSafe;
|
||||
chosen_mode_index += 1;
|
||||
}
|
||||
if (!skip_release_fast) {
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseFast;
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseFast;
|
||||
chosen_mode_index += 1;
|
||||
}
|
||||
if (!skip_release_small) {
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.Mode.ReleaseSmall;
|
||||
chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;
|
||||
chosen_mode_index += 1;
|
||||
}
|
||||
const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ pub const ExecutableOptions = struct {
|
|||
root_source_file: ?LazyPath = null,
|
||||
version: ?std.SemanticVersion = null,
|
||||
target: CrossTarget = .{},
|
||||
optimize: std.builtin.Mode = .Debug,
|
||||
optimize: std.builtin.OptimizeMode = .Debug,
|
||||
linkage: ?Step.Compile.Linkage = null,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
|
|
@ -509,7 +509,7 @@ pub const ObjectOptions = struct {
|
|||
name: []const u8,
|
||||
root_source_file: ?LazyPath = null,
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
|
|
@ -541,7 +541,7 @@ pub const SharedLibraryOptions = struct {
|
|||
root_source_file: ?LazyPath = null,
|
||||
version: ?std.SemanticVersion = null,
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
|
|
@ -574,7 +574,7 @@ pub const StaticLibraryOptions = struct {
|
|||
name: []const u8,
|
||||
root_source_file: ?LazyPath = null,
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
version: ?std.SemanticVersion = null,
|
||||
max_rss: usize = 0,
|
||||
link_libc: ?bool = null,
|
||||
|
|
@ -608,7 +608,7 @@ pub const TestOptions = struct {
|
|||
name: []const u8 = "test",
|
||||
root_source_file: LazyPath,
|
||||
target: CrossTarget = .{},
|
||||
optimize: std.builtin.Mode = .Debug,
|
||||
optimize: std.builtin.OptimizeMode = .Debug,
|
||||
version: ?std.SemanticVersion = null,
|
||||
max_rss: usize = 0,
|
||||
filter: ?[]const u8 = null,
|
||||
|
|
@ -644,7 +644,7 @@ pub const AssemblyOptions = struct {
|
|||
name: []const u8,
|
||||
source_file: LazyPath,
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
max_rss: usize = 0,
|
||||
zig_lib_dir: ?LazyPath = null,
|
||||
};
|
||||
|
|
@ -1000,10 +1000,10 @@ pub fn step(self: *Build, name: []const u8, description: []const u8) *Step {
|
|||
}
|
||||
|
||||
pub const StandardOptimizeOptionOptions = struct {
|
||||
preferred_optimize_mode: ?std.builtin.Mode = null,
|
||||
preferred_optimize_mode: ?std.builtin.OptimizeMode = null,
|
||||
};
|
||||
|
||||
pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.Mode {
|
||||
pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptions) std.builtin.OptimizeMode {
|
||||
if (options.preferred_optimize_mode) |mode| {
|
||||
if (self.option(bool, "release", "optimize for end users") orelse false) {
|
||||
return mode;
|
||||
|
|
@ -1012,7 +1012,7 @@ pub fn standardOptimizeOption(self: *Build, options: StandardOptimizeOptionOptio
|
|||
}
|
||||
} else {
|
||||
return self.option(
|
||||
std.builtin.Mode,
|
||||
std.builtin.OptimizeMode,
|
||||
"optimize",
|
||||
"Prioritize performance, safety, or binary size (-O flag)",
|
||||
) orelse .Debug;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ step: Step,
|
|||
name: []const u8,
|
||||
target: CrossTarget,
|
||||
target_info: NativeTargetInfo,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
linker_script: ?LazyPath = null,
|
||||
version_script: ?[]const u8 = null,
|
||||
out_filename: []const u8,
|
||||
|
|
@ -269,7 +269,7 @@ pub const Options = struct {
|
|||
name: []const u8,
|
||||
root_source_file: ?LazyPath = null,
|
||||
target: CrossTarget,
|
||||
optimize: std.builtin.Mode,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
kind: Kind,
|
||||
linkage: ?Linkage = null,
|
||||
version: ?std.SemanticVersion = null,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pub const AddExecutableOptions = struct {
|
|||
name: ?[]const u8 = null,
|
||||
version: ?std.SemanticVersion = null,
|
||||
target: ?CrossTarget = null,
|
||||
optimize: ?std.builtin.Mode = null,
|
||||
optimize: ?std.builtin.OptimizeMode = null,
|
||||
linkage: ?Step.Compile.Linkage = null,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ pub const InitOptions = struct {
|
|||
/// this flag would be set to disable this machinery to avoid false positives.
|
||||
disable_lld_caching: bool = false,
|
||||
cache_mode: CacheMode = .incremental,
|
||||
optimize_mode: std.builtin.Mode = .Debug,
|
||||
optimize_mode: std.builtin.OptimizeMode = .Debug,
|
||||
keep_source_files_loaded: bool = false,
|
||||
clang_argv: []const []const u8 = &[0][]const u8{},
|
||||
lib_dirs: []const []const u8 = &[0][]const u8{},
|
||||
|
|
@ -5348,7 +5348,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: Allocator) Alloca
|
|||
\\ .ofmt = object_format,
|
||||
\\}};
|
||||
\\pub const object_format = std.Target.ObjectFormat.{};
|
||||
\\pub const mode = std.builtin.Mode.{};
|
||||
\\pub const mode = std.builtin.OptimizeMode.{};
|
||||
\\pub const link_libc = {};
|
||||
\\pub const link_libcpp = {};
|
||||
\\pub const have_error_return_tracing = {};
|
||||
|
|
@ -5631,7 +5631,7 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
|
|||
|
||||
/// This decides the optimization mode for all zig-provided libraries, including
|
||||
/// compiler-rt, libcxx, libc, libunwind, etc.
|
||||
pub fn compilerRtOptMode(comp: Compilation) std.builtin.Mode {
|
||||
pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
|
||||
if (comp.debug_compiler_runtime_libs) {
|
||||
return comp.bin_file.options.optimize_mode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5640,7 +5640,7 @@ pub fn getTarget(mod: Module) Target {
|
|||
return mod.comp.bin_file.options.target;
|
||||
}
|
||||
|
||||
pub fn optimizeMode(mod: Module) std.builtin.Mode {
|
||||
pub fn optimizeMode(mod: Module) std.builtin.OptimizeMode {
|
||||
return mod.comp.bin_file.options.optimize_mode;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ pub const Options = struct {
|
|||
target: std.Target,
|
||||
output_mode: std.builtin.OutputMode,
|
||||
link_mode: std.builtin.LinkMode,
|
||||
optimize_mode: std.builtin.Mode,
|
||||
optimize_mode: std.builtin.OptimizeMode,
|
||||
machine_code_model: std.builtin.CodeModel,
|
||||
root_name: [:0]const u8,
|
||||
/// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`.
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@ fn buildOutputType(
|
|||
arg_mode: ArgMode,
|
||||
) !void {
|
||||
var color: Color = .auto;
|
||||
var optimize_mode: std.builtin.Mode = .Debug;
|
||||
var optimize_mode: std.builtin.OptimizeMode = .Debug;
|
||||
var provided_name: ?[]const u8 = null;
|
||||
var link_mode: ?std.builtin.LinkMode = null;
|
||||
var dll_export_fns: ?bool = null;
|
||||
|
|
@ -1595,7 +1595,7 @@ fn buildOutputType(
|
|||
}
|
||||
}
|
||||
if (optimize_mode_string) |s| {
|
||||
optimize_mode = std.meta.stringToEnum(std.builtin.Mode, s) orelse
|
||||
optimize_mode = std.meta.stringToEnum(std.builtin.OptimizeMode, s) orelse
|
||||
fatal("unrecognized optimization mode: '{s}'", .{s});
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ pub fn hasDebugInfo(target: std.Target) bool {
|
|||
return true;
|
||||
}
|
||||
|
||||
pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {
|
||||
pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.OptimizeMode {
|
||||
if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) {
|
||||
return .ReleaseSmall;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ pub const Case = struct {
|
|||
/// In order to be able to run e.g. Execution updates, this must be set
|
||||
/// to Executable.
|
||||
output_mode: std.builtin.OutputMode,
|
||||
optimize_mode: std.builtin.Mode = .Debug,
|
||||
optimize_mode: std.builtin.OptimizeMode = .Debug,
|
||||
updates: std.ArrayList(Update),
|
||||
emit_bin: bool = true,
|
||||
emit_h: bool = false,
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ const Code = struct {
|
|||
name: []const u8,
|
||||
source_token: Token,
|
||||
just_check_syntax: bool,
|
||||
mode: std.builtin.Mode,
|
||||
mode: std.builtin.OptimizeMode,
|
||||
link_objects: []const []const u8,
|
||||
target_str: ?[]const u8,
|
||||
link_libc: bool,
|
||||
|
|
@ -589,7 +589,7 @@ fn genToc(allocator: Allocator, tokenizer: *Tokenizer) !Toc {
|
|||
return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str});
|
||||
}
|
||||
|
||||
var mode: std.builtin.Mode = .Debug;
|
||||
var mode: std.builtin.OptimizeMode = .Debug;
|
||||
var link_objects = std.ArrayList([]const u8).init(allocator);
|
||||
defer link_objects.deinit();
|
||||
var target_str: ?[]const u8 = null;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue