@zigc/lib 0.16.0-test.1 → 0.17.0-dev.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/LICENSE +19 -0
  2. package/c/fcntl.zig +6 -1
  3. package/c/inttypes.zig +0 -10
  4. package/c/math.zig +138 -114
  5. package/c/pthread.zig +57 -0
  6. package/c/search.zig +1 -27
  7. package/c/stdlib/drand48.zig +0 -57
  8. package/c/stdlib.zig +0 -100
  9. package/c/string.zig +20 -7
  10. package/c/strings.zig +0 -38
  11. package/c/stropts.zig +17 -0
  12. package/c/unistd.zig +27 -26
  13. package/c/wchar.zig +10 -0
  14. package/c.zig +3 -2
  15. package/compiler/aro/aro/Attribute/names.zig +604 -589
  16. package/compiler/aro/aro/Attribute.zig +202 -116
  17. package/compiler/aro/aro/Builtins/common.zig +874 -863
  18. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  19. package/compiler/aro/aro/Builtins.zig +0 -1
  20. package/compiler/aro/aro/CodeGen.zig +8 -7
  21. package/compiler/aro/aro/Compilation.zig +137 -111
  22. package/compiler/aro/aro/Diagnostics.zig +21 -17
  23. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  24. package/compiler/aro/aro/Driver.zig +138 -63
  25. package/compiler/aro/aro/LangOpts.zig +12 -2
  26. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  27. package/compiler/aro/aro/Parser.zig +352 -153
  28. package/compiler/aro/aro/Pragma.zig +3 -2
  29. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  30. package/compiler/aro/aro/Preprocessor.zig +136 -62
  31. package/compiler/aro/aro/Target.zig +17 -12
  32. package/compiler/aro/aro/Tokenizer.zig +31 -14
  33. package/compiler/aro/aro/Toolchain.zig +4 -7
  34. package/compiler/aro/aro/Tree.zig +178 -148
  35. package/compiler/aro/aro/TypeStore.zig +82 -24
  36. package/compiler/aro/aro/Value.zig +13 -17
  37. package/compiler/aro/aro/features.zig +1 -0
  38. package/compiler/aro/aro/pragmas/message.zig +3 -2
  39. package/compiler/aro/aro/pragmas/once.zig +0 -1
  40. package/compiler/aro/aro/record_layout.zig +3 -3
  41. package/compiler/aro/aro/text_literal.zig +3 -2
  42. package/compiler/aro/assembly_backend/x86_64.zig +7 -8
  43. package/compiler/aro/backend/Assembly.zig +1 -2
  44. package/compiler/aro/backend/Interner.zig +2 -2
  45. package/compiler/aro/backend/Ir.zig +100 -92
  46. package/compiler/aro/include/ptrcheck.h +49 -0
  47. package/compiler/aro/main.zig +26 -10
  48. package/compiler/build_runner.zig +1 -2
  49. package/compiler/objdump.zig +93 -0
  50. package/compiler/reduce/Walk.zig +7 -7
  51. package/compiler/reduce.zig +5 -1
  52. package/compiler/resinator/compile.zig +2 -2
  53. package/compiler/resinator/main.zig +7 -1
  54. package/compiler/resinator/preprocess.zig +1 -3
  55. package/compiler/std-docs.zig +8 -1
  56. package/compiler/test_runner.zig +194 -62
  57. package/compiler/translate-c/MacroTranslator.zig +80 -11
  58. package/compiler/translate-c/PatternList.zig +1 -9
  59. package/compiler/translate-c/Scope.zig +43 -6
  60. package/compiler/translate-c/Translator.zig +369 -127
  61. package/compiler/translate-c/ast.zig +19 -11
  62. package/compiler/translate-c/main.zig +76 -17
  63. package/compiler_rt/cos.zig +140 -53
  64. package/compiler_rt/divmodei4.zig +40 -17
  65. package/compiler_rt/exp.zig +1 -6
  66. package/compiler_rt/exp2.zig +1 -6
  67. package/compiler_rt/exp_f128.zig +377 -0
  68. package/compiler_rt/fabs.zig +0 -2
  69. package/compiler_rt/fma.zig +0 -2
  70. package/compiler_rt/fmax.zig +0 -2
  71. package/compiler_rt/fmin.zig +0 -2
  72. package/compiler_rt/fmod.zig +0 -2
  73. package/compiler_rt/limb64.zig +1127 -0
  74. package/compiler_rt/log.zig +0 -2
  75. package/compiler_rt/log10.zig +0 -2
  76. package/compiler_rt/log2.zig +0 -2
  77. package/compiler_rt/long_double.zig +37 -0
  78. package/compiler_rt/mulXi3.zig +1 -1
  79. package/compiler_rt/mulo.zig +6 -1
  80. package/compiler_rt/rem_pio2l.zig +173 -0
  81. package/compiler_rt/round.zig +0 -2
  82. package/compiler_rt/sin.zig +139 -56
  83. package/compiler_rt/sincos.zig +277 -72
  84. package/compiler_rt/sqrt.zig +0 -2
  85. package/compiler_rt/ssp.zig +1 -1
  86. package/compiler_rt/tan.zig +117 -48
  87. package/compiler_rt/trig.zig +256 -6
  88. package/compiler_rt/trunc.zig +0 -2
  89. package/compiler_rt/udivmodei4.zig +28 -0
  90. package/compiler_rt.zig +2 -0
  91. package/fuzzer.zig +857 -307
  92. package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
  93. package/libc/musl/src/math/pow.c +343 -0
  94. package/package.json +1 -1
  95. package/std/Build/Cache.zig +6 -6
  96. package/std/Build/Fuzz.zig +6 -19
  97. package/std/Build/Module.zig +1 -1
  98. package/std/Build/Step/CheckObject.zig +3 -3
  99. package/std/Build/Step/Compile.zig +18 -1
  100. package/std/Build/Step/ConfigHeader.zig +49 -33
  101. package/std/Build/Step/InstallArtifact.zig +18 -0
  102. package/std/Build/Step/Run.zig +538 -89
  103. package/std/Build/Step/TranslateC.zig +0 -6
  104. package/std/Build/Step.zig +10 -19
  105. package/std/Build/WebServer.zig +31 -19
  106. package/std/Build/abi.zig +47 -11
  107. package/std/Build.zig +17 -17
  108. package/std/Io/Dir.zig +7 -2
  109. package/std/Io/Dispatch.zig +5 -13
  110. package/std/Io/File/Reader.zig +3 -1
  111. package/std/Io/File/Writer.zig +8 -6
  112. package/std/Io/File.zig +1 -0
  113. package/std/Io/Kqueue.zig +2 -2
  114. package/std/Io/Reader.zig +8 -9
  115. package/std/Io/Semaphore.zig +112 -17
  116. package/std/Io/Terminal.zig +1 -1
  117. package/std/Io/Threaded.zig +352 -180
  118. package/std/Io/Uring.zig +15 -16
  119. package/std/Io/Writer.zig +46 -42
  120. package/std/Io/net.zig +11 -11
  121. package/std/Io.zig +1052 -20
  122. package/std/SemanticVersion.zig +1 -1
  123. package/std/Target/Query.zig +2 -2
  124. package/std/Target.zig +53 -7
  125. package/std/Thread.zig +8 -3
  126. package/std/array_hash_map.zig +105 -573
  127. package/std/array_list.zig +22 -31
  128. package/std/bit_set.zig +22 -6
  129. package/std/builtin/assembly.zig +68 -0
  130. package/std/builtin.zig +4 -0
  131. package/std/c/haiku.zig +3 -0
  132. package/std/c/serenity.zig +1 -6
  133. package/std/c.zig +106 -24
  134. package/std/compress/flate/Compress.zig +3 -3
  135. package/std/compress/flate/Decompress.zig +2 -3
  136. package/std/compress/zstd/Decompress.zig +2 -4
  137. package/std/crypto/Certificate/Bundle.zig +15 -1
  138. package/std/crypto/Certificate.zig +13 -1
  139. package/std/crypto/ascon.zig +75 -33
  140. package/std/crypto/codecs/asn1/Oid.zig +12 -1
  141. package/std/crypto/codecs/asn1.zig +33 -18
  142. package/std/crypto/codecs/base64_hex_ct.zig +16 -8
  143. package/std/crypto/ml_kem.zig +2 -9
  144. package/std/crypto/tls/Client.zig +79 -4
  145. package/std/crypto/tls.zig +1 -1
  146. package/std/crypto.zig +1 -0
  147. package/std/debug/Dwarf.zig +29 -9
  148. package/std/debug/Info.zig +4 -0
  149. package/std/debug/MachOFile.zig +46 -8
  150. package/std/debug/Pdb.zig +540 -37
  151. package/std/debug/SelfInfo/Elf.zig +19 -18
  152. package/std/debug/SelfInfo/MachO.zig +18 -7
  153. package/std/debug/SelfInfo/Windows.zig +138 -36
  154. package/std/debug.zig +181 -66
  155. package/std/enums.zig +25 -19
  156. package/std/fmt.zig +8 -3
  157. package/std/fs/path.zig +6 -4
  158. package/std/heap/ArenaAllocator.zig +145 -154
  159. package/std/heap/BufferFirstAllocator.zig +165 -0
  160. package/std/heap/debug_allocator.zig +7 -7
  161. package/std/heap.zig +2 -126
  162. package/std/http/Client.zig +31 -30
  163. package/std/http.zig +14 -13
  164. package/std/json/Scanner.zig +2 -2
  165. package/std/json/Stringify.zig +3 -3
  166. package/std/json/dynamic.zig +4 -4
  167. package/std/math/big/int.zig +16 -17
  168. package/std/mem/Allocator.zig +4 -5
  169. package/std/mem.zig +48 -0
  170. package/std/os/emscripten.zig +2 -18
  171. package/std/os/linux/IoUring.zig +2 -0
  172. package/std/os/linux/aarch64.zig +41 -12
  173. package/std/os/linux/arc.zig +173 -0
  174. package/std/os/linux/arm.zig +41 -12
  175. package/std/os/linux/hexagon.zig +33 -11
  176. package/std/os/linux/loongarch32.zig +41 -13
  177. package/std/os/linux/loongarch64.zig +41 -12
  178. package/std/os/linux/m68k.zig +41 -13
  179. package/std/os/linux/mips.zig +67 -36
  180. package/std/os/linux/mips64.zig +60 -29
  181. package/std/os/linux/mipsn32.zig +60 -29
  182. package/std/os/linux/or1k.zig +41 -12
  183. package/std/os/linux/powerpc.zig +41 -12
  184. package/std/os/linux/powerpc64.zig +41 -12
  185. package/std/os/linux/riscv32.zig +41 -12
  186. package/std/os/linux/riscv64.zig +41 -12
  187. package/std/os/linux/s390x.zig +44 -7
  188. package/std/os/linux/sparc64.zig +83 -52
  189. package/std/os/linux/thumb.zig +52 -36
  190. package/std/os/linux/x32.zig +41 -12
  191. package/std/os/linux/x86.zig +42 -13
  192. package/std/os/linux/x86_64.zig +41 -12
  193. package/std/os/linux.zig +419 -438
  194. package/std/os/uefi/tables/boot_services.zig +9 -8
  195. package/std/os/windows.zig +2 -2
  196. package/std/os.zig +41 -0
  197. package/std/pdb.zig +143 -4
  198. package/std/posix.zig +6 -12
  199. package/std/priority_dequeue.zig +13 -12
  200. package/std/priority_queue.zig +5 -4
  201. package/std/process/Child.zig +1 -1
  202. package/std/process/Environ.zig +1 -1
  203. package/std/process.zig +1 -1
  204. package/std/sort.zig +3 -3
  205. package/std/start.zig +17 -4
  206. package/std/std.zig +19 -6
  207. package/std/testing/FailingAllocator.zig +4 -4
  208. package/std/testing/Smith.zig +37 -2
  209. package/std/zig/Ast/Render.zig +187 -459
  210. package/std/zig/Ast.zig +0 -4
  211. package/std/zig/AstGen.zig +86 -103
  212. package/std/zig/AstRlAnnotate.zig +0 -11
  213. package/std/zig/AstSmith.zig +2602 -0
  214. package/std/zig/BuiltinFn.zig +0 -32
  215. package/std/zig/Client.zig +8 -3
  216. package/std/zig/LibCInstallation.zig +4 -3
  217. package/std/zig/Parse.zig +90 -81
  218. package/std/zig/Server.zig +26 -0
  219. package/std/zig/WindowsSdk.zig +13 -13
  220. package/std/zig/Zir.zig +66 -62
  221. package/std/zig/ZonGen.zig +6 -5
  222. package/std/zig/c_translation/helpers.zig +14 -9
  223. package/std/zig/llvm/Builder.zig +119 -60
  224. package/std/zig/system.zig +20 -4
  225. package/std/zig/tokenizer.zig +2 -1
  226. package/std/zig.zig +7 -10
  227. package/std/zip.zig +5 -5
  228. package/zig.h +340 -1
  229. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  230. package/libc/mingw/complex/cabs.c +0 -48
  231. package/libc/mingw/complex/cabsf.c +0 -48
  232. package/libc/mingw/complex/cacos.c +0 -50
  233. package/libc/mingw/complex/cacosf.c +0 -50
  234. package/libc/mingw/complex/carg.c +0 -48
  235. package/libc/mingw/complex/cargf.c +0 -48
  236. package/libc/mingw/complex/casin.c +0 -50
  237. package/libc/mingw/complex/casinf.c +0 -50
  238. package/libc/mingw/complex/catan.c +0 -50
  239. package/libc/mingw/complex/catanf.c +0 -50
  240. package/libc/mingw/complex/ccos.c +0 -50
  241. package/libc/mingw/complex/ccosf.c +0 -50
  242. package/libc/mingw/complex/cexp.c +0 -48
  243. package/libc/mingw/complex/cexpf.c +0 -48
  244. package/libc/mingw/complex/cimag.c +0 -48
  245. package/libc/mingw/complex/cimagf.c +0 -48
  246. package/libc/mingw/complex/clog.c +0 -48
  247. package/libc/mingw/complex/clog10.c +0 -49
  248. package/libc/mingw/complex/clog10f.c +0 -49
  249. package/libc/mingw/complex/clogf.c +0 -48
  250. package/libc/mingw/complex/conj.c +0 -48
  251. package/libc/mingw/complex/conjf.c +0 -48
  252. package/libc/mingw/complex/cpow.c +0 -48
  253. package/libc/mingw/complex/cpowf.c +0 -48
  254. package/libc/mingw/complex/cproj.c +0 -48
  255. package/libc/mingw/complex/cprojf.c +0 -48
  256. package/libc/mingw/complex/creal.c +0 -48
  257. package/libc/mingw/complex/crealf.c +0 -48
  258. package/libc/mingw/complex/csin.c +0 -50
  259. package/libc/mingw/complex/csinf.c +0 -50
  260. package/libc/mingw/complex/csqrt.c +0 -48
  261. package/libc/mingw/complex/csqrtf.c +0 -48
  262. package/libc/mingw/complex/ctan.c +0 -50
  263. package/libc/mingw/complex/ctanf.c +0 -50
  264. package/libc/mingw/math/arm/s_rint.c +0 -86
  265. package/libc/mingw/math/arm/s_rintf.c +0 -51
  266. package/libc/mingw/math/arm/sincos.S +0 -30
  267. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  268. package/libc/mingw/math/arm64/rint.c +0 -12
  269. package/libc/mingw/math/arm64/rintf.c +0 -12
  270. package/libc/mingw/math/arm64/sincos.S +0 -32
  271. package/libc/mingw/math/bsd_private_base.h +0 -148
  272. package/libc/mingw/math/fdiml.c +0 -24
  273. package/libc/mingw/math/frexpf.c +0 -13
  274. package/libc/mingw/math/frexpl.c +0 -71
  275. package/libc/mingw/math/x86/acosf.c +0 -29
  276. package/libc/mingw/math/x86/atanf.c +0 -23
  277. package/libc/mingw/math/x86/atanl.c +0 -18
  278. package/libc/mingw/math/x86/cos.def.h +0 -65
  279. package/libc/mingw/math/x86/cosl.c +0 -46
  280. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  281. package/libc/mingw/math/x86/ldexp.c +0 -23
  282. package/libc/mingw/math/x86/scalbn.S +0 -41
  283. package/libc/mingw/math/x86/scalbnf.S +0 -40
  284. package/libc/mingw/math/x86/sin.def.h +0 -65
  285. package/libc/mingw/math/x86/sinl.c +0 -46
  286. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  287. package/libc/mingw/math/x86/tanl.S +0 -62
  288. package/libc/mingw/misc/btowc.c +0 -28
  289. package/libc/mingw/misc/wcstof.c +0 -66
  290. package/libc/mingw/misc/wcstoimax.c +0 -132
  291. package/libc/mingw/misc/wcstoumax.c +0 -126
  292. package/libc/mingw/misc/wctob.c +0 -29
  293. package/libc/mingw/misc/winbs_uint64.c +0 -6
  294. package/libc/mingw/misc/winbs_ulong.c +0 -6
  295. package/libc/mingw/misc/winbs_ushort.c +0 -6
  296. package/libc/mingw/stdio/_Exit.c +0 -10
  297. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  298. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  299. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  300. package/libc/mingw/stdio/_stat64i32.c +0 -37
  301. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  302. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  303. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  304. package/libc/mingw/winpthreads/spinlock.c +0 -82
  305. package/libc/musl/src/legacy/isastream.c +0 -7
  306. package/libc/musl/src/legacy/valloc.c +0 -8
  307. package/libc/musl/src/linux/tee.c +0 -8
  308. package/libc/musl/src/math/__cosl.c +0 -96
  309. package/libc/musl/src/math/__sinl.c +0 -78
  310. package/libc/musl/src/math/__tanl.c +0 -143
  311. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  312. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  313. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  314. package/libc/musl/src/math/cosl.c +0 -39
  315. package/libc/musl/src/math/fdim.c +0 -10
  316. package/libc/musl/src/math/fdimf.c +0 -10
  317. package/libc/musl/src/math/fdiml.c +0 -18
  318. package/libc/musl/src/math/finite.c +0 -7
  319. package/libc/musl/src/math/finitef.c +0 -7
  320. package/libc/musl/src/math/frexp.c +0 -23
  321. package/libc/musl/src/math/frexpf.c +0 -23
  322. package/libc/musl/src/math/frexpl.c +0 -29
  323. package/libc/musl/src/math/i386/lrint.c +0 -8
  324. package/libc/musl/src/math/i386/lrintf.c +0 -8
  325. package/libc/musl/src/math/i386/rintf.c +0 -7
  326. package/libc/musl/src/math/lrint.c +0 -72
  327. package/libc/musl/src/math/lrintf.c +0 -8
  328. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  329. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  330. package/libc/musl/src/math/rintf.c +0 -30
  331. package/libc/musl/src/math/s390x/rintf.c +0 -15
  332. package/libc/musl/src/math/sincosl.c +0 -60
  333. package/libc/musl/src/math/sinl.c +0 -41
  334. package/libc/musl/src/math/tanl.c +0 -29
  335. package/libc/musl/src/math/x32/lrint.s +0 -5
  336. package/libc/musl/src/math/x32/lrintf.s +0 -5
  337. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  338. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  339. package/libc/musl/src/string/strdup.c +0 -10
  340. package/libc/musl/src/string/strndup.c +0 -12
  341. package/libc/musl/src/string/wcsdup.c +0 -10
  342. package/libc/musl/src/thread/pthread_spin_destroy.c +0 -6
  343. package/libc/musl/src/thread/pthread_spin_init.c +0 -6
  344. package/libc/musl/src/thread/pthread_spin_lock.c +0 -8
  345. package/libc/musl/src/thread/pthread_spin_trylock.c +0 -7
  346. package/libc/musl/src/thread/pthread_spin_unlock.c +0 -7
  347. package/libc/musl/src/unistd/dup2.c +0 -20
  348. package/libc/musl/src/unistd/dup3.c +0 -26
  349. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
  350. package/libc/wasi/thread-stub/pthread_spin_lock.c +0 -8
  351. package/libc/wasi/thread-stub/pthread_spin_trylock.c +0 -8
  352. package/libc/wasi/thread-stub/pthread_spin_unlock.c +0 -7
