authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-11 20:50:51-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-11 20:51:12-07:00
log89e0881f11c8fdb2dd981c4198618d071d323026
tree4d610eb087571299a30eb956d7e0023a56008c4b
parentac8a8d0c5996bbf627438768e3c23154a6404183

remove bad advice from `@import("builtin")`

also update doc comments on `std.lang.CompilerBackend`.

2 files changed, 15 insertions(+), 14 deletions(-)

lib/std/lang.zig+15-12
......@@ -1252,21 +1252,23 @@ pub const BranchHint = enum(u3) {
12521252 unpredictable,
12531253};
12541254
1255/// This enum is set by the compiler and communicates which compiler backend is
1256/// used to produce machine code.
1257/// Think carefully before deciding to observe this value. Nearly all code should
1258/// be agnostic to the backend that implements the language. The use case
1259/// to use this value is to **work around problems with compiler implementations.**
1255/// This enum is set by the compiler and communicates which compiler
1256/// implementation is used to produce machine code.
12601257///
1261/// Avoid failing the compilation if the compiler backend does not match a
1262/// whitelist of backends; rather one should detect that a known problem would
1263/// occur in a blacklist of backends.
1258/// In theory, Zig code should be agnostic to the backend that implements the
1259/// language. The only reason to observe this value is to **work around
1260/// problems with compiler implementations.**
12641261///
1265/// The enum is nonexhaustive so that alternate Zig language implementations may
1266/// choose a number as their tag (please use a random number generator rather
1267/// than a "cute" number) and codebases can interact with these values even if
1262/// A common pitful is failing the compilation if the compiler backend does not
1263/// match a whitelist of backends; a more resilient strategy is to detect that
1264/// a known problem would occur in a blacklist of backends.
1265///
1266/// The enum is nonexhaustive so that alternate Zig language implementations
1267/// may choose a random number as their tag, thereby avoiding conflicts with
1268/// other implementations, and codebases can interact with these values even if
12681269/// this upstream enum does not have a name for the number. Of course, upstream
1269/// is happy to accept pull requests to add Zig implementations to this enum.
1270/// is happy to accept patches to add additional Zig implementations to this
1271/// enum.
12701272///
12711273/// This data structure is part of the Zig language specification.
12721274pub const CompilerBackend = enum(u64) {
......@@ -1283,6 +1285,7 @@ pub const CompilerBackend = enum(u64) {
12831285 stage2_llvm = 2,
12841286 /// The reference implementation self-hosted compiler of Zig, using the
12851287 /// backend that generates C source code.
1288 ///
12861289 /// Note that one can observe whether the compilation will output C code
12871290 /// directly with `object_format` value rather than the `compiler_backend` value.
12881291 stage2_c = 3,
src/Builtin.zig-2
......@@ -53,8 +53,6 @@ pub fn append(opts: @This(), buffer: *std.array_list.Managed(u8)) Allocator.Erro
5353 @setEvalBranchQuota(4000);
5454 try buffer.print(
5555 \\const std = @import("std");
56 \\/// Zig version. When writing code that supports multiple versions of Zig, prefer
57 \\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
5856 \\pub const zig_version = std.SemanticVersion.parse(zig_version_string) catch unreachable;
5957 \\pub const zig_version_string = "{s}";
6058 \\pub const zig_backend = std.lang.CompilerBackend.{f};