@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
@@ -1,5 +1,4 @@
1
1
  const std = @import("std");
2
- const Io = std.Io;
3
2
  const mem = std.mem;
4
3
  const Allocator = mem.Allocator;
5
4
  const process = std.process;
@@ -9,6 +8,7 @@ const Assembly = backend.Assembly;
9
8
  const Ir = backend.Ir;
10
9
  const Object = backend.Object;
11
10
 
11
+ const Attribute = @import("Attribute.zig");
12
12
  const Compilation = @import("Compilation.zig");
13
13
  const Diagnostics = @import("Diagnostics.zig");
14
14
  const DepFile = @import("DepFile.zig");
@@ -52,6 +52,7 @@ implicit_includes: std.ArrayList(Source) = .empty,
52
52
  /// List of includes that will be used to construct the compilation's search path
53
53
  includes: std.ArrayList(Compilation.Include) = .empty,
54
54
  link_objects: std.ArrayList([]const u8) = .empty,
55
+ macro_prefix_map: std.ArrayList(struct { []const u8, []const u8 }) = .empty,
55
56
  output_name: ?[]const u8 = null,
56
57
  sysroot: ?[]const u8 = null,
57
58
  resource_dir: ?[]const u8 = null,
@@ -134,9 +135,8 @@ strip: bool = false,
134
135
  unwindlib: ?[]const u8 = null,
135
136
 