@@ -2343,12 +2343,13 @@ pub const Global = struct {
2343
2343
  none = maxInt(u32),
2344
2344
  _,
2345
2345
 
2346
- pub fn unwrap(self: Index, builder: *const Builder) Index {
2347
- var cur = self;
2346
+ pub fn unwrap(orig_index: Index, builder: *const Builder) Index {
2347
+ var cur = orig_index;
2348
2348
  while (true) {
2349
- const replacement = cur.getReplacement(builder);
2350
- if (replacement == .none) return cur;
2351
- cur = replacement;
2349
+ switch (builder.globals.values()[@intFromEnum(cur)].kind) {
2350
+ .replaced => |replacement| cur = replacement,
2351
+ else => return cur,
2352
+ }
2352
2353
  }
2353
2354
  }
2354
2355
 
@@ -2388,8 +2389,12 @@ pub const Global = struct {
2388
2389
  return self.ptrConst(builder).type;
2389
2390
  }
2390
2391
 
2391
- pub fn toConst(self: Index) Constant {
2392
- return @enumFromInt(@intFromEnum(Constant.first_global) + @intFromEnum(self));
2392
+ pub fn toConst(global: Index) Constant {
2393
+ return @enumFromInt(@intFromEnum(Constant.first_global) + @intFromEnum(global));
2394
+ }
2395
+
2396
+ pub fn toValue(global: Index) Value {
2397
+ return global.toConst().toValue();
2393
2398
  }
2394
2399
 
2395
2400
  pub fn setLinkage(self: Index, linkage: Linkage, builder: *Builder) void {
@@ -2450,6 +2455,42 @@ pub const Global = struct {
2450
2455
  self.ptr(builder).kind = .{ .replaced = .none };
2451
2456
  }
2452
2457
 
2458
+ /// Replaces whatever this `Global` currently contains with a new `Function`. Similar to
2459
+ /// `Builder.addFunction`, but the same `Global` is reused.
2460
+ pub fn toNewFunction(global: Index, builder: *Builder) Allocator.Error!Function.Index {
2461
+ try builder.functions.ensureUnusedCapacity(builder.gpa, 1);
2462
+ errdefer comptime unreachable;
2463
+ const function: Function.Index = @enumFromInt(builder.functions.items.len);
2464
+ builder.functions.appendAssumeCapacity(.{
2465
+ .global = global,
2466
+ .strip = undefined,
2467
+ });
2468
+ global.ptr(builder).kind = .{ .function = function };
2469
+ return function;
2470
+ }
2471
+
2472
+ /// Replaces whatever this `Global` currently contains with a new `Variable`. Similar to
2473
+ /// `Builder.addVariable`, but the same `Global` is reused.
2474
+ pub fn toNewVariable(global: Index, builder: *Builder) Allocator.Error!Variable.Index {
2475
+ try builder.variables.ensureUnusedCapacity(builder.gpa, 1);
2476
+ errdefer comptime unreachable;
2477
+ const variable: Variable.Index = @enumFromInt(builder.variables.items.len);
2478
+ builder.variables.appendAssumeCapacity(.{ .global = global });
2479
+ global.ptr(builder).kind = .{ .variable = variable };
2480
+ return variable;
2481
+ }
2482
+
2483
+ /// Replaces whatever this `Global` currently contains with a new `Alias`. Similar to
2484
+ /// `Builder.addAlias`, but the same `Global` is reused.
2485
+ pub fn toNewAlias(global: Index, builder: *Builder) Allocator.Error!Alias.Index {
2486
+ try builder.aliases.ensureUnusedCapacity(builder.gpa, 1);
2487
+ errdefer comptime unreachable;
2488
+ const alias: Alias.Index = @enumFromInt(builder.aliases.items.len);
2489
+ builder.aliass.appendAssumeCapacity(.{ .global = global, .aliasee = .none });
2490
+ global.ptr(builder).kind = .{ .alias = alias };
2491
+ return alias;
2492
+ }
2493
+
2453
2494
  fn updateDsoLocal(self: Index, builder: *Builder) void {
2454
2495
  const self_ptr = self.ptr(builder);
2455
2496
  switch (self_ptr.linkage) {
@@ -2494,13 +2535,6 @@ pub const Global = struct {
2494
2535
  self.renameAssumeCapacity(builder.next_replaced_global, builder);
2495
2536
  self.ptr(builder).kind = .{ .replaced = other.unwrap(builder) };
2496
2537
  }
2497
-
2498
- fn getReplacement(self: Index, builder: *const Builder) Index {
2499
- return switch (builder.globals.values()[@intFromEnum(self)].kind) {
2500
- .replaced => |replacement| replacement,
2501
- else => .none,
2502
- };
2503
- }
2504
2538
  };
2505
2539
  };
2506
2540
 
@@ -2593,22 +2627,6 @@ pub const Variable = struct {
2593
2627
  return self.toConst(builder).toValue();
2594
2628
  }
2595
2629
 
2596
- pub fn setLinkage(self: Index, linkage: Linkage, builder: *Builder) void {
2597
- return self.ptrConst(builder).global.setLinkage(linkage, builder);
2598
- }
2599
-
2600
- pub fn setVisibility(self: Index, visibility: Visibility, builder: *Builder) void {
2601
- return self.ptrConst(builder).global.setVisibility(visibility, builder);
2602
- }
2603
-
2604
- pub fn setDllStorageClass(self: Index, class: DllStorageClass, builder: *Builder) void {
2605
- return self.ptrConst(builder).global.setDllStorageClass(class, builder);
2606
- }
2607
-
2608
- pub fn setUnnamedAddr(self: Index, unnamed_addr: UnnamedAddr, builder: *Builder) void {
2609
- return self.ptrConst(builder).global.setUnnamedAddr(unnamed_addr, builder);
2610
- }
2611
-
2612
2630
  pub fn setThreadLocal(self: Index, thread_local: ThreadLocal, builder: *Builder) void {
2613
2631
  self.ptr(builder).thread_local = thread_local;
2614
2632
  }
@@ -7620,9 +7638,9 @@ pub const Constant = enum(u32) {
7620
7638
  std.math.big.int.calcToStringLimbsBufferLen(expected_limbs, 10)
7621
7639
  ]std.math.big.Limb,
7622
7640
  };
7623
- var stack align(@alignOf(ExpectedContents)) =
7624
- std.heap.stackFallback(@sizeOf(ExpectedContents), data.builder.gpa);
7625
- const allocator = stack.get();
7641
+ var bfa_buf: ExpectedContents = undefined;
7642
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), data.builder.gpa);
7643
+ const allocator = bfa.allocator();
7626
7644
  const str = bigint.toStringAlloc(allocator, 10, undefined) catch return error.WriteFailed;
7627
7645
  defer allocator.free(str);
7628
7646
  try w.writeAll(str);
@@ -9191,9 +9209,9 @@ pub fn getIntrinsic(
9191
9209
  fields: [expected_fields_len]Type,
9192
9210
  },
9193
9211
  };
