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

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 (242) hide show
  1. package/LICENSE +19 -0
  2. package/c/math.zig +135 -35
  3. package/c/stropts.zig +17 -0
  4. package/c.zig +1 -0
  5. package/compiler/aro/aro/Attribute/names.zig +604 -589
  6. package/compiler/aro/aro/Attribute.zig +202 -116
  7. package/compiler/aro/aro/Builtins/common.zig +874 -863
  8. package/compiler/aro/aro/Builtins/eval.zig +15 -7
  9. package/compiler/aro/aro/Builtins.zig +0 -1
  10. package/compiler/aro/aro/CodeGen.zig +3 -1
  11. package/compiler/aro/aro/Compilation.zig +120 -97
  12. package/compiler/aro/aro/Diagnostics.zig +21 -17
  13. package/compiler/aro/aro/Driver/GCCDetector.zig +635 -0
  14. package/compiler/aro/aro/Driver.zig +124 -50
  15. package/compiler/aro/aro/LangOpts.zig +12 -2
  16. package/compiler/aro/aro/Parser/Diagnostic.zig +79 -19
  17. package/compiler/aro/aro/Parser.zig +336 -142
  18. package/compiler/aro/aro/Preprocessor/Diagnostic.zig +21 -0
  19. package/compiler/aro/aro/Preprocessor.zig +127 -56
  20. package/compiler/aro/aro/Target.zig +17 -12
  21. package/compiler/aro/aro/Tokenizer.zig +31 -14
  22. package/compiler/aro/aro/Toolchain.zig +4 -7
  23. package/compiler/aro/aro/Tree.zig +178 -148
  24. package/compiler/aro/aro/TypeStore.zig +82 -24
  25. package/compiler/aro/aro/Value.zig +13 -17
  26. package/compiler/aro/aro/features.zig +1 -0
  27. package/compiler/aro/aro/pragmas/once.zig +0 -1
  28. package/compiler/aro/aro/record_layout.zig +3 -3
  29. package/compiler/aro/assembly_backend/x86_64.zig +3 -4
  30. package/compiler/aro/backend/Assembly.zig +1 -2
  31. package/compiler/aro/backend/Interner.zig +2 -2
  32. package/compiler/aro/backend/Ir.zig +100 -92
  33. package/compiler/aro/include/ptrcheck.h +49 -0
  34. package/compiler/aro/main.zig +26 -10
  35. package/compiler/build_runner.zig +1 -0
  36. package/compiler/objdump.zig +93 -0
  37. package/compiler/reduce.zig +5 -1
  38. package/compiler/resinator/compile.zig +2 -2
  39. package/compiler/resinator/main.zig +7 -1
  40. package/compiler/resinator/preprocess.zig +1 -3
  41. package/compiler/std-docs.zig +8 -1
  42. package/compiler/test_runner.zig +193 -61
  43. package/compiler/translate-c/MacroTranslator.zig +80 -11
  44. package/compiler/translate-c/PatternList.zig +1 -9
  45. package/compiler/translate-c/Scope.zig +43 -6
  46. package/compiler/translate-c/Translator.zig +364 -126
  47. package/compiler/translate-c/ast.zig +19 -11
  48. package/compiler/translate-c/main.zig +75 -16
  49. package/compiler_rt/cos.zig +141 -52
  50. package/compiler_rt/limb64.zig +266 -0
  51. package/compiler_rt/long_double.zig +37 -0
  52. package/compiler_rt/mulo.zig +6 -1
  53. package/compiler_rt/rem_pio2l.zig +173 -0
  54. package/compiler_rt/sin.zig +140 -55
  55. package/compiler_rt/sincos.zig +279 -72
  56. package/compiler_rt/tan.zig +118 -47
  57. package/compiler_rt/trig.zig +256 -6
  58. package/compiler_rt.zig +2 -0
  59. package/fuzzer.zig +855 -307
  60. package/libc/musl/src/math/pow.c +343 -0
  61. package/package.json +1 -1
  62. package/std/Build/Fuzz.zig +6 -19
  63. package/std/Build/Module.zig +1 -1
  64. package/std/Build/Step/CheckObject.zig +3 -3
  65. package/std/Build/Step/Compile.zig +18 -0
  66. package/std/Build/Step/ConfigHeader.zig +49 -33
  67. package/std/Build/Step/InstallArtifact.zig +18 -0
  68. package/std/Build/Step/Run.zig +536 -87
  69. package/std/Build/Step/TranslateC.zig +0 -6
  70. package/std/Build/Step.zig +8 -15
  71. package/std/Build/WebServer.zig +29 -17
  72. package/std/Build/abi.zig +47 -11
  73. package/std/Build.zig +17 -14
  74. package/std/Io/Dispatch.zig +2 -0
  75. package/std/Io/File/Reader.zig +3 -1
  76. package/std/Io/File.zig +1 -0
  77. package/std/Io/Kqueue.zig +2 -2
  78. package/std/Io/Threaded.zig +181 -143
  79. package/std/Io/Uring.zig +2 -1
  80. package/std/Io.zig +970 -2
  81. package/std/Target.zig +3 -2
  82. package/std/Thread.zig +8 -3
  83. package/std/array_hash_map.zig +96 -555
  84. package/std/array_list.zig +22 -31
  85. package/std/bit_set.zig +22 -6
  86. package/std/builtin/assembly.zig +68 -0
  87. package/std/c.zig +17 -17
  88. package/std/compress/flate/Compress.zig +3 -3
  89. package/std/crypto/Certificate/Bundle.zig +15 -1
  90. package/std/crypto/codecs/asn1.zig +33 -18
  91. package/std/crypto/codecs/base64_hex_ct.zig +14 -4
  92. package/std/debug/Dwarf.zig +29 -9
  93. package/std/debug/Info.zig +4 -0
  94. package/std/debug/MachOFile.zig +46 -8
  95. package/std/debug/Pdb.zig +539 -36
  96. package/std/debug/SelfInfo/Elf.zig +19 -18
  97. package/std/debug/SelfInfo/MachO.zig +18 -7
  98. package/std/debug/SelfInfo/Windows.zig +138 -36
  99. package/std/debug.zig +179 -65
  100. package/std/enums.zig +25 -19
  101. package/std/heap/ArenaAllocator.zig +145 -154
  102. package/std/heap/debug_allocator.zig +7 -7
  103. package/std/http/Client.zig +10 -6
  104. package/std/http.zig +11 -9
  105. package/std/json/Stringify.zig +3 -3
  106. package/std/json/dynamic.zig +4 -4
  107. package/std/math/big/int.zig +16 -17
  108. package/std/mem/Allocator.zig +4 -5
  109. package/std/mem.zig +48 -0
  110. package/std/os/emscripten.zig +2 -18
  111. package/std/os/linux/arc.zig +144 -0
  112. package/std/os/linux.zig +21 -4
  113. package/std/os/windows.zig +2 -2
  114. package/std/pdb.zig +143 -4
  115. package/std/posix.zig +6 -12
  116. package/std/priority_dequeue.zig +13 -12
  117. package/std/priority_queue.zig +5 -4
  118. package/std/process/Child.zig +1 -1
  119. package/std/process/Environ.zig +1 -1
  120. package/std/start.zig +17 -4
  121. package/std/std.zig +19 -6
  122. package/std/testing/FailingAllocator.zig +4 -4
  123. package/std/testing/Smith.zig +37 -2
  124. package/std/zig/Ast/Render.zig +186 -458
  125. package/std/zig/Ast.zig +0 -4
  126. package/std/zig/AstGen.zig +44 -7
  127. package/std/zig/AstSmith.zig +2602 -0
  128. package/std/zig/Client.zig +8 -3
  129. package/std/zig/Parse.zig +83 -74
  130. package/std/zig/Server.zig +26 -0
  131. package/std/zig/Zir.zig +17 -0
  132. package/std/zig/c_translation/helpers.zig +14 -9
  133. package/std/zig/llvm/Builder.zig +107 -48
  134. package/std/zig/system.zig +20 -4
  135. package/std/zig/tokenizer.zig +2 -1
  136. package/std/zig.zig +6 -0
  137. package/compiler/aro/aro/Driver/Filesystem.zig +0 -241
  138. package/libc/mingw/complex/cabs.c +0 -48
  139. package/libc/mingw/complex/cabsf.c +0 -48
  140. package/libc/mingw/complex/cacos.c +0 -50
  141. package/libc/mingw/complex/cacosf.c +0 -50
  142. package/libc/mingw/complex/carg.c +0 -48
  143. package/libc/mingw/complex/cargf.c +0 -48
  144. package/libc/mingw/complex/casin.c +0 -50
  145. package/libc/mingw/complex/casinf.c +0 -50
  146. package/libc/mingw/complex/catan.c +0 -50
  147. package/libc/mingw/complex/catanf.c +0 -50
  148. package/libc/mingw/complex/ccos.c +0 -50
  149. package/libc/mingw/complex/ccosf.c +0 -50
  150. package/libc/mingw/complex/cexp.c +0 -48
  151. package/libc/mingw/complex/cexpf.c +0 -48
  152. package/libc/mingw/complex/cimag.c +0 -48
  153. package/libc/mingw/complex/cimagf.c +0 -48
  154. package/libc/mingw/complex/clog.c +0 -48
  155. package/libc/mingw/complex/clog10.c +0 -49
  156. package/libc/mingw/complex/clog10f.c +0 -49
  157. package/libc/mingw/complex/clogf.c +0 -48
  158. package/libc/mingw/complex/conj.c +0 -48
  159. package/libc/mingw/complex/conjf.c +0 -48
  160. package/libc/mingw/complex/cpow.c +0 -48
  161. package/libc/mingw/complex/cpowf.c +0 -48
  162. package/libc/mingw/complex/cproj.c +0 -48
  163. package/libc/mingw/complex/cprojf.c +0 -48
  164. package/libc/mingw/complex/creal.c +0 -48
  165. package/libc/mingw/complex/crealf.c +0 -48
  166. package/libc/mingw/complex/csin.c +0 -50
  167. package/libc/mingw/complex/csinf.c +0 -50
  168. package/libc/mingw/complex/csqrt.c +0 -48
  169. package/libc/mingw/complex/csqrtf.c +0 -48
  170. package/libc/mingw/complex/ctan.c +0 -50
  171. package/libc/mingw/complex/ctanf.c +0 -50
  172. package/libc/mingw/math/arm/s_rint.c +0 -86
  173. package/libc/mingw/math/arm/s_rintf.c +0 -51
  174. package/libc/mingw/math/arm/sincos.S +0 -30
  175. package/libc/mingw/math/arm-common/sincosl.c +0 -13
  176. package/libc/mingw/math/arm64/rint.c +0 -12
  177. package/libc/mingw/math/arm64/rintf.c +0 -12
  178. package/libc/mingw/math/arm64/sincos.S +0 -32
  179. package/libc/mingw/math/bsd_private_base.h +0 -148
  180. package/libc/mingw/math/frexpf.c +0 -13
  181. package/libc/mingw/math/frexpl.c +0 -71
  182. package/libc/mingw/math/x86/acosf.c +0 -29
  183. package/libc/mingw/math/x86/atanf.c +0 -23
  184. package/libc/mingw/math/x86/atanl.c +0 -18
  185. package/libc/mingw/math/x86/cos.def.h +0 -65
  186. package/libc/mingw/math/x86/cosl.c +0 -46
  187. package/libc/mingw/math/x86/cosl_internal.S +0 -55
  188. package/libc/mingw/math/x86/ldexp.c +0 -23
  189. package/libc/mingw/math/x86/scalbn.S +0 -41
  190. package/libc/mingw/math/x86/scalbnf.S +0 -40
  191. package/libc/mingw/math/x86/sin.def.h +0 -65
  192. package/libc/mingw/math/x86/sinl.c +0 -46
  193. package/libc/mingw/math/x86/sinl_internal.S +0 -58
  194. package/libc/mingw/math/x86/tanl.S +0 -62
  195. package/libc/mingw/misc/btowc.c +0 -28
  196. package/libc/mingw/misc/wcstof.c +0 -66
  197. package/libc/mingw/misc/wcstoimax.c +0 -132
  198. package/libc/mingw/misc/wcstoumax.c +0 -126
  199. package/libc/mingw/misc/wctob.c +0 -29
  200. package/libc/mingw/misc/winbs_uint64.c +0 -6
  201. package/libc/mingw/misc/winbs_ulong.c +0 -6
  202. package/libc/mingw/misc/winbs_ushort.c +0 -6
  203. package/libc/mingw/stdio/_Exit.c +0 -10
  204. package/libc/mingw/stdio/_findfirst64i32.c +0 -21
  205. package/libc/mingw/stdio/_findnext64i32.c +0 -21
  206. package/libc/mingw/stdio/_fstat64i32.c +0 -37
  207. package/libc/mingw/stdio/_stat64i32.c +0 -37
  208. package/libc/mingw/stdio/_wfindfirst64i32.c +0 -21
  209. package/libc/mingw/stdio/_wfindnext64i32.c +0 -21
  210. package/libc/mingw/stdio/_wstat64i32.c +0 -37
  211. package/libc/musl/src/legacy/isastream.c +0 -7
  212. package/libc/musl/src/legacy/valloc.c +0 -8
  213. package/libc/musl/src/math/__cosl.c +0 -96
  214. package/libc/musl/src/math/__sinl.c +0 -78
  215. package/libc/musl/src/math/__tanl.c +0 -143
  216. package/libc/musl/src/math/aarch64/lrint.c +0 -10
  217. package/libc/musl/src/math/aarch64/lrintf.c +0 -10
  218. package/libc/musl/src/math/aarch64/rintf.c +0 -7
  219. package/libc/musl/src/math/cosl.c +0 -39
  220. package/libc/musl/src/math/fdim.c +0 -10
  221. package/libc/musl/src/math/finite.c +0 -7
  222. package/libc/musl/src/math/finitef.c +0 -7
  223. package/libc/musl/src/math/frexp.c +0 -23
  224. package/libc/musl/src/math/frexpf.c +0 -23
  225. package/libc/musl/src/math/frexpl.c +0 -29
  226. package/libc/musl/src/math/i386/lrint.c +0 -8
  227. package/libc/musl/src/math/i386/lrintf.c +0 -8
  228. package/libc/musl/src/math/i386/rintf.c +0 -7
  229. package/libc/musl/src/math/lrint.c +0 -72
  230. package/libc/musl/src/math/lrintf.c +0 -8
  231. package/libc/musl/src/math/powerpc64/lrint.c +0 -16
  232. package/libc/musl/src/math/powerpc64/lrintf.c +0 -16
  233. package/libc/musl/src/math/rintf.c +0 -30
  234. package/libc/musl/src/math/s390x/rintf.c +0 -15
  235. package/libc/musl/src/math/sincosl.c +0 -60
  236. package/libc/musl/src/math/sinl.c +0 -41
  237. package/libc/musl/src/math/tanl.c +0 -29
  238. package/libc/musl/src/math/x32/lrint.s +0 -5
  239. package/libc/musl/src/math/x32/lrintf.s +0 -5
  240. package/libc/musl/src/math/x86_64/lrint.c +0 -8
  241. package/libc/musl/src/math/x86_64/lrintf.c +0 -8
  242. package/libc/wasi/libc-bottom-half/sources/reallocarray.c +0 -14
