diff options
author | 2023-04-14 03:58:38 -0700 | |
---|---|---|
committer | 2023-04-14 03:58:38 -0700 | |
commit | f6a4516d667f7cf000fb2e3123d29079a5ced272 (patch) | |
tree | 4f108bdbd550f6bc05e5e06814c8b271e8ce8d13 | |
parent | 6c69c2b36462100792bb3d1b23aba8afbee0253f (diff) | |
download | bun-f6a4516d667f7cf000fb2e3123d29079a5ced272.tar.gz bun-f6a4516d667f7cf000fb2e3123d29079a5ced272.tar.zst bun-f6a4516d667f7cf000fb2e3123d29079a5ced272.zip |
Upgrade Zig (#2656)
* Upgrade Zig
* Don't add `d` files in github actions
* Revert "Don't add `d` files in github actions"
This reverts commit 446e2dd6743da08ec4136233fdc9179dbbf58fca.
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
-rw-r--r-- | .github/workflows/zig-fmt.yml | 2 | ||||
-rw-r--r-- | Dockerfile | 2 | ||||
-rw-r--r-- | build.zig | 20 | ||||
-rw-r--r-- | src/bun.js/bindings/header-gen.zig | 6 | ||||
-rw-r--r-- | src/bun.js/bindings/headers-cpp.h | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.h | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/static_export.zig | 2 | ||||
-rw-r--r-- | src/bun.js/javascript.zig | 1 | ||||
-rw-r--r-- | src/bun.js/module_loader.zig | 1 | ||||
-rw-r--r-- | src/bun.js/webcore/streams.zig | 8 | ||||
-rw-r--r-- | src/http_client_async.zig | 3 | ||||
-rw-r--r-- | src/js_printer.zig | 2 | ||||
-rw-r--r-- | src/string_immutable.zig | 7 |
13 files changed, 30 insertions, 28 deletions
diff --git a/.github/workflows/zig-fmt.yml b/.github/workflows/zig-fmt.yml index 9f4e2207a..3d0f352bf 100644 --- a/.github/workflows/zig-fmt.yml +++ b/.github/workflows/zig-fmt.yml @@ -1,7 +1,7 @@ name: zig-fmt env: - ZIG_VERSION: 0.11.0-dev.1783+436e99d13 + ZIG_VERSION: 0.11.0-dev.2571+31738de28 on: pull_request: diff --git a/Dockerfile b/Dockerfile index bc14fbaa7..6479c209c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 ARG WEBKIT_TAG=feb9 ARG ZIG_TAG=jul1 -ARG ZIG_VERSION="0.11.0-dev.1783+436e99d13" +ARG ZIG_VERSION="0.11.0-dev.2571+31738de28" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION} @@ -218,6 +218,7 @@ pub fn build(b: *Build) !void { .target = target, .optimize = optimize, }); + var default_build_options: BunBuildOptions = brk: { const is_baseline = arch.isX86() and (target.cpu_model == .baseline or !std.Target.x86.featureSetHas(target.getCpuFeatures(), .avx2)); @@ -285,11 +286,12 @@ 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 }), + }; var actual_build_options = default_build_options; if (b.option(bool, "generate-sizes", "Generate sizes of things") orelse false) { actual_build_options.sizegen = true; - obj.setOutputDir(b.pathFromRoot("misctools/sizegen")); } obj.addOptions("build_options", actual_build_options.step(b)); @@ -299,7 +301,6 @@ pub fn build(b: *Build) !void { obj.strip = false; obj.bundle_compiler_rt = false; obj.omit_frame_pointer = optimize != .Debug; - // Disable stack probing on x86 so we don't need to include compiler_rt if (target.getCpuArch().isX86()) obj.disable_stack_probing = true; @@ -449,10 +450,12 @@ pub fn build(b: *Build) !void { .root_source_file = FileSource.relative(test_file orelse "src/main.zig"), .target = target, }); - headers_obj.setFilter(test_filter); + 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.setOutputDir(dir); + 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.?); @@ -489,8 +492,6 @@ pub fn build(b: *Build) !void { // headers_step.dependOn(&after.step); // } } - if (obj.emit_bin != .no_emit) - obj.setOutputDir(output_dir); b.default_step.dependOn(obj_step); } @@ -568,9 +569,12 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, comptime Ta obj.strip = false; - obj.setOutputDir(output_dir); // 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 (target.getOsTag() != .freestanding) obj.linkLibC(); if (target.getOsTag() != .freestanding) obj.bundle_compiler_rt = false; diff --git a/src/bun.js/bindings/header-gen.zig b/src/bun.js/bindings/header-gen.zig index 179c884d5..cb1629de7 100644 --- a/src/bun.js/bindings/header-gen.zig +++ b/src/bun.js/bindings/header-gen.zig @@ -23,9 +23,9 @@ const ENABLE_REWRITE_RETURN = false; pub fn cTypeLabel(comptime Type: type) ?[]const u8 { return switch (comptime Type) { - *StaticExport.c_char => "char*", - [*c]u8, *const StaticExport.c_char => "const char*", - StaticExport.c_char => "char", + *c_char => "char*", + [*c]u8, *const c_char => "const char*", + c_char => "char", *void => "void", bool => "bool", usize => "size_t", diff --git a/src/bun.js/bindings/headers-cpp.h b/src/bun.js/bindings/headers-cpp.h index 2b9349144..f90e2f0d9 100644 --- a/src/bun.js/bindings/headers-cpp.h +++ b/src/bun.js/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1681365101 +//-- AUTOGENERATED FILE -- 1681462444 // clang-format off #pragma once diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index fbf902a8a..b547edc44 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format off -//-- AUTOGENERATED FILE -- 1681365101 +//-- AUTOGENERATED FILE -- 1681462444 #pragma once #include <stddef.h> diff --git a/src/bun.js/bindings/static_export.zig b/src/bun.js/bindings/static_export.zig index a3d47e56e..2a5189210 100644 --- a/src/bun.js/bindings/static_export.zig +++ b/src/bun.js/bindings/static_export.zig @@ -12,5 +12,3 @@ pub fn Decl(comptime this: *const @This()) std.builtin.Type.Declaration { pub fn wrappedName(comptime this: *const @This()) []const u8 { return comptime "wrap" ++ this.symbol_name; } - -pub const c_char = enum(u8) { _ }; diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 3b8b8903e..3616e174d 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1,7 +1,6 @@ const std = @import("std"); const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; const StaticExport = @import("./bindings/static_export.zig"); -const c_char = StaticExport.c_char; const bun = @import("bun"); const string = bun.string; const Output = bun.Output; diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 85bc04f53..9ec142176 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1,7 +1,6 @@ const std = @import("std"); const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false; const StaticExport = @import("./bindings/static_export.zig"); -const c_char = StaticExport.c_char; const bun = @import("bun"); const string = bun.string; const Output = bun.Output; diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 91215886d..e73c34b5e 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -2155,7 +2155,7 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { } defer { - if (comptime @hasField(SinkType, "done") and this.sink.done) { + if ((comptime @hasField(SinkType, "done")) and this.sink.done) { callframe.this().unprotect(); } } @@ -2216,8 +2216,10 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { } defer { - if (comptime @hasField(SinkType, "done") and this.sink.done) { - callframe.this().unprotect(); + if (comptime @hasField(SinkType, "done")) { + if (this.sink.done) { + callframe.this().unprotect(); + } } } diff --git a/src/http_client_async.zig b/src/http_client_async.zig index c75883ad7..bf33e65fc 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -1083,7 +1083,8 @@ const os = std.os; pub fn hashHeaderName(name: string) u64 { var hasher = std.hash.Wyhash.init(0); var remain = name; - var buf: [hasher.buf.len]u8 = undefined; + + var buf: [@sizeOf(@TypeOf(hasher.buf))]u8 = undefined; while (remain.len > 0) { const end = @min(hasher.buf.len, remain.len); diff --git a/src/js_printer.zig b/src/js_printer.zig index 1b9ba9aa0..f809c6280 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -1510,7 +1510,7 @@ fn NewPrinter( // this only applies to template literal strings // but we print a template literal if there is a \n or a \r // which is often if the string is long and UTF-16 - if (comptime quote == '`') { + if (quote == '`') { const remain = text[i..]; if (remain.len > 1 and remain[0] < last_ascii and remain[0] > first_ascii and remain[0] != '$' and diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 44d64dc49..887d819a1 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -24,7 +24,7 @@ pub inline fn contains(self: string, str: string) bool { } pub fn toUTF16Literal(comptime str: []const u8) []const u16 { - comptime { + return comptime brk: { comptime var output: [str.len]u16 = undefined; for (str, 0..) |c, i| { @@ -34,9 +34,8 @@ pub fn toUTF16Literal(comptime str: []const u8) []const u16 { const Static = struct { pub const literal: []const u16 = output[0..]; }; - - return Static.literal; - } + break :brk Static.literal; + }; } const OptionalUsize = std.meta.Int(.unsigned, @bitSizeOf(usize) - 1); |