9194
- var stack align(@max(@alignOf(std.heap.StackFallbackAllocator(0)), @alignOf(ExpectedContents))) =
9195
- std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
9196
- const allocator = stack.get();
9212
+ var bfa_buf: ExpectedContents = undefined;
9213
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
9214
+ const allocator = bfa.allocator();
9197
9215
 
9198
9216
  const name = name: {
9199
9217
  {
@@ -9692,8 +9710,12 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
9692
9710
 
9693
9711
  if (self.variables.items.len > 0) {
9694
9712
  if (need_newline) try w.writeByte('\n') else need_newline = true;
9695
- for (self.variables.items) |variable| {
9696
- if (variable.global.getReplacement(self) != .none) continue;
9713
+ for (self.variables.items, 0..) |variable, variable_i| {
9714
+ // Skip the variable if its global has been repurposed for something else.
9715
+ switch (variable.global.ptrConst(self).kind) {
9716
+ .variable => |v| if (@intFromEnum(v) != variable_i) continue,
9717
+ else => continue,
9718
+ }
9697
9719
  const global = variable.global.ptrConst(self);
9698
9720
  metadata_formatter.need_comma = true;
9699
9721
  defer metadata_formatter.need_comma = undefined;
@@ -9723,8 +9745,12 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
9723
9745
 
9724
9746
  if (self.aliases.items.len > 0) {
9725
9747
  if (need_newline) try w.writeByte('\n') else need_newline = true;
9726
- for (self.aliases.items) |alias| {
9727
- if (alias.global.getReplacement(self) != .none) continue;
9748
+ for (self.aliases.items, 0..) |alias, alias_i| {
9749
+ // Skip the alias if its global has been repurposed for something else.
9750
+ switch (alias.global.ptrConst(self).kind) {
9751
+ .alias => |a| if (@intFromEnum(a) != alias_i) continue,
9752
+ else => continue,
9753
+ }
9728
9754
  const global = alias.global.ptrConst(self);
9729
9755
  metadata_formatter.need_comma = true;
9730
9756
  defer metadata_formatter.need_comma = undefined;
@@ -9750,7 +9776,11 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
9750
9776
  defer attribute_groups.deinit(self.gpa);
9751
9777
 
9752
9778
  for (0.., self.functions.items) |function_i, function| {
9753
- if (function.global.getReplacement(self) != .none) continue;
9779
+ // Skip the function if its global has been repurposed for something else.
9780
+ switch (function.global.ptrConst(self).kind) {
9781
+ .function => |f| if (@intFromEnum(f) != function_i) continue,
9782
+ else => continue,
9783
+ }
9754
9784
  if (need_newline) try w.writeByte('\n') else need_newline = true;
9755
9785
  const function_index: Function.Index = @enumFromInt(function_i);
9756
9786
  const global = function.global.ptrConst(self);
@@ -10577,9 +10607,9 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
10577
10607
  std.math.big.int.calcToStringLimbsBufferLen(expected_limbs, 10)
10578
10608
  ]std.math.big.Limb,
10579
10609
  };
10580
- var stack align(@alignOf(ExpectedContents)) =
10581
- std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
10582
- const allocator = stack.get();
10610
+ var bfa_buf: ExpectedContents = undefined;
10611
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
10612
+ const allocator = bfa.allocator();
10583
10613
 
10584
10614
  const limbs = self.metadata_limbs.items[extra.limbs_index..][0..extra.limbs_len];
10585
10615
  const bigint: std.math.big.int.Const = .{
@@ -11099,9 +11129,9 @@ fn bigIntConstAssumeCapacity(
11099
11129
  const bits = type_item.data;
11100
11130
 
11101
11131
  const ExpectedContents = [64 / @sizeOf(std.math.big.Limb)]std.math.big.Limb;
11102
- var stack align(@alignOf(ExpectedContents)) =
11103
- std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
11104
- const allocator = stack.get();
11132
+ var bfa_buf: ExpectedContents = undefined;
11133
+ var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
11134
+ const allocator = bfa.allocator();
11105
11135
 
11106
11136
  var limbs: []std.math.big.Limb = &.{};
11107
11137
  defer allocator.free(limbs);
@@ -13687,20 +13717,32 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
13687
13717
  self.aliases.items.len,
13688
13718
  );
13689
13719
 
13690
- for (self.variables.items) |variable| {
13691
- if (variable.global.getReplacement(self) != .none) continue;
13720
+ for (self.variables.items, 0..) |variable, variable_i| {
13721
+ // Skip the variable if its global has been repurposed for something else.
13722
+ switch (variable.global.ptrConst(self).kind) {
13723
+ .variable => |v| if (@intFromEnum(v) != variable_i) continue,
13724
+ else => continue,
13725
+ }
13692
13726
 
13693
13727
  globals.putAssumeCapacity(variable.global, {});
13694
13728
  }
13695
13729
 
13696
- for (self.functions.items) |function| {
13697
- if (function.global.getReplacement(self) != .none) continue;
13730
+ for (self.functions.items, 0..) |function, function_i| {
13731
+ // Skip the function if its global has been repurposed for something else.
13732
+ switch (function.global.ptrConst(self).kind) {
13733
+ .function => |f| if (@intFromEnum(f) != function_i) continue,
13734
+ else => continue,
13735
+ }
13698
13736
 
13699
13737
  globals.putAssumeCapacity(function.global, {});
13700
13738
  }
13701
13739
 
13702
- for (self.aliases.items) |alias| {
13703
- if (alias.global.getReplacement(self) != .none) continue;
13740
+ for (self.aliases.items, 0..) |alias, alias_i| {
13741
+ // Skip the alias if its global has been repurposed for something else.
13742
+ switch (alias.global.ptrConst(self).kind) {
13743
+ .alias => |a| if (@intFromEnum(a) != alias_i) continue,
13744
+ else => continue,
13745
+ }
13704
13746
 
13705
13747
  globals.putAssumeCapacity(alias.global, {});
13706
13748
  }
@@ -13742,8 +13784,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
13742
13784
  defer section_map.deinit(self.gpa);
13743
13785
  try section_map.ensureUnusedCapacity(self.gpa, globals.count());
13744
13786
 
13745
- for (self.variables.items) |variable| {
13746
- if (variable.global.getReplacement(self) != .none) continue;
13787
+ for (self.variables.items, 0..) |variable, variable_i| {
13788
+ // Skip the variable if its global has been repurposed for something else.
13789
+ switch (variable.global.ptrConst(self).kind) {
13790
+ .variable => |v| if (@intFromEnum(v) != variable_i) continue,
13791
+ else => continue,
13792
+ }
13747
13793
 
13748
13794
  const section = blk: {
13749
13795
  if (variable.section == .none) break :blk 0;
@@ -13789,8 +13835,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
13789
13835
  });
13790
13836
  }
13791
13837
 
13792
- for (self.functions.items) |func| {
13793
- if (func.global.getReplacement(self) != .none) continue;
13838
+ for (self.functions.items, 0..) |func, func_i| {
13839
+ // Skip the function if its global has been repurposed for something else.
13840
+ switch (func.global.ptrConst(self).kind) {
13841
+ .function => |f| if (@intFromEnum(f) != func_i) continue,
13842
+ else => continue,
13843
+ }
13794
13844
 
13795
13845
  const section = blk: {
13796
13846
  if (func.section == .none) break :blk 0;
@@ -13830,8 +13880,12 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
13830
13880
  });
13831
13881
  }
13832
13882
 
13833
- for (self.aliases.items) |alias| {
13834
- if (alias.global.getReplacement(self) != .none) continue;
13883
+ for (self.aliases.items, 0..) |alias, alias_i| {
13884
+ // Skip the alias if its global has been repurposed for something else.
13885
+ switch (alias.global.ptrConst(self).kind) {
13886
+ .alias => |a| if (@intFromEnum(a) != alias_i) continue,
13887
+ else => continue,
13888
+ }
13835
13889
 
13836
13890
  const strtab = alias.global.strtab(self);
13837
13891
 
@@ -14635,8 +14689,13 @@ pub fn toBitcode(self: *Builder, allocator: Allocator, producer: Producer) bitco
14635
14689
  };
14636
14690
 
14637
14691
  for (self.functions.items, 0..) |func, func_index| {
14692
+ // Skip the function if its global has been repurposed for something else.
14693
+ switch (func.global.ptrConst(self).kind) {
14694
+ .function => |f| if (@intFromEnum(f) != func_index) continue,
14695
+ else => continue,
14696
+ }
14697
+
14638
14698
  const FunctionBlock = ir.ModuleBlock.FunctionBlock;
14639
- if (func.global.getReplacement(self) != .none) continue;
14640
14699
 
14641
14700
  if (func.instructions.len == 0) continue;
14642
14701
 
@@ -423,6 +423,7 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target {
423
423
  error.ConnectionResetByPeer => return error.Unexpected,
424
424
  error.NotOpenForReading => return error.Unexpected,
425
425
  error.SocketUnconnected => return error.Unexpected,
426
+ error.ReadOnlyFileSystem => return error.Unexpected,
426
427
 
427
428
  error.AccessDenied,
428
429
  error.SymLinkLoop,
@@ -853,6 +854,7 @@ fn glibcVerFromRPath(io: Io, rpath: []const u8) !std.SemanticVersion {
853
854
  error.PathAlreadyExists => return error.Unexpected, // read-only
854
855
  error.DeviceBusy => return error.Unexpected, // read-only
855
856
  error.FileBusy => return error.Unexpected, // read-only
857
+ error.ReadOnlyFileSystem => return error.Unexpected, // read-only
856
858
  error.NoDevice => return error.Unexpected, // not asking for a special device
857
859
  error.FileTooBig => return error.Unexpected,
858
860
  error.WouldBlock => return error.Unexpected, // not opened in non-blocking
@@ -1183,11 +1185,25 @@ fn detectAndroidApiLevel(io: Io) !u32 {
1183
1185
  return error.ApiLevelQueryFailed;
1184
1186
  };
1185
1187
 
1186
- const term = try child.wait(io);
1187
- if (term != .exited or term.exited != 0) {
1188
- std.log.err("getprop terminated abnormally: {}", .{term});
1189
- return error.ApiLevelQueryFailed;
1188
+ switch (try child.wait(io)) {
1189
+ .exited => |code| if (code != 0) {
1190
+ std.log.err("getprop terminated abnormally with exit code: {d}", .{code});
1191
+ return error.ApiLevelQueryFailed;
1192
+ },
1193
+ .signal => |sig| {
1194
+ std.log.err("getprop terminated abnormally with signal: {t}", .{sig});
1195
+ return error.ApiLevelQueryFailed;
1196
+ },
1197
+ .stopped => |sig| {
1198
+ std.log.err("getprop stopped abnormally with signal: {t}", .{sig});
1199
+ return error.ApiLevelQueryFailed;
1200
+ },
1201
+ .unknown => {
1202
+ std.log.err("getprop terminated abnormally", .{});
1203
+ return error.ApiLevelQueryFailed;
1204
+ },
1190
1205
  }
1206
+
1191
1207
  return api_level;
1192
1208
  }
1193
1209
 
@@ -313,7 +313,8 @@ pub const Token = struct {
313
313
  return tag.lexeme() orelse switch (tag) {
314
314
  .invalid => "invalid token",
315
315
  .identifier => "an identifier",
316
- .string_literal, .multiline_string_literal_line => "a string literal",
316
+ .string_literal => "a string literal",
317
+ .multiline_string_literal_line => "a multiline string literal",
317
318
  .char_literal => "a character literal",
318
319
  .eof => "EOF",
319
320
  .builtin => "a builtin function",
package/std/zig.zig CHANGED
@@ -23,6 +23,7 @@ pub const primitives = @import("zig/primitives.zig");
23
23
  pub const isPrimitive = primitives.isPrimitive;
24
24
  pub const Ast = @import("zig/Ast.zig");
25
25
  pub const AstGen = @import("zig/AstGen.zig");
26
+ pub const AstSmith = @import("zig/AstSmith.zig");
26
27
  pub const Zir = @import("zig/Zir.zig");
27
28
  pub const Zoir = @import("zig/Zoir.zig");
28
29
  pub const ZonGen = @import("zig/ZonGen.zig");
@@ -743,6 +744,7 @@ pub fn parseTargetQueryOrReportFatalError(
743
744
  pub const EnvVar = enum {
744
745
  ZIG_GLOBAL_CACHE_DIR,
745
746
  ZIG_LOCAL_CACHE_DIR,
747
+ ZIG_LOCAL_PKG_DIR,
746
748
  ZIG_LIB_DIR,
747
749
  ZIG_LIBC,
748
750
  ZIG_BUILD_RUNNER,
@@ -795,11 +797,6 @@ pub const SimpleComptimeReason = enum(u32) {
795
797
  operand_branchHint,
796
798
  operand_setRuntimeSafety,
797
799
  operand_embedFile,
798
- operand_cImport,
799
- operand_cDefine_macro_name,
800
- operand_cDefine_macro_value,
801
- operand_cInclude_file_name,
802
- operand_cUndef_macro_name,
803
800
  operand_shuffle_mask,
804
801
  operand_atomicRmw_operation,
805
802
  operand_reduce_operation,
@@ -890,11 +887,6 @@ pub const SimpleComptimeReason = enum(u32) {
890
887
  .operand_branchHint => "operand to '@branchHint' must be comptime-known",
891
888
  .operand_setRuntimeSafety => "operand to '@setRuntimeSafety' must be comptime-known",
892
889
  .operand_embedFile => "operand to '@embedFile' must be comptime-known",
893
- .operand_cImport => "operand to '@cImport' is evaluated at comptime",
894
- .operand_cDefine_macro_name => "'@cDefine' macro name must be comptime-known",
895
- .operand_cDefine_macro_value => "'@cDefine' macro value must be comptime-known",
896
- .operand_cInclude_file_name => "'@cInclude' file name must be comptime-known",
897
- .operand_cUndef_macro_name => "'@cUndef' macro name must be comptime-known",
898
890
  .operand_shuffle_mask => "'@shuffle' mask must be comptime-known",
899
891
  .operand_atomicRmw_operation => "'@atomicRmw' operation must be comptime-known",
900
892
  .operand_reduce_operation => "'@reduce' operation must be comptime-known",
@@ -985,11 +977,14 @@ pub const EmitArtifact = enum {
985
977
  docs,
986
978
  pdb,
987
979
  h,
980
+ compiler_rt_dyn_lib,
988
981
 
989
982
  /// If using `Server` to communicate with the compiler, it will place requested artifacts in
990
983
  /// paths under the output directory, where those paths are named according to this function.
991
984
  /// Returned string is allocated with `gpa` and owned by the caller.
992
985
  pub fn cacheName(ea: EmitArtifact, gpa: Allocator, opts: BinNameOptions) Allocator.Error![]const u8 {
986
+ // hack for stage2_x86_64 + coff. See Coff.flush.
987
+ if (ea == .compiler_rt_dyn_lib) return "compiler_rt.dll";
993
988
  const suffix: []const u8 = switch (ea) {
994
989
  .bin => return binNameAlloc(gpa, opts),
995
990
  .@"asm" => ".s",
@@ -999,6 +994,7 @@ pub const EmitArtifact = enum {
999
994
  .docs => "-docs",
1000
995
  .pdb => ".pdb",
1001
996
  .h => ".h",
997
+ .compiler_rt_dyn_lib => unreachable,
1002
998
  };
1003
999
  return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix });
1004
1000
  }
@@ -1166,6 +1162,7 @@ pub const ClangCliParam = struct {
1166
1162
  test {
1167
1163
  _ = Ast;
1168
1164
  _ = AstRlAnnotate;
1165
+ _ = AstSmith;
1169
1166
  _ = BuiltinFn;
1170
1167
  _ = Client;
1171
1168
  _ = ErrorBundle;
package/std/zip.zig CHANGED
@@ -143,7 +143,7 @@ pub const EndRecord = extern struct {
143
143
  const read_buf: []u8 = buf[buf.len - new_loaded_len ..][0..read_len];
144
144
  fr.interface.readSliceAll(read_buf) catch |err| switch (err) {
145
145
  error.ReadFailed => return fr.err.?,
146
- error.EndOfStream => return error.EndOfStream,
146
+ error.EndOfStream => |e| return e,
147
147
  };
148
148
  loaded_len = new_loaded_len;
149
149
  }
@@ -310,7 +310,7 @@ pub const Iterator = struct {
310
310
  try input.seekTo(stream_len - locator_end_offset);
311
311
  const locator = input.interface.takeStruct(EndLocator64, .little) catch |err| switch (err) {
312
312
  error.ReadFailed => return input.err.?,
313
- error.EndOfStream => return error.EndOfStream,
313
+ error.EndOfStream => |e| return e,
314
314
  };
315
315
  if (!std.mem.eql(u8, &locator.signature, &end_locator64_sig))
316
316
  return error.ZipBadLocatorSig;
@@ -323,7 +323,7 @@ pub const Iterator = struct {
323
323
 
324
324
  const record64 = input.interface.takeStruct(EndRecord64, .little) catch |err| switch (err) {
325
325
  error.ReadFailed => return input.err.?,
326
- error.EndOfStream => return error.EndOfStream,
326
+ error.EndOfStream => |e| return e,
327
327
  };
328
328
 
329
329
  if (!std.mem.eql(u8, &record64.signature, &end_record64_sig))
@@ -379,7 +379,7 @@ pub const Iterator = struct {
379
379
  try input.seekTo(header_zip_offset);
380
380
  const header = input.interface.takeStruct(CentralDirectoryFileHeader, .little) catch |err| switch (err) {
381
381
  error.ReadFailed => return input.err.?,
382
- error.EndOfStream => return error.EndOfStream,
382
+ error.EndOfStream => |e| return e,
383
383
  };
384
384
  if (!std.mem.eql(u8, &header.signature, &central_file_header_sig))
385
385
  return error.ZipBadCdOffset;
@@ -410,7 +410,7 @@ pub const Iterator = struct {
410
410
  try input.seekTo(header_zip_offset + @sizeOf(CentralDirectoryFileHeader) + header.filename_len);
411
411
  input.interface.readSliceAll(extra) catch |err| switch (err) {
412
412
  error.ReadFailed => return input.err.?,
413
- error.EndOfStream => return error.EndOfStream,
413
+ error.EndOfStream => |e| return e,
414
414
  };
415
415
 
416
416
  var extra_offset: usize = 0;