136
137
  pub fn deinit(d: *Driver) void {
137
- const io = d.comp.io;
138
138
  for (d.link_objects.items[d.link_objects.items.len - d.temp_file_count ..]) |obj| {
139
- Io.Dir.deleteFileAbsolute(io, obj) catch {};
139
+ std.Io.Dir.deleteFileAbsolute(d.comp.io, obj) catch {};
140
140
  d.comp.gpa.free(obj);
141
141
  }
142
142
  d.inputs.deinit(d.comp.gpa);
@@ -144,6 +144,7 @@ pub fn deinit(d: *Driver) void {
144
144
  d.implicit_includes.deinit(d.comp.gpa);
145
145
  d.includes.deinit(d.comp.gpa);
146
146
  d.link_objects.deinit(d.comp.gpa);
147
+ d.macro_prefix_map.deinit(d.comp.gpa);
147
148
  d.* = undefined;
148
149
  }
149
150
 
@@ -177,6 +178,10 @@ pub const usage =
177
178
  \\ -darwin-target-variant-triple
178
179
  \\ Specify the darwin target variant triple
179
180
  \\ -fapple-kext Use Apple's kernel extensions ABI
181
+ \\ -fexperimental-bounds-safety
182
+ \\ Enable experimental clang-style bounds safety attributes (INCOMPLETE)
183
+ \\ -fno-experimental-bounds-safety
184
+ \\ Disable experimental clang-style bounds safety attributes
180
185
  \\ -fchar8_t Enable char8_t (enabled by default in C23 and later)
181
186
  \\ -fno-char8_t Disable char8_t (disabled by default for pre-C23)
182
187
  \\ -fcolor-diagnostics Enable colors in diagnostics
@@ -218,6 +223,8 @@ pub const usage =
218
223
  \\ -fuse-line-directives Use `#line <num>` linemarkers in preprocessed output
219
224
  \\ -fno-use-line-directives
220
225
  \\ Use `# <num>` linemarkers in preprocessed output
226
+ \\ -fvisibility=[default|hidden|internal|protected]
227
+ \\ Set the default ELF image symbol visibility to the specified option—all symbols are marked with this unless overridden within the code
221
228
  \\ -iquote <dir> Add directory to QUOTE include search path
222
229
  \\ -I <dir> Add directory to include search path
223
230
  \\ -idirafter <dir> Add directory to AFTER include search path
@@ -375,6 +382,17 @@ pub fn parseArgs(
375
382
  d.use_line_directives = false;
376
383
  } else if (mem.eql(u8, arg, "-fapple-kext")) {
377
384
  d.apple_kext = true;
385
+ } else if (option(arg, "-fvisibility=")) |visibility| {
386
+ d.comp.langopts.default_symbol_visibility = Attribute.visibilityFromString(visibility) orelse
387
+ return d.fatal("unsupported value '{s}'' in '{s}'", .{ visibility, arg });
388
+ } else if (option(arg, "-frandom-seed=")) |_| {
389
+ // Ignore
390
+ } else if (option(arg, "-fmacro-prefix-map=")) |kv| {
391
+ const pair = mem.cutScalar(u8, kv, '=') orelse {
392
+ try d.err("invalid argument '{s}' to '-fmacro-prefix-map=", .{kv});
393
+ continue;
394
+ };
395
+ try d.macro_prefix_map.append(gpa, pair);
378
396
  } else if (option(arg, "-mcmodel=")) |cmodel| {
379
397
  d.comp.cmodel = std.meta.stringToEnum(std.builtin.CodeModel, cmodel) orelse
380
398
  return d.fatal("unsupported machine code model: '{s}'", .{arg});
@@ -415,6 +433,10 @@ pub fn parseArgs(
415
433
  d.dependencies.file = path;
416
434
  } else if (mem.eql(u8, arg, "-MV")) {
417
435
  d.dependencies.format = .nmake;
436
+ } else if (mem.eql(u8, arg, "-fexperimental-bounds-safety")) {
437
+ d.comp.langopts.bounds_safety = .clang;
438
+ } else if (mem.eql(u8, arg, "-fno-experimental-bounds-safety")) {
439
+ d.comp.langopts.bounds_safety = .none;
418
440
  } else if (mem.eql(u8, arg, "-fchar8_t")) {
419
441
  d.comp.langopts.has_char8_t_override = true;
420
442
  } else if (mem.eql(u8, arg, "-fno-char8_t")) {
@@ -635,6 +657,42 @@ pub fn parseArgs(
635
657
  d.output_name = file;
636
658
  } else if (option(arg, "--sysroot=")) |sysroot| {
637
659
  d.sysroot = sysroot;
660
+ } else if (mem.eql(u8, arg, "--sysroot")) {
661
+ i += 1;
662
+ if (i >= args.len) {
663
+ try d.err("expected argument after --sysroot", .{});
664
+ continue;
665
+ }
666
+ d.sysroot = args[i];
667
+ } else if (mem.startsWith(u8, arg, "-isysroot")) {
668
+ var path = arg["-isysroot".len..];
669
+ if (path.len == 0) {
670
+ i += 1;
671
+ if (i >= args.len) {
672
+ try d.err("expected argument after -isysroot", .{});
673
+ continue;
674
+ }
675
+ path = args[i];
676
+ }
677
+ d.sysroot = path;
678
+ } else if (mem.eql(u8, arg, "-rpath")) {
679
+ i += 1;
680
+ if (i >= args.len) {
681
+ try d.err("expected argument after -rpath", .{});
682
+ continue;
683
+ }
684
+ // ignore for now
685
+ } else if (mem.startsWith(u8, arg, "-L")) {
686
+ var path = arg["-L".len..];
687
+ if (path.len == 0) {
688
+ i += 1;
689
+ if (i >= args.len) {
690
+ try d.err("expected argument after -L", .{});
691
+ continue;
692
+ }
693
+ path = args[i];
694
+ }
695
+ // ignore for now
638
696
  } else if (mem.eql(u8, arg, "-Wp,-v")) {
639
697
  // TODO this is not how this argument should work
640
698
  d.verbose_search_path = true;
@@ -706,6 +764,10 @@ pub fn parseArgs(
706
764
  d.comp.langopts.preserve_comments = true;
707
765
  d.comp.langopts.preserve_comments_in_macros = true;
708
766
  comment_arg = arg;
767
+ } else if (option(arg, "-fuse-ld=")) |linker_name| {
768
+ d.use_linker = linker_name;
769
+ } else if (mem.eql(u8, arg, "-fuse-ld=")) {
770
+ d.use_linker = null;
709
771
  } else if (option(arg, "--ld-path=")) |linker_path| {
710
772
  d.linker_path = linker_path;
711
773
  } else if (mem.eql(u8, arg, "-r")) {
@@ -810,6 +872,7 @@ pub fn parseArgs(
810
872
  .clang => try d.diagnostics.set("clang", .off),
811
873
  .gcc => try d.diagnostics.set("gnu", .off),
812
874
  .msvc => try d.diagnostics.set("microsoft", .off),
875
+ .no => {},
813
876
  }
814
877
  }
815
878
  if (d.comp.langopts.preserve_comments and !d.only_preprocess) {
@@ -884,8 +947,9 @@ fn addImacros(d: *Driver, path: []const u8) !void {
884
947
  }
885
948
 
886
949
  pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
887
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
888
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
950
+ var bfa_buf: [1024]u8 = undefined;
951
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
952
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
889
953
  defer allocating.deinit();
890
954
 
891
955
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -893,8 +957,9 @@ pub fn err(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
893
957
  }
894
958
 
895
959
  pub fn warn(d: *Driver, fmt: []const u8, args: anytype) Compilation.Error!void {
896
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
897
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
960
+ var bfa_buf: [1024]u8 = undefined;
961
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
962
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
898
963
  defer allocating.deinit();
899
964
 
900
965
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -1038,8 +1103,9 @@ fn parseTarget(d: *Driver, arch_os_abi: []const u8, opt_cpu_features: ?[]const u
1038
1103
  }
1039
1104
 
1040
1105
  pub fn fatal(d: *Driver, comptime fmt: []const u8, args: anytype) error{ FatalError, OutOfMemory } {
1041
- var sf = std.heap.stackFallback(1024, d.comp.gpa);
1042
- var allocating: std.Io.Writer.Allocating = .init(sf.get());
1106
+ var bfa_buf: [1024]u8 = undefined;
1107
+ var bfa: std.heap.BufferFirstAllocator = .init(&bfa_buf, d.comp.gpa);
1108
+ var allocating: std.Io.Writer.Allocating = .init(bfa.allocator());
1043
1109
  defer allocating.deinit();
1044
1110
 
1045
1111
  Diagnostics.formatArgs(&allocating.writer, fmt, args) catch return error.OutOfMemory;
@@ -1063,20 +1129,22 @@ pub fn printDiagnosticsStats(d: *Driver) void {
1063
1129
  }
1064
1130
  }
1065
1131
 
1066
- pub fn detectConfig(d: *Driver, file: Io.File) std.Io.tty.Config {
1132
+ pub fn detectMode(d: *Driver, file: std.Io.File) std.Io.Cancelable!std.Io.Terminal.Mode {
1067
1133
  if (d.diagnostics.color == false) return .no_color;
1068
1134
  const force_color = d.diagnostics.color == true;
1069
1135
 
1070
- if (file.supportsAnsiEscapeCodes()) return .escape_codes;
1071
- if (@import("builtin").os.tag == .windows and file.isTty()) {
1072
- var info: std.os.windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
1073
- if (std.os.windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) == std.os.windows.FALSE) {
1074
- return if (force_color) .escape_codes else .no_color;
1136
+ const io = d.comp.io;
1137
+ if (try file.supportsAnsiEscapeCodes(io)) return .escape_codes;
1138
+ if (@import("builtin").os.tag == .windows and try file.isTty(io)) {
1139
+ var get_console_info = std.os.windows.CONSOLE.USER_IO.GET_SCREEN_BUFFER_INFO;
1140
+ switch (try get_console_info.operate(io, file)) {
1141
+ .SUCCESS => return .{ .windows_api = .{
1142
+ .io = io,
1143
+ .file = file,
1144
+ .reset_attributes = get_console_info.Data.wAttributes,
1145
+ } },
1146
+ else => {},
1075
1147
  }
1076
- return .{ .windows_api = .{
1077
- .handle = file.handle,
1078
- .reset_attributes = info.wAttributes,
1079
- } };
1080
1148
  }
1081
1149
 
1082
1150
  return if (force_color) .escape_codes else .no_color;
@@ -1105,17 +1173,16 @@ pub fn errorDescription(e: anyerror) []const u8 {
1105
1173
 
1106
1174
  /// The entry point of the Aro compiler.
1107
1175
  /// **MAY call `exit` if `fast_exit` is set.**
1108
- pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_exit: bool, asm_gen_fn: ?AsmCodeGenFn) Compilation.Error!void {
1176
+ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_exit: bool, asm_gen_fn: ?AsmCodeGenFn) (Compilation.Error || std.Io.Cancelable)!void {
1109
1177
  const user_macros = macros: {
1110
1178
  var macro_buf: std.ArrayList(u8) = .empty;
1111
1179
  defer macro_buf.deinit(d.comp.gpa);
1112
1180
 
1113
1181
  var stdout_buf: [256]u8 = undefined;
1114
- var stdout = Io.File.stdout().writer(&stdout_buf);
1182
+ var stdout = std.Io.File.stdout().writer(d.comp.io, &stdout_buf);
1115
1183
  if (parseArgs(d, &stdout.interface, &macro_buf, args) catch |er| switch (er) {
1116
1184
  error.WriteFailed => return d.fatal("failed to write to stdout: {s}", .{errorDescription(er)}),
1117
- error.OutOfMemory => return error.OutOfMemory,
1118
- error.FatalError => return error.FatalError,
1185
+ error.OutOfMemory, error.FatalError => |e| return e,
1119
1186
  }) return;
1120
1187
  if (macro_buf.items.len > std.math.maxInt(u32)) {
1121
1188
  return d.fatal("user provided macro source exceeded max size", .{});
@@ -1139,12 +1206,11 @@ pub fn main(d: *Driver, tc: *Toolchain, args: []const []const u8, comptime fast_
1139
1206
  };
1140
1207
 
1141
1208
  tc.discover() catch |er| switch (er) {
1142
- error.OutOfMemory => return error.OutOfMemory,
1209
+ error.OutOfMemory => |e| return e,
1143
1210
  error.TooManyMultilibs => return d.fatal("found more than one multilib with the same priority", .{}),
1144
1211
  };
1145
1212
  tc.defineSystemIncludes() catch |er| switch (er) {
1146
- error.OutOfMemory => return error.OutOfMemory,
1147
- error.FatalError => return error.FatalError,
1213
+ error.OutOfMemory, error.FatalError => |e| return e,
1148
1214
  };
1149
1215
  try d.comp.initSearchPath(d.includes.items, d.verbose_search_path);
1150
1216
 
@@ -1217,14 +1283,13 @@ pub fn getDepFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u
1217
1283
  }
1218
1284
 
1219
1285
  fn getRandomFilename(d: *Driver, buf: *[std.fs.max_name_bytes]u8, extension: []const u8) ![]const u8 {
1220
- const io = d.comp.io;
1221
1286
  const random_bytes_count = 12;
1222
- const sub_path_len = comptime std.base64.url_safe.Encoder.calcSize(random_bytes_count);
1287
+ const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count);
1223
1288
 
1224
1289
  var random_bytes: [random_bytes_count]u8 = undefined;
1225
- io.random(&random_bytes);
1290
+ d.comp.io.random(&random_bytes);
1226
1291
  var random_name: [sub_path_len]u8 = undefined;
1227
- _ = std.base64.url_safe.Encoder.encode(&random_name, &random_bytes);
1292
+ _ = std.fs.base64_encoder.encode(&random_name, &random_bytes);
1228
1293
 
1229
1294
  const fmt_template = "/tmp/{s}{s}";
1230
1295
  const fmt_args = .{
@@ -1251,12 +1316,11 @@ fn getOutFileName(d: *Driver, source: Source, buf: *[std.fs.max_name_bytes]u8) !
1251
1316
  }
1252
1317
 
1253
1318
  fn invokeAssembler(d: *Driver, tc: *Toolchain, input_path: []const u8, output_path: []const u8) !void {
1254
- const io = d.comp.io;
1255
1319
  var assembler_path_buf: [std.fs.max_path_bytes]u8 = undefined;
1256
1320
  const assembler_path = try tc.getAssemblerPath(&assembler_path_buf);
1257
1321
  const argv = [_][]const u8{ assembler_path, input_path, "-o", output_path };
1258
1322
 
1259
- var child = std.process.spawn(io, .{
1323
+ var child = std.process.spawn(d.comp.io, .{
1260
1324
  .argv = &argv,
1261
1325
  // TODO handle better
1262
1326
  .stdin = .inherit,
@@ -1265,8 +1329,8 @@ fn invokeAssembler(d: *Driver, tc: *Toolchain, input_path: []const u8, output_pa
1265
1329
  }) catch |er| {
1266
1330
  return d.fatal("unable to spawn linker: {s}", .{errorDescription(er)});
1267
1331
  };
1268
- const term = child.wait(io) catch |er| {
1269
- return d.fatal("unable to wait linker: {s}", .{errorDescription(er)});
1332
+ const term = child.wait(d.comp.io) catch |er| {
1333
+ return d.fatal("error waiting for linker: {s}", .{errorDescription(er)});
1270
1334
  };
1271
1335
  switch (term) {
1272
1336
  .exited => |code| if (code != 0) {
@@ -1289,13 +1353,16 @@ fn processSource(
1289
1353
  comptime fast_exit: bool,
1290
1354
  asm_gen_fn: ?AsmCodeGenFn,
1291
1355
  ) !void {
1292
- const gpa = d.comp.gpa;
1293
- d.comp.generated_buf.items.len = 0;
1356
+ const comp = d.comp;
1357
+ const io = comp.io;
1358
+ const gpa = comp.gpa;
1359
+ comp.generated_buf.items.len = 0;
1294
1360
  const prev_total = d.diagnostics.errors;
1295
1361
 
1296
- const io = d.comp.io;
1297
-
1298
- var pp = try Preprocessor.initDefault(d.comp);
1362
+ var pp = try Preprocessor.init(comp, .{
1363
+ .base_file = source.id,
1364
+ .path_replacements = d.macro_prefix_map.items,
1365
+ });
1299
1366
  defer pp.deinit();
1300
1367
 
1301
1368
  var name_buf: [std.fs.max_name_bytes]u8 = undefined;
@@ -1304,8 +1371,8 @@ fn processSource(
1304
1371
 
1305
1372
  if (opt_dep_file) |*dep_file| pp.dep_file = dep_file;
1306
1373
 
1307
- if (d.comp.langopts.ms_extensions) {
1308
- d.comp.ms_cwd_source_id = source.id;
1374
+ if (comp.langopts.ms_extensions) {
1375
+ comp.ms_cwd_source_id = source.id;
1309
1376
  }
1310
1377
  const dump_mode = d.debug_dump_letters.getPreprocessorDumpMode();
1311
1378
  if (d.verbose_pp) pp.verbose = true;
@@ -1333,10 +1400,10 @@ fn processSource(
1333
1400
  const dep_file_name = try d.getDepFileName(source, writer_buf[0..std.fs.max_name_bytes]);
1334
1401
 
1335
1402
  const file = if (dep_file_name) |path|
1336
- d.comp.cwd.createFile(io, path, .{}) catch |er|
1403
+ comp.cwd.createFile(io, path, .{}) catch |er|
1337
1404
  return d.fatal("unable to create dependency file '{s}': {s}", .{ path, errorDescription(er) })
1338
1405
  else
1339
- Io.File.stdout();
1406
+ std.Io.File.stdout();
1340
1407
  defer if (dep_file_name != null) file.close(io);
1341
1408
 
1342
1409
  var file_writer = file.writer(io, &writer_buf);
@@ -1358,10 +1425,10 @@ fn processSource(
1358
1425
  }
1359
1426
 
1360
1427
  const file = if (d.output_name) |some|
1361
- d.comp.cwd.createFile(io, some, .{}) catch |er|
1428
+ comp.cwd.createFile(io, some, .{}) catch |er|
1362
1429
  return d.fatal("unable to create output file '{s}': {s}", .{ some, errorDescription(er) })
1363
1430
  else
1364
- Io.File.stdout();
1431
+ std.Io.File.stdout();
1365
1432
  defer if (d.output_name != null) file.close(io);
1366
1433
 
1367
1434
  var file_writer = file.writer(io, &writer_buf);
@@ -1376,8 +1443,11 @@ fn processSource(
1376
1443
  defer tree.deinit();
1377
1444
 
1378
1445
  if (d.verbose_ast) {
1379
- var stdout = Io.File.stdout().writer(&writer_buf);
1380
- tree.dump(d.detectConfig(stdout.file), &stdout.interface) catch {};
1446
+ var stdout = std.Io.File.stdout().writer(io, &writer_buf);
1447
+ tree.dump(.{
1448
+ .mode = try d.detectMode(stdout.file),
1449
+ .writer = &stdout.interface,
1450
+ }) catch {};
1381
1451
  }
1382
1452
 
1383
1453
  d.printDiagnosticsStats();
@@ -1392,10 +1462,10 @@ fn processSource(
1392
1462
  return;
1393
1463
  }
1394
1464
 
1395
- if (d.comp.target.ofmt != .elf or d.comp.target.cpu.arch != .x86_64) {
1465
+ if (comp.target.ofmt != .elf or comp.target.cpu.arch != .x86_64) {
1396
1466
  return d.fatal(
1397
1467
  "unsupported target {s}-{s}-{s}, currently only x86-64 elf is supported",
1398
- .{ @tagName(d.comp.target.cpu.arch), @tagName(d.comp.target.os.tag), @tagName(d.comp.target.abi) },
1468
+ .{ @tagName(comp.target.cpu.arch), @tagName(comp.target.os.tag), @tagName(comp.target.abi) },
1399
1469
  );
1400
1470
  }
1401
1471
 
@@ -1407,15 +1477,15 @@ fn processSource(
1407
1477
  .{},
1408
1478
  );
1409
1479
 
1410
- const assembly = try asm_fn(d.comp.target.toZigTarget(), &tree);
1480
+ const assembly = try asm_fn(comp.target.toZigTarget(), &tree);
1411
1481
  defer assembly.deinit(gpa);
1412
1482
 
1413
1483
  if (d.only_preprocess_and_compile) {
1414
- const out_file = d.comp.cwd.createFile(io, out_file_name, .{}) catch |er|
1484
+ const out_file = comp.cwd.createFile(io, out_file_name, .{}) catch |er|
1415
1485
  return d.fatal("unable to create output file '{s}': {s}", .{ out_file_name, errorDescription(er) });
1416
1486
  defer out_file.close(io);
1417
1487
 
1418
- assembly.writeToFile(out_file) catch |er|
1488
+ assembly.writeToFile(io, out_file) catch |er|
1419
1489
  return d.fatal("unable to write to output file '{s}': {s}", .{ out_file_name, errorDescription(er) });
1420
1490
  if (fast_exit) std.process.exit(0); // Not linking, no need for cleanup.
1421
1491
  return;
@@ -1425,10 +1495,10 @@ fn processSource(
1425
1495
  // then assemble to out_file_name
1426
1496
  var assembly_name_buf: [std.fs.max_name_bytes]u8 = undefined;
1427
1497
  const assembly_out_file_name = try d.getRandomFilename(&assembly_name_buf, ".s");
1428
- const out_file = d.comp.cwd.createFile(io, assembly_out_file_name, .{}) catch |er|
1498
+ const out_file = comp.cwd.createFile(io, assembly_out_file_name, .{}) catch |er|
1429
1499
  return d.fatal("unable to create output file '{s}': {s}", .{ assembly_out_file_name, errorDescription(er) });
1430
1500
  defer out_file.close(io);
1431
- assembly.writeToFile(out_file) catch |er|
1501
+ assembly.writeToFile(io, out_file) catch |er|
1432
1502
  return d.fatal("unable to write to output file '{s}': {s}", .{ assembly_out_file_name, errorDescription(er) });
1433
1503
  try d.invokeAssembler(tc, assembly_out_file_name, out_file_name);
1434
1504
  if (d.only_compile) {
@@ -1440,8 +1510,11 @@ fn processSource(
1440
1510
  defer ir.deinit(gpa);
1441
1511
 
1442
1512
  if (d.verbose_ir) {
1443
- var stdout = Io.File.stdout().writer(&writer_buf);
1444
- ir.dump(gpa, d.detectConfig(stdout.file), &stdout.interface) catch {};
1513
+ var stdout = std.Io.File.stdout().writer(io, &writer_buf);
1514
+ ir.dump(gpa, .{
1515
+ .mode = try d.detectMode(stdout.file),
1516
+ .writer = &stdout.interface,
1517
+ }) catch {};
1445
1518
  }
1446
1519
 
1447
1520
  var render_errors: Ir.Renderer.ErrorList = .{};
@@ -1450,8 +1523,8 @@ fn processSource(
1450
1523
  render_errors.deinit(gpa);
1451
1524
  }
1452
1525
 
1453
- var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |e| switch (e) {
1454
- error.OutOfMemory => return error.OutOfMemory,
1526
+ var obj = ir.render(gpa, d.comp.target.toZigTarget(), &render_errors) catch |er| switch (er) {
1527
+ error.OutOfMemory => |e| return e,
1455
1528
  error.LowerFail => {
1456
1529
  return d.fatal(
1457
1530
  "unable to render Ir to machine code: {s}",
@@ -1494,8 +1567,9 @@ fn dumpLinkerArgs(w: *std.Io.Writer, items: []const []const u8) !void {
1494
1567
  /// The entry point of the Aro compiler.
1495
1568
  /// **MAY call `exit` if `fast_exit` is set.**
1496
1569
  pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compilation.Error!void {
1497
- const gpa = d.comp.gpa;
1498
- const io = d.comp.io;
1570
+ const comp = d.comp;
1571
+ const io = comp.io;
1572
+ const gpa = comp.gpa;
1499
1573
  var argv: std.ArrayList([]const u8) = .empty;
1500
1574
  defer argv.deinit(gpa);
1501
1575
 
@@ -1507,7 +1581,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compil
1507
1581
 
1508
1582
  if (d.verbose_linker_args) {
1509
1583
  var stdout_buf: [4096]u8 = undefined;
1510
- var stdout = Io.File.stdout().writer(&stdout_buf);
1584
+ var stdout = std.Io.File.stdout().writer(io, &stdout_buf);
1511
1585
  dumpLinkerArgs(&stdout.interface, argv.items) catch {
1512
1586
  return d.fatal("unable to dump linker args: {s}", .{errorDescription(stdout.err.?)});
1513
1587
  };
@@ -1521,8 +1595,9 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compil
1521
1595
  }) catch |er| {
1522
1596
  return d.fatal("unable to spawn linker: {s}", .{errorDescription(er)});
1523
1597
  };
1598
+
1524
1599
  const term = child.wait(io) catch |er| {
1525
- return d.fatal("unable to wait linker: {s}", .{errorDescription(er)});
1600
+ return d.fatal("error waiting for linker: {s}", .{errorDescription(er)});
1526
1601
  };
1527
1602
  switch (term) {
1528
1603
  .exited => |code| if (code != 0) {
@@ -1541,7 +1616,7 @@ pub fn invokeLinker(d: *Driver, tc: *Toolchain, comptime fast_exit: bool) Compil
1541
1616
 
1542
1617
  fn exitWithCleanup(d: *Driver, code: u8) noreturn {
1543
1618
  for (d.link_objects.items[d.link_objects.items.len - d.temp_file_count ..]) |obj| {
1544
- std.fs.deleteFileAbsolute(obj) catch {};
1619
+ std.Io.Dir.deleteFileAbsolute(d.comp.io, obj) catch {};
1545
1620
  }
1546
1621
  std.process.exit(code);
1547
1622
  }
@@ -7,16 +7,22 @@ pub const Compiler = enum {
7
7
  clang,
8
8
  gcc,
9
9
  msvc,
10
+ no,
10
11
 
11
12
  pub fn defaultGccVersion(self: Compiler) u32 {
12
13
  return switch (self) {
13
14
  .clang => 4 * 10_000 + 2 * 100 + 1,
14
- .gcc => 7 * 10_000 + 1 * 100 + 0,
15
+ .no, .gcc => 7 * 10_000 + 1 * 100 + 0,
15
16
  .msvc => 0,
16
17
  };
17
18
  }
18
19
  };
19
20
 
21
+ pub const BoundsSafety = enum {
22
+ none,
23
+ clang,
24
+ };
25
+
20
26
  /// The floating-point evaluation method for intermediate results within a single expression
21
27
  pub const FPEvalMethod = enum(i8) {
22
28
  /// The evaluation method cannot be determined or is inconsistent for this target.
@@ -116,7 +122,7 @@ pub const Standard = enum {
116
122
 
117
123
  const LangOpts = @This();
118
124
 
119
- emulate: Compiler = .clang,
125
+ emulate: Compiler = .no,
120
126
  standard: Standard = .default,
121
127
  /// -fshort-enums option, makes enums only take up as much space as they need to hold all the values.
122
128
  short_enums: bool = false,
@@ -149,6 +155,10 @@ preserve_comments_in_macros: bool = false,
149
155
  /// e.g. 4.2.1 == 40201
150
156
  gnuc_version: ?u32 = null,
151
157
 
158
+ bounds_safety: BoundsSafety = .none,
159
+
160
+ default_symbol_visibility: std.builtin.SymbolVisibility = .default,
161
+
152
162
  pub fn setStandard(self: *LangOpts, name: []const u8) error{InvalidStandard}!void {
153
163
  self.standard = Standard.NameMap.get(name) orelse return error.InvalidStandard;
154
164
  }
@@ -79,9 +79,9 @@ pub const expected_integer_constant_expr: Diagnostic = .{
79
79
  };
80
80
 
81
81
  pub const missing_type_specifier: Diagnostic = .{
82
- .fmt = "type specifier missing, defaults to 'int'",
82
+ .fmt = "type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int",
83
83
  .opt = .@"implicit-int",
84
- .kind = .warning,
84
+ .kind = .@"error",
85
85
  };
86
86
 
87
87
  pub const missing_type_specifier_c23: Diagnostic = .{
@@ -90,9 +90,9 @@ pub const missing_type_specifier_c23: Diagnostic = .{
90
90
  };
91
91
 
92
92
  pub const param_not_declared: Diagnostic = .{
93
- .fmt = "parameter '{s}' was not declared, defaults to 'int'",
93
+ .fmt = "parameter '{s}' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int",
94
94
  .opt = .@"implicit-int",
95
- .kind = .warning,
95
+ .kind = .@"error",
96
96
  .extension = true,
97
97
  };
98
98
 
@@ -216,8 +216,13 @@ pub const illegal_storage_on_func: Diagnostic = .{
216
216
  .kind = .@"error",
217
217
  };
218
218
 
219
- pub const illegal_storage_on_global: Diagnostic = .{
220
- .fmt = "illegal storage class on global variable",
219
+ pub const auto_on_global: Diagnostic = .{
220
+ .fmt = "'auto' specified on global variable",
221
+ .kind = .@"error",
222
+ };
223
+
224
+ pub const register_on_global: Diagnostic = .{
225
+ .fmt = "register name not specified for global variable",
221
226
  .kind = .@"error",
222
227
  };
223
228
 
@@ -1507,13 +1512,38 @@ pub const builtin_must_be_called: Diagnostic = .{
1507
1512
  .kind = .@"error",
1508
1513
  };
1509
1514
 
1510
- pub const va_start_not_in_func: Diagnostic = .{
1511
- .fmt = "'va_start' cannot be used outside a function",
1515
+ pub const va_func_not_in_func: Diagnostic = .{
1516
+ .fmt = "'{s}' cannot be used outside a function",
1517
+ .kind = .@"error",
1518
+ };
1519
+
1520
+ pub const va_func_fixed_args: Diagnostic = .{
1521
+ .fmt = "'{s}' used in a function with fixed args",
1522
+ .kind = .@"error",
1523
+ };
1524
+
1525
+ pub const va_func_not_always_inline: Diagnostic = .{
1526
+ .fmt = "'{s}' used in a function that is not always inlined",
1527
+ .kind = .@"error",
1528
+ };
1529
+
1530
+ pub const va_pack_non_call: Diagnostic = .{
1531
+ .fmt = "'__va_arg_pack' used outside a call",
1532
+ .kind = .@"error",
1533
+ };
1534
+
1535
+ pub const va_pack_non_variadic_call: Diagnostic = .{
1536
+ .fmt = "'__va_arg_pack' passed to non-variadic function",
1537
+ .kind = .@"error",
1538
+ };
1539
+
1540
+ pub const va_pack_non_variadic_arg: Diagnostic = .{
1541
+ .fmt = "'__va_arg_pack' passed as non-variadic argument",
1512
1542
  .kind = .@"error",
1513
1543
  };
1514
1544
 
1515
- pub const va_start_fixed_args: Diagnostic = .{
1516
- .fmt = "'va_start' used in a function with fixed args",
1545
+ pub const va_pack_non_final_arg: Diagnostic = .{
1546
+ .fmt = "'__va_arg_pack' is not the final argument",
1517
1547
  .kind = .@"error",
1518
1548
  };
1519
1549
 
@@ -2258,11 +2288,11 @@ pub const unterminated_char_literal_error: Diagnostic = .{
2258
2288
  .kind = .@"error",
2259
2289
  };
2260
2290
 
2261
- // pub const def_no_proto_deprecated: Diagnostic = .{
2262
- // .fmt = "a function definition without a prototype is deprecated in all versions of C and is not supported in C23",
2263
- // .kind = .warning,
2264
- // .opt = .@"deprecated-non-prototype",
2265
- // };
2291
+ pub const def_no_proto_deprecated: Diagnostic = .{
2292
+ .fmt = "a function definition without a prototype is deprecated in all versions of C and is not supported in C23",
2293
+ .kind = .warning,
2294
+ .opt = .@"deprecated-non-prototype",
2295
+ };
2266
2296
 
2267
2297
  pub const passing_args_to_kr: Diagnostic = .{
2268
2298
  .fmt = "passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C23",
@@ -2296,6 +2326,11 @@ pub const invalid_compound_literal_storage_class: Diagnostic = .{
2296
2326
  .kind = .@"error",
2297
2327
  };
2298
2328
 
2329
+ pub const register_on_global_compound_literal: Diagnostic = .{
2330
+ .fmt = "file scope compound literal specifies 'register'",
2331
+ .kind = .@"error",
2332
+ };
2333
+
2299
2334
  pub const identifier_not_normalized: Diagnostic = .{
2300
2335
  .fmt = "'{normalized}' is not in NFC",
2301
2336
  .kind = .warning,
@@ -2465,10 +2500,9 @@ pub const declared_const_here: Diagnostic = .{
2465
2500
  .kind = .note,
2466
2501
  };
2467
2502
 
2468
- pub const nonnull_not_applicable: Diagnostic = .{
2469
- .fmt = "'nonnull' attribute only applies to functions, methods, and parameters",
2470
- .kind = .warning,
2471
- .opt = .@"ignored-attributes",
2503
+ pub const pointer_bounds_declared_here: Diagnostic = .{
2504
+ .fmt = "pointer '{s}' declared {s} here",
2505
+ .kind = .note,
2472
2506
  };
2473
2507
 
2474
2508
  pub const mixing_decimal_floats: Diagnostic = .{
@@ -2480,3 +2514,29 @@ pub const invalid_attribute_location: Diagnostic = .{
2480
2514
  .fmt = "{s} cannot appear here",
2481
2515
  .kind = .@"error",
2482
2516
  };
2517
+
2518
+ pub const attribute_requires_pointer: Diagnostic = .{
2519
+ .fmt = "'{s}' attribute only applies to pointer arguments",
2520
+ .kind = .@"error",
2521
+ };
2522
+
2523
+ pub const single_requires_zero_index: Diagnostic = .{
2524
+ .fmt = "array subscript on single pointer must use a constant index of 0 to be in bounds",
2525
+ .kind = .@"error",
2526
+ };
2527
+
2528
+ pub const pointer_arith_single: Diagnostic = .{
2529
+ .fmt = "pointer arithmetic on single pointer is out of bounds; consider adding '__counted_by'",
2530
+ .kind = .@"error",
2531
+ };
2532
+
2533
+ pub const redundant_bounds_annotation: Diagnostic = .{
2534
+ .fmt = "pointer annotated with {s} multiple times. Annotate only once to remove this warning",
2535
+ .kind = .warning,
2536
+ .opt = .@"bounds-attributes-redundant",
2537
+ };
2538
+
2539
+ pub const multiple_bounds_annotations: Diagnostic = .{
2540
+ .fmt = "pointer cannot have more than one bound attribute",
2541
+ .kind = .@"error",
2542
+ };