From ae4e835a662a3b8c512511b87f4a44065e26dbb7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 19 Jul 2026 17:22:10 -0700 Subject: [PATCH 1/2] std.lang: rename OptimizeMode to Optimize and remove "release" from the enum tag names. no functional change, however, despite the addition of backwards-compatibile declarations in this patch, it is breaking because expressions that use `==` or `!=` operators will not able to use the deprecated names. I predict these names to survive until the 1.0 tag without any more breakage. --- build.zig | 16 ++--- lib/c/malloc.zig | 4 +- lib/compiler/Maker.zig | 6 +- lib/compiler/Maker/Step/TranslateC.zig | 6 +- lib/compiler/Maker/WebServer.zig | 2 +- lib/compiler/aro/aro/Diagnostics.zig | 2 +- lib/compiler/aro/main.zig | 2 +- lib/compiler/std-docs.zig | 4 +- lib/compiler/translate-c/main.zig | 2 +- lib/compiler_rt/memcpy.zig | 2 +- lib/compiler_rt/memmove.zig | 2 +- lib/docs/wasm/markdown/Document.zig | 2 +- lib/fuzzer.zig | 6 +- lib/std/Build.zig | 60 ++++++++++++------- lib/std/Build/Configuration.zig | 8 +-- lib/std/Build/Step/Compile.zig | 4 +- lib/std/Io/Dispatch.zig | 2 +- lib/std/Io/Threaded.zig | 12 ++-- lib/std/Io/Uring.zig | 2 +- lib/std/Random/benchmark.zig | 2 +- lib/std/c/darwin/dispatch.zig | 4 +- lib/std/compress/flate/Compress.zig | 2 +- lib/std/compress/flate/token.zig | 6 +- lib/std/crypto/25519/field.zig | 4 +- lib/std/crypto/benchmark.zig | 2 +- lib/std/crypto/ghash_polyval.zig | 10 ++-- lib/std/crypto/kangarootwelve.zig | 2 +- lib/std/crypto/keccak_p.zig | 4 +- lib/std/crypto/pcurves/p256/p256_64.zig | 34 +++++------ .../crypto/pcurves/p256/p256_scalar_64.zig | 34 +++++------ lib/std/crypto/pcurves/p384/p384_64.zig | 34 +++++------ .../crypto/pcurves/p384/p384_scalar_64.zig | 34 +++++------ .../crypto/pcurves/secp256k1/secp256k1_64.zig | 34 +++++------ .../pcurves/secp256k1/secp256k1_scalar_64.zig | 34 +++++------ lib/std/debug.zig | 14 ++--- lib/std/fmt.zig | 4 +- lib/std/fmt/float.zig | 2 +- lib/std/hash/benchmark.zig | 2 +- lib/std/heap/SafeAllocator.zig | 2 +- lib/std/http/test.zig | 18 +++--- lib/std/json/Stringify.zig | 6 +- lib/std/lang.zig | 40 +++++++++++-- lib/std/log.zig | 2 +- lib/std/math/hypot.zig | 8 +-- lib/std/process.zig | 4 +- lib/std/sort/block.zig | 2 +- lib/std/start.zig | 4 +- lib/std/std.zig | 4 +- lib/std/zig/Zir.zig | 2 +- src/Builtin.zig | 6 +- src/Compilation.zig | 40 ++++++------- src/Compilation/Config.zig | 14 ++--- src/Module.zig | 18 +++--- src/Sema.zig | 18 +++--- src/codegen/aarch64/Mir.zig | 4 +- src/codegen/c.zig | 8 +-- src/codegen/llvm.zig | 8 +-- src/codegen/llvm/FuncGen.zig | 8 +-- src/codegen/riscv64/CodeGen.zig | 6 +- src/codegen/sparc64/CodeGen.zig | 6 +- src/codegen/wasm/Mir.zig | 4 +- src/codegen/x86_64/CodeGen.zig | 8 +-- src/libs/libcxx.zig | 6 +- src/libs/libunwind.zig | 2 +- src/libs/mingw.zig | 4 +- src/link/C.zig | 2 +- src/link/Coff.zig | 16 ++--- src/link/Elf.zig | 2 +- src/link/Elf/ZigObject.zig | 8 +-- src/link/Elf2.zig | 8 +-- src/link/Lld.zig | 28 ++++----- src/link/MachO.zig | 2 +- src/link/MachO/ZigObject.zig | 8 +-- src/main.zig | 51 ++++++++-------- src/target.zig | 10 ++-- test/behavior/cast.zig | 2 +- test/behavior/floatop.zig | 2 +- test/behavior/int128.zig | 2 +- test/c_abi/main.zig | 6 +- .../invalid_member_of_builtin_enum.zig | 2 +- test/src/ErrorTrace.zig | 4 +- test/standalone/dependency_options/build.zig | 18 +++--- test/standalone/simple/build.zig | 10 ++-- test/tests.zig | 44 +++++++------- tools/doctest.zig | 6 +- tools/migrate_langref.zig | 4 +- 86 files changed, 470 insertions(+), 423 deletions(-) diff --git a/build.zig b/build.zig index 385d4d5b7e0288d79a07c4c2c314cb7e6bc30c5d..0bd1abe03359bdd5c84086c95286568022a53bc4 100644 --- a/build.zig +++ b/build.zig @@ -207,7 +207,7 @@ pub fn build(b: *std.Build) !void { const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: { if (strip == true) break :blk @as(u32, 0); - if (optimize != .Debug) break :blk 0; + if (optimize != .debug) break :blk 0; break :blk 4; }; @@ -256,7 +256,7 @@ pub fn build(b: *std.Build) !void { exe.root_module.link_libc = true; } - const is_debug = optimize == .Debug; + const is_debug = optimize == .debug; const enable_debug_extensions = b.option(bool, "debug-extensions", "Enable commands and options useful for debugging the compiler") orelse is_debug; const enable_logging = b.option(bool, "log", "Enable debug logging with --debug-log") orelse is_debug; @@ -403,8 +403,8 @@ pub fn build(b: *std.Build) !void { if (tracy) |tracy_dir| { const tracy_mod = b.createModule(.{ .target = target, - // Always build Tracy in ReleaseFast so that it doesn't make Debug compiler builds unusable. - .optimize = .ReleaseFast, + // Always build Tracy in ReleaseFast so that it doesn't make -Odebug compiler builds unusable. + .optimize = .fast, .root_source_file = null, .link_libc = true, .link_libcpp = true, @@ -434,19 +434,19 @@ pub fn build(b: *std.Build) !void { var chosen_opt_modes_buf: [4]std.lang.OptimizeMode = undefined; var chosen_mode_index: usize = 0; if (!skip_debug) { - chosen_opt_modes_buf[chosen_mode_index] = .Debug; + chosen_opt_modes_buf[chosen_mode_index] = .debug; chosen_mode_index += 1; } if (!skip_release_safe) { - chosen_opt_modes_buf[chosen_mode_index] = .ReleaseSafe; + chosen_opt_modes_buf[chosen_mode_index] = .safe; chosen_mode_index += 1; } if (!skip_release_fast) { - chosen_opt_modes_buf[chosen_mode_index] = .ReleaseFast; + chosen_opt_modes_buf[chosen_mode_index] = .fast; chosen_mode_index += 1; } if (!skip_release_small) { - chosen_opt_modes_buf[chosen_mode_index] = .ReleaseSmall; + chosen_opt_modes_buf[chosen_mode_index] = .small; chosen_mode_index += 1; } const optimize_modes = chosen_opt_modes_buf[0..chosen_mode_index]; diff --git a/lib/c/malloc.zig b/lib/c/malloc.zig index 69f56641d0a26a9f4b68bbe75cc26de9203c6f1d..b9ba905440726fecbe7204ecd4e2d42bad198579 100644 --- a/lib/c/malloc.zig +++ b/lib/c/malloc.zig @@ -59,8 +59,8 @@ const Header = packed struct(u64) { } const safety = switch (builtin.mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; const max_addr_bits = switch (safety) { true => 48, // Ensures space for Canary bits. diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 8b7c9a23edf2701ae1a84f45525d8bccf2a7a1f0..b5db0e68f7597a1e951900e8b741afb20521bcda 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -69,10 +69,10 @@ var debug_maker_leaks: bool = false; const AvoidableWebServer = if (builtin.single_threaded) void else WebServer; -const is_debug_mode = builtin.mode == .Debug; +const is_debug_mode = builtin.mode == .debug; const use_safe_allocator = switch (builtin.mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; const InstallPaths = struct { diff --git a/lib/compiler/Maker/Step/TranslateC.zig b/lib/compiler/Maker/Step/TranslateC.zig index 94b90d65dc9a8ec48871d945924cb0e4461e80f4..79b8571ba6bfef3474ac68e2036f9bdbd1c2f5f8 100644 --- a/lib/compiler/Maker/Step/TranslateC.zig +++ b/lib/compiler/Maker/Step/TranslateC.zig @@ -49,9 +49,9 @@ pub fn make( const opt: ?OptimizeMode = switch (conf_tc.flags.optimize) { .debug, .default => null, // Skip since it's the default - .safe => .ReleaseSafe, - .fast => .ReleaseFast, - .small => .ReleaseSmall, + .safe => .safe, + .fast => .fast, + .small => .small, }; if (opt) |o| argv.appendAssumeCapacity(try arena.print("-O{t}", .{o})); diff --git a/lib/compiler/Maker/WebServer.zig b/lib/compiler/Maker/WebServer.zig index e47f18bb5f786aba032d64dc37f806200f15636c..1064519adc547a78c26bafc23351a640367178f5 100644 --- a/lib/compiler/Maker/WebServer.zig +++ b/lib/compiler/Maker/WebServer.zig @@ -501,7 +501,7 @@ fn serveRequest(ws: *WebServer, req: *http.Server.Request) !void { if (mem.eql(u8, target, "/main.js")) return serveLibFile(ws, req, "build-web/main.js", "application/javascript"); if (mem.eql(u8, target, "/style.css")) return serveLibFile(ws, req, "build-web/style.css", "text/css"); if (mem.eql(u8, target, "/time_report.css")) return serveLibFile(ws, req, "build-web/time_report.css", "text/css"); - if (mem.eql(u8, target, "/main.wasm")) return serveClientWasm(ws, req, if (debug) .Debug else .ReleaseFast); + if (mem.eql(u8, target, "/main.wasm")) return serveClientWasm(ws, req, if (debug) .debug else .fast); if (ws.fuzz) |*fuzz| { if (mem.eql(u8, target, "/sources.tar")) return fuzz.serveSourcesTar(req); diff --git a/lib/compiler/aro/aro/Diagnostics.zig b/lib/compiler/aro/aro/Diagnostics.zig index e2cd09c19f952da6c3e9507011443efea189cb5a..7bfa8be6efbdf7cb4af49d683e67bd2ab86fc068 100644 --- a/lib/compiler/aro/aro/Diagnostics.zig +++ b/lib/compiler/aro/aro/Diagnostics.zig @@ -510,7 +510,7 @@ pub fn formatArgs(w: *std.Io.Writer, fmt: []const u8, args: anytype) std.Io.Writ pub fn templateIndex(w: *std.Io.Writer, fmt: []const u8, template: []const u8) std.Io.Writer.Error!usize { const i = std.mem.indexOf(u8, fmt, template) orelse { - if (@import("builtin").mode == .Debug) { + if (@import("builtin").mode == .debug) { std.debug.panic("template `{s}` not found in format string `{s}`", .{ template, fmt }); } try w.print("template `{s}` not found in format string `{s}` (this is a bug in arocc)", .{ template, fmt }); diff --git a/lib/compiler/aro/main.zig b/lib/compiler/aro/main.zig index 7d946af0c54790f78c63b8efbe048a3c1f2af372..1bfc84caad7831b6132864158694e51b940080fc 100644 --- a/lib/compiler/aro/main.zig +++ b/lib/compiler/aro/main.zig @@ -40,7 +40,7 @@ pub fn main(init: process.Init.Minimal) u8 { defer threaded.deinit(); const io = threaded.io(); - const fast_exit = @import("builtin").mode != .Debug; + const fast_exit = @import("builtin").mode != .debug; const args = init.args.toSlice(arena) catch { std.debug.print("out of memory\n", .{}); diff --git a/lib/compiler/std-docs.zig b/lib/compiler/std-docs.zig index f41159adea3c864e0c02fe2402bbba70196dd91d..f53123ae925a7fb4d997e1b8c1a5463624077780 100644 --- a/lib/compiler/std-docs.zig +++ b/lib/compiler/std-docs.zig @@ -142,9 +142,9 @@ fn serveRequest(request: *std.http.Server.Request, context: *Context) !void { { try serveDocsFile(request, context, "docs/main.js", "application/javascript"); } else if (std.mem.eql(u8, request.head.target, "/main.wasm")) { - try serveWasm(request, context, .ReleaseFast); + try serveWasm(request, context, .fast); } else if (std.mem.eql(u8, request.head.target, "/debug/main.wasm")) { - try serveWasm(request, context, .Debug); + try serveWasm(request, context, .debug); } else if (std.mem.eql(u8, request.head.target, "/sources.tar") or std.mem.eql(u8, request.head.target, "/debug/sources.tar")) { diff --git a/lib/compiler/translate-c/main.zig b/lib/compiler/translate-c/main.zig index 95836a94519ecbae20eea20f63b03d161301376c..e5c3961076a2daa2ec4a119c5903f175db96857c 100644 --- a/lib/compiler/translate-c/main.zig +++ b/lib/compiler/translate-c/main.zig @@ -9,7 +9,7 @@ const compiler_util = @import("../util.zig"); const Translator = @import("Translator.zig"); -const fast_exit = @import("builtin").mode != .Debug; +const fast_exit = @import("builtin").mode != .debug; pub fn main(init: process.Init) u8 { const gpa = init.gpa; diff --git a/lib/compiler_rt/memcpy.zig b/lib/compiler_rt/memcpy.zig index bb3c91eea83601771be7a61f1f4a8cd3d20e2249..b75f40ea4324448579f97f499cfb76493386adcf 100644 --- a/lib/compiler_rt/memcpy.zig +++ b/lib/compiler_rt/memcpy.zig @@ -11,7 +11,7 @@ comptime { .visibility = compiler_rt.visibility, }; - if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64) + if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) @export(&memcpySmall, export_options) else @export(&memcpyFast, export_options); diff --git a/lib/compiler_rt/memmove.zig b/lib/compiler_rt/memmove.zig index ad501e758aba4bcd1b2247900369cbeffbd8275a..b02a4c7e54b538c0192a058caa660c465f09db5f 100644 --- a/lib/compiler_rt/memmove.zig +++ b/lib/compiler_rt/memmove.zig @@ -14,7 +14,7 @@ comptime { .visibility = compiler_rt.visibility, }; - if (builtin.mode == .ReleaseSmall or builtin.zig_backend == .stage2_aarch64) + if (builtin.mode == .small or builtin.zig_backend == .stage2_aarch64) @export(&memmoveSmall, export_options) else @export(&memmoveFast, export_options); diff --git a/lib/docs/wasm/markdown/Document.zig b/lib/docs/wasm/markdown/Document.zig index 97507506af7a15bb5a800085930709d1446d8a11..7cde78f32b5ca948ab6e940f558a43dcd9d9bacc 100644 --- a/lib/docs/wasm/markdown/Document.zig +++ b/lib/docs/wasm/markdown/Document.zig @@ -108,7 +108,7 @@ pub const Node = struct { // In Debug and ReleaseSafe builds, there may be hidden extra fields // included for safety checks. Without such safety checks enabled, // we always want this union to be 8 bytes. - if (builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.mode != .debug and builtin.mode != .safe) { assert(@sizeOf(Data) == 8); } } diff --git a/lib/fuzzer.zig b/lib/fuzzer.zig index 65f677fb4e95b301403ef95f3f7f4034697df856..a6e1a65fbb6fcaba7313cea9503bfd06cc2fd4de 100644 --- a/lib/fuzzer.zig +++ b/lib/fuzzer.zig @@ -41,8 +41,8 @@ fn logOverride( var safe_allocator: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{}); const gpa = switch (builtin.mode) { - .Debug, .ReleaseSafe => safe_allocator.allocator(), - .ReleaseFast, .ReleaseSmall => std.heap.smp_allocator, + .debug, .safe => safe_allocator.allocator(), + .fast, .small => std.heap.smp_allocator, }; // Seperate from `exec` to allow initialization before `exec` is. @@ -1209,7 +1209,7 @@ const Fuzzer = struct { f.req_bytes = @intCast(f.input_builder.bytes_table.items.len); const quality: Input.Best.Quality = .{ .n_pcs = n_pcs: { - @setRuntimeSafety(builtin.mode == .Debug); // Necessary for vectorization + @setRuntimeSafety(builtin.mode == .debug); // Necessary for vectorization var n: u32 = 0; for (exec.pc_counters) |c| { n += @intFromBool(c != 0); diff --git a/lib/std/Build.zig b/lib/std/Build.zig index fc2d9909729f1417a4ac486ffea254846137d09b..79b681e7404623d141293d7379d88c94f196f683 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -1210,13 +1210,16 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw return null; }, .scalar => |s| { - if (std.meta.stringToEnum(T, s)) |enum_lit| { - return enum_lit; - } else { - log.err("expected -D{s} to be of type {s}", .{ name, @typeName(T) }); - b.markInvalidUserInput(); - return null; + if (T == std.lang.Optimize) { + if (std.lang.Optimize.fromString(s)) |tag| { + return tag; + } + } else if (std.meta.stringToEnum(T, s)) |tag| { + return tag; } + log.err("expected -D{s} to be of type {q}", .{ name, @typeName(T) }); + b.markInvalidUserInput(); + return null; }, }, .string => switch (option_ptr.value) { @@ -1262,23 +1265,36 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw }, .scalar => |s| { const Child = @typeInfo(T).pointer.child; - const value = std.meta.stringToEnum(Child, s) orelse { - log.err("expected -D{s} to be of type {s}", .{ name, @typeName(Child) }); - b.markInvalidUserInput(); - return null; - }; - return arena.dupe(Child, &[_]Child{value}) catch @panic("OOM"); + if (Child == std.lang.Optimize) { + if (std.lang.Optimize.fromString(s)) |tag| { + return arena.dupe(Child, &.{tag}) catch @panic("OOM"); + } + } else { + if (std.meta.stringToEnum(Child, s)) |tag| { + return arena.dupe(Child, &.{tag}) catch @panic("OOM"); + } + } + log.err("expected -D{s} to be of type {q}", .{ name, @typeName(Child) }); + b.markInvalidUserInput(); + return null; }, .list => |lst| { const Child = @typeInfo(T).pointer.child; const new_list = graph.alloc(Child, lst.items.len); for (new_list, lst.items) |*new_item, str| { - new_item.* = std.meta.stringToEnum(Child, str) orelse { - log.err("expected -D{s} to be of type {s}", .{ name, @typeName(Child) }); - b.markInvalidUserInput(); - arena.free(new_list); - return null; - }; + if (Child == std.lang.Optimize) { + if (std.lang.Optimize.fromString(str)) |tag| { + new_item.* = tag; + continue; + } + } + if (std.meta.stringToEnum(Child, str)) |tag| { + new_item.* = tag; + continue; + } + log.err("expected -D{s} to be of type {q}", .{ name, @typeName(Child) }); + b.markInvalidUserInput(); + return null; } return new_list; }, @@ -1359,14 +1375,14 @@ pub fn standardOptimizeOption(b: *Build, options: StandardOptimizeOptionOptions) } return switch (graph.release_mode) { - .off => .Debug, + .off => .debug, .any => { std.debug.print("the project does not declare a preferred optimization mode. choose: --release=fast, --release=safe, or --release=small\n", .{}); process.exit(1); }, - .fast => .ReleaseFast, - .safe => .ReleaseSafe, - .small => .ReleaseSmall, + .fast => .fast, + .safe => .safe, + .small => .small, }; } diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index b839523867b4f151b9761b7178bd2d0290e593eb..31da18abfd88368efb7ded2112d3343bdcf6201a 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -1655,10 +1655,10 @@ pub const Module = struct { pub fn init(o: ?std.builtin.OptimizeMode) Optimize { return switch (o orelse return .default) { - .Debug => .debug, - .ReleaseSafe => .safe, - .ReleaseFast => .fast, - .ReleaseSmall => .small, + .debug => .debug, + .safe => .safe, + .fast => .fast, + .small => .small, }; } }; diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index cc0ac4e99d52b94973fd6bc5269790deff2898cf..b14e0c254846d0bda46e06f735015f877dcf9a36 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -390,7 +390,7 @@ pub fn create(owner: *std.Build, options: Options) *Compile { @tagName(options.kind) else owner.fmt("{t} {s}", .{ options.kind, name }), - @tagName(options.root_module.optimize orelse .Debug), + @tagName(options.root_module.optimize orelse .debug), resolved_target.query.zigTriple(arena) catch @panic("OOM"), }); @@ -645,7 +645,7 @@ pub fn producesPdbFile(compile: *Compile) bool { if (target.ofmt == .c) return false; if (compile.use_llvm == false) return false; if (compile.root_module.strip == true or - (compile.root_module.strip == null and compile.root_module.optimize == .ReleaseSmall)) + (compile.root_module.strip == null and compile.root_module.optimize == .small)) { return false; } diff --git a/lib/std/Io/Dispatch.zig b/lib/std/Io/Dispatch.zig index 438ee0d31b4bb907690c3f355a16d10392b1b60f..4f58bc8bdf7645ae97bd1131a13974552d07e7a8 100644 --- a/lib/std/Io/Dispatch.zig +++ b/lib/std/Io/Dispatch.zig @@ -3897,7 +3897,7 @@ fn fileMemoryMapDestroy(userdata: ?*anyopaque, mm: *File.MemoryMap) void { if (memory.len == 0) return; switch (c.errno(c.munmap(memory.ptr, memory.len))) { .SUCCESS => {}, - else => |err| if (builtin.mode == .Debug) + else => |err| if (builtin.mode == .debug) std.log.err("failed to unmap {d} bytes at {*}: {t}", .{ memory.len, memory.ptr, err }), } mm.* = undefined; diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index b3cc49cd3f792f3a3c70e086d9c9bf2034abc56c..d1ba12a8e29f0b9c38915cacbe04514303cc06dc 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -4,7 +4,7 @@ const builtin = @import("builtin"); const native_os = builtin.os.tag; const is_windows = native_os == .windows; const is_darwin = native_os.isDarwin(); -const is_debug = builtin.mode == .Debug; +const is_debug = builtin.mode == .debug; const std = @import("../std.zig"); const Io = std.Io; @@ -440,12 +440,12 @@ pub const UseFchmodat2 = if (have_fchmodat2 and !have_fchmodat_flags) enum { pub const apc_align = @max(default_fn_align, 2); const default_fn_align = switch (builtin.mode) { - .Debug, .ReleaseSafe, .ReleaseFast => switch (builtin.cpu.arch) { + .debug, .safe, .fast => switch (builtin.cpu.arch) { else => |arch| @compileError("Unsupported architecture: " ++ @tagName(arch)), .arm, .thumb => 4, .aarch64, .x86, .x86_64 => 16, }, - .ReleaseSmall => 1, + .small => 1, }; const Runnable = struct { @@ -18172,7 +18172,7 @@ fn fileMemoryMapCreate( error.Unseekable, error.Canceled, error.AccessDenied => |e| return e, error.OperationUnsupported => {}, else => { - if (builtin.mode == .Debug) + if (builtin.mode == .debug) std.log.warn("memory mapping failed with {t}, falling back to file operations", .{err}); }, } @@ -18279,7 +18279,7 @@ fn createFileMap( .INVALID_VIEW_SIZE => |status| return windows.statusBug(status), else => |status| return windows.unexpectedStatus(status), } - if (builtin.mode == .Debug) { + if (builtin.mode == .debug) { const page_size = std.heap.pageSize(); const alignment: Alignment = .fromByteUnits(page_size); assert(contents_len == alignment.forward(len)); @@ -18370,7 +18370,7 @@ fn fileMemoryMapDestroy(userdata: ?*anyopaque, mm: *File.MemoryMap) void { switch (posix.errno(posix.system.munmap(memory.ptr, memory.len))) { .SUCCESS => {}, else => |e| { - if (builtin.mode == .Debug) + if (builtin.mode == .debug) std.log.err("failed to unmap {d} bytes at {*}: {t}", .{ memory.len, memory.ptr, e }); }, } diff --git a/lib/std/Io/Uring.zig b/lib/std/Io/Uring.zig index c2c7e57edff411b2c469519858391f3d1eb0724d..59d932311384d4e3de96ef51d618e61338e4783c 100644 --- a/lib/std/Io/Uring.zig +++ b/lib/std/Io/Uring.zig @@ -4050,7 +4050,7 @@ fn fileMemoryMapDestroy(userdata: ?*anyopaque, mm: *File.MemoryMap) void { if (memory.len == 0) return; switch (linux.errno(linux.munmap(memory.ptr, memory.len))) { .SUCCESS => {}, - else => |err| if (builtin.mode == .Debug) + else => |err| if (builtin.mode == .debug) std.log.err("failed to unmap {d} bytes at {*}: {t}", .{ memory.len, memory.ptr, err }), } mm.* = undefined; diff --git a/lib/std/Random/benchmark.zig b/lib/std/Random/benchmark.zig index 1e23c933912851a7f539fd17f076b362b73a27ec..59b6c8168045f7e28963e066f54e472e77555f04 100644 --- a/lib/std/Random/benchmark.zig +++ b/lib/std/Random/benchmark.zig @@ -122,7 +122,7 @@ fn usage() void { } fn mode(comptime x: comptime_int) comptime_int { - return if (builtin.mode == .Debug) x / 64 else x; + return if (builtin.mode == .debug) x / 64 else x; } pub fn main(init: std.process.Init) !void { diff --git a/lib/std/c/darwin/dispatch.zig b/lib/std/c/darwin/dispatch.zig index 770eadf7170f915d877d3d079c7d13b9585ae0a1..5a00b856192b64e786daad59cada13eca06b6ec7 100644 --- a/lib/std/c/darwin/dispatch.zig +++ b/lib/std/c/darwin/dispatch.zig @@ -44,8 +44,8 @@ pub const once_t = enum(isize) { once_f(predicate, context, function); } else asm volatile ("" ::: .{ .memory = true }); switch (builtin.mode) { - .Debug, .ReleaseSafe => {}, - .ReleaseFast, .ReleaseSmall => if (predicate.* != .done) unreachable, + .debug, .safe => {}, + .fast, .small => if (predicate.* != .done) unreachable, } } }; diff --git a/lib/std/compress/flate/Compress.zig b/lib/std/compress/flate/Compress.zig index 23ca2cb634a086080d49ddede293691046f13b4c..167bddd1b6923b2dd22fa2267c38c6e5118f8c39 100644 --- a/lib/std/compress/flate/Compress.zig +++ b/lib/std/compress/flate/Compress.zig @@ -738,7 +738,7 @@ fn matchAndAddHash(c: *Compress, i: usize, h: Hash, gt: u16, max_chain: u16, goo fn clenHlen(freqs: [19]u16) u4 { // Note that the first four codes (16, 17, 18, and 0) are always present. - if (builtin.mode != .ReleaseSmall and (std.simd.suggestVectorLength(u16) orelse 1) >= 8) { + if (builtin.mode != .small and (std.simd.suggestVectorLength(u16) orelse 1) >= 8) { const V = @Vector(16, u16); const hlen_mul: V = comptime m: { var hlen_mul: [16]u16 = undefined; diff --git a/lib/std/compress/flate/token.zig b/lib/std/compress/flate/token.zig index 3c0866896d2cd966e3bd23fdd82cecfa54761fc8..de84f045e83d7296a079326a78dc95fc29b04c1b 100644 --- a/lib/std/compress/flate/token.zig +++ b/lib/std/compress/flate/token.zig @@ -57,9 +57,9 @@ const fixed_dist = blk: { }; // All paramters of codes can be derived matchematically, however some are faster to -// do via lookup table. For ReleaseSmall, we do all mathematically to save space. -pub const LenCode = if (builtin.mode != .ReleaseSmall) LookupLenCode else ShortLenCode; -pub const DistCode = if (builtin.mode != .ReleaseSmall) LookupDistCode else ShortDistCode; +// do via lookup table. For -Osmall, we do all mathematically to save space. +pub const LenCode = if (builtin.mode != .small) LookupLenCode else ShortLenCode; +pub const DistCode = if (builtin.mode != .small) LookupDistCode else ShortDistCode; const ShortLenCode = ShortCode(u8, u2, u3, true); const ShortDistCode = ShortCode(u15, u1, u4, false); /// For length and distance codes, they having this format. diff --git a/lib/std/crypto/25519/field.zig b/lib/std/crypto/25519/field.zig index d10f92550a5877b7dfde918a2e9718af948569bb..1c707815872a62d57417f04d572d7d6006110aac 100644 --- a/lib/std/crypto/25519/field.zig +++ b/lib/std/crypto/25519/field.zig @@ -7,8 +7,8 @@ const NotSquareError = crypto.errors.NotSquareError; // Inline conditionally, when it can result in large code generation. const bloaty_inline: std.builtin.CallingConvention = switch (builtin.mode) { - .ReleaseSafe, .ReleaseFast => .@"inline", - .Debug, .ReleaseSmall => .auto, + .safe, .fast => .@"inline", + .debug, .small => .auto, }; pub const Fe = struct { diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index ef19aac818b764604ed562d2d6832170f4ed91f9..2cc49344b39108a118c000506b531e7520d91047 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -493,7 +493,7 @@ fn usage() void { } fn mode(comptime x: comptime_int) comptime_int { - return if (builtin.mode == .Debug) x / 64 else x; + return if (builtin.mode == .debug) x / 64 else x; } pub fn main(init: std.process.Init) !void { diff --git a/lib/std/crypto/ghash_polyval.zig b/lib/std/crypto/ghash_polyval.zig index 9f648c3fb34048f703f0346f96ea543d901a5d94..2ae68da1d654ee0a1ff33390637c5240a3f26aae 100644 --- a/lib/std/crypto/ghash_polyval.zig +++ b/lib/std/crypto/ghash_polyval.zig @@ -30,7 +30,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { pub const mac_length = 16; pub const key_length = 16; - const pc_count = if (builtin.mode != .ReleaseSmall) 16 else 2; + const pc_count = if (builtin.mode != .small) 16 else 2; const agg_4_threshold = 22; const agg_8_threshold = 84; const agg_16_threshold = 328; @@ -61,7 +61,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { hx[0] = h; hx[1] = reduce(clsq128(hx[0])); // h^2 - if (builtin.mode != .ReleaseSmall) { + if (builtin.mode != .small) { hx[2] = reduce(clmul128(hx[1], h)); // h^3 hx[3] = reduce(clsq128(hx[1])); // h^4 = h^2^2 if (block_count >= agg_8_threshold) { @@ -303,7 +303,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { var i: usize = 0; - if (builtin.mode != .ReleaseSmall and msg.len >= agg_16_threshold * block_length) { + if (builtin.mode != .small and msg.len >= agg_16_threshold * block_length) { // 16-blocks aggregated reduction while (i + 256 <= msg.len) : (i += 256) { var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[15 - 0]); @@ -313,7 +313,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { } acc = reduce(u); } - } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_8_threshold * block_length) { + } else if (builtin.mode != .small and msg.len >= agg_8_threshold * block_length) { // 8-blocks aggregated reduction while (i + 128 <= msg.len) : (i += 128) { var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[7 - 0]); @@ -323,7 +323,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { } acc = reduce(u); } - } else if (builtin.mode != .ReleaseSmall and msg.len >= agg_4_threshold * block_length) { + } else if (builtin.mode != .small and msg.len >= agg_4_threshold * block_length) { // 4-blocks aggregated reduction while (i + 64 <= msg.len) : (i += 64) { var u = clmul128(acc ^ mem.readInt(u128, msg[i..][0..16], endian), st.hx[3 - 0]); diff --git a/lib/std/crypto/kangarootwelve.zig b/lib/std/crypto/kangarootwelve.zig index f43ae24c69172b000b2f7d4b420f03f93f505e64..735d476591854adae4ea5a4a417a3ce6d8a67b86 100644 --- a/lib/std/crypto/kangarootwelve.zig +++ b/lib/std/crypto/kangarootwelve.zig @@ -1398,7 +1398,7 @@ test "KT128 sequential and parallel produce same output for many random lengths" var prng = std.Random.DefaultPrng.init(std.testing.random_seed); const random = prng.random(); - const num_tests = if (builtin.mode == .Debug) 10 else 1000; + const num_tests = if (builtin.mode == .debug) 10 else 1000; const max_length = 250000; for (0..num_tests) |_| { diff --git a/lib/std/crypto/keccak_p.zig b/lib/std/crypto/keccak_p.zig index 6aa2345aed5550d1d3a320887a8d99e4d115f277..b707833e2d7a5a56cc8c38cd989ff6bee5a9b0a1 100644 --- a/lib/std/crypto/keccak_p.zig +++ b/lib/std/crypto/keccak_p.zig @@ -202,7 +202,7 @@ pub fn State(comptime f: u11, comptime capacity: u11, comptime rounds: u5) type // In debug mode, track transitions to prevent insecure ones. const Op = enum { uninitialized, initialized, updated, absorb, squeeze }; - const TransitionTracker = if (mode == .Debug) struct { + const TransitionTracker = if (mode == .debug) struct { op: Op = .uninitialized, fn to(tracker: *@This(), next_op: Op) void { @@ -294,7 +294,7 @@ pub fn State(comptime f: u11, comptime capacity: u11, comptime rounds: u5) type /// Permute the state pub fn permute(self: *Self) void { - if (mode == .Debug) { + if (mode == .debug) { if (self.transition.op == .absorb and self.offset > 0) { @panic("cannot permute with pending input - call fillBlock() or pad() instead"); } diff --git a/lib/std/crypto/pcurves/p256/p256_64.zig b/lib/std/crypto/pcurves/p256/p256_64.zig index e79d51814e28ae67719c50354e4fe1c0a7061697..8cc9016ed38957ae5cd6647141dd0909dc3b90c3 100644 --- a/lib/std/crypto/pcurves/p256/p256_64.zig +++ b/lib/std/crypto/pcurves/p256/p256_64.zig @@ -110,7 +110,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -129,7 +129,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -145,7 +145,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -437,7 +437,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -730,7 +730,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -783,7 +783,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -826,7 +826,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -869,7 +869,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -1022,7 +1022,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1297,7 +1297,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); out1.* = x1; @@ -1315,7 +1315,7 @@ pub fn nonzero(out1: *u64, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -1343,7 +1343,7 @@ pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[3]); const x2 = (arg1[2]); @@ -1452,7 +1452,7 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[31])) << 56); const x2 = (@as(u64, (arg1[30])) << 48); @@ -1527,7 +1527,7 @@ pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = @as(u64, 0x1); out1[1] = 0xffffffff00000000; @@ -1544,7 +1544,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[5]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xffffffffffffffff; out1[1] = 0xffffffff; @@ -1582,7 +1582,7 @@ pub fn msat(out1: *[5]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[4]u64, arg1: u64, arg2: [5]u64, arg3: [5]u64, arg4: [4]u64, arg5: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1816,7 +1816,7 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0x67ffffffb8000000; out1[1] = 0xc000000038000000; diff --git a/lib/std/crypto/pcurves/p256/p256_scalar_64.zig b/lib/std/crypto/pcurves/p256/p256_scalar_64.zig index c549831b20e3260874f8c97179394b044b291741..db350196a4ca66f7624a39569b2d7e3296745821 100644 --- a/lib/std/crypto/pcurves/p256/p256_scalar_64.zig +++ b/lib/std/crypto/pcurves/p256/p256_scalar_64.zig @@ -110,7 +110,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -129,7 +129,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -145,7 +145,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -485,7 +485,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -826,7 +826,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -879,7 +879,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -922,7 +922,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -965,7 +965,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -1178,7 +1178,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1501,7 +1501,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); out1.* = x1; @@ -1519,7 +1519,7 @@ pub fn nonzero(out1: *u64, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -1547,7 +1547,7 @@ pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[3]); const x2 = (arg1[2]); @@ -1656,7 +1656,7 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[31])) << 56); const x2 = (@as(u64, (arg1[30])) << 48); @@ -1731,7 +1731,7 @@ pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xc46353d039cdaaf; out1[1] = 0x4319055258e8617b; @@ -1748,7 +1748,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[5]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xf3b9cac2fc632551; out1[1] = 0xbce6faada7179e84; @@ -1786,7 +1786,7 @@ pub fn msat(out1: *[5]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[4]u64, arg1: u64, arg2: [5]u64, arg3: [5]u64, arg4: [4]u64, arg5: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -2020,7 +2020,7 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xd739262fb7fcfbb5; out1[1] = 0x8ac6f75d20074414; diff --git a/lib/std/crypto/pcurves/p384/p384_64.zig b/lib/std/crypto/pcurves/p384/p384_64.zig index d6f33028f73e744e048bb764b588bc7379868845..99d9dc82b2ba99d26de4c324c5c3ac239846a47a 100644 --- a/lib/std/crypto/pcurves/p384/p384_64.zig +++ b/lib/std/crypto/pcurves/p384/p384_64.zig @@ -79,7 +79,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -98,7 +98,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -114,7 +114,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -834,7 +834,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1555,7 +1555,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1626,7 +1626,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1683,7 +1683,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1740,7 +1740,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -2225,7 +2225,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -2862,7 +2862,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | (arg1[5])))))); out1.* = x1; @@ -2880,7 +2880,7 @@ pub fn nonzero(out1: *u64, arg1: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[6]u64, arg1: u1, arg2: [6]u64, arg3: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -2914,7 +2914,7 @@ pub fn selectznz(out1: *[6]u64, arg1: u1, arg2: [6]u64, arg3: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[48]u8, arg1: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[5]); const x2 = (arg1[4]); @@ -3069,7 +3069,7 @@ pub fn toBytes(out1: *[48]u8, arg1: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[6]u64, arg1: [48]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[47])) << 56); const x2 = (@as(u64, (arg1[46])) << 48); @@ -3176,7 +3176,7 @@ pub fn fromBytes(out1: *[6]u64, arg1: [48]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xffffffff00000001; out1[1] = 0xffffffff; @@ -3195,7 +3195,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[7]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xffffffff; out1[1] = 0xffffffff00000000; @@ -3235,7 +3235,7 @@ pub fn msat(out1: *[7]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[7]u64, out3: *[7]u64, out4: *[6]u64, out5: *[6]u64, arg1: u64, arg2: [7]u64, arg3: [7]u64, arg4: [6]u64, arg5: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -3561,7 +3561,7 @@ pub fn divstep(out1: *u64, out2: *[7]u64, out3: *[7]u64, out4: *[6]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xfff69400fff18fff; out1[1] = 0x2b7feffffd3ff; diff --git a/lib/std/crypto/pcurves/p384/p384_scalar_64.zig b/lib/std/crypto/pcurves/p384/p384_scalar_64.zig index 74f7e7813fed2a5bc0c685d5f9ba85e478ed3ce0..0b618e615442dfccd128b264029302205c286ecd 100644 --- a/lib/std/crypto/pcurves/p384/p384_scalar_64.zig +++ b/lib/std/crypto/pcurves/p384/p384_scalar_64.zig @@ -79,7 +79,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -98,7 +98,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -114,7 +114,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -834,7 +834,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1555,7 +1555,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1626,7 +1626,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1683,7 +1683,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1740,7 +1740,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -2225,7 +2225,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -2916,7 +2916,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | (arg1[5])))))); out1.* = x1; @@ -2934,7 +2934,7 @@ pub fn nonzero(out1: *u64, arg1: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[6]u64, arg1: u1, arg2: [6]u64, arg3: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -2968,7 +2968,7 @@ pub fn selectznz(out1: *[6]u64, arg1: u1, arg2: [6]u64, arg3: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[48]u8, arg1: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[5]); const x2 = (arg1[4]); @@ -3123,7 +3123,7 @@ pub fn toBytes(out1: *[48]u8, arg1: [6]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[6]u64, arg1: [48]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[47])) << 56); const x2 = (@as(u64, (arg1[46])) << 48); @@ -3230,7 +3230,7 @@ pub fn fromBytes(out1: *[6]u64, arg1: [48]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0x1313e695333ad68d; out1[1] = 0xa7e5f24db74f5885; @@ -3249,7 +3249,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[7]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xecec196accc52973; out1[1] = 0x581a0db248b0a77a; @@ -3289,7 +3289,7 @@ pub fn msat(out1: *[7]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[7]u64, out3: *[7]u64, out4: *[6]u64, out5: *[6]u64, arg1: u64, arg2: [7]u64, arg3: [7]u64, arg4: [6]u64, arg5: [6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -3615,7 +3615,7 @@ pub fn divstep(out1: *u64, out2: *[7]u64, out3: *[7]u64, out4: *[6]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[6]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0x49589ae0e6045b6a; out1[1] = 0x3c9a5352870040ed; diff --git a/lib/std/crypto/pcurves/secp256k1/secp256k1_64.zig b/lib/std/crypto/pcurves/secp256k1/secp256k1_64.zig index 547da19bea45f80db08cd2bc1d5172265cecd72a..8decda2f2525f288583ced40b12c7413862ebf6d 100644 --- a/lib/std/crypto/pcurves/secp256k1/secp256k1_64.zig +++ b/lib/std/crypto/pcurves/secp256k1/secp256k1_64.zig @@ -79,7 +79,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -98,7 +98,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -114,7 +114,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -454,7 +454,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -795,7 +795,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -848,7 +848,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -891,7 +891,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -934,7 +934,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -1167,7 +1167,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1430,7 +1430,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); out1.* = x1; @@ -1448,7 +1448,7 @@ pub fn nonzero(out1: *u64, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -1476,7 +1476,7 @@ pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[3]); const x2 = (arg1[2]); @@ -1585,7 +1585,7 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[31])) << 56); const x2 = (@as(u64, (arg1[30])) << 48); @@ -1660,7 +1660,7 @@ pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0x1000003d1; out1[1] = 0x0; @@ -1677,7 +1677,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[5]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xfffffffefffffc2f; out1[1] = 0xffffffffffffffff; @@ -1715,7 +1715,7 @@ pub fn msat(out1: *[5]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[4]u64, arg1: u64, arg2: [5]u64, arg3: [5]u64, arg4: [4]u64, arg5: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -1949,7 +1949,7 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xf201a41831525e0a; out1[1] = 0x9953f9ddcd648d85; diff --git a/lib/std/crypto/pcurves/secp256k1/secp256k1_scalar_64.zig b/lib/std/crypto/pcurves/secp256k1/secp256k1_scalar_64.zig index 71e6f1baba7bd6107d85097e2ce297402f4a475a..09bfc15a10d44970b38d7f51b802a28cb908afe5 100644 --- a/lib/std/crypto/pcurves/secp256k1/secp256k1_scalar_64.zig +++ b/lib/std/crypto/pcurves/secp256k1/secp256k1_scalar_64.zig @@ -79,7 +79,7 @@ fn subborrowxU64(out1: *u64, out2: *u1, arg1: u1, arg2: u64, arg3: u64) void { /// out1: [0x0 ~> 0xffffffffffffffff] /// out2: [0x0 ~> 0xffffffffffffffff] fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x = @as(u128, arg1) * @as(u128, arg2); out1.* = @as(u64, @truncate(x)); @@ -98,7 +98,7 @@ fn mulxU64(out1: *u64, out2: *u64, arg1: u64, arg2: u64) void { /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const mask = 0 -% @as(u64, arg1); out1.* = (mask & arg3) | ((~mask) & arg2); @@ -114,7 +114,7 @@ fn cmovznzU64(out1: *u64, arg1: u1, arg2: u64, arg3: u64) void { /// 0 ≤ eval out1 < m /// pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -454,7 +454,7 @@ pub fn mul(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -795,7 +795,7 @@ pub fn square(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEl /// 0 ≤ eval out1 < m /// pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -848,7 +848,7 @@ pub fn add(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement, arg2: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -891,7 +891,7 @@ pub fn sub(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -934,7 +934,7 @@ pub fn opp(out1: *MontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldEleme /// 0 ≤ eval out1 < m /// pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[0]); var x2: u64 = undefined; @@ -1167,7 +1167,7 @@ pub fn fromMontgomery(out1: *NonMontgomeryDomainFieldElement, arg1: MontgomeryDo /// 0 ≤ eval out1 < m /// pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[1]); const x2 = (arg1[2]); @@ -1490,7 +1490,7 @@ pub fn toMontgomery(out1: *MontgomeryDomainFieldElement, arg1: NonMontgomeryDoma /// Output Bounds: /// out1: [0x0 ~> 0xffffffffffffffff] pub fn nonzero(out1: *u64, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); out1.* = x1; @@ -1508,7 +1508,7 @@ pub fn nonzero(out1: *u64, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; cmovznzU64(&x1, arg1, (arg2[0]), (arg3[0])); @@ -1536,7 +1536,7 @@ pub fn selectznz(out1: *[4]u64, arg1: u1, arg2: [4]u64, arg3: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (arg1[3]); const x2 = (arg1[2]); @@ -1645,7 +1645,7 @@ pub fn toBytes(out1: *[32]u8, arg1: [4]u64) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); const x1 = (@as(u64, (arg1[31])) << 56); const x2 = (@as(u64, (arg1[30])) << 48); @@ -1720,7 +1720,7 @@ pub fn fromBytes(out1: *[4]u64, arg1: [32]u8) void { /// 0 ≤ eval out1 < m /// pub fn setOne(out1: *MontgomeryDomainFieldElement) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0x402da1732fc9bebf; out1[1] = 0x4551231950b75fc4; @@ -1737,7 +1737,7 @@ pub fn setOne(out1: *MontgomeryDomainFieldElement) void { /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn msat(out1: *[5]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xbfd25e8cd0364141; out1[1] = 0xbaaedce6af48a03b; @@ -1775,7 +1775,7 @@ pub fn msat(out1: *[5]u64) void { /// out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] /// out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[4]u64, arg1: u64, arg2: [5]u64, arg3: [5]u64, arg4: [4]u64, arg5: [4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); var x1: u64 = undefined; var x2: u1 = undefined; @@ -2009,7 +2009,7 @@ pub fn divstep(out1: *u64, out2: *[5]u64, out3: *[5]u64, out4: *[4]u64, out5: *[ /// Output Bounds: /// out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] pub fn divstepPrecomp(out1: *[4]u64) void { - @setRuntimeSafety(mode == .Debug); + @setRuntimeSafety(mode == .debug); out1[0] = 0xd7431a4d2b9cb4e9; out1[1] = 0xab67d35a32d9c503; diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 9a83de8e1061d603b3e82c80d6e84cc8a640441b..8aaee0e29edaba4523a70710de7eca31cf0bc078 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -241,8 +241,8 @@ pub const Symbol = struct { /// library, when the caller probably wants to use the optimization mode of /// their own module. pub const runtime_safety = switch (builtin.mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; /// Whether we can unwind the stack on this target, allowing capturing and/or printing the current @@ -257,7 +257,7 @@ pub const sys_can_stack_trace = switch (builtin.cpu.arch) { // because Emscripten's implementation is very slow. .wasm32, .wasm64, - => native_os == .emscripten and builtin.mode == .Debug, + => native_os == .emscripten and builtin.mode == .debug, // `@returnAddress()` is unsupported in LLVM 21. .bpfel, @@ -419,16 +419,16 @@ pub const CpuContextPtr = if (cpu_context.Native == noreturn) noreturn else *con /// Invokes detectable illegal behavior when `ok` is `false`. /// -/// In Debug and ReleaseSafe modes, calls to this function are always +/// In debug and safe modes, calls to this function are always /// generated, and the `unreachable` statement triggers a panic. /// -/// In ReleaseFast and ReleaseSmall modes, calls to this function are optimized +/// In fast and small modes, calls to this function are optimized /// away, and in fact the optimizer is able to use the assertion in its /// heuristics. /// /// Inside a test block, it is best to use the `testing` module rather than /// this function, because this function may not detect a test failure in -/// ReleaseFast and ReleaseSmall mode. Outside of a test block, this assert +/// fast and small mode. Outside of a test block, this assert /// function is the correct function to use. pub fn assert(ok: bool) void { @disableInstrumentation(); @@ -1760,7 +1760,7 @@ test "manage resources correctly" { /// In release mode, it is size 0 and all methods are no-ops. /// This is a pre-made type with default settings. /// For more advanced usage, see `ConfigurableTrace`. -pub const Trace = ConfigurableTrace(2, 4, builtin.mode == .Debug); +pub const Trace = ConfigurableTrace(2, 4, builtin.mode == .debug); pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize, comptime is_enabled: bool) type { return struct { diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 92e04955ed48a2628f78ae040326c3a853f88b11..7cdc44269cdc95b492eb8ac718a53d7fe721af55 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -261,7 +261,7 @@ test printInt { /// Converts values in the range [0, 100) to a base 10 string. pub fn digits2(value: u8) [2]u8 { - if (builtin.mode == .ReleaseSmall) { + if (builtin.mode == .small) { return .{ @intCast('0' + value / 10), @intCast('0' + value % 10) }; } else { return "00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"[value * 2 ..][0..2].*; @@ -924,7 +924,7 @@ test "enum" { // test very large enum to verify ct branch quota is large enough // TODO: https://github.com/ziglang/zig/issues/15609 - if (!((builtin.cpu.arch == .wasm32) and builtin.mode == .Debug)) { + if (!((builtin.cpu.arch == .wasm32) and builtin.mode == .debug)) { try expectFmt("enum: .INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION}); } diff --git a/lib/std/fmt/float.zig b/lib/std/fmt/float.zig index 44a71f90f42c47b608d6db65b1b7a59243680507..25bf97f22ae52df136be9dbbdeab2e0fdedfdc18 100644 --- a/lib/std/fmt/float.zig +++ b/lib/std/fmt/float.zig @@ -65,7 +65,7 @@ pub fn render(buf: []u8, value: anytype, options: Options) Error![]const u8 { const DT = if (@bitSizeOf(T) <= 64) u64 else u128; const tables = switch (DT) { - u64 => if (@import("builtin").mode == .ReleaseSmall) &Backend64_TablesSmall else &Backend64_TablesFull, + u64 => if (@import("builtin").mode == .small) &Backend64_TablesSmall else &Backend64_TablesFull, u128 => &Backend128_Tables, else => unreachable, }; diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index 3f5b763d9b0f2eb207b597c8e41098f272a090d0..a4ea82d68e6fef34b7ade95fe69bffac17e43021 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -355,7 +355,7 @@ fn usage() void { } fn mode(comptime x: comptime_int) comptime_int { - return if (builtin.mode == .Debug) x / 64 else x; + return if (builtin.mode == .debug) x / 64 else x; } pub fn main(init: std.process.Init) !void { diff --git a/lib/std/heap/SafeAllocator.zig b/lib/std/heap/SafeAllocator.zig index cfe24f4c0b1f0dabeaedaff76cc33d6ae32669c3..41199df8aa39d526938dc72a2ceccd80168c3dc0 100644 --- a/lib/std/heap/SafeAllocator.zig +++ b/lib/std/heap/SafeAllocator.zig @@ -39,7 +39,7 @@ const SafeAllocator = @This(); const scoped_log = std.log.scoped(.SafeAllocator); pub const Options = struct { - const is_debug = @import("builtin").mode == .Debug; + const is_debug = @import("builtin").mode == .debug; const page_size_log2 = @max(math.log2_int(usize, std.heap.page_size_max), 8); stack_trace_frames: usize = if (is_debug and std.debug.sys_can_stack_trace) 7 else 0, diff --git a/lib/std/http/test.zig b/lib/std/http/test.zig index 4182a766c5a132f8dca6fa24adafae86ba15e4d2..39f2063f65d7c1b175ce0750e9512abaee3f2c20 100644 --- a/lib/std/http/test.zig +++ b/lib/std/http/test.zig @@ -34,7 +34,7 @@ test "content length reader state update" { } test "trailers" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -121,7 +121,7 @@ test "trailers" { } test "HTTP server handles a chunked transfer coding request" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -190,7 +190,7 @@ test "HTTP server handles a chunked transfer coding request" { } test "echo content server" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -281,7 +281,7 @@ test "echo content server" { } test "Server.Request.respondStreaming non-chunked, unknown content-length" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -360,7 +360,7 @@ test "Server.Request.respondStreaming non-chunked, unknown content-length" { } test "receiving arbitrary http headers from the client" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -426,7 +426,7 @@ test "receiving arbitrary http headers from the client" { } test "general client/server API coverage" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -922,7 +922,7 @@ test "general client/server API coverage" { } test "Server streams both reading and writing" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -1192,7 +1192,7 @@ fn createTestServer(io: Io, S: type) !*TestServer { } test "redirect to different connection" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; @@ -1280,7 +1280,7 @@ test "redirect to different connection" { } test "boot failed connections from the pool" { - if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 + if (builtin.cpu.arch.isPowerPC64() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/194257 if (builtin.os.tag == .openbsd) return error.SkipZigTest; // https://codeberg.org/ziglang/zig/issues/30806 const io = std.testing.io; diff --git a/lib/std/json/Stringify.zig b/lib/std/json/Stringify.zig index 565c41b5e8e96c5bc3d3726df0171554fc8ed4d9..03c5d8fe4611dce85280df2de435194bf9a9fb1f 100644 --- a/lib/std/json/Stringify.zig +++ b/lib/std/json/Stringify.zig @@ -54,8 +54,8 @@ else void = if (build_mode_has_safety) .none else {}, const build_mode_has_safety = switch (@import("builtin").mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; /// The `safety_checks_hint` parameter determines how much memory is used to enable assertions that the above grammar is being followed, @@ -66,7 +66,7 @@ const build_mode_has_safety = switch (@import("builtin").mode) { /// If `.checked_to_fixed_depth` is used, there is additionally an assertion that the nesting depth never exceeds the given limit. /// `.checked_to_fixed_depth` embeds the storage required in the `Stringify` struct. /// `.assumed_correct` requires no space and performs none of these assertions. -/// In `ReleaseFast` and `ReleaseSmall` mode, the given `safety_checks_hint` is ignored and is always treated as `.assumed_correct`. +/// In fast and small optimization modes, the given `safety_checks_hint` is ignored and is always treated as `.assumed_correct`. const safety_checks_hint: union(enum) { /// Rounded up to the nearest multiple of 8. checked_to_fixed_depth: usize, diff --git a/lib/std/lang.zig b/lib/std/lang.zig index 02a1c90e5a915a26a7186d3733a2893a99c765dd..daa2482eec7429bcd90a83ae2e2515681be29187 100644 --- a/lib/std/lang.zig +++ b/lib/std/lang.zig @@ -107,13 +107,43 @@ pub const CodeModel = enum(u4) { tiny, }; +/// Deprecated, to be removed after 0.18.0 +pub const OptimizeMode = Optimize; + /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. -pub const OptimizeMode = enum { - Debug, - ReleaseSafe, - ReleaseFast, - ReleaseSmall, +pub const Optimize = enum { + /// Safety checks enabled. Optimize for bug detection, accurate debug info, + /// and compilation speed (in that order). + debug, + /// Safety checks enabled. Optimize for runtime performance. + safe, + /// Safety checks disabled. Optimize for runtime performance. + fast, + /// Safety checks disabled. Optimize for machine code size, then runtime performance. + small, + + /// Deprecated, to be removed after 0.18.0 + pub const Debug: @This() = .debug; + /// Deprecated, to be removed after 0.18.0 + pub const ReleaseSafe: @This() = .safe; + /// Deprecated, to be removed after 0.18.0 + pub const ReleaseFast: @This() = .fast; + /// Deprecated, to be removed after 0.18.0 + pub const ReleaseSmall: @This() = .small; + /// Deprecated, to be removed after 0.18.0 + pub fn fromString(s: []const u8) ?@This() { + return std.StaticStringMap(@This()).initComptime(&.{ + .{ "Debug", .debug }, + .{ "ReleaseSafe", .safe }, + .{ "ReleaseFast", .fast }, + .{ "ReleaseSmall", .small }, + .{ "debug", .debug }, + .{ "safe", .safe }, + .{ "fast", .fast }, + .{ "small", .small }, + }).get(s); + } }; /// The calling convention of a function defines how arguments and return values are passed, as well diff --git a/lib/std/log.zig b/lib/std/log.zig index 5a219a005a6d4274c0d7df0aa16a5cf8ce10f653..9599308b91784eaa0319f1563746de3097405f03 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -53,7 +53,7 @@ pub const Level = enum { /// The default log level is based on build mode. pub const default_level: Level = switch (builtin.mode) { .Debug => .debug, - .ReleaseSafe, .ReleaseFast, .ReleaseSmall => .info, + .safe, .fast, .small => .info, }; pub const ScopeLevel = struct { diff --git a/lib/std/math/hypot.zig b/lib/std/math/hypot.zig index f661e56d4ce9e46d51cce9487e783c4df78bed9c..ef3fc97af3d3ea21b7cb525c616d248ffc20da7d 100644 --- a/lib/std/math/hypot.zig +++ b/lib/std/math/hypot.zig @@ -93,13 +93,13 @@ const hypot_test_cases = .{ }; test hypot { - if (builtin.cpu.arch.isPowerPC() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 + if (builtin.cpu.arch.isPowerPC() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 try expect(hypot(0.3, 0.4) == 0.5); } test "hypot.correct" { if (builtin.target.cpu.arch == .x86_64 and builtin.target.os.tag == .macos) return error.SkipZigTest; - if (builtin.cpu.arch.isPowerPC() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 + if (builtin.cpu.arch.isPowerPC() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 inline for (.{ f16, f32, f64, f128 }) |T| { inline for (hypot_test_cases) |v| { @@ -111,7 +111,7 @@ test "hypot.correct" { test "hypot.precise" { if (builtin.target.cpu.arch == .x86_64 and builtin.target.os.tag == .macos) return error.SkipZigTest; - if (builtin.cpu.arch.isPowerPC() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 + if (builtin.cpu.arch.isPowerPC() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 inline for (.{ f16, f32, f64 }) |T| { // f128 seems to be 5 ulp inline for (hypot_test_cases) |v| { @@ -122,7 +122,7 @@ test "hypot.precise" { } test "hypot.special" { - if (builtin.cpu.arch.isPowerPC() and builtin.mode != .Debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 + if (builtin.cpu.arch.isPowerPC() and builtin.mode != .debug) return error.SkipZigTest; // https://github.com/llvm/llvm-project/issues/171869 @setEvalBranchQuota(2000); inline for (.{ f16, f32, f64, f128 }) |T| { try expect(math.isNan(hypot(nan(T), 0.0))); diff --git a/lib/std/process.zig b/lib/std/process.zig index e134ef16d9adb9abed54448861c72b12bb12a4c0..33adef9e29fa5444df291db23aec45045b65d4e2 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -644,7 +644,7 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 { /// leaks can be accurate. In release builds, this calls `exit` with code zero, /// and does not return. pub fn cleanExit(io: Io) void { - if (builtin.mode == .Debug) return; + if (builtin.mode == .debug) return; _ = io.lockStderr(&.{}, .no_color) catch {}; exit(0); } @@ -809,7 +809,7 @@ pub fn abort() noreturn { // even when linking libc on Windows we use our own abort implementation. // See https://github.com/ziglang/zig/issues/2071 for more details. if (native_os == .windows) { - if (builtin.mode == .Debug and windows.peb().BeingDebugged.toBool()) { + if (builtin.mode == .debug and windows.peb().BeingDebugged.toBool()) { @breakpoint(); } windows.ntdll.RtlExitUserProcess(3); diff --git a/lib/std/sort/block.zig b/lib/std/sort/block.zig index 4c94fb78adb6fde1582e0e806f84cfdfe88ec7a6..674e785afadf9c29f8869044de85bdc3fdfb7c85 100644 --- a/lib/std/sort/block.zig +++ b/lib/std/sort/block.zig @@ -103,7 +103,7 @@ pub fn block( context: anytype, comptime lessThanFn: fn (@TypeOf(context), lhs: T, rhs: T) bool, ) void { - const lessThan = if (builtin.mode == .Debug) struct { + const lessThan = if (builtin.mode == .debug) struct { fn lessThan(ctx: @TypeOf(context), lhs: T, rhs: T) bool { const lt = lessThanFn(ctx, lhs, rhs); const gt = lessThanFn(ctx, rhs, lhs); diff --git a/lib/std/start.zig b/lib/std/start.zig index c95e36e7778e5e6f041d7b51411d1a1e3b353601..2530b80d360c4e9b61bb8f2d4e25006d20aea2c3 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -742,8 +742,8 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.c) c_int { const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'"; const use_safe_allocator = !is_wasm and switch (builtin.mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => !builtin.link_libc and builtin.single_threaded, // Also not ideal. + .debug, .safe => true, + .fast, .small => !builtin.link_libc and builtin.single_threaded, // Also not ideal. }; var safe_allocator: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{}); diff --git a/lib/std/std.zig b/lib/std/std.zig index e7c50a946091a47dccf4cf1301d2982189ff8589..d1d8361967220fe75485de92ef207dfdac3363a0 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -162,7 +162,7 @@ pub const Options = struct { /// This enables `std.http.Client` to log ssl secrets to the file specified by the SSLKEYLOGFILE /// env var. Creating such a log file allows other programs with access to that file to decrypt /// all `std.http.Client` traffic made by this program. - http_enable_ssl_key_log_file: bool = @import("builtin").mode == .Debug, + http_enable_ssl_key_log_file: bool = @import("builtin").mode == .debug, side_channels_mitigations: crypto.SideChannelsMitigations = crypto.default_side_channels_mitigations, @@ -192,7 +192,7 @@ pub const Options = struct { /// If this happens the fix is to add the error code to the corresponding /// switch expression, possibly introduce a new error in the error set, and /// send a patch to Zig. - unexpected_error_tracing: bool = @import("builtin").mode == .Debug and switch (@import("builtin").zig_backend) { + unexpected_error_tracing: bool = @import("builtin").mode == .debug and switch (@import("builtin").zig_backend) { .stage2_llvm, .stage2_x86_64 => true, else => false, }, diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig index bce7bd281ef314870fe68528cde51d4813a41a17..1ec523e8694eb854692a94fbe560e25b11046a34 100644 --- a/lib/std/zig/Zir.zig +++ b/lib/std/zig/Zir.zig @@ -2522,7 +2522,7 @@ pub const Inst = struct { // bigger than expected. Note that in Debug builds, Zig is allowed // to insert a secret field for safety checks. comptime { - if (builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.mode != .debug and builtin.mode != .safe) { assert(@sizeOf(Data) == 8); } } diff --git a/src/Builtin.zig b/src/Builtin.zig index 7975f2b04bf7c1ca82c3dc786221f903be884cc4..e70252e47d8427eecac589c9d5711d9286d6b878 100644 --- a/src/Builtin.zig +++ b/src/Builtin.zig @@ -7,7 +7,7 @@ is_test: bool, single_threaded: bool, link_libc: bool, link_libcpp: bool, -optimize_mode: std.lang.OptimizeMode, +optimize_mode: std.lang.Optimize, error_tracing: bool, valgrind: bool, sanitize_thread: bool, @@ -239,7 +239,9 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro try buffer.print( \\pub const object_format: std.Target.ObjectFormat = .{f}; - \\pub const mode: std.lang.OptimizeMode = .{f}; + \\/// Deprecated, to be removed after 0.18.0 + \\pub const mode = optimize; + \\pub const optimize: std.lang.Optimize = .{f}; \\pub const link_libc = {}; \\pub const link_libcpp = {}; \\pub const have_error_return_tracing = {}; diff --git a/src/Compilation.zig b/src/Compilation.zig index 293b553d233ce437470ab229ad14c721e33ef56b..83b0f7ff2b206b23c947437fc514ca1c1cefed6a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -172,7 +172,7 @@ verbose_link: bool, link_depfile: ?[]const u8, disable_c_depfile: bool, stack_report: bool, -debug_compiler_runtime_libs: ?std.lang.OptimizeMode, +debug_compiler_runtime_libs: ?std.lang.Optimize, debug_compile_errors: bool, /// Do not check this field directly. Instead, use the `debugIncremental` wrapper function. debug_incremental: bool, @@ -1506,7 +1506,7 @@ pub const CreateOptions = struct { verbose_llvm_bc: ?[]const u8 = null, link_depfile: ?[]const u8 = null, verbose_llvm_cpu_features: bool = false, - debug_compiler_runtime_libs: ?std.lang.OptimizeMode = null, + debug_compiler_runtime_libs: ?std.lang.Optimize = null, debug_compile_errors: bool = false, debug_incremental: bool = false, /// Normally when you create a `Compilation`, Zig will automatically build @@ -2160,7 +2160,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, .framework_dirs = options.framework_dirs, .rpath_list = options.rpath_list, .symbol_wrap_set = options.symbol_wrap_set, - .repro = options.linker_repro orelse (options.root_mod.optimize_mode != .Debug), + .repro = options.linker_repro orelse (options.root_mod.optimize_mode != .debug), .allow_shlib_undefined = options.linker_allow_shlib_undefined, .bind_global_refs_locally = options.linker_bind_global_refs_locally orelse false, .compress_debug_sections = options.linker_compress_debug_sections orelse .none, @@ -3189,8 +3189,8 @@ fn flush(comp: *Compilation, arena: Allocator) (Io.Cancelable || Allocator.Error break :p try p.toStringZ(arena); }, - .is_debug = comp.root_mod.optimize_mode == .Debug, - .is_small = comp.root_mod.optimize_mode == .ReleaseSmall, + .is_debug = comp.root_mod.optimize_mode == .debug, + .is_small = comp.root_mod.optimize_mode == .small, .time_report = if (comp.time_report) |*p| p else null, .sanitize_thread = comp.config.any_sanitize_thread, .fuzz = comp.config.any_fuzz, @@ -4744,7 +4744,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) SubU defer arena_allocator.deinit(); const arena = arena_allocator.allocator(); - const optimize_mode = std.lang.OptimizeMode.ReleaseSmall; + const optimize_mode: std.lang.Optimize = .small; const output_mode = std.lang.OutputMode.Exe; const resolved_target: Module.ResolvedTarget = .{ .result = std.zig.system.resolveTargetQuery(io, .{ @@ -5910,8 +5910,8 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 // them being defined matches the behavior of how MSVC calls rc.exe which is the more // relevant behavior in this case. switch (rc_src.owner.optimize_mode) { - .Debug, .ReleaseSafe => {}, - .ReleaseFast, .ReleaseSmall => try argv.append("-DNDEBUG"), + .debug, .safe => {}, + .fast, .small => try argv.append("-DNDEBUG"), } try argv.appendSlice(rc_src.extra_flags); try argv.appendSlice(&.{ "--", rc_src.src_path, out_res_path }); @@ -6178,11 +6178,11 @@ fn addCommonCCArgs( // LLVM IR files don't support these flags. if (ext != .ll and ext != .bc) { switch (mod.optimize_mode) { - .Debug => {}, - .ReleaseSafe => { + .debug => {}, + .safe => { try argv.append("-D_FORTIFY_SOURCE=2"); }, - .ReleaseFast, .ReleaseSmall => { + .fast, .small => { try argv.append("-DNDEBUG"); }, } @@ -6333,7 +6333,7 @@ fn addCommonCCArgs( } } - if (mod.optimize_mode != .Debug) { + if (mod.optimize_mode != .debug) { try argv.append("-Werror=date-time"); } }, @@ -6412,18 +6412,18 @@ fn addCommonCCArgs( } switch (mod.optimize_mode) { - .Debug => { + .debug => { // Clang has -Og for compatibility with GCC, but currently it is just equivalent // to -O1. Besides potentially impairing debugging, -O1/-Og significantly // increases compile times. try argv.append("-O0"); }, - .ReleaseSafe => { + .safe => { // See the comment in the BuildModeFastRelease case for why we pass -O2 rather // than -O3 here. try argv.append("-O2"); }, - .ReleaseFast => { + .fast => { // Here we pass -O2 rather than -O3 because, although we do the equivalent of // -O3 in Zig code, the justification for the difference here is that Zig // has better detection and prevention of undefined behavior, so -O3 is safer for @@ -6431,7 +6431,7 @@ fn addCommonCCArgs( // running in -O2 and thus the -O3 path has been tested less. try argv.append("-O2"); }, - .ReleaseSmall => { + .small => { try argv.append("-Os"); }, } @@ -7557,15 +7557,15 @@ 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.lang.OptimizeMode { +pub fn compilerRtOptMode(comp: Compilation) std.lang.Optimize { if (comp.debug_compiler_runtime_libs) |mode| { return mode; } const target = &comp.root_mod.resolved_target.result; switch (comp.root_mod.optimize_mode) { - .Debug, .ReleaseSafe => return target_util.defaultCompilerRtOptimizeMode(target), - .ReleaseFast => return .ReleaseFast, - .ReleaseSmall => return .ReleaseSmall, + .debug, .safe => return target_util.defaultCompilerRtOptimizeMode(target), + .fast => return .fast, + .small => return .small, } } diff --git a/src/Compilation/Config.zig b/src/Compilation/Config.zig index ad0d709425cfaccd284cd929bc7329604a325213..85915ded1b97d4e324a1cebbdb1385758ebea6f0 100644 --- a/src/Compilation/Config.zig +++ b/src/Compilation/Config.zig @@ -59,7 +59,7 @@ export_memory: bool, shared_memory: bool, is_test: bool, debug_format: DebugFormat, -root_optimize_mode: std.lang.OptimizeMode, +root_optimize_mode: std.lang.Optimize, root_strip: bool, root_error_tracing: bool, dll_export_fns: bool, @@ -80,7 +80,7 @@ pub const Options = struct { is_test: bool, have_zcu: bool, emit_bin: bool, - root_optimize_mode: ?std.lang.OptimizeMode = null, + root_optimize_mode: ?std.lang.Optimize = null, root_strip: ?bool = null, root_error_tracing: ?bool = null, link_mode: ?std.lang.LinkMode = null, @@ -196,7 +196,7 @@ pub fn resolve(options: Options) ResolveError!Config { break :b options.use_lib_llvm orelse true; }; - const root_optimize_mode = options.root_optimize_mode orelse .Debug; + const root_optimize_mode = options.root_optimize_mode orelse .debug; // Make a decision on whether to use Clang or Aro for translate-c and compiling C files. const c_frontend: CFrontend = b: { @@ -357,7 +357,7 @@ pub fn resolve(options: Options) ResolveError!Config { if (!use_lib_llvm and options.emit_bin) break :b false; // Prefer LLVM for release builds. - if (root_optimize_mode != .Debug) break :b true; + if (root_optimize_mode != .debug) break :b true; // load_dynamic_library standalone test not passing on this combination // https://github.com/ziglang/zig/issues/24080 @@ -486,7 +486,7 @@ pub fn resolve(options: Options) ResolveError!Config { const root_strip = b: { if (options.root_strip) |x| break :b x; - if (root_optimize_mode == .ReleaseSmall) break :b true; + if (root_optimize_mode == .small) break :b true; if (!target_util.hasDebugInfo(target)) break :b true; break :b false; }; @@ -512,8 +512,8 @@ pub fn resolve(options: Options) ResolveError!Config { if (root_strip) break :b false; if (!backend_supports_error_tracing) break :b false; break :b switch (root_optimize_mode) { - .Debug => true, - .ReleaseSafe, .ReleaseFast, .ReleaseSmall => false, + .debug => true, + .safe, .fast, .small => false, }; }; diff --git a/src/Module.zig b/src/Module.zig index c351d9eaf4bb29baa41306fa0b80cf3f42276e08..d245c0cf02f15bb7ed695dcac2914285c9debfb6 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -26,7 +26,7 @@ fully_qualified_name: []const u8, deps: Deps = .{}, resolved_target: ResolvedTarget, -optimize_mode: std.lang.OptimizeMode, +optimize_mode: std.lang.Optimize, code_model: std.lang.CodeModel, single_threaded: bool, error_tracing: bool, @@ -67,7 +67,7 @@ pub const CreateOptions = struct { pub const Inherited = struct { /// If this is null then `parent` must be non-null. resolved_target: ?ResolvedTarget = null, - optimize_mode: ?std.lang.OptimizeMode = null, + optimize_mode: ?std.lang.Optimize = null, code_model: ?std.lang.CodeModel = null, single_threaded: ?bool = null, error_tracing: ?bool = null, @@ -144,7 +144,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Module { if (options.inherited.valgrind) |x| break :b x; if (options.parent) |p| break :b p.valgrind; if (strip) break :b false; - break :b optimize_mode == .Debug; + break :b optimize_mode == .debug; }; const single_threaded = b: { @@ -212,7 +212,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Module { const omit_frame_pointer = b: { if (options.inherited.omit_frame_pointer) |x| break :b x; if (options.parent) |p| break :b p.omit_frame_pointer; - if (optimize_mode == .ReleaseSmall) { + if (optimize_mode == .small) { // On x86, in most cases, keeping the frame pointer usually results in smaller binary size. // This has to do with how instructions for memory access via the stack base pointer register (when keeping the frame pointer) // are smaller than instructions for memory access via the stack pointer register (when omitting the frame pointer). @@ -251,21 +251,21 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Module { }; const is_safe_mode = switch (optimize_mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; const sanitize_c: std.zig.SanitizeC = b: { if (options.inherited.sanitize_c) |x| break :b x; if (options.parent) |p| break :b p.sanitize_c; break :b switch (optimize_mode) { - .Debug => .full, + .debug => .full, // It's recommended to use the minimal runtime in production // environments due to the security implications of the full runtime. // The minimal runtime doesn't provide much benefit over simply // trapping, however, so we do that instead. - .ReleaseSafe => .trap, - .ReleaseFast, .ReleaseSmall => .off, + .safe => .trap, + .fast, .small => .off, }; }; diff --git a/src/Sema.zig b/src/Sema.zig index 20df87823ce2703925d26d0f5e7020415b00d7ce..6dafdeb0ee6c53fb6f116272e28c641239573cff 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -532,20 +532,20 @@ pub const Block = struct { fn wantSafeTypes(block: *const Block) bool { return block.want_safety orelse switch (block.ownerModule().optimize_mode) { - .Debug => true, - .ReleaseSafe => true, - .ReleaseFast => false, - .ReleaseSmall => false, + .debug => true, + .safe => true, + .fast => false, + .small => false, }; } fn wantSafety(block: *const Block) bool { if (block.isComptime()) return false; // runtime safety checks are pointless in comptime blocks return block.want_safety orelse switch (block.ownerModule().optimize_mode) { - .Debug => true, - .ReleaseSafe => true, - .ReleaseFast => false, - .ReleaseSmall => false, + .debug => true, + .safe => true, + .fast => false, + .small => false, }; } @@ -2247,7 +2247,7 @@ fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) ?Value { .inferred_alloc_comptime => unreachable, // assertion failure else => {}, } - // LLVM fails to eliminate this `classify` call in ReleaseFast, which hurts performance, so + // LLVM fails to eliminate this `classify` call in -Ofast, which hurts performance, so // we must explicitly check for `std.debug.runtime_safety`. if (std.debug.runtime_safety) switch (sema.typeOf(inst).classify(zcu)) { .no_possible_value => unreachable, // values of this type do not exist diff --git a/src/codegen/aarch64/Mir.zig b/src/codegen/aarch64/Mir.zig index 7b976acde1c5401ef294ede213416828c55d26a9..ad40e86902d4273b2b558fa1b1b97add12b29345 100644 --- a/src/codegen/aarch64/Mir.zig +++ b/src/codegen/aarch64/Mir.zig @@ -70,8 +70,8 @@ pub fn emit( const func_align = switch (nav.resolved.?.@"align") { .none => switch (mod.optimize_mode) { - .Debug, .ReleaseSafe, .ReleaseFast => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => target_util.minFunctionAlignment(target), + .debug, .safe, .fast => target_util.defaultFunctionAlignment(target), + .small => target_util.minFunctionAlignment(target), }, else => |a| a.maxStrict(target_util.minFunctionAlignment(target)), }; diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 0dc4ae6f3997ae55f4b068f725d5a02b3dea50a7..9ecd3a4e0b1f4483c878e056cf3786bccafed62b 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -453,8 +453,8 @@ pub const Function = struct { fn wantSafety(f: *Function) bool { return switch (f.dg.mod.optimize_mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; } @@ -1306,8 +1306,8 @@ pub const DeclGen = struct { }; const safety_on = switch (dg.mod.optimize_mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }; switch (ty.toIntern()) { diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index fc1c494828fc8d8f141be115c54231bcbe38814c..2405f51b3e90f9dab947bcef12f778445f2a3f64 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -653,7 +653,7 @@ pub const Object = struct { }), debug_enums_fwd_ref, debug_globals_fwd_ref, - .{ .optimized = comp.root_mod.optimize_mode != .Debug }, + .{ .optimized = comp.root_mod.optimize_mode != .debug }, ); try builder.addNamedMetadata(try builder.string("llvm.dbg.cu"), &.{debug_compile_unit}); @@ -1028,7 +1028,7 @@ pub const Object = struct { const optimize_mode = comp.root_mod.optimize_mode; - const opt_level: bindings.CodeGenOptLevel = if (optimize_mode == .Debug) + const opt_level: bindings.CodeGenOptLevel = if (optimize_mode == .debug) .None else .Aggressive; @@ -1299,7 +1299,7 @@ pub const Object = struct { .NoReturn = fn_info.return_type == .noreturn_type, }, .sp_flags = .{ - .Optimized = owner_mod.optimize_mode != .Debug, + .Optimized = owner_mod.optimize_mode != .debug, .Definition = true, .LocalToUnit = is_internal_linkage, }, @@ -2798,7 +2798,7 @@ pub const Object = struct { &o.builder, ); } - if (owner_mod.optimize_mode == .ReleaseSmall) { + if (owner_mod.optimize_mode == .small) { try attributes.addFnAttr(.minsize, &o.builder); try attributes.addFnAttr(.optsize, &o.builder); } diff --git a/src/codegen/llvm/FuncGen.zig b/src/codegen/llvm/FuncGen.zig index d8b8eede7c09febaf5485ef0c013fff94934d8ef..6e2d71994a6f67a10a9aa7723071c419cd1815e4 100644 --- a/src/codegen/llvm/FuncGen.zig +++ b/src/codegen/llvm/FuncGen.zig @@ -696,7 +696,7 @@ fn genBodyDebugScope( .{ .di_flags = .{ .StaticMember = true }, .sp_flags = .{ - .Optimized = mod.optimize_mode != .Debug, + .Optimized = mod.optimize_mode != .debug, .Definition = true, .LocalToUnit = true, // inline functions cannot be exported }, @@ -2516,7 +2516,7 @@ fn airDbgVarVal(self: *FuncGen, inst: Air.Inst.Index, is_arg: bool) Allocator.Er }, "", ); - } else if (owner_mod.optimize_mode == .Debug and !self.is_naked) { + } else if (owner_mod.optimize_mode == .debug and !self.is_naked) { // We avoid taking this path for naked functions because there's no guarantee that such // functions even have a valid stack pointer, making the `alloca` + `store` unsafe. @@ -4689,7 +4689,7 @@ fn airArg(self: *FuncGen, inst: Air.Inst.Index) Allocator.Error!Builder.Value { }, "", ); - } else if (mod.optimize_mode == .Debug) { + } else if (mod.optimize_mode == .debug) { const alloca = try self.buildZigAlloca(inst_ty, .none); try self.store(alloca, .none, arg_val, inst_ty, .normal); _ = try self.wip.callIntrinsic( @@ -4820,7 +4820,7 @@ fn airStore(fg: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error!Bu // unexpected call in the user's code. This is problematic if the code in question is // not ready to correctly make calls yet, such as in our early PIE startup code, or in // the early stages of a dynamic linker, etc. - if (!safety and owner_mod.optimize_mode == .Debug) { + if (!safety and owner_mod.optimize_mode == .debug) { return .none; } diff --git a/src/codegen/riscv64/CodeGen.zig b/src/codegen/riscv64/CodeGen.zig index 2b953f3bbef4ac4924b37ac4cb3d8f524b7bc9d9..4ee131d079c666a52516e480137782e44f45a553 100644 --- a/src/codegen/riscv64/CodeGen.zig +++ b/src/codegen/riscv64/CodeGen.zig @@ -8339,9 +8339,9 @@ fn resolveCallingConventionValues( fn wantSafety(func: *Func) bool { return switch (func.mod.optimize_mode) { .Debug => true, - .ReleaseSafe => true, - .ReleaseFast => false, - .ReleaseSmall => false, + .safe => true, + .fast => false, + .small => false, }; } diff --git a/src/codegen/sparc64/CodeGen.zig b/src/codegen/sparc64/CodeGen.zig index c5161485d377a68949901d6ed882346289a1c354..be9102f81ec684c11afe4cce59742823704b3175 100644 --- a/src/codegen/sparc64/CodeGen.zig +++ b/src/codegen/sparc64/CodeGen.zig @@ -4764,9 +4764,9 @@ fn truncRegister( fn wantSafety(self: *Self) bool { return switch (self.bin_file.comp.root_mod.optimize_mode) { .Debug => true, - .ReleaseSafe => true, - .ReleaseFast => false, - .ReleaseSmall => false, + .safe => true, + .fast => false, + .small => false, }; } diff --git a/src/codegen/wasm/Mir.zig b/src/codegen/wasm/Mir.zig index 454592c5d2198e14d895b2e19586775396ef5395..8e5f1c32f958d8ea2403ea2260a421da08e153c9 100644 --- a/src/codegen/wasm/Mir.zig +++ b/src/codegen/wasm/Mir.zig @@ -661,8 +661,8 @@ pub const Inst = struct { comptime { switch (builtin.mode) { - .Debug, .ReleaseSafe => {}, - .ReleaseFast, .ReleaseSmall => assert(@sizeOf(Data) == 4), + .debug, .safe => {}, + .fast, .small => assert(@sizeOf(Data) == 4), } } }; diff --git a/src/codegen/x86_64/CodeGen.zig b/src/codegen/x86_64/CodeGen.zig index 1b29b50549173fe0d0855f541238971f8fcba181..da0ace1f6dd5fe09e00eaf3c7e5b572de2d2e50a 100644 --- a/src/codegen/x86_64/CodeGen.zig +++ b/src/codegen/x86_64/CodeGen.zig @@ -182502,8 +182502,8 @@ fn hasFeature(cg: *CodeGen, feature: std.Target.x86.Feature) bool { .slow_unaligned_mem_16, .slow_unaligned_mem_32, => switch (cg.mod.optimize_mode) { - .Debug, .ReleaseSafe, .ReleaseFast => null, - .ReleaseSmall => false, + .debug, .safe, .fast => null, + .small => false, }, .fast_11bytenop, .fast_15bytenop, @@ -182523,8 +182523,8 @@ fn hasFeature(cg: *CodeGen, feature: std.Target.x86.Feature) bool { .fast_vector_fsqrt, .fast_vector_shift_masks, => switch (cg.mod.optimize_mode) { - .Debug, .ReleaseSafe, .ReleaseFast => null, - .ReleaseSmall => true, + .debug, .safe, .fast => null, + .small => true, }, .mmx => false, .sahf => switch (cg.target.cpu.arch) { diff --git a/src/libs/libcxx.zig b/src/libs/libcxx.zig index 502199a58fbee46259a18257192e97d79cab3678..4036cec8f6447425bd9c7e8eaba5c60e2b33a17c 100644 --- a/src/libs/libcxx.zig +++ b/src/libs/libcxx.zig @@ -539,15 +539,15 @@ pub fn addCxxArgs( // is simple and works everywhere. try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); switch (optimize_mode) { - .Debug => { + .debug => { try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG"); try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_ENFORCE"); }, - .ReleaseFast, .ReleaseSmall => { + .fast, .small => { try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE"); try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_IGNORE"); }, - .ReleaseSafe => { + .safe => { try cflags.append("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST"); try cflags.append("-D_LIBCPP_ASSERTION_SEMANTIC_DEFAULT=_LIBCPP_ASSERTION_SEMANTIC_ENFORCE"); }, diff --git a/src/libs/libunwind.zig b/src/libs/libunwind.zig index 82ef9c34bc3d76b5cdbf2306ff8faf2526f54cbb..46c4b0332aad75d110ab172ccc3209a8257c66b4 100644 --- a/src/libs/libunwind.zig +++ b/src/libs/libunwind.zig @@ -118,7 +118,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr // defines will be correct. try cflags.append("-D_LIBUNWIND_IS_NATIVE_ONLY"); - if (comp.root_mod.optimize_mode == .Debug) { + if (comp.root_mod.optimize_mode == .debug) { try cflags.append("-D_DEBUG"); } if (!comp.config.any_non_single_threaded) { diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 99257442052cea392327370ca91879be1371cb3c..224b5ec27b4c0e8dac994ec4a54f85a689a11449 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -135,8 +135,8 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre }); switch (comp.compilerRtOptMode()) { - .Debug, .ReleaseSafe => try winpthreads_args.append("-DWINPTHREAD_DBG"), - .ReleaseFast, .ReleaseSmall => {}, + .debug, .safe => try winpthreads_args.append("-DWINPTHREAD_DBG"), + .fast, .small => {}, } for (mingw32_winpthreads_src) |dep| { diff --git a/src/link/C.zig b/src/link/C.zig index ae8526aafefb5adbcff87d1a90f789653e9faa8a..a6830126fb2f048af065093adf6e99e2778e0c88 100644 --- a/src/link/C.zig +++ b/src/link/C.zig @@ -429,7 +429,7 @@ pub fn createEmpty( .tag = .c, .comp = comp, .emit = emit, - .gc_sections = options.gc_sections orelse (optimize_mode != .Debug and output_mode != .Obj), + .gc_sections = options.gc_sections orelse (optimize_mode != .debug and output_mode != .Obj), .print_gc_sections = options.print_gc_sections, .stack_size = options.stack_size orelse 16777216, .allow_shlib_undefined = options.allow_shlib_undefined orelse false, diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 136c1184f64554dfcee7d60c7e044d662a778d82..1f756a5bf1bfd130f2fdc62c7d990e1a9320ff62 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -5598,11 +5598,11 @@ fn updateFuncInner( const ni = try coff.mf.addLastChildNode(gpa, sec_si.node(coff), .{ .alignment = switch (nav.resolved.?.@"align") { .none => switch (mod.optimize_mode) { - .Debug, - .ReleaseSafe, - .ReleaseFast, + .debug, + .safe, + .fast, => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => target_util.minFunctionAlignment(target), + .small => target_util.minFunctionAlignment(target), }, else => |a| a.maxStrict(target_util.minFunctionAlignment(target)), }.toStdMem(), @@ -6649,11 +6649,11 @@ fn flushGlobal(coff: *Coff, gmi: Node.GlobalMapIndex) !bool { const target = &comp.root_mod.resolved_target.result; const alignment = switch (comp.root_mod.optimize_mode) { - .Debug, - .ReleaseSafe, - .ReleaseFast, + .debug, + .safe, + .fast, => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => target_util.minFunctionAlignment(target), + .small => target_util.minFunctionAlignment(target), }.toStdMem(); const parent_si = (try coff.pseudoSectionMapIndex( .@".thunks", diff --git a/src/link/Elf.zig b/src/link/Elf.zig index d0448f575793e6af830d9ae3b37cf3ca827a89bb..cda6d5321069bfe23b53efb10eb6dc6da8a0bc6d 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -260,7 +260,7 @@ pub fn createEmpty( .tag = .elf, .comp = comp, .emit = emit, - .gc_sections = options.gc_sections orelse (optimize_mode != .Debug and output_mode != .Obj), + .gc_sections = options.gc_sections orelse (optimize_mode != .debug and output_mode != .Obj), .print_gc_sections = options.print_gc_sections, .stack_size = options.stack_size orelse 16777216, .allow_shlib_undefined = options.allow_shlib_undefined orelse !is_native_os, diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 9c0d1202776faa558015eec68b86fe3d3bbbe407..cd3378c8d69f457bb45e028def978067a219196d 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -1299,7 +1299,7 @@ fn getNavShdrIndex( } if (nav_val.isUndef(zcu)) return switch (zcu.navFileScope(nav_index).mod.?.optimize_mode) { - .Debug, .ReleaseSafe => { + .debug, .safe => { if (self.data_index) |symbol_index| return self.symbol(symbol_index).outputShndx(elf_file).?; const osec = try elf_file.addSection(.{ @@ -1311,7 +1311,7 @@ fn getNavShdrIndex( self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec); return osec; }, - .ReleaseFast, .ReleaseSmall => { + .fast, .small => { if (self.bss_index) |symbol_index| return self.symbol(symbol_index).outputShndx(elf_file).?; const osec = try elf_file.addSection(.{ @@ -1374,8 +1374,8 @@ fn updateNavCode( const target = &mod.resolved_target.result; const required_alignment = switch (nav.resolved.?.@"align") { .none => switch (mod.optimize_mode) { - .Debug, .ReleaseSafe, .ReleaseFast => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => target_util.minFunctionAlignment(target), + .debug, .safe, .fast => target_util.defaultFunctionAlignment(target), + .small => target_util.minFunctionAlignment(target), }.maxStrict(Type.fromInterned(nav.resolved.?.type).abiAlignment(zcu)), else => |a| a.maxStrict(target_util.minFunctionAlignment(target)), }; diff --git a/src/link/Elf2.zig b/src/link/Elf2.zig index a3ef197aba481bfb355d2d913efffbede87c55ae..128dbe9edb835fdd75409ea96eeb646d60882ff2 100644 --- a/src/link/Elf2.zig +++ b/src/link/Elf2.zig @@ -4782,11 +4782,11 @@ fn navMapIndex(elf: *Elf, zcu: *Zcu, nav_index: InternPool.Nav.Index) Error!Node break :a switch (nav.resolved.?.@"align") { else => |a| a.maxStrict(min), .none => switch (mod.optimize_mode) { - .Debug, - .ReleaseSafe, - .ReleaseFast, + .debug, + .safe, + .fast, => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => min, + .small => min, }.maxStrict(Type.fromInterned(nav.resolved.?.type).abiAlignment(zcu)), }; }, diff --git a/src/link/Lld.zig b/src/link/Lld.zig index 715c0ba69f0c8f50ad6306ad7519c173a4d3dc0e..eaefd684d6f0582df96e1111033122290ee13297 100644 --- a/src/link/Lld.zig +++ b/src/link/Lld.zig @@ -208,8 +208,8 @@ pub fn createEmpty( const optimize_mode = comp.root_mod.optimize_mode; const gc_sections: bool = options.gc_sections orelse switch (target.ofmt) { - .coff => optimize_mode != .Debug, - .elf => optimize_mode != .Debug and output_mode != .Obj, + .coff => optimize_mode != .debug, + .elf => optimize_mode != .debug and output_mode != .Obj, .wasm => output_mode != .Obj, else => unreachable, }; @@ -456,9 +456,9 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { if (comp.config.lto != .none) { switch (optimize_mode) { - .Debug => {}, - .ReleaseSmall => try argv.append("-OPT:lldlto=2"), - .ReleaseFast, .ReleaseSafe => try argv.append("-OPT:lldlto=3"), + .debug => {}, + .small => try argv.append("-OPT:lldlto=2"), + .fast, .safe => try argv.append("-OPT:lldlto=3"), } } if (comp.config.output_mode == .Exe) { @@ -865,15 +865,15 @@ fn elfLink(lld: *Lld, arena: Allocator) !void { if (comp.config.lto != .none) { switch (comp.root_mod.optimize_mode) { - .Debug => {}, - .ReleaseSmall => try argv.append("--lto-O2"), - .ReleaseFast, .ReleaseSafe => try argv.append("--lto-O3"), + .debug => {}, + .small => try argv.append("--lto-O2"), + .fast, .safe => try argv.append("--lto-O3"), } } switch (comp.root_mod.optimize_mode) { - .Debug => {}, - .ReleaseSmall => try argv.append("-O2"), - .ReleaseFast, .ReleaseSafe => try argv.append("-O3"), + .debug => {}, + .small => try argv.append("-O2"), + .fast, .safe => try argv.append("-O3"), } if (elf.entry_name) |name| { @@ -1416,9 +1416,9 @@ fn wasmLink(lld: *Lld, arena: Allocator) !void { if (comp.config.lto != .none) { switch (comp.root_mod.optimize_mode) { - .Debug => {}, - .ReleaseSmall => try argv.append("-O2"), - .ReleaseFast, .ReleaseSafe => try argv.append("-O3"), + .debug => {}, + .small => try argv.append("-O2"), + .fast, .safe => try argv.append("-O3"), } } diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 41d0c4fd5dc7a7854585b0a0d335c87a608e876c..543d803b11286b8a22155ba80d785012d9f49363 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -181,7 +181,7 @@ pub fn createEmpty( .tag = .macho, .comp = comp, .emit = emit, - .gc_sections = options.gc_sections orelse (optimize_mode != .Debug), + .gc_sections = options.gc_sections orelse (optimize_mode != .debug), .print_gc_sections = options.print_gc_sections, .stack_size = options.stack_size orelse 16777216, .allow_shlib_undefined = allow_shlib_undefined, diff --git a/src/link/MachO/ZigObject.zig b/src/link/MachO/ZigObject.zig index 8d7407a0a397e9f4f0df654ef4eb45fe19e0e108..71a4bc6dc70c0465a079f035d459a07d8720ceed 100644 --- a/src/link/MachO/ZigObject.zig +++ b/src/link/MachO/ZigObject.zig @@ -946,8 +946,8 @@ fn updateNavCode( const target = &mod.resolved_target.result; const required_alignment = switch (nav.resolved.?.@"align") { .none => switch (mod.optimize_mode) { - .Debug, .ReleaseSafe, .ReleaseFast => target_util.defaultFunctionAlignment(target), - .ReleaseSmall => target_util.minFunctionAlignment(target), + .debug, .safe, .fast => target_util.defaultFunctionAlignment(target), + .small => target_util.minFunctionAlignment(target), }, else => |a| a.maxStrict(target_util.minFunctionAlignment(target)), }; @@ -1172,8 +1172,8 @@ fn getNavOutputSection( if (nav.resolved.?.@"const") return macho_file.zig_const_sect_index.?; if (nav_val.isUndef(zcu)) return switch (zcu.navFileScope(nav_index).mod.?.optimize_mode) { - .Debug, .ReleaseSafe => macho_file.zig_data_sect_index.?, - .ReleaseFast, .ReleaseSmall => macho_file.zig_bss_sect_index.?, + .debug, .safe => macho_file.zig_data_sect_index.?, + .fast, .small => macho_file.zig_bss_sect_index.?, }; for (code) |byte| { if (byte != 0) break; diff --git a/src/main.zig b/src/main.zig index 4fe6de03247578285c251daed3eb8d3982ac5dca..94011c81f9215df1da00328f221c41e42b9bc214 100644 --- a/src/main.zig +++ b/src/main.zig @@ -44,9 +44,9 @@ pub const std_options: std.Options = .{ .logFn = log, .log_level = switch (builtin.mode) { - .Debug => .debug, - .ReleaseSafe, .ReleaseFast => .info, - .ReleaseSmall => .err, + .debug => .debug, + .safe, .fast => .info, + .small => .err, }, }; pub const std_options_cwd = if (native_os == .wasi) wasi_cwd else null; @@ -158,8 +158,8 @@ pub fn log( const use_safe_allocator = build_options.debug_gpa or (native_os != .wasi and !builtin.link_libc and switch (builtin.mode) { - .Debug, .ReleaseSafe => true, - .ReleaseFast, .ReleaseSmall => false, + .debug, .safe => true, + .fast, .small => false, }); var safe_allocator: std.heap.SafeAllocator = .init(std.heap.page_allocator, .{ @@ -360,7 +360,7 @@ fn mainArgs( .prepend_zig_exe_path = true, .prepend_seed = true, .debug_env_var = .ZIG_DEBUG_MAKER, - .release_mode = .ReleaseSafe, + .release_mode = .safe, }); }, .clang, .@"-cc1", .@"-cc1as" => { @@ -568,10 +568,10 @@ const usage_build_generic = \\Per-Module Compile Options: \\ -target [name] -- see the targets command \\ -O [mode] Choose what to optimize for - \\ Debug (default) Optimizations off, safety on - \\ ReleaseFast Optimize for performance, safety off - \\ ReleaseSafe Optimize for performance, safety on - \\ ReleaseSmall Optimize for small binary, safety off + \\ debug (default) Prioritize bug detection, accurate debug info, compilation speed + \\ fast Prioritize runtime performance. Safety checks off. + \\ safe Enable both safety checks and machine code optimizations + \\ small Prioritize small binary size. Safety checks off. \\ -ofmt=[fmt] Override target object format \\ elf Executable and Linking Format \\ c C source code @@ -994,7 +994,7 @@ fn buildOutputType( var minor_subsystem_version: ?u16 = null; var mingw_unicode_entry_point: bool = false; var enable_link_snapshots: bool = false; - var debug_compiler_runtime_libs: ?std.lang.OptimizeMode = null; + var debug_compiler_runtime_libs: ?std.lang.Optimize = null; var install_name: ?[]const u8 = null; var hash_style: link.File.Lld.Elf.HashStyle = .both; var entitlements: ?[]const u8 = null; @@ -1433,7 +1433,7 @@ fn buildOutputType( enable_link_snapshots = true; } } else if (mem.eql(u8, arg, "--debug-rt")) { - debug_compiler_runtime_libs = .Debug; + debug_compiler_runtime_libs = .debug; } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| { debug_compiler_runtime_libs = parseOptimizeMode(rest); } else if (mem.eql(u8, arg, "--debug-incremental")) { @@ -2271,18 +2271,18 @@ fn buildOutputType( if (mem.eql(u8, level, "s") or mem.eql(u8, level, "z")) { - mod_opts.optimize_mode = .ReleaseSmall; + mod_opts.optimize_mode = .small; } else if (mem.eql(u8, level, "1") or mem.eql(u8, level, "2") or mem.eql(u8, level, "3") or mem.eql(u8, level, "4") or mem.eql(u8, level, "fast")) { - mod_opts.optimize_mode = .ReleaseFast; + mod_opts.optimize_mode = .fast; } else if (mem.eql(u8, level, "g") or mem.eql(u8, level, "0")) { - mod_opts.optimize_mode = .Debug; + mod_opts.optimize_mode = .debug; } else { try cc_argv.appendSlice(arena, it.other_args); } @@ -2356,9 +2356,9 @@ fn buildOutputType( // `sanitize_c` will resolve to! So we either have to pick `off` or `full`. // // `full` has the potential to be problematic if `optimize_mode` turns out to - // be `ReleaseFast`/`ReleaseSmall` because the user will get a slower and larger + // be `fast`/`small` because the user will get a slower and larger // binary than expected. On the other hand, if `optimize_mode` turns out to be - // `Debug`/`ReleaseSafe`, `off` would mean UBSan would unexpectedly be disabled. + // `debug`/`safe`, `off` would mean UBSan would unexpectedly be disabled. // // `off` seems very slightly less bad, so let's go with that. mod_opts.sanitize_c = .off; @@ -2972,8 +2972,8 @@ fn buildOutputType( } if (mod_opts.sanitize_c) |wsc| { - if (wsc != .off and mod_opts.optimize_mode == .ReleaseFast) { - mod_opts.optimize_mode = .ReleaseSafe; + if (wsc != .off and mod_opts.optimize_mode == .fast) { + mod_opts.optimize_mode = .safe; } } @@ -4875,7 +4875,7 @@ const JitCmdOptions = struct { /// Send error bundles via std.zig.Server over stdout server: bool = false, debug_env_var: EnvVar = .ZIG_DEBUG_CMD, - release_mode: std.lang.OptimizeMode = .ReleaseFast, + release_mode: std.lang.Optimize = .fast, }; fn jitCmd( @@ -4926,11 +4926,11 @@ fn jitCmdInner( const self_exe_path = process.executablePathAlloc(io, arena) catch |err| fatal("unable to find self exe path: {t}", .{err}); - const optimize_mode: std.lang.OptimizeMode = if (options.debug_env_var.isSet(environ_map)) - .Debug + const optimize_mode: std.lang.Optimize = if (options.debug_env_var.isSet(environ_map)) + .debug else options.release_mode; - const strip = optimize_mode != .Debug; + const strip = optimize_mode != .debug; var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map); const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); @@ -6008,9 +6008,8 @@ fn parseRcIncludes(arg: []const u8) std.zig.RcIncludes { fatal("unsupported rc includes type: {q}", .{arg}); } -fn parseOptimizeMode(s: []const u8) std.lang.OptimizeMode { - return stringToEnum(std.lang.OptimizeMode, s) orelse - fatal("unrecognized optimization mode: {q}", .{s}); +fn parseOptimizeMode(s: []const u8) std.lang.Optimize { + return std.lang.Optimize.fromString(s) orelse fatal("unrecognized optimization mode: {q}", .{s}); } fn parseWasiExecModel(s: []const u8) std.lang.WasiExecModel { diff --git a/src/target.zig b/src/target.zig index ca3b3d93de1a74114d621c8065e96d561e413dc8..0ed4053701fd696db7540b42dbf5aaf890e47921 100644 --- a/src/target.zig +++ b/src/target.zig @@ -357,12 +357,12 @@ pub fn libcProvidesStackProtector(target: *const std.Target) bool { /// Returns true if `@returnAddress()` is supported by the target and has a /// reasonably performant implementation for the requested optimization mode. -pub fn supportsReturnAddress(target: *const std.Target, optimize: std.lang.OptimizeMode) bool { +pub fn supportsReturnAddress(target: *const std.Target, optimize: std.lang.Optimize) bool { return switch (target.cpu.arch) { // Emscripten currently implements `emscripten_return_address()` by calling // out into JavaScript and parsing a stack trace, which introduces significant // overhead that we would prefer to avoid in release builds. - .wasm32, .wasm64 => target.os.tag == .emscripten and optimize == .Debug, + .wasm32, .wasm64 => target.os.tag == .emscripten and optimize == .debug, .bpfel, .bpfeb => false, .spirv32, .spirv64 => false, else => true, @@ -417,11 +417,11 @@ pub fn hasDebugInfo(target: *const std.Target) bool { }; } -pub fn defaultCompilerRtOptimizeMode(target: *const std.Target) std.lang.OptimizeMode { +pub fn defaultCompilerRtOptimizeMode(target: *const std.Target) std.lang.Optimize { if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) { - return .ReleaseSmall; + return .small; } else { - return .ReleaseFast; + return .fast; } } diff --git a/test/behavior/cast.zig b/test/behavior/cast.zig index 192afbe68d030d894827f1b0caa642ba8f79ff0c..d13fc8e83d36590bb20b329f3accd39eae411a4d 100644 --- a/test/behavior/cast.zig +++ b/test/behavior/cast.zig @@ -498,7 +498,7 @@ test "array coercion to undefined at runtime" { @setRuntimeSafety(true); - if (builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.mode != .debug and builtin.mode != .safe) { return error.SkipZigTest; } diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 780ed846d34a1f4cc45f6fa40467b97e93a2cdb0..76b21b6f15316a95c3ee6d98a759ff06e8c03715 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -1678,7 +1678,7 @@ test "runtime isNan(inf * 0)" { test "optimized float mode" { if (builtin.zig_backend != .stage2_llvm) return error.SkipZigTest; - if (builtin.mode == .Debug) return error.SkipZigTest; + if (builtin.mode == .debug) return error.SkipZigTest; const big = 0x1p40; const small = 0.001; diff --git a/test/behavior/int128.zig b/test/behavior/int128.zig index ce69d80522516c71cc586b84bb3784f0ba9c75e6..f02aed4f90c68d6676404aed8e728b2b9a4916ba 100644 --- a/test/behavior/int128.zig +++ b/test/behavior/int128.zig @@ -31,7 +31,7 @@ test "undefined 128 bit int" { @setRuntimeSafety(true); // TODO implement @setRuntimeSafety - if (builtin.mode != .Debug and builtin.mode != .ReleaseSafe) { + if (builtin.mode != .debug and builtin.mode != .safe) { return error.SkipZigTest; } diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 1fd570b4ed40b6a50d2085c8d65a32fa941b36fc..f9a48477a714b250696652184e1511ccf86bae28 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -16754,7 +16754,7 @@ test "CFF: Zig returns to C" { } test "CFF: C passes to Zig" { if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; - if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; + if (builtin.cpu.arch.isRISCV() and builtin.mode != .debug) return error.SkipZigTest; if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; @@ -16764,7 +16764,7 @@ test "CFF: C passes to Zig" { try expectOk(c_send_CFF()); } test "CFF: C returns to Zig" { - if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; + if (builtin.cpu.arch.isRISCV() and builtin.mode != .debug) return error.SkipZigTest; if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest; if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; @@ -16920,7 +16920,7 @@ extern fn c_f16_struct(f16_struct) f16_struct; test "f16 struct" { if (builtin.target.cpu.arch.isMIPS64()) return error.SkipZigTest; if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; - if (builtin.cpu.arch.isArm() and builtin.mode != .Debug) return error.SkipZigTest; + if (builtin.cpu.arch.isArm() and builtin.mode != .debug) return error.SkipZigTest; if (builtin.cpu.arch == .s390x) return error.SkipZigTest; if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; diff --git a/test/cases/compile_errors/invalid_member_of_builtin_enum.zig b/test/cases/compile_errors/invalid_member_of_builtin_enum.zig index 48f1012c1f6884d6a34c2255edd9e2924743c1b1..9902f027bf45c5db93744caa8242194df29a3f41 100644 --- a/test/cases/compile_errors/invalid_member_of_builtin_enum.zig +++ b/test/cases/compile_errors/invalid_member_of_builtin_enum.zig @@ -6,5 +6,5 @@ export fn entry() void { // error // -// :3:35: error: enum 'lang.OptimizeMode' has no member named 'x86' +// :3:35: error: enum 'lang.Optimize' has no member named 'x86' // : note: enum declared here diff --git a/test/src/ErrorTrace.zig b/test/src/ErrorTrace.zig index f6f80f8b138d2f7a663b4fe1d5d8d58bc8ef43de..c4150eded5d4b17fffc2a386d3c7b9411ded6665 100644 --- a/test/src/ErrorTrace.zig +++ b/test/src/ErrorTrace.zig @@ -60,9 +60,9 @@ fn addCaseConfig( const b = self.b; const error_tracing: bool = tracing: { - if (optimize == .Debug) break :tracing true; + if (optimize == .debug) break :tracing true; if (backend != .llvm) break :tracing true; - if (optimize == .ReleaseSmall) break :tracing false; + if (optimize == .small) break :tracing false; for (case.disable_trace_optimized) |disable| { const d_arch, const d_os = disable; if (target.result.cpu.arch == d_arch and target.result.os.tag == d_os) { diff --git a/test/standalone/dependency_options/build.zig b/test/standalone/dependency_options/build.zig index 8966920617d0a9bd1c851b96a83abc1e617e6ba0..f56bef5ae48942740f0a23161357876c3f70f7e9 100644 --- a/test/standalone/dependency_options/build.zig +++ b/test/standalone/dependency_options/build.zig @@ -11,11 +11,11 @@ pub fn build(b: *std.Build) !void { const none_specified_mod = none_specified.module("dummy"); if (!none_specified_mod.resolved_target.?.query.eql(b.graph.host.query)) return error.TestFailed; const expected_optimize: std.builtin.OptimizeMode = switch (b.graph.release_mode) { - .off => .Debug, + .off => .debug, .any => unreachable, - .fast => .ReleaseFast, - .safe => .ReleaseSafe, - .small => .ReleaseSmall, + .fast => .fast, + .safe => .safe, + .small => .small, }; if (none_specified_mod.optimize.? != expected_optimize) return error.TestFailed; @@ -44,7 +44,7 @@ pub fn build(b: *std.Build) !void { const all_specified = b.dependency("other", .{ .target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }), - .optimize = @as(std.builtin.OptimizeMode, .ReleaseSafe), + .optimize = @as(std.builtin.OptimizeMode, .safe), .bool = @as(bool, true), .int = @as(i64, 123), .float = @as(f64, 0.5), @@ -66,11 +66,11 @@ pub fn build(b: *std.Build) !void { if (all_specified_mod.resolved_target.?.result.cpu.arch != .x86_64) return error.TestFailed; if (all_specified_mod.resolved_target.?.result.os.tag != .windows) return error.TestFailed; if (all_specified_mod.resolved_target.?.result.abi != .gnu) return error.TestFailed; - if (all_specified_mod.optimize.? != .ReleaseSafe) return error.TestFailed; + if (all_specified_mod.optimize.? != .safe) return error.TestFailed; const all_specified_optional = b.dependency("other", .{ .target = @as(?std.Build.ResolvedTarget, b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu })), - .optimize = @as(?std.builtin.OptimizeMode, .ReleaseSafe), + .optimize = @as(?std.builtin.OptimizeMode, .safe), .bool = @as(?bool, true), .int = @as(?i64, 123), .float = @as(?f64, 0.5), @@ -92,7 +92,7 @@ pub fn build(b: *std.Build) !void { const all_specified_literal = b.dependency("other", .{ .target = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }), - .optimize = .ReleaseSafe, + .optimize = .safe, .bool = true, .int = 123, .float = 0.5, @@ -130,7 +130,7 @@ pub fn build(b: *std.Build) !void { // to the same cached dependency instance. const all_specified_alt = b.dependency("other", .{ .target = @as(std.Target.Query, .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .gnu }), - .optimize = "ReleaseSafe", + .optimize = "safe", .bool = .true, .int = "123", .float = @as(f16, 0.5), diff --git a/test/standalone/simple/build.zig b/test/standalone/simple/build.zig index af9da93a2b8a947ad9ccd72c547eb478217330f3..a61f2f1e975a1c3e46b1546791743842773e92de 100644 --- a/test/standalone/simple/build.zig +++ b/test/standalone/simple/build.zig @@ -13,26 +13,26 @@ pub fn build(b: *std.Build) void { var optimize_modes_buf: [4]std.builtin.OptimizeMode = undefined; var optimize_modes_len: usize = 0; if (!skip_debug) { - optimize_modes_buf[optimize_modes_len] = .Debug; + optimize_modes_buf[optimize_modes_len] = .debug; optimize_modes_len += 1; } if (!skip_release_safe) { - optimize_modes_buf[optimize_modes_len] = .ReleaseSafe; + optimize_modes_buf[optimize_modes_len] = .safe; optimize_modes_len += 1; } if (!skip_release_fast) { - optimize_modes_buf[optimize_modes_len] = .ReleaseFast; + optimize_modes_buf[optimize_modes_len] = .fast; optimize_modes_len += 1; } if (!skip_release_small) { - optimize_modes_buf[optimize_modes_len] = .ReleaseSmall; + optimize_modes_buf[optimize_modes_len] = .small; optimize_modes_len += 1; } const optimize_modes = optimize_modes_buf[0..optimize_modes_len]; for (cases) |case| { for (optimize_modes) |optimize| { - if (!case.all_modes and optimize != .Debug) continue; + if (!case.all_modes and optimize != .debug) continue; if (case.os_filter) |os_tag| { if (os_tag != builtin.os.tag) continue; } diff --git a/test/tests.zig b/test/tests.zig index 78f397d3f4e0c47053d98c5a51049a8dd7507fa9..9a11d7c496a5179e02c74969f4481034764baa55 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -23,7 +23,7 @@ pub const LinkContext = @import("src/Link.zig"); const ModuleTestTarget = struct { linkage: ?std.builtin.LinkMode = null, target: std.Target.Query = .{}, - optimize_mode: std.builtin.OptimizeMode = .Debug, + optimize_mode: std.builtin.OptimizeMode = .debug, link_libc: ?bool = null, single_threaded: ?bool = null, use_llvm: ?bool = null, @@ -57,38 +57,38 @@ const module_test_targets = blk: { }, .{ - .optimize_mode = .ReleaseFast, + .optimize_mode = .fast, }, .{ .link_libc = true, - .optimize_mode = .ReleaseFast, + .optimize_mode = .fast, }, .{ - .optimize_mode = .ReleaseFast, + .optimize_mode = .fast, .single_threaded = true, }, .{ - .optimize_mode = .ReleaseSafe, + .optimize_mode = .safe, }, .{ .link_libc = true, - .optimize_mode = .ReleaseSafe, + .optimize_mode = .safe, }, .{ - .optimize_mode = .ReleaseSafe, + .optimize_mode = .safe, .single_threaded = true, }, .{ - .optimize_mode = .ReleaseSmall, + .optimize_mode = .small, }, .{ .link_libc = true, - .optimize_mode = .ReleaseSmall, + .optimize_mode = .small, }, .{ - .optimize_mode = .ReleaseSmall, + .optimize_mode = .small, .single_threaded = true, }, @@ -200,7 +200,7 @@ const module_test_targets = blk: { // }, // .use_llvm = false, // .use_lld = false, - // .optimize_mode = .ReleaseFast, + // .optimize_mode = .fast, // .strip = true, // .skip_modules = &.{"std"}, // TODO get these passing //}, @@ -213,7 +213,7 @@ const module_test_targets = blk: { // }, // .use_llvm = false, // .use_lld = false, - // .optimize_mode = .ReleaseFast, + // .optimize_mode = .fast, // .strip = true, // .skip_modules = &.{"std"}, // TODO get these passing //}, @@ -1257,7 +1257,7 @@ const module_test_targets = blk: { // }, // .use_llvm = false, // .use_lld = false, - // .optimize_mode = .ReleaseFast, + // .optimize_mode = .fast, // .strip = true, //}, @@ -2063,7 +2063,7 @@ const c_abi_targets = blk: { const LinkTarget = struct { target: std.Target.Query = .{}, - optimize_mode: std.builtin.OptimizeMode = .Debug, + optimize_mode: std.builtin.OptimizeMode = .debug, link_libc: bool = false, use_llvm: bool = false, use_lld: bool = false, @@ -2368,7 +2368,7 @@ pub fn addStackTraceTests( .root_module = b.createModule(.{ .root_source_file = b.path("test/src/convert-stack-trace.zig"), .target = b.graph.host, - .optimize = .Debug, + .optimize = .debug, }), }); @@ -2422,7 +2422,7 @@ pub fn addErrorTraceTests( .root_module = b.createModule(.{ .root_source_file = b.path("test/src/convert-stack-trace.zig"), .target = b.graph.host, - .optimize = .Debug, + .optimize = .debug, }), }); @@ -2486,10 +2486,10 @@ pub fn addStandaloneTests( .enable_ios_sdk = enable_ios_sdk, .enable_macos_sdk = enable_macos_sdk, .enable_symlinks_windows = enable_symlinks_windows, - .simple_skip_debug = mem.indexOfScalar(OptimizeMode, optimize_modes, .Debug) == null, - .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSafe) == null, - .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseFast) == null, - .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSmall) == null, + .simple_skip_debug = mem.indexOfScalar(OptimizeMode, optimize_modes, .debug) == null, + .simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .safe) == null, + .simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .fast) == null, + .simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .small) == null, }); const test_cases_dep_step = test_cases_dep.builder.default_step; test_cases_dep_step.name = b.dupe(test_cases_dep_name); @@ -3057,7 +3057,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt if (use_llvm) |x| return x; if (query.ofmt == .c) return false; switch (optimize_mode) { - .Debug => {}, + .debug => {}, else => return true, } const cpu_arch = query.cpu_arch orelse builtin.cpu.arch; @@ -3314,7 +3314,7 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons .root_module = b.createModule(.{ .root_source_file = b.path("tools/incr-check.zig"), .target = b.graph.host, - .optimize = .Debug, + .optimize = .debug, }), }); diff --git a/tools/doctest.zig b/tools/doctest.zig index d1d7919a51f299ecea3914ac8307d6b6741723a6..fcd67e8458a31ea03323b87cbfb222fc31852f94 100644 --- a/tools/doctest.zig +++ b/tools/doctest.zig @@ -915,11 +915,11 @@ fn parseManifest(arena: Allocator, source_bytes: []const u8) !Code { while (it.next()) |prefixed_line| { const line = skipPrefix(prefixed_line); if (mem.startsWith(u8, line, "optimize=")) { - mode = std.meta.stringToEnum(std.builtin.OptimizeMode, line["optimize=".len..]) orelse - fatal("bad optimization mode line: '{s}'", .{line}); + mode = std.builtin.Optimize.fromString(line["optimize=".len..]) orelse + fatal("bad optimization mode line: {q}", .{line}); } else if (mem.startsWith(u8, line, "link_mode=")) { link_mode = std.meta.stringToEnum(std.builtin.LinkMode, line["link_mode=".len..]) orelse - fatal("bad link mode line: '{s}'", .{line}); + fatal("bad link mode line: {q}", .{line}); } else if (mem.startsWith(u8, line, "link_object=")) { try link_objects.append(arena, line["link_object=".len..]); } else if (mem.startsWith(u8, line, "additional_option=")) { diff --git a/tools/migrate_langref.zig b/tools/migrate_langref.zig index 2810bfd3eaa60752eaa075746d18735a441a2760..4c48113a8698f91067d5b7887adb3286df3bc351 100644 --- a/tools/migrate_langref.zig +++ b/tools/migrate_langref.zig @@ -319,7 +319,7 @@ fn walk(arena: Allocator, io: Io, tokenizer: *Tokenizer, out_dir: Dir, w: anytyp return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str}); } - var mode: std.builtin.OptimizeMode = .Debug; + var mode: std.builtin.OptimizeMode = .debug; var link_objects = std.array_list.Managed([]const u8).init(arena); var target_str: ?[]const u8 = null; var link_libc = false; @@ -403,7 +403,7 @@ fn walk(arena: Allocator, io: Io, tokenizer: *Tokenizer, out_dir: Dir, w: anytyp }, } - if (mode != .Debug) + if (mode != .debug) try code.print("// optimize={s}\n", .{@tagName(mode)}); for (link_objects.items) |link_object| { -- 2.54.0 From f2c2ee28cbb2aad3943a5726ea5d1dfa427c96af Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 19 Jul 2026 21:28:40 -0700 Subject: [PATCH 2/2] std.lang.Optimize: provide alternative to std.debug.runtime_safety --- lib/std/debug.zig | 13 ++++++------- lib/std/lang.zig | 9 +++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 8aaee0e29edaba4523a70710de7eca31cf0bc078..898ae314d9084e35fed670b03854959ec06beead 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -237,13 +237,12 @@ pub const Symbol = struct { }; }; -/// Deprecated because it returns the optimization mode of the standard -/// library, when the caller probably wants to use the optimization mode of -/// their own module. -pub const runtime_safety = switch (builtin.mode) { - .debug, .safe => true, - .fast, .small => false, -}; +/// Deprecated in favor of `std.lang.Optimize.runtimeSafety`, to be removed after 0.18.0 +/// +/// Returns whether the standard library has safety checks enabled. Callsites +/// likely would rather know whether their own module's optimization mode +/// (found via `@import("builtin").optimize`) has safety checks enabled. +pub const runtime_safety = builtin.mode.runtimeSafety(); /// Whether we can unwind the stack on this target, allowing capturing and/or printing the current /// stack trace. It is still legal to call `captureCurrentStackTrace`, `writeCurrentStackTrace`, and diff --git a/lib/std/lang.zig b/lib/std/lang.zig index daa2482eec7429bcd90a83ae2e2515681be29187..2f0868c39331456b03f055cafd8546f19ac51b07 100644 --- a/lib/std/lang.zig +++ b/lib/std/lang.zig @@ -144,6 +144,15 @@ pub const Optimize = enum { .{ "small", .small }, }).get(s); } + + /// Returns whether illegal behavior safety checks are enabled based on the + /// provided optimization mode. + pub fn runtimeSafety(o: @This()) bool { + return switch (o) { + .debug, .safe => true, + .fast, .small => false, + }; + } }; /// The calling convention of a function defines how arguments and return values are passed, as well -- 2.54.0