@zigc/lib 0.17.0-dev.256 → 0.17.0-dev.269

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.17.0-dev.256",
3
+ "version": "0.17.0-dev.269",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,7 +59,7 @@ pub fn joinStringZ(p: Path, gpa: Allocator, sub_path: []const u8) Allocator.Erro
59
59
  return p.root_dir.joinZ(gpa, parts);
60
60
  }
61
61
 
62
- pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.File.OpenFlags) !Io.File {
62
+ pub fn openFile(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.OpenFileOptions) !Io.File {
63
63
  var buf: [fs.max_path_bytes]u8 = undefined;
64
64
  const joined_path = if (p.sub_path.len == 0) sub_path else p: {
65
65
  break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
@@ -2468,7 +2468,7 @@ fn dirCreateFile(
2468
2468
  userdata: ?*anyopaque,
2469
2469
  dir: Dir,
2470
2470
  sub_path: []const u8,
2471
- flags: File.CreateFlags,
2471
+ flags: Dir.CreateFileOptions,
2472
2472
  ) File.OpenError!File {
2473
2473
  const ev: *Evented = @ptrCast(@alignCast(userdata));
2474
2474
  _ = ev;
@@ -2601,7 +2601,7 @@ fn dirOpenFile(
2601
2601
  userdata: ?*anyopaque,
2602
2602
  dir: Dir,
2603
2603
  sub_path: []const u8,
2604
- flags: File.OpenFlags,
2604
+ flags: Dir.OpenFileOptions,
2605
2605
  ) File.OpenError!File {
2606
2606
  const ev: *Evented = @ptrCast(@alignCast(userdata));
2607
2607
 
@@ -3936,7 +3936,7 @@ fn fileMemoryMapWrite(userdata: ?*anyopaque, mm: *File.MemoryMap) File.WritePosi
3936
3936
 
3937
3937
  fn processExecutableOpen(
3938
3938
  userdata: ?*anyopaque,
3939
- flags: File.OpenFlags,
3939
+ flags: Dir.OpenFileOptions,
3940
3940
  ) process.OpenExecutableError!File {
3941
3941
  const ev: *Evented = @ptrCast(@alignCast(userdata));
3942
3942
  // _NSGetExecutablePath() returns a path that might be a symlink to
package/std/Io/File.zig CHANGED
@@ -142,21 +142,12 @@ pub fn stat(file: File, io: Io) StatError!Stat {
142
142
  return io.vtable.fileStat(io.userdata, file);
143
143
  }
144
144
 
145
- /// Deprecated, renamed to `Dir.OpenFileOptions.Mode`.
146
- pub const OpenMode = Dir.OpenFileOptions.Mode;
147
-
148
145
  pub const Lock = enum {
149
146
  none,
150
147
  shared,
151
148
  exclusive,
152
149
  };
153
150
 
154
- /// Deprecated, renamed to `Dir.OpenFileOptions`
155
- pub const OpenFlags = Dir.OpenFileOptions;
156
-
157
- /// Deprecated, renamed to `Dir.CreateFileOptions`.
158
- pub const CreateFlags = Dir.CreateFileOptions;
159
-
160
151
  pub const OpenError = error{
161
152
  PipeBusy,
162
153
  NoDevice,
package/std/Io/Kqueue.zig CHANGED
@@ -877,7 +877,7 @@ fn dirAccess(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir
877
877
  _ = options;
878
878
  @panic("TODO");
879
879
  }
880
- fn dirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
880
+ fn dirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: Dir.CreateFileOptions) File.OpenError!File {
881
881
  const k: *Kqueue = @ptrCast(@alignCast(userdata));
882
882
  _ = k;
883
883
  _ = dir;
@@ -885,7 +885,7 @@ fn dirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: F
885
885
  _ = flags;
886
886
  @panic("TODO");
887
887
  }
888
- fn dirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File {
888
+ fn dirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: Dir.OpenFileOptions) File.OpenError!File {
889
889
  const k: *Kqueue = @ptrCast(@alignCast(userdata));
890
890
  _ = k;
891
891
  _ = dir;
package/std/Io/Uring.zig CHANGED
@@ -2812,7 +2812,7 @@ fn dirCreateFile(
2812
2812
  userdata: ?*anyopaque,
2813
2813
  dir: Dir,
2814
2814
  sub_path: []const u8,
2815
- flags: File.CreateFlags,
2815
+ flags: Dir.CreateFileOptions,
2816
2816
  ) File.OpenError!File {
2817
2817
  const ev: *Evented = @ptrCast(@alignCast(userdata));
2818
2818
 
@@ -2996,7 +2996,7 @@ fn dirOpenFile(
2996
2996
  userdata: ?*anyopaque,
2997
2997
  dir: Dir,
2998
2998
  sub_path: []const u8,
2999
- flags: File.OpenFlags,
2999
+ flags: Dir.OpenFileOptions,
3000
3000
  ) File.OpenError!File {
3001
3001
  const ev: *Evented = @ptrCast(@alignCast(userdata));
3002
3002
 
@@ -4104,7 +4104,7 @@ fn fileMemoryMapWrite(userdata: ?*anyopaque, mm: *File.MemoryMap) File.WritePosi
4104
4104
 
4105
4105
  fn processExecutableOpen(
4106
4106
  userdata: ?*anyopaque,
4107
- flags: File.OpenFlags,
4107
+ flags: Dir.OpenFileOptions,
4108
4108
  ) process.OpenExecutableError!File {
4109
4109
  const ev: *Evented = @ptrCast(@alignCast(userdata));
4110
4110
  return dirOpenFile(ev, .{ .handle = linux.AT.FDCWD }, "/proc/self/exe", flags);
package/std/Io.zig CHANGED
@@ -54,9 +54,6 @@ pub const VTable = struct {
54
54
  /// If it returns `null` it means `result` has been already populated and
55
55
  /// `await` will be a no-op.
56
56
  ///
57
- /// When this function returns non-null, the implementation guarantees that
58
- /// a unit of concurrency has been assigned to the returned task.
59
- ///
60
57
  /// Thread-safe.
61
58
  async: *const fn (
62
59
  /// Corresponds to `Io.userdata`.
@@ -111,10 +108,6 @@ pub const VTable = struct {
111
108
  result_alignment: std.mem.Alignment,
112
109
  ) void,
113
110
 
114
- /// When this function returns, implementation guarantees that `start` has
115
- /// either already been called, or a unit of concurrency has been assigned
116
- /// to the task of calling the function.
117
- ///
118
111
  /// Thread-safe.
119
112
  groupAsync: *const fn (
120
113
  /// Corresponds to `Io.userdata`.
@@ -1251,8 +1244,11 @@ pub const Group = struct {
1251
1244
  /// cancelation propagation boundary.
1252
1245
  ///
1253
1246
  /// Once this function is called, there are resources associated with the
1254
- /// group. To release those resources, `Group.await` or `Group.cancel` must
1255
- /// eventually be called.
1247
+ /// group. To release those resources, `await` or `cancel` must eventually
1248
+ /// be called.
1249
+ ///
1250
+ /// `function` is not guaranteed to have been called until `await` or
1251
+ /// `cancel` is called.
1256
1252
  pub fn async(g: *Group, io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))) void {
1257
1253
  const Args = @TypeOf(args);
1258
1254
  const TypeErased = struct {
@@ -1290,6 +1286,9 @@ pub const Group = struct {
1290
1286
  /// will also cause `error.Canceled` to be returned when the group
1291
1287
  /// does ultimately finish.
1292
1288
  ///
1289
+ /// After this function returns, all tasks of the `Group` created with
1290
+ /// `async` or `concurrent` are guaranteed to have run.
1291
+ ///
1293
1292
  /// Idempotent. Not threadsafe.
1294
1293
  ///
1295
1294
  /// It is safe to call this function concurrently with `Group.async` or
@@ -1304,6 +1303,9 @@ pub const Group = struct {
1304
1303
  /// Equivalent to `await` but immediately requests cancelation on all
1305
1304
  /// members of the group.
1306
1305
  ///
1306
+ /// After this function returns, all tasks of the `Group` created with
1307
+ /// `async` or `concurrent` are guaranteed to have run.
1308
+ ///
1307
1309
  /// For a description of cancelation and cancelation points, see `Future.cancel`.
1308
1310
  ///
1309
1311
  /// Idempotent. Not threadsafe.
@@ -2922,7 +2924,7 @@ pub fn failingDirAccess(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, o
2922
2924
  return error.FileNotFound;
2923
2925
  }
2924
2926
 
2925
- pub fn failingDirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: File.CreateFlags) File.OpenError!File {
2927
+ pub fn failingDirCreateFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.CreateFileOptions) File.OpenError!File {
2926
2928
  _ = userdata;
2927
2929
  _ = dir;
2928
2930
  _ = sub_path;
@@ -2938,7 +2940,7 @@ pub fn failingDirCreateFileAtomic(userdata: ?*anyopaque, dir: Dir, sub_path: []c
2938
2940
  return error.NoSpaceLeft;
2939
2941
  }
2940
2942
 
2941
- pub fn failingDirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: File.OpenFlags) File.OpenError!File {
2943
+ pub fn failingDirOpenFile(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, flags: Dir.OpenFileOptions) File.OpenError!File {
2942
2944
  _ = userdata;
2943
2945
  _ = dir;
2944
2946
  _ = sub_path;
@@ -3275,7 +3277,7 @@ pub fn unreachableFileMemoryMapWrite(userdata: ?*anyopaque, mm: *File.MemoryMap)
3275
3277
  unreachable;
3276
3278
  }
3277
3279
 
3278
- pub fn failingProcessExecutableOpen(userdata: ?*anyopaque, flags: File.OpenFlags) std.process.OpenExecutableError!File {
3280
+ pub fn failingProcessExecutableOpen(userdata: ?*anyopaque, flags: Dir.OpenFileOptions) std.process.OpenExecutableError!File {
3279
3281
  _ = userdata;
3280
3282
  _ = flags;
3281
3283
  return error.FileNotFound;
package/std/Thread.zig CHANGED
@@ -695,6 +695,9 @@ const PosixThreadImpl = struct {
695
695
  .linux => {
696
696
  return LinuxThreadImpl.getCpuCount();
697
697
  },
698
+ .emscripten => {
699
+ return @as(usize, @intCast(std.os.emscripten.emscripten_num_logical_cores()));
700
+ },
698
701
  .openbsd => {
699
702
  var count: c_int = undefined;
700
703
  var count_size: usize = @sizeOf(c_int);
@@ -887,17 +887,25 @@ pub fn Custom(
887
887
  }
888
888
 
889
889
  /// Modify an entry's key without reordering any entries.
890
- pub fn setKey(self: *Self, gpa: Allocator, index: usize, new_key: K) Oom!void {
890
+ pub fn setKey(self: *Self, index: usize, new_key: K) void {
891
891
  if (@sizeOf(ByIndexContext) != 0)
892
892
  @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call setKeyContext instead.");
893
- return setKeyContext(self, gpa, index, new_key, undefined);
893
+ return setKeyContext(self, index, new_key, undefined);
894
894
  }
895
895
 
896
- pub fn setKeyContext(self: *Self, gpa: Allocator, index: usize, new_key: K, ctx: Context) Oom!void {
897
- const key_ptr = &self.entries.items(.key)[index];
898
- key_ptr.* = new_key;
899
- if (store_hash) self.entries.items(.hash)[index] = checkedHash(ctx, key_ptr.*);
900
- try rebuildIndex(self, gpa, undefined);
896
+ pub fn setKeyContext(self: *Self, index: usize, new_key: K, ctx: Context) void {
897
+ if (self.index_header) |header| {
898
+ self.removeFromIndexByIndex(index, if (store_hash) {} else ctx, header);
899
+
900
+ self.entries.items(.key)[index] = new_key;
901
+ const h = checkedHash(ctx, new_key);
902
+ if (store_hash) self.entries.items(.hash)[index] = h;
903
+
904
+ insertEntryIntoNewHeader(header, h, index);
905
+ } else {
906
+ self.entries.items(.key)[index] = new_key;
907
+ if (store_hash) self.entries.items(.hash)[index] = checkedHash(ctx, new_key);
908
+ }
901
909
  }
902
910
 
903
911
  fn rebuildIndex(self: *Self, gpa: Allocator, ctx: Context) Oom!void {
@@ -1420,39 +1428,50 @@ pub fn Custom(
1420
1428
  fn insertAllEntriesIntoNewHeaderGeneric(self: *Self, ctx: ByIndexContext, header: *IndexHeader, comptime I: type) void {
1421
1429
  const slice = self.entries.slice();
1422
1430
  const items = if (store_hash) slice.items(.hash) else slice.items(.key);
1423
- const indexes = header.indexes(I);
1424
1431
 
1425
- entry_loop: for (items, 0..) |key, i| {
1426
- const h = if (store_hash) key else checkedHash(ctx, key);
1427
- const start_index = safeTruncate(usize, h);
1428
- const end_index = start_index +% indexes.len;
1429
- var index = start_index;
1430
- var entry_index = @as(I, @intCast(i));
1431
- var distance_from_start_index: I = 0;
1432
- while (index != end_index) : ({
1433
- index +%= 1;
1434
- distance_from_start_index += 1;
1435
- }) {
1436
- const slot = header.constrainIndex(index);
1437
- const next_index = indexes[slot];
1438
- if (next_index.isEmpty()) {
1439
- indexes[slot] = .{
1440
- .distance_from_start_index = distance_from_start_index,
1441
- .entry_index = entry_index,
1442
- };
1443
- continue :entry_loop;
1444
- }
1445
- if (next_index.distance_from_start_index < distance_from_start_index) {
1446
- indexes[slot] = .{
1447
- .distance_from_start_index = distance_from_start_index,
1448
- .entry_index = entry_index,
1449
- };
1450
- distance_from_start_index = next_index.distance_from_start_index;
1451
- entry_index = next_index.entry_index;
1452
- }
1432
+ for (items, 0..) |hash_or_key, i| {
1433
+ const h = if (store_hash) hash_or_key else checkedHash(ctx, hash_or_key);
1434
+ insertEntryIntoNewHeaderGeneric(header, h, i, I);
1435
+ }
1436
+ }
1437
+
1438
+ fn insertEntryIntoNewHeader(header: *IndexHeader, h: u32, i: usize) void {
1439
+ switch (header.capacityIndexType()) {
1440
+ .u8 => insertEntryIntoNewHeaderGeneric(header, h, i, u8),
1441
+ .u16 => insertEntryIntoNewHeaderGeneric(header, h, i, u16),
1442
+ .u32 => insertEntryIntoNewHeaderGeneric(header, h, i, u32),
1443
+ }
1444
+ }
1445
+ fn insertEntryIntoNewHeaderGeneric(header: *IndexHeader, h: u32, i: usize, comptime I: type) void {
1446
+ const indexes = header.indexes(I);
1447
+ const start_index = safeTruncate(usize, h);
1448
+ const end_index = start_index +% indexes.len;
1449
+ var index = start_index;
1450
+ var entry_index: I = @intCast(i);
1451
+ var distance_from_start_index: I = 0;
1452
+ while (index != end_index) : ({
1453
+ index +%= 1;
1454
+ distance_from_start_index += 1;
1455
+ }) {
1456
+ const slot = header.constrainIndex(index);
1457
+ const next_index = indexes[slot];
1458
+ if (next_index.isEmpty()) {
1459
+ indexes[slot] = .{
1460
+ .distance_from_start_index = distance_from_start_index,
1461
+ .entry_index = entry_index,
1462
+ };
1463
+ return;
1464
+ }
1465
+ if (next_index.distance_from_start_index < distance_from_start_index) {
1466
+ indexes[slot] = .{
1467
+ .distance_from_start_index = distance_from_start_index,
1468
+ .entry_index = entry_index,
1469
+ };
1470
+ distance_from_start_index = next_index.distance_from_start_index;
1471
+ entry_index = next_index.entry_index;
1453
1472
  }
1454
- unreachable;
1455
1473
  }
1474
+ unreachable;
1456
1475
  }
1457
1476
 
1458
1477
  fn checkedHash(ctx: anytype, key: anytype) u32 {
@@ -2118,7 +2137,7 @@ test "setKey storehash true" {
2118
2137
  try map.put(gpa, 12, 34);
2119
2138
  try map.put(gpa, 56, 78);
2120
2139
 
2121
- try map.setKey(gpa, 0, 42);
2140
+ map.setKey(0, 42);
2122
2141
  try testing.expectEqual(2, map.count());
2123
2142
  try testing.expectEqual(false, map.contains(12));
2124
2143
  try testing.expectEqual(34, map.get(42));
@@ -2134,13 +2153,49 @@ test "setKey storehash false" {
2134
2153
  try map.put(gpa, 12, 34);
2135
2154
  try map.put(gpa, 56, 78);
2136
2155
 
2137
- try map.setKey(gpa, 0, 42);
2156
+ map.setKey(0, 42);
2138
2157
  try testing.expectEqual(2, map.count());
2139
2158
  try testing.expectEqual(false, map.contains(12));
2140
2159
  try testing.expectEqual(34, map.get(42));
2141
2160
  try testing.expectEqual(78, map.get(56));
2142
2161
  }
2143
2162
 
2163
+ test "setKey storehash false with index" {
2164
+ const gpa = std.testing.allocator;
2165
+
2166
+ const T = ArrayHashMap(usize, usize, AutoContext(usize), false);
2167
+
2168
+ var map: T = .empty;
2169
+ defer map.deinit(gpa);
2170
+
2171
+ for (0..T.linear_scan_max + 1) |i| try map.put(gpa, i, i);
2172
+
2173
+ map.setKey(0, 42);
2174
+ try testing.expectEqual(T.linear_scan_max + 1, map.count());
2175
+ try testing.expectEqual(false, map.contains(0));
2176
+ try testing.expectEqual(0, map.get(42));
2177
+
2178
+ for (1..T.linear_scan_max + 1) |i| try testing.expectEqual(i, map.get(i));
2179
+ }
2180
+
2181
+ test "setKey storehash true with index" {
2182
+ const gpa = std.testing.allocator;
2183
+
2184
+ const T = ArrayHashMap(usize, usize, AutoContext(usize), false);
2185
+
2186
+ var map: ArrayHashMap(usize, usize, AutoContext(usize), true) = .empty;
2187
+ defer map.deinit(gpa);
2188
+
2189
+ for (0..T.linear_scan_max + 1) |i| try map.put(gpa, i, i);
2190
+
2191
+ map.setKey(0, 42);
2192
+ try testing.expectEqual(T.linear_scan_max + 1, map.count());
2193
+ try testing.expectEqual(false, map.contains(0));
2194
+ try testing.expectEqual(0, map.get(42));
2195
+
2196
+ for (1..T.linear_scan_max + 1) |i| try testing.expectEqual(i, map.get(i));
2197
+ }
2198
+
2144
2199
  pub fn getHashPtrAddrFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
2145
2200
  return struct {
2146
2201
  fn hash(ctx: Context, key: K) u32 {
package/std/c.zig CHANGED
@@ -11619,6 +11619,7 @@ const private = struct {
11619
11619
  extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path: [*:0]const u8, buf: *Stat, flag: u32) c_int;
11620
11620
  extern "c" fn @"readdir$INODE64"(dir: *DIR) ?*dirent;
11621
11621
  extern "c" fn @"stat$INODE64"(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
11622
+ extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
11622
11623
 
11623
11624
  /// macos modernized symbols.
11624
11625
  extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
@@ -882,6 +882,7 @@ pub extern "c" fn emscripten_hide_mouse() void;
882
882
  pub extern "c" fn emscripten_set_canvas_size(width: c_int, height: c_int) void;
883
883
  pub extern "c" fn emscripten_get_canvas_size(width: *c_int, height: *c_int, isFullscreen: *c_int) void;
884
884
  pub extern "c" fn emscripten_get_now() f64;
885
+ pub extern "c" fn emscripten_num_logical_cores() c_int;
885
886
  pub extern "c" fn emscripten_random() f32;
886
887
  pub const em_idb_onload_func = ?*const fn (?*anyopaque, ?*anyopaque, c_int) callconv(.c) void;
887
888
  pub extern "c" fn emscripten_idb_async_load(db_name: [*:0]const u8, file_id: [*:0]const u8, arg: ?*anyopaque, onload: em_idb_onload_func, onerror: em_arg_callback_func) void;
package/std/process.zig CHANGED
@@ -3,6 +3,7 @@ const native_os = builtin.os.tag;
3
3
 
4
4
  const std = @import("std.zig");
5
5
  const Io = std.Io;
6
+ const Dir = std.Io.Dir;
6
7
  const File = std.Io.File;
7
8
  const fs = std.fs;
8
9
  const mem = std.mem;
@@ -784,7 +785,7 @@ pub fn executableDirPathAlloc(io: Io, allocator: Allocator) ExecutablePathAllocE
784
785
 
785
786
  pub const OpenExecutableError = File.OpenError || ExecutablePathError || File.LockError;
786
787
 
787
- pub fn openExecutable(io: Io, flags: File.OpenFlags) OpenExecutableError!File {
788
+ pub fn openExecutable(io: Io, flags: Dir.OpenFileOptions) OpenExecutableError!File {
788
789
  return io.vtable.processExecutableOpen(io.userdata, flags);
789
790
  }
790
791
 
@@ -5,6 +5,7 @@ const builtin = @import("builtin");
5
5
  const is_darwin = builtin.target.os.tag.isDarwin();
6
6
  const is_windows = builtin.target.os.tag == .windows;
7
7
  const is_haiku = builtin.target.os.tag == .haiku;
8
+ const is_serenity = builtin.target.os.tag == .serenity;
8
9
 
9
10
  const std = @import("std");
10
11
  const Io = std.Io;
@@ -112,7 +113,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
112
113
  return error.ParseError;
113
114
  }
114
115
 
115
- if (self.gcc_dir == null and os_tag == .haiku) {
116
+ if (self.gcc_dir == null and (os_tag == .haiku or os_tag == .serenity)) {
116
117
  log.err("gcc_dir may not be empty for {s}", .{@tagName(os_tag)});
117
118
  return error.ParseError;
118
119
  }
@@ -207,8 +208,12 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
207
208
  try self.findNativeCrtDirWindows(gpa, io, args.target, sdk);
208
209
  } else if (is_haiku) {
209
210
  try self.findNativeIncludeDirPosix(gpa, io, args);
210
- try self.findNativeGccDirHaiku(gpa, io, args);
211
+ try self.findNativeGccDirPosix(gpa, io, args);
211
212
  self.crt_dir = try gpa.dupe(u8, "/system/develop/lib");
213
+ } else if (is_serenity) {
214
+ try self.findNativeIncludeDirPosix(gpa, io, args);
215
+ try self.findNativeGccDirPosix(gpa, io, args);
216
+ self.crt_dir = try gpa.dupe(u8, "/usr/lib");
212
217
  } else if (builtin.target.os.tag == .illumos) {
213
218
  // There is only one libc, and its headers/libraries are always in the same spot.
214
219
  self.include_dir = try gpa.dupe(u8, "/usr/include");
@@ -314,7 +319,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
314
319
  const include_dir_example_file = if (is_haiku) "posix/stdlib.h" else "stdlib.h";
315
320
  const sys_include_dir_example_file = if (is_windows)
316
321
  "sys\\types.h"
317
- else if (is_haiku)
322
+ else if (is_haiku or is_serenity)
318
323
  "errno.h"
319
324
  else
320
325
  "sys/errno.h";
@@ -457,7 +462,7 @@ fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args:
457
462
  });
458
463
  }
459
464
 
460
- fn findNativeGccDirHaiku(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
465
+ fn findNativeGccDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
461
466
  self.gcc_dir = try ccPrintFileName(gpa, io, .{
462
467
  .environ_map = args.environ_map,
463
468
  .search_basename = "crtbeginS.o",
@@ -949,6 +954,22 @@ pub const CrtBasenames = struct {
949
954
  },
950
955
  .static_exe, .static_pie => .{},
951
956
  },
957
+ .serenity => switch (mode) {
958
+ .dynamic_lib => .{
959
+ .crtbegin = "crtbeginS.o",
960
+ .crtend = "crtendS.o",
961
+ },
962
+ .dynamic_exe, .static_exe => .{
963
+ .crt0 = "crt0.o",
964
+ .crtbegin = "crtbegin.o",
965
+ .crtend = "crtend.o",
966
+ },
967
+ .dynamic_pie, .static_pie => .{
968
+ .crt0 = "crt0.o",
969
+ .crtbegin = "crtbeginS.o",
970
+ .crtend = "crtendS.o",
971
+ },
972
+ },
952
973
  else => .{},
953
974
  };
954
975
  }
@@ -993,7 +1014,7 @@ pub fn resolveCrtPaths(
993
1014
  .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null,
994
1015
  };
995
1016
  },
996
- .haiku => {
1017
+ .haiku, .serenity => {
997
1018
  const gcc_dir_path: Path = .{
998
1019
  .root_dir = std.Build.Cache.Directory.cwd(),
999
1020
  .sub_path = lci.gcc_dir orelse return error.LibCInstallationMissingCrtDir,