@zigc/lib 0.17.0-dev.633 → 0.17.0-dev.644

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.
@@ -104,6 +104,7 @@ fn getPkgs(
104
104
  else => |e| return e,
105
105
  };
106
106
 
107
+ step.clearFailedCommand(maker.gpa);
107
108
  pc.pkgs = result;
108
109
  return result;
109
110
  }
@@ -1291,11 +1291,9 @@ fn appendModuleFlags(
1291
1291
 
1292
1292
  if (m.resolved_target.get(conf)) |resolved_target| {
1293
1293
  // Communicate the query via CLI since it's more compact.
1294
- if (resolved_target.query.get(conf)) |compact_query| {
1294
+ if (resolved_target.unwrapQuery(conf)) |query| {
1295
1295
  try zig_args.ensureUnusedCapacity(gpa, 6);
1296
1296
 
1297
- const query = compact_query.unwrap(conf);
1298
-
1299
1297
  zig_args.appendAssumeCapacity("-target");
1300
1298
  zig_args.appendAssumeCapacity(try query.zigTriple(arena));
1301
1299
 
@@ -332,6 +332,12 @@ pub fn make(
332
332
 
333
333
  try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest);
334
334
  try populateGeneratedPaths(maker, output_placeholders.items, cache_root, &digest);
335
+
336
+ // The utility functions that spawn the child process must unconditionally allocate
337
+ // the failed command because at that point it is not known whether the step will
338
+ // pass or fail based on the process termination. Here we free the memory since
339
+ // the step has succeeded.
340
+ step.clearFailedCommand(gpa);
335
341
  }
336
342
 
337
343
  /// Reads stdout of a Zig test process until a termination condition is reached:
@@ -1823,8 +1829,7 @@ fn runCommand(
1823
1829
  }
1824
1830
  const root_module = producer.root_module.get(conf);
1825
1831
  const root_module_target = root_module.resolved_target.get(conf).?.result.get(conf);
1826
- const other_target_query = root_module_target.unwrap(conf);
1827
- const root_target = std.zig.system.resolveTargetQuery(io, other_target_query) catch unreachable;
1832
+ const root_target = root_module_target.unwrapTarget(conf);
1828
1833
  const link_libc = maker.stepByIndex(producer_index).extended.compile.is_linking_libc;
1829
1834
 
1830
1835
  const host: std.Target = std.zig.system.resolveTargetQuery(io, .{}) catch |he| switch (he) {
@@ -1908,6 +1913,12 @@ fn runCommand(
1908
1913
  // by default. '-S inherit-env' was added in Wasmtime version 20.
1909
1914
  interp_argv.appendAssumeCapacity("-Sinherit-env");
1910
1915
  interp_argv.appendSliceAssumeCapacity(argv);
1916
+
1917
+ // Enable more detailed backtraces by default, but allow the user to override this (e.g.
1918
+ // with `WASMTIME_BACKTRACE_DETAILS=0`) if desired.
1919
+ if (environ_map.get("WASMTIME_BACKTRACE_DETAILS") == null) {
1920
+ try environ_map.put("WASMTIME_BACKTRACE_DETAILS", "1");
1921
+ }
1911
1922
  } else {
1912
1923
  return failForeign(arena, &conf_run, maker, run_index, "-fwasmtime", argv[0], &root_target, &host);
1913
1924
  }
@@ -2143,7 +2154,11 @@ fn spawnChildAndCollect(
2143
2154
  .dir => unreachable,
2144
2155
  .inherit => null,
2145
2156
  };
2146
- errdefer step.setFailedCommand(gpa, argv, .{
2157
+ // We have to set the failed command here regardless of whether this
2158
+ // function returns an error because only after this function returns
2159
+ // does the logic determine whether the child process termination was
2160
+ // success or failure.
2161
+ step.setFailedCommand(gpa, argv, .{
2147
2162
  .cwd = cwd_string,
2148
2163
  .child_env = environ_map,
2149
2164
  .parent_env = &graph.environ_map,
@@ -40,10 +40,11 @@ pub fn make(
40
40
  argv.appendAssumeCapacity("--global-cache-dir");
41
41
  argv.appendAssumeCapacity(graph.global_cache_root.path orelse ".");
42
42
 
43
- if (conf_tc.target.get(conf).?.query.unwrap()) |compact_query| {
44
- const query = compact_query.get(conf).unwrap(conf);
45
- argv.appendAssumeCapacity("-target");
46
- argv.appendAssumeCapacity(try query.zigTriple(arena));
43
+ if (conf_tc.target.get(conf)) |resolved_target| {
44
+ if (resolved_target.unwrapQuery(conf)) |query| {
45
+ argv.appendAssumeCapacity("-target");
46
+ argv.appendAssumeCapacity(try query.zigTriple(arena));
47
+ }
47
48
  }
48
49
 
49
50
  switch (conf_tc.flags.optimize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.17.0-dev.633",
3
+ "version": "0.17.0-dev.644",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2144,6 +2144,33 @@ pub const ResolvedTarget = struct {
2144
2144
  return (unwrap(this) orelse return null).get(c);
2145
2145
  }
2146
2146
  };
2147
+
2148
+ pub fn unwrapQuery(rt: *const ResolvedTarget, c: *const Configuration) ?std.Target.Query {
2149
+ const tq = rt.query.get(c) orelse return null;
2150
+ const cpu_arch = tq.flags.cpu_arch.unwrap() orelse rt.result.get(c).flags.cpu_arch.unwrap().?;
2151
+ return .{
2152
+ .cpu_arch = cpu_arch,
2153
+ .cpu_model = switch (tq.flags.cpu_model) {
2154
+ .native => .native,
2155
+ .baseline => .baseline,
2156
+ .determined_by_arch_os => .determined_by_arch_os,
2157
+ .explicit => .{ .explicit = cpu_arch.parseCpuModel(tq.cpu_name.value.?.slice(c)).? },
2158
+ },
2159
+ .cpu_features_add = tq.cpu_features_add.value orelse .empty,
2160
+ .cpu_features_sub = tq.cpu_features_sub.value orelse .empty,
2161
+ .os_tag = tq.flags.os_tag.unwrap(),
2162
+ .os_version_min = tq.os_version_min.u.unwrap(c),
2163
+ .os_version_max = tq.os_version_max.u.unwrap(c),
2164
+ .glibc_version = if (tq.glibc_version.value) |s|
2165
+ std.SemanticVersion.parse(s.slice(c)) catch unreachable
2166
+ else
2167
+ null,
2168
+ .android_api_level = tq.android_api_level.value,
2169
+ .abi = tq.flags.abi.unwrap(),
2170
+ .dynamic_linker = if (tq.dynamic_linker.value) |s| .init(s.slice(c)) else null,
2171
+ .ofmt = tq.flags.object_format.unwrap(),
2172
+ };
2173
+ }
2147
2174
  };
2148
2175
 
2149
2176
  pub const TargetQuery = struct {
@@ -2731,29 +2758,50 @@ pub const TargetQuery = struct {
2731
2758
  dynamic_linker: bool,
2732
2759
  };
2733
2760
 
2734
- pub fn unwrap(tq: *const TargetQuery, c: *const Configuration) std.Target.Query {
2735
- const cpu_arch = tq.flags.cpu_arch.unwrap();
2761
+ pub fn unwrapTarget(tq: *const TargetQuery, c: *const Configuration) std.Target {
2762
+ const cpu_arch = tq.flags.cpu_arch.unwrap().?;
2763
+ const os_tag = tq.flags.os_tag.unwrap().?;
2736
2764
  return .{
2737
- .cpu_arch = cpu_arch,
2738
- .cpu_model = switch (tq.flags.cpu_model) {
2739
- .native => .native,
2740
- .baseline => .baseline,
2741
- .determined_by_arch_os => .determined_by_arch_os,
2742
- .explicit => .{ .explicit = cpu_arch.?.parseCpuModel(tq.cpu_name.value.?.slice(c)).? },
2765
+ .cpu = .{
2766
+ .arch = cpu_arch,
2767
+ .model = cpu_arch.parseCpuModel(tq.cpu_name.value.?.slice(c)).?,
2768
+ .features = tq.cpu_features_add.value.?,
2743
2769
  },
2744
- .cpu_features_add = tq.cpu_features_add.value orelse .empty,
2745
- .cpu_features_sub = tq.cpu_features_sub.value orelse .empty,
2746
- .os_tag = tq.flags.os_tag.unwrap(),
2747
- .os_version_min = tq.os_version_min.u.unwrap(c),
2748
- .os_version_max = tq.os_version_max.u.unwrap(c),
2749
- .glibc_version = if (tq.glibc_version.value) |s|
2750
- std.SemanticVersion.parse(s.slice(c)) catch unreachable
2751
- else
2752
- null,
2753
- .android_api_level = tq.android_api_level.value,
2754
- .abi = tq.flags.abi.unwrap(),
2755
- .dynamic_linker = if (tq.dynamic_linker.value) |s| .init(s.slice(c)) else null,
2756
- .ofmt = tq.flags.object_format.unwrap(),
2770
+ .os = .{
2771
+ .tag = os_tag,
2772
+ .version_range = switch (os_tag) {
2773
+ .linux => .{ .linux = .{
2774
+ .range = .{
2775
+ .min = tq.os_version_min.u.unwrap(c).?.semver,
2776
+ .max = tq.os_version_max.u.unwrap(c).?.semver,
2777
+ },
2778
+ .glibc = std.SemanticVersion.parse(tq.glibc_version.value.?.slice(c)) catch unreachable,
2779
+ .android = tq.android_api_level.value.?,
2780
+ } },
2781
+ .hurd => .{ .hurd = .{
2782
+ .range = .{
2783
+ .min = tq.os_version_min.u.unwrap(c).?.semver,
2784
+ .max = tq.os_version_max.u.unwrap(c).?.semver,
2785
+ },
2786
+ .glibc = std.SemanticVersion.parse(tq.glibc_version.value.?.slice(c)) catch unreachable,
2787
+ } },
2788
+ .windows => .{ .windows = .{
2789
+ .min = tq.os_version_min.u.unwrap(c).?.windows,
2790
+ .max = tq.os_version_max.u.unwrap(c).?.windows,
2791
+ } },
2792
+ else => switch (tq.os_version_min.u.unwrap(c).?) {
2793
+ .none => .{ .none = {} },
2794
+ .semver => |min| .{ .semver = .{
2795
+ .min = min,
2796
+ .max = tq.os_version_max.u.unwrap(c).?.semver,
2797
+ } },
2798
+ .windows => unreachable,
2799
+ },
2800
+ },
2801
+ },
2802
+ .abi = tq.flags.abi.unwrap().?,
2803
+ .ofmt = tq.flags.object_format.unwrap().?,
2804
+ .dynamic_linker = .init(if (tq.dynamic_linker.value) |s| s.slice(c) else null),
2757
2805
  };
2758
2806
  }
2759
2807
  };
package/std/Build.zig CHANGED
@@ -830,7 +830,17 @@ pub fn addModule(b: *Build, name: []const u8, options: Module.CreateOptions) *Mo
830
830
  const graph = b.graph;
831
831
  const arena = graph.arena;
832
832
  const module = Module.create(b, options);
833
- b.modules.put(arena, graph.dupeString(name), module) catch @panic("OOM");
833
+ const gop = b.modules.getOrPutValue(
834
+ arena,
835
+ graph.dupeString(name),
836
+ module,
837
+ ) catch @panic("OOM");
838
+ if (gop.found_existing) {
839
+ panic(
840
+ "A module with the name '{s}' has already been added to the package. Consider creating a private module with std.Build.createModule",
841
+ .{name},
842
+ );
843
+ }
834
844
  return module;
835
845
  }
836
846
 
@@ -992,13 +1002,33 @@ pub fn addWriteFile(b: *Build, file_path: []const u8, data: []const u8) *Step.Wr
992
1002
  pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile {
993
1003
  const graph = b.graph;
994
1004
  const wf = Step.WriteFile.create(b);
995
- b.named_writefiles.put(graph.arena, graph.dupeString(name), wf) catch @panic("OOM");
1005
+ const gop = b.named_writefiles.getOrPutValue(
1006
+ graph.arena,
1007
+ graph.dupeString(name),
1008
+ wf,
1009
+ ) catch @panic("OOM");
1010
+ if (gop.found_existing) {
1011
+ panic(
1012
+ "A WriteFile step with the name '{s}' has already been added to the package. Consider creating a private WriteFile step with std.Build.addWriteFiles",
1013
+ .{name},
1014
+ );
1015
+ }
996
1016
  return wf;
997
1017
  }
998
1018
 
999
1019
  pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void {
1000
1020
  const graph = b.graph;
1001
- b.named_lazy_paths.put(graph.arena, graph.dupeString(name), lp.dupe(graph)) catch @panic("OOM");
1021
+ const gop = b.named_lazy_paths.getOrPutValue(
1022
+ graph.arena,
1023
+ graph.dupeString(name),
1024
+ lp.dupe(graph),
1025
+ ) catch @panic("OOM");
1026
+ if (gop.found_existing) {
1027
+ panic(
1028
+ "A LazyPath with the name '{s}' has already been added to the package.",
1029
+ .{name},
1030
+ );
1031
+ }
1002
1032
  }
1003
1033
 
1004
1034
  /// Creates a step for mutating files inside a temporary directory created lazily
package/std/Io/Kqueue.zig CHANGED
@@ -1403,7 +1403,7 @@ fn openSocketPosix(
1403
1403
 
1404
1404
  if (options.ip6_only) {
1405
1405
  if (posix.IPV6 == void) return error.OptionUnsupported;
1406
- try setSocketOption(k, socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 0);
1406
+ try setSocketOption(k, socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 1);
1407
1407
  }
1408
1408
 
1409
1409
  return socket_fd;
@@ -12409,7 +12409,7 @@ fn openSocketPosix(
12409
12409
 
12410
12410
  if (options.ip6_only) {
12411
12411
  if (posix.IPV6 == void) return error.OptionUnsupported;
12412
- try setSocketOptionPosix(socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 0);
12412
+ try setSocketOptionPosix(socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 1);
12413
12413
  }
12414
12414
 
12415
12415
  return socket_fd;
package/std/Io/Uring.zig CHANGED
@@ -2739,6 +2739,7 @@ fn dirOpenDir(
2739
2739
  error.FileBusy => return errnoBug(.TXTBSY),
2740
2740
  error.PathAlreadyExists => return errnoBug(.EXIST), // Not creating.
2741
2741
  error.OperationUnsupported => return errnoBug(.OPNOTSUPP), // No TMPFILE, no locks.
2742
+ error.ReadOnlyFileSystem => return errnoBug(.ROFS), // Not creating.
2742
2743
  else => |e| return e,
2743
2744
  },
2744
2745
  };
@@ -3164,6 +3165,7 @@ fn dirRealPathFile(
3164
3165
  }, 0) catch |err| switch (err) {
3165
3166
  error.WouldBlock => return errnoBug(.AGAIN),
3166
3167
  error.OperationUnsupported => return errnoBug(.OPNOTSUPP), // Not asking for locks.
3168
+ error.ReadOnlyFileSystem => return errnoBug(.ROFS), // Not creating.
3167
3169
  else => |e| return e,
3168
3170
  };
3169
3171
  defer ev.closeAsync(fd);
@@ -5984,7 +5986,7 @@ fn socket(
5984
5986
 
5985
5987
  if (options.ip6_only) {
5986
5988
  if (linux.IPV6 == void) return error.OptionUnsupported;
5987
- try ev.setsockopt(cancel_region, socket_fd, linux.IPPROTO.IPV6, linux.IPV6.V6ONLY, 0);
5989
+ try ev.setsockopt(cancel_region, socket_fd, linux.IPPROTO.IPV6, linux.IPV6.V6ONLY, 1);
5988
5990
  }
5989
5991
 
5990
5992
  return socket_fd;