Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
18 changes: 9 additions & 9 deletions lib/std/Build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/std/Build/Step/Compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/std/Build/Step/TranslateC.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
6 changes: 3 additions & 3 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5610,7 +5610,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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/link.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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});
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/src/Cases.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tools/docgen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down