| ... | @@ -1252,21 +1252,23 @@ pub const BranchHint = enum(u3) { | ... | @@ -1252,21 +1252,23 @@ pub const BranchHint = enum(u3) { |
| 1252 | unpredictable, | 1252 | unpredictable, |
| 1253 | }; | 1253 | }; |
| 1254 | | 1254 | |
| 1255 | /// This enum is set by the compiler and communicates which compiler backend is | 1255 | /// This enum is set by the compiler and communicates which compiler |
| 1256 | /// used to produce machine code. | 1256 | /// implementation is 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.** | | |
| 1260 | /// | 1257 | /// |
| 1261 | /// Avoid failing the compilation if the compiler backend does not match a | 1258 | /// In theory, Zig code should be agnostic to the backend that implements the |
| 1262 | /// whitelist of backends; rather one should detect that a known problem would | 1259 | /// language. The only reason to observe this value is to **work around |
| 1263 | /// occur in a blacklist of backends. | 1260 | /// problems with compiler implementations.** |
| 1264 | /// | 1261 | /// |
| 1265 | /// The enum is nonexhaustive so that alternate Zig language implementations may | 1262 | /// A common pitful is failing the compilation if the compiler backend does not |
| 1266 | /// choose a number as their tag (please use a random number generator rather | 1263 | /// match a whitelist of backends; a more resilient strategy is to detect that |
| 1267 | /// than a "cute" number) and codebases can interact with these values even if | 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 |
| 1268 | /// this upstream enum does not have a name for the number. Of course, upstream | 1269 | /// 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. |
| 1270 | /// | 1272 | /// |
| 1271 | /// This data structure is part of the Zig language specification. | 1273 | /// This data structure is part of the Zig language specification. |
| 1272 | pub const CompilerBackend = enum(u64) { | 1274 | pub const CompilerBackend = enum(u64) { |
| ... | @@ -1283,6 +1285,7 @@ pub const CompilerBackend = enum(u64) { | ... | @@ -1283,6 +1285,7 @@ pub const CompilerBackend = enum(u64) { |
| 1283 | stage2_llvm = 2, | 1285 | stage2_llvm = 2, |
| 1284 | /// The reference implementation self-hosted compiler of Zig, using the | 1286 | /// The reference implementation self-hosted compiler of Zig, using the |
| 1285 | /// backend that generates C source code. | 1287 | /// backend that generates C source code. |
| | 1288 | /// |
| 1286 | /// Note that one can observe whether the compilation will output C code | 1289 | /// Note that one can observe whether the compilation will output C code |
| 1287 | /// directly with `object_format` value rather than the `compiler_backend` value. | 1290 | /// directly with `object_format` value rather than the `compiler_backend` value. |
| 1288 | stage2_c = 3, | 1291 | stage2_c = 3, |