authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-14 15:05:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-14 15:05:24-07:00
log872800c0a5eecf5f919942dc35df7af7bd4b0be3
treecaaa8a1ef1b4a2176ea2a05c4106e14a430fe641
parentb8f1a054e7df7573cf3fb14e96e12581579b783e

langref: update optimization mode names


1 files changed, 31 insertions(+), 31 deletions(-)

doc/langref.html.in+31-31
......@@ -798,7 +798,7 @@
798798 value. Using this value would be a bug. The value will be unused, or overwritten before being used."
799799 </p>
800800 <p>
801 In {#link|Debug#} and {#link|ReleaseSafe#} mode, Zig writes {#syntax#}0xaa{#endsyntax#} bytes to undefined memory. This is to catch
801 In {#link|debug#} and {#link|safe#} mode, Zig writes {#syntax#}0xaa{#endsyntax#} bytes to undefined memory. This is to catch
802802 bugs early, and to help detect use of undefined memory in a debugger. However, this behavior is only an
803803 implementation feature, not a language semantic, so it is not guaranteed to be observable to code.
804804 </p>
......@@ -2854,11 +2854,11 @@ or
28542854 {#header_close#}
28552855 {#header_open|unreachable#}
28562856 <p>
2857 In {#link|Debug#} and {#link|ReleaseSafe#} mode
2857 In {#link|debug#} and {#link|safe#} mode
28582858 {#syntax#}unreachable{#endsyntax#} emits a call to {#syntax#}panic{#endsyntax#} with the message <code>reached unreachable code</code>.
28592859 </p>
28602860 <p>
2861 In {#link|ReleaseFast#} and {#link|ReleaseSmall#} mode, the optimizer uses the assumption that {#syntax#}unreachable{#endsyntax#} code
2861 In {#link|fast#} and {#link|small#} mode, the optimizer uses the assumption that {#syntax#}unreachable{#endsyntax#} code
28622862 will never be hit to perform optimizations.
28632863 </p>
28642864 {#header_open|Basics#}
......@@ -2871,7 +2871,7 @@ or
28712871 {#header_open|At Compile-Time#}
28722872 {#code|test_comptime_unreachable.zig#}
28732873
2874 {#see_also|Zig Test|Build Mode|comptime#}
2874 {#see_also|Zig Test|Optimization Mode|comptime#}
28752875 {#header_close#}
28762876 {#header_close#}
28772877 {#header_open|noreturn#}
......@@ -3094,7 +3094,7 @@ or
30943094 Here we know for sure that "1234" will parse successfully. So we put the
30953095 {#syntax#}unreachable{#endsyntax#} value on the right hand side.
30963096 {#syntax#}unreachable{#endsyntax#} invokes safety-checked {#link|Illegal Behavior#}, so
3097 in {#link|Debug#} and {#link|ReleaseSafe#}, triggers a safety panic by default. So, while
3097 in {#link|debug#} and {#link|safe#}, triggers a safety panic by default. So, while
30983098 we're debugging the application, if there <em>was</em> a surprise error here, the application
30993099 would crash appropriately.
31003100 </p>
......@@ -3187,7 +3187,7 @@ fn createFoo(param: i32) !Foo {
31873187 <li>These primitives give enough expressiveness that it's completely practical
31883188 to have failing to check for an error be a compile error. If you really want
31893189 to ignore the error, you can add {#syntax#}catch unreachable{#endsyntax#} and
3190 get the added benefit of crashing in Debug and ReleaseSafe modes if your assumption was wrong.
3190 get the added benefit of crashing in {#link|debug#} and {#link|safe#} modes if your assumption was wrong.
31913191 </li>
31923192 <li>
31933193 Since Zig understands error types, it can pre-weight branches in favor of
......@@ -3269,7 +3269,7 @@ fn createFoo(param: i32) !Foo {
32693269 to increase their development pace.
32703270 </p>
32713271 <p>
3272 Error Return Traces are enabled by default in {#link|Debug#} builds and disabled by default in {#link|ReleaseFast#}, {#link|ReleaseSafe#} and {#link|ReleaseSmall#} builds.
3272 Error Return Traces are enabled by default in {#link|debug#} builds and disabled by default in {#link|fast#}, {#link|safe#} and {#link|small#} builds.
32733273 </p>
32743274 <p>
32753275 There are a few ways to activate this error return tracing feature:
......@@ -3657,7 +3657,7 @@ void do_a_thing(struct Foo *foo) {
36573657 {#code|zero_bit_types.zig#}
36583658
36593659 <p>When this turns into machine code, there is no code generated in the
3660 body of {#syntax#}entry{#endsyntax#}, even in {#link|Debug#} mode. For example, on x86_64:</p>
3660 body of {#syntax#}entry{#endsyntax#}, even in {#link|debug#} mode. For example, on x86_64:</p>
36613661 <pre><code>0000000000000010 &lt;entry&gt;:
36623662 10: 55 push %rbp
36633663 11: 48 89 e5 mov %rsp,%rbp
......@@ -6022,15 +6022,15 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
60226022
60236023 {#header_close#}
60246024
6025 {#header_open|Build Mode#}
6025 {#header_open|Optimization Mode#}
60266026 <p>
6027 Zig has four build modes:
6027 Zig has four optimization modes:
60286028 </p>
60296029 <ul>
6030 <li>{#link|Debug#} (default)</li>
6031 <li>{#link|ReleaseFast#}</li>
6032 <li>{#link|ReleaseSafe#}</li>
6033 <li>{#link|ReleaseSmall#}</li>
6030 <li>{#link|debug#} (default)</li>
6031 <li>{#link|fast#}</li>
6032 <li>{#link|safe#}</li>
6033 <li>{#link|small#}</li>
60346034 </ul>
60356035 <p>
60366036 To add standard build options to a <code class="file">build.zig</code> file:
......@@ -6041,12 +6041,12 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
60416041 This causes these options to be available:
60426042 </p>
60436043 <dl>
6044 <dt><kbd>-Doptimize=Debug</kbd></dt><dd>Optimizations off and safety on (default)</dd>
6045 <dt><kbd>-Doptimize=ReleaseSafe</kbd></dt><dd>Optimizations on and safety on</dd>
6046 <dt><kbd>-Doptimize=ReleaseFast</kbd></dt><dd>Optimizations on and safety off</dd>
6047 <dt><kbd>-Doptimize=ReleaseSmall</kbd></dt><dd>Size optimizations on and safety off</dd>
6044 <dt><kbd>-Doptimize=debug</kbd></dt><dd>Optimizations off and safety on (default)</dd>
6045 <dt><kbd>-Doptimize=safe</kbd></dt><dd>Optimizations on and safety on</dd>
6046 <dt><kbd>-Doptimize=fast</kbd></dt><dd>Optimizations on and safety off</dd>
6047 <dt><kbd>-Doptimize=small</kbd></dt><dd>Size optimizations on and safety off</dd>
60486048 </dl>
6049 {#header_open|Debug#}
6049 {#header_open|debug#}
60506050 {#shell_samp#}$ zig build-exe example.zig{#end_shell_samp#}
60516051 <ul>
60526052 <li>Fast compilation speed</li>
......@@ -6056,8 +6056,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
60566056 <li>No reproducible build requirement</li>
60576057 </ul>
60586058 {#header_close#}
6059 {#header_open|ReleaseFast#}
6060 {#shell_samp#}$ zig build-exe example.zig -O ReleaseFast{#end_shell_samp#}
6059 {#header_open|fast#}
6060 {#shell_samp#}$ zig build-exe example.zig -Ofast{#end_shell_samp#}
60616061 <ul>
60626062 <li>Fast runtime performance</li>
60636063 <li>Safety checks disabled</li>
......@@ -6066,8 +6066,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
60666066 <li>Reproducible build</li>
60676067 </ul>
60686068 {#header_close#}
6069 {#header_open|ReleaseSafe#}
6070 {#shell_samp#}$ zig build-exe example.zig -O ReleaseSafe{#end_shell_samp#}
6069 {#header_open|safe#}
6070 {#shell_samp#}$ zig build-exe example.zig -Osafe{#end_shell_samp#}
60716071 <ul>
60726072 <li>Medium runtime performance</li>
60736073 <li>Safety checks enabled</li>
......@@ -6076,8 +6076,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
60766076 <li>Reproducible build</li>
60776077 </ul>
60786078 {#header_close#}
6079 {#header_open|ReleaseSmall#}
6080 {#shell_samp#}$ zig build-exe example.zig -O ReleaseSmall{#end_shell_samp#}
6079 {#header_open|small#}
6080 {#shell_samp#}$ zig build-exe example.zig -Osmall{#end_shell_samp#}
60816081 <ul>
60826082 <li>Medium runtime performance</li>
60836083 <li>Safety checks disabled</li>
......@@ -6122,7 +6122,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
61226122 </p>
61236123 <p>
61246124 Most Illegal Behavior is safety-checked. However, to facilitate optimizations, safety checks are disabled by default
6125 in the {#link|ReleaseFast#} and {#link|ReleaseSmall#} optimization modes. Safety checks can also be enabled or disabled
6125 in the {#link|fast#} and {#link|small#} optimization modes. Safety checks can also be enabled or disabled
61266126 on a per-block basis, overriding the default for the current optimization mode, using {#link|@setRuntimeSafety#}. When
61276127 safety checks are disabled, Safety-Checked Illegal Behavior behaves like Unchecked Illegal Behavior; that is, any behavior
61286128 may result from invoking it.
......@@ -6464,14 +6464,14 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
64646464 </li>
64656465 <li>
64666466 Finally, if none of the above apply, you need a general purpose allocator.
6467 If you are in Debug mode, {#syntax#}std.heap.DebugAllocator{#endsyntax#} is available as a
6467 If you are in {#link|debug#} mode, {#syntax#}std.heap.DebugAllocator{#endsyntax#} is available as a
64686468 function that takes a {#link|comptime#} {#link|struct#} of configuration options and returns a type.
64696469 Generally, you will set up exactly one in your main function, and
64706470 then pass it or sub-allocators around to various parts of your
64716471 application.
64726472 </li>
64736473 <li>
6474 If you are compiling in ReleaseFast mode, {#syntax#}std.heap.smp_allocator{#endsyntax#} is
6474 If you are compiling in {#link|fast#} mode, {#syntax#}std.heap.smp_allocator{#endsyntax#} is
64756475 a solid choice for a general purpose allocator.
64766476 </li>
64776477 <li>
......@@ -6611,7 +6611,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
66116611 Example of what is imported with {#syntax#}@import("builtin"){#endsyntax#}:
66126612 </p>
66136613 {#builtin#}
6614 {#see_also|Build Mode#}
6614 {#see_also|Optimization Mode#}
66156615 {#header_close#}
66166616 {#header_open|Compilation Model#}
66176617 <p>
......@@ -7803,8 +7803,8 @@ fn readU32Be() u32 {}
78037803 {#syntax#}unreachable{#endsyntax#} can be used to assert that control flow will never happen upon a particular location.
78047804 Depending on the build mode, {#syntax#}unreachable{#endsyntax#} may emit a panic.
78057805 <ul>
7806 <li>Emits a panic in {#syntax#}Debug{#endsyntax#} and {#syntax#}ReleaseSafe{#endsyntax#} mode, or when using <kbd>zig test</kbd>.</li>
7807 <li>Does not emit a panic in {#syntax#}ReleaseFast{#endsyntax#} and {#syntax#}ReleaseSmall{#endsyntax#} mode.</li>
7806 <li>Emits a panic in {#link|debug#} and {#link|safe#} mode, or when using <kbd>zig test</kbd>.</li>
7807 <li>Does not emit a panic in {#link|fast#} and {#link|small#} mode.</li>
78087808 <li>See also {#link|unreachable#}</li>
78097809 </ul>
78107810 </td>