Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update zig to 0.11.0 #4233

Merged
merged 19 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ src/js/out/tmp
src/js/out/DebugPath.h

make-dev-stats.csv

.uuid
39 changes: 21 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ pub fn build(b: *Build) !void {
.root_source_file = FileSource.relative(root_src),
.target = target,
.optimize = optimize,
.main_pkg_path = .{ .cwd_relative = b.pathFromRoot(".") },
});

var default_build_options: BunBuildOptions = brk: {
Expand Down Expand Up @@ -239,8 +240,6 @@ pub fn build(b: *Build) !void {
};

{
obj.setMainPkgPath(b.pathFromRoot("."));

try addInternalPackages(
b,
obj,
Expand Down Expand Up @@ -271,9 +270,13 @@ pub fn build(b: *Build) !void {
std.io.getStdErr().writer().print("Output: {s}/{s}\n\n", .{ output_dir, bun_executable_name }) catch unreachable;

defer obj_step.dependOn(&obj.step);
obj.emit_bin = .{
.emit_to = b.fmt("{s}/{s}.o", .{ output_dir, bun_executable_name }),
};

// = .{
// .generated_path = .{
// .path = b.fmt("{s}/{s}.o", .{ output_dir, bun_executable_name }),
// },
// };

var actual_build_options = default_build_options;
if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) {
actual_build_options.sizegen = true;
Expand All @@ -289,9 +292,9 @@ pub fn build(b: *Build) !void {
// Disable stack probing on x86 so we don't need to include compiler_rt
if (target.getCpuArch().isX86()) obj.disable_stack_probing = true;

if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) {
obj.emit_bin = .no_emit;
}
// if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) {
// obj.emit_bin = .no_emit;
// }

if (target.getOsTag() == .linux) {
// obj.want_lto = tar;
Expand All @@ -310,7 +313,7 @@ pub fn build(b: *Build) !void {
.optimize = optimize,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?);
try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path);
var headers_build_options = default_build_options;
headers_build_options.bindgen = true;
headers_obj.addOptions("build_options", default_build_options.step(b));
Expand Down Expand Up @@ -440,9 +443,9 @@ pub fn build(b: *Build) !void {
headers_obj.filter = test_filter;
if (test_bin_) |test_bin| {
headers_obj.name = std.fs.path.basename(test_bin);
if (std.fs.path.dirname(test_bin)) |dir| headers_obj.emit_bin = .{
.emit_to = b.fmt("{s}/{s}", .{ dir, headers_obj.name }),
};
// if (std.fs.path.dirname(test_bin)) |dir| headers_obj.emit_bin = .{
// .emit_to = b.fmt("{s}/{s}", .{ dir, headers_obj.name }),
// };
}

try configureObjectStep(b, headers_obj, @TypeOf(target), target, obj.main_pkg_path.?);
Expand All @@ -456,8 +459,8 @@ pub fn build(b: *Build) !void {

pub var original_make_fn: ?*const fn (step: *std.build.Step) anyerror!void = null;

pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Target: type, target: Target, main_pkg_path: []const u8) !void {
obj.setMainPkgPath(main_pkg_path);
pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Target: type, target: Target, main_pkg_path: ?Build.LazyPath) !void {
obj.main_pkg_path = main_pkg_path;

// obj.setTarget(target);
try addInternalPackages(b, obj, std.heap.page_allocator, b.zig_exe, target);
Expand All @@ -466,10 +469,10 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Ta

// obj.setBuildMode(optimize);
obj.bundle_compiler_rt = false;
if (obj.emit_bin == .default)
obj.emit_bin = .{
.emit_to = b.fmt("{s}/{s}.o", .{ output_dir, obj.name }),
};
// if (obj.emit_bin == .default)
// obj.emit_bin = .{
// .emit_to = b.fmt("{s}/{s}.o", .{ output_dir, obj.name }),
// };

if (target.getOsTag() != .freestanding) obj.linkLibC();
if (target.getOsTag() != .freestanding) obj.bundle_compiler_rt = false;
Expand Down
12 changes: 6 additions & 6 deletions src/analytics/analytics_schema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ pub const analytics = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -361,8 +361,8 @@ pub const analytics = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -411,8 +411,8 @@ pub const analytics = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down
76 changes: 38 additions & 38 deletions src/api/schema.zig
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -391,8 +391,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -418,8 +418,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -648,8 +648,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -799,8 +799,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -820,8 +820,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -838,8 +838,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -856,8 +856,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -1124,8 +1124,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -1139,8 +1139,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -1246,8 +1246,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -1953,8 +1953,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -2180,8 +2180,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -2195,8 +2195,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -2266,8 +2266,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -2473,8 +2473,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -2506,8 +2506,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand All @@ -2524,8 +2524,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down Expand Up @@ -3142,8 +3142,8 @@ pub const Api = struct {

_,

pub fn jsonStringify(self: *const @This(), opts: anytype, o: anytype) !void {
return try std.json.stringify(@tagName(self), opts, o);
pub fn jsonStringify(self: *const @This(), writer: anytype) !void {
return try writer.write(@tagName(self));
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/ast/base.zig
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ pub const Ref = packed struct(u64) {
return self.tag == .invalid;
}

pub fn jsonStringify(self: *const Ref, options: anytype, writer: anytype) !void {
return try std.json.stringify([2]u32{ self.sourceIndex(), self.innerIndex() }, options, writer);
pub fn jsonStringify(self: *const Ref, writer: anytype) !void {
return try writer.write([2]u32{ self.sourceIndex(), self.innerIndex() });
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/JSBundler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ pub const JSBundler = struct {
external: bool = false,

pub fn deinit(this: *@This()) void {
bun.default_allocator.destroy(this.path);
bun.default_allocator.destroy(this.namespace);
bun.default_allocator.free(this.path);
bun.default_allocator.free(this.namespace);
}
},
no_match: void,
Expand Down Expand Up @@ -747,7 +747,7 @@ pub const JSBundler = struct {
pub fn deinit(this: *Value) void {
switch (this.*) {
.success => |success| {
bun.default_allocator.destroy(success.source_code);
bun.default_allocator.free(success.source_code);
},
.err => |*err| {
err.deinit(bun.default_allocator);
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/bun/socket.zig
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ pub const Listener = struct {
pub fn deinit(this: UnixOrHost) void {
switch (this) {
.unix => |u| {
bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(u.ptr))));
bun.default_allocator.free(u);
},
.host => |h| {
bun.default_allocator.destroy(@as([*]u8, @ptrFromInt(@intFromPtr(h.host.ptr))));
bun.default_allocator.free(h.host);
},
}
}
Expand Down Expand Up @@ -831,7 +831,7 @@ pub const Listener = struct {
this.connection.deinit();
if (this.protos) |protos| {
this.protos = null;
bun.default_allocator.destroy(protos);
bun.default_allocator.free(protos);
}
bun.default_allocator.destroy(this);
}
Expand Down
Loading