@@ -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
  }
@@ -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);
@@ -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");
@@ -985,11 +986,14 @@ pub const EmitArtifact = enum {
985
986
  docs,
986
987
  pdb,
987
988
  h,
989
+ compiler_rt_dyn_lib,
988
990
 
989
991
  /// If using `Server` to communicate with the compiler, it will place requested artifacts in
990
992
  /// paths under the output directory, where those paths are named according to this function.
991
993
  /// Returned string is allocated with `gpa` and owned by the caller.
992
994
  pub fn cacheName(ea: EmitArtifact, gpa: Allocator, opts: BinNameOptions) Allocator.Error![]const u8 {
995
+ // hack for stage2_x86_64 + coff. See Coff.flush.
996
+ if (ea == .compiler_rt_dyn_lib) return "compiler_rt.dll";
993
997
  const suffix: []const u8 = switch (ea) {
994
998
  .bin => return binNameAlloc(gpa, opts),
995
999
  .@"asm" => ".s",
@@ -999,6 +1003,7 @@ pub const EmitArtifact = enum {
999
1003
  .docs => "-docs",
1000
1004
  .pdb => ".pdb",
1001
1005
  .h => ".h",
1006
+ .compiler_rt_dyn_lib => unreachable,
1002
1007
  };
1003
1008
  return std.fmt.allocPrint(gpa, "{s}{s}", .{ opts.root_name, suffix });
1004
1009
  }
@@ -1166,6 +1171,7 @@ pub const ClangCliParam = struct {
1166
1171
  test {
1167
1172
  _ = Ast;
1168
1173
  _ = AstRlAnnotate;
1174
+ _ = AstSmith;
1169
1175
  _ = BuiltinFn;
1170
1176
  _ = Client;
1171
1177
  _ = ErrorBundle;
@@ -1,241 +0,0 @@
1
- const builtin = @import("builtin");
2
- const is_windows = builtin.os.tag == .windows;
3
-
4
- const std = @import("std");
5
- const Io = std.Io;
6
- const mem = std.std.mem;
7
-
8
- fn readFileFake(entries: []const Filesystem.Entry, path: []const u8, buf: []u8) ?[]const u8 {
9
- @branchHint(.cold);
10
- for (entries) |entry| {
11
- if (mem.eql(u8, entry.path, path)) {
12
- const len = @min(entry.contents.len, buf.len);
13
- @memcpy(buf[0..len], entry.contents[0..len]);
14
- return buf[0..len];
15
- }
16
- }
17
- return null;
18
- }
19
-
20
- fn findProgramByNameFake(entries: []const Filesystem.Entry, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
21
- @branchHint(.cold);
22
- if (mem.indexOfScalar(u8, name, '/') != null) {
23
- @memcpy(buf[0..name.len], name);
24
- return buf[0..name.len];
25
- }
26
- const path_env = path orelse return null;
27
- var fib = std.heap.FixedBufferAllocator.init(buf);
28
-
29
- var it = mem.tokenizeScalar(u8, path_env, std.fs.path.delimiter);
30
- while (it.next()) |path_dir| {
31
- defer fib.reset();
32
- const full_path = std.fs.path.join(fib.allocator(), &.{ path_dir, name }) catch continue;
33
- if (canExecuteFake(entries, full_path)) return full_path;
34
- }
35
-
36
- return null;
37
- }
38
-
39
- fn canExecuteFake(entries: []const Filesystem.Entry, path: []const u8) bool {
40
- @branchHint(.cold);
41
- for (entries) |entry| {
42
- if (mem.eql(u8, entry.path, path)) {
43
- return entry.executable;
44
- }
45
- }
46
- return false;
47
- }
48
-
49
- fn existsFake(entries: []const Filesystem.Entry, path: []const u8) bool {
50
- @branchHint(.cold);
51
- var buf: [std.fs.max_path_bytes]u8 = undefined;
52
- var fib = std.heap.FixedBufferAllocator.init(&buf);
53
- const resolved = std.fs.path.resolvePosix(fib.allocator(), &.{path}) catch return false;
54
- for (entries) |entry| {
55
- if (mem.eql(u8, entry.path, resolved)) return true;
56
- }
57
- return false;
58
- }
59
-
60
- fn canExecutePosix(io: Io, path: []const u8) bool {
61
- Io.Dir.accessAbsolute(io, path, .{ .execute = true }) catch return false;
62
- // Todo: ensure path is not a directory
63
- return true;
64
- }
65
-
66
- /// TODO
67
- fn canExecuteWindows(path: []const u8) bool {
68
- _ = path;
69
- return true;
70
- }
71
-
72
- /// TODO
73
- fn findProgramByNameWindows(allocator: std.mem.Allocator, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
74
- _ = path;
75
- _ = buf;
76
- _ = name;
77
- _ = allocator;
78
- return null;
79
- }
80
-
81
- /// TODO: does WASI need special handling?
82
- fn findProgramByNamePosix(name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
83
- if (mem.indexOfScalar(u8, name, '/') != null) {
84
- @memcpy(buf[0..name.len], name);
85
- return buf[0..name.len];
86
- }
87
- const path_env = path orelse return null;
88
- var fib = std.heap.FixedBufferAllocator.init(buf);
89
-
90
- var it = mem.tokenizeScalar(u8, path_env, std.fs.path.delimiter);
91
- while (it.next()) |path_dir| {
92
- defer fib.reset();
93
- const full_path = std.fs.path.join(fib.allocator(), &.{ path_dir, name }) catch continue;
94
- if (canExecutePosix(full_path)) return full_path;
95
- }
96
-
97
- return null;
98
- }
99
-
100
- pub const Filesystem = union(enum) {
101
- real: std.Io.Dir,
102
- fake: []const Entry,
103
-
104
- const Entry = struct {
105
- path: []const u8,
106
- contents: []const u8 = "",
107
- executable: bool = false,
108
- };
109
-
110
- const FakeDir = struct {
111
- entries: []const Entry,
112
- path: []const u8,
113
-
114
- fn iterate(self: FakeDir) FakeDir.Iterator {
115
- return .{
116
- .entries = self.entries,
117
- .base = self.path,
118
- };
119
- }
120
-
121
- const Iterator = struct {
122
- entries: []const Entry,
123
- base: []const u8,
124
- i: usize = 0,
125
-
126
- fn next(self: *@This()) !?std.Io.Dir.Entry {
127
- while (self.i < self.entries.len) {
128
- const entry = self.entries[self.i];
129
- self.i += 1;
130
- if (entry.path.len == self.base.len) continue;
131
- if (std.mem.startsWith(u8, entry.path, self.base)) {
132
- const remaining = entry.path[self.base.len + 1 ..];
133
- if (std.mem.indexOfScalar(u8, remaining, std.fs.path.sep) != null) continue;
134
- const extension = std.fs.path.extension(remaining);
135
- const kind: std.Io.Dir.Entry.Kind = if (extension.len == 0) .directory else .file;
136
- return .{ .name = remaining, .kind = kind };
137
- }
138
- }
139
- return null;
140
- }
141
- };
142
- };
143
-
144
- const Dir = union(enum) {
145
- dir: std.Io.Dir,
146
- fake: FakeDir,
147
-
148
- pub fn iterate(self: Dir) Iterator {
149
- return switch (self) {
150
- .dir => |dir| .{ .iterator = dir.iterate() },
151
- .fake => |fake| .{ .fake = fake.iterate() },
152
- };
153
- }
154
-
155
- pub fn close(self: *Dir, io: Io) void {
156
- switch (self.*) {
157
- .dir => |*d| d.close(io),
158
- .fake => {},
159
- }
160
- }
161
- };
162
-
163
- const Iterator = union(enum) {
164
- iterator: std.Io.Dir.Iterator,
165
- fake: FakeDir.Iterator,
166
-
167
- pub fn next(self: *Iterator) std.Io.Dir.Iterator.Error!?std.Io.Dir.Entry {
168
- return switch (self.*) {
169
- .iterator => |*it| it.next(),
170
- .fake => |*it| it.next(),
171
- };
172
- }
173
- };
174
-
175
- pub fn exists(fs: Filesystem, io: Io, path: []const u8) bool {
176
- switch (fs) {
177
- .real => |cwd| {
178
- cwd.access(io, path, .{}) catch return false;
179
- return true;
180
- },
181
- .fake => |paths| return existsFake(paths, path),
182
- }
183
- }
184
-
185
- pub fn joinedExists(fs: Filesystem, parts: []const []const u8) bool {
186
- var buf: [std.fs.max_path_bytes]u8 = undefined;
187
- var fib = std.heap.FixedBufferAllocator.init(&buf);
188
- const joined = std.fs.path.join(fib.allocator(), parts) catch return false;
189
- return fs.exists(joined);
190
- }
191
-
192
- pub fn canExecute(fs: Filesystem, path: []const u8) bool {
193
- return switch (fs) {
194
- .real => if (is_windows) canExecuteWindows(path) else canExecutePosix(path),
195
- .fake => |entries| canExecuteFake(entries, path),
196
- };
197
- }
198
-
199
- /// Search for an executable named `name` using platform-specific logic
200
- /// If it's found, write the full path to `buf` and return a slice of it
201
- /// Otherwise retun null
202
- pub fn findProgramByName(fs: Filesystem, allocator: std.mem.Allocator, name: []const u8, path: ?[]const u8, buf: []u8) ?[]const u8 {
203
- std.debug.assert(name.len > 0);
204
- return switch (fs) {
205
- .real => if (is_windows) findProgramByNameWindows(allocator, name, path, buf) else findProgramByNamePosix(name, path, buf),
206
- .fake => |entries| findProgramByNameFake(entries, name, path, buf),
207
- };
208
- }
209
-
210
- /// Read the file at `path` into `buf`.
211
- /// Returns null if any errors are encountered
212
- /// Otherwise returns a slice of `buf`. If the file is larger than `buf` partial contents are returned
213
- pub fn readFile(fs: Filesystem, io: Io, path: []const u8, buf: []u8) ?[]const u8 {
214
- return switch (fs) {
215
- .real => |cwd| {
216
- const file = cwd.openFile(io, path, .{}) catch return null;
217
- defer file.close(io);
218
-
219
- const bytes_read = file.readAll(buf) catch return null;
220
- return buf[0..bytes_read];
221
- },
222
- .fake => |entries| readFileFake(entries, path, buf),
223
- };
224
- }
225
-
226
- pub fn openDir(fs: Filesystem, io: Io, dir_name: []const u8) std.Io.Dir.OpenError!Dir {
227
- return switch (fs) {
228
- .real => |cwd| .{ .dir = try cwd.openDir(io, dir_name, .{ .access_sub_paths = false, .iterate = true }) },
229
- .fake => |entries| .{ .fake = .{ .entries = entries, .path = dir_name } },
230
- };
231
- }
232
- };
233
-
234
- test "Fake filesystem" {
235
- const fs: Filesystem = .{ .fake = &.{
236
- .{ .path = "/usr/bin" },
237
- } };
238
- try std.testing.expect(fs.exists("/usr/bin"));
239
- try std.testing.expect(fs.exists("/usr/bin/foo/.."));
240
- try std.testing.expect(!fs.exists("/usr/bin/bar"));
241
- }
@@ -1,48 +0,0 @@
1
- /*
2
- This Software is provided under the Zope Public License (ZPL) Version 2.1.
3
-
4
- Copyright (c) 2009, 2010 by the mingw-w64 project
5
-
6
- See the AUTHORS file for the list of contributors to the mingw-w64 project.
7
-
8
- This license has been certified as open source. It has also been designated
9
- as GPL compatible by the Free Software Foundation (FSF).
10
-
11
- Redistribution and use in source and binary forms, with or without
12
- modification, are permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions in source code must retain the accompanying copyright
15
- notice, this list of conditions, and the following disclaimer.
16
- 2. Redistributions in binary form must reproduce the accompanying
17
- copyright notice, this list of conditions, and the following disclaimer
18
- in the documentation and/or other materials provided with the
19
- distribution.
20
- 3. Names of the copyright holders must not be used to endorse or promote
21
- products derived from this software without prior written permission
22
- from the copyright holders.
23
- 4. The right to distribute this software or to use it for any purpose does
24
- not give you the right to use Servicemarks (sm) or Trademarks (tm) of
25
- the copyright holders. Use of them is covered by separate agreement
26
- with the copyright holders.
27
- 5. If any files are modified, you must cause the modified files to carry
28
- prominent notices stating that you changed the files and the date of
29
- any change.
30
-
31
- Disclaimer
32
-
33
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
34
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
35
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
36
- EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
37
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
39
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43
- */
44
-
45
- /* double version of the functions. */
46
- #define _NEW_COMPLEX_DOUBLE 1
47
- #include "complex_internal.h"
48
- #include "cabs.def.h"