diff options
author | 2021-07-26 18:57:09 -0700 | |
---|---|---|
committer | 2021-07-26 18:57:09 -0700 | |
commit | a4a62d9874198097245f3da8e8695587b7ecd456 (patch) | |
tree | 84f0343b5b1c1cfa7ac7bc1d1bd0166d09bcb361 | |
parent | d9cf78c267344eaee08e8429f2a27946c5e4f344 (diff) | |
download | bun-a4a62d9874198097245f3da8e8695587b7ecd456.tar.gz bun-a4a62d9874198097245f3da8e8695587b7ecd456.tar.zst bun-a4a62d9874198097245f3da8e8695587b7ecd456.zip |
Fix build issues
Former-commit-id: 5164b69b57e8c11666591823c5b83435facce5c8
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | build.zig | 3 | ||||
-rw-r--r-- | src/bundler.zig | 4 | ||||
-rw-r--r-- | src/deps/picohttpparser.h.gch | bin | 0 -> 491772 bytes | |||
-rw-r--r-- | src/deps/zig-clap/clap/comptime.zig | 20 | ||||
-rw-r--r-- | src/env.zig | 8 | ||||
-rw-r--r-- | src/fs.zig | 8 | ||||
-rw-r--r-- | src/global.zig | 2 | ||||
-rw-r--r-- | src/http.zig | 4 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers-cpp.h | 2 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/headers.h | 2 | ||||
-rw-r--r-- | src/js_ast.zig | 13 | ||||
-rw-r--r-- | src/js_lexer_tables.zig | 4 | ||||
-rw-r--r-- | src/options.zig | 4 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 4 | ||||
-rw-r--r-- | src/watcher.zig | 7 |
16 files changed, 49 insertions, 44 deletions
@@ -57,9 +57,11 @@ sizegen: clang++ src/javascript/jsc/headergen/sizegen.cpp -o /tmp/sizegen $(CLANG_FLAGS) /tmp/sizegen > src/javascript/jsc/bindings/sizes.zig - -speedy-prod-native-macos: - cd src/deps; clang -c picohttpparser.c; cd ../../ + +picohttp: + clang -O3 -g -c src/deps/picohttpparser.c -Isrc/deps -o src/deps/picohttpparser.o; cd ../../ + +speedy-prod-native-macos: picohttp zig build -Drelease-fast -Dtarget=x86_64-macos-gnu speedy-prod-native-macos-lib: @@ -45,7 +45,7 @@ pub fn build(b: *std.build.Builder) void { var exe: *std.build.LibExeObjStep = undefined; var output_dir_buf = std.mem.zeroes([4096]u8); var bin_label = if (mode == std.builtin.Mode.Debug) "/debug/" else "/"; - const output_dir = std.fmt.bufPrint(&output_dir_buf, "build{s}{s}-{s}", .{ bin_label, @tagName(target.getOs().tag), @tagName(target.getCpuArch()) }) catch unreachable; + const output_dir = b.pathFromRoot(std.fmt.bufPrint(&output_dir_buf, "build{s}{s}-{s}", .{ bin_label, @tagName(target.getOs().tag), @tagName(target.getCpuArch()) }) catch unreachable); if (target.getOsTag() == .wasi) { exe.enable_wasmtime = true; @@ -233,6 +233,7 @@ pub fn build(b: *std.build.Builder) void { javascript.strip = false; javascript.packages = std.ArrayList(std.build.Pkg).fromOwnedSlice(b.allocator, b.allocator.dupe(std.build.Pkg, exe.packages.items) catch unreachable); + javascript.setOutputDir(output_dir); javascript.setBuildMode(mode); diff --git a/src/bundler.zig b/src/bundler.zig index facf965f0..9cbb97626 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -327,14 +327,14 @@ pub fn NewBundler(cache_files: bool) type { // When there are no more modules to process, we generate the metadata // To find the metadata, you look at the byte offset: initial_header[magic_bytes.len..initial_header.len - 1] // Then, you add that number to initial_header.len - const initial_header = { + const initial_header = brk: { var buf = std.mem.zeroes([magic_bytes.len + 5]u8); std.mem.copy(u8, &buf, magic_bytes); var remainder = buf[magic_bytes.len..]; // Write an invalid byte offset to be updated after the file ends std.mem.writeIntNative(u32, remainder[0 .. remainder.len - 1], 0); buf[buf.len - 1] = '\n'; - return buf; + break :brk buf; }; const code_start_byte_offset: u32 = initial_header.len; diff --git a/src/deps/picohttpparser.h.gch b/src/deps/picohttpparser.h.gch Binary files differnew file mode 100644 index 000000000..00b76aaf6 --- /dev/null +++ b/src/deps/picohttpparser.h.gch diff --git a/src/deps/zig-clap/clap/comptime.zig b/src/deps/zig-clap/clap/comptime.zig index 122ff16ad..deb4b3466 100644 --- a/src/deps/zig-clap/clap/comptime.zig +++ b/src/deps/zig-clap/clap/comptime.zig @@ -11,17 +11,17 @@ pub fn ComptimeClap( comptime Id: type, comptime params: []const clap.Param(Id), ) type { - var flags: usize = 0; - var single_options: usize = 0; - var multi_options: usize = 0; - var converted_params: []const clap.Param(usize) = &[_]clap.Param(usize){}; + var _flags: usize = 0; + var _single_options: usize = 0; + var _multi_options: usize = 0; + var _converted_params: []const clap.Param(usize) = &[_]clap.Param(usize){}; for (params) |param| { var index: usize = 0; if (param.names.long != null or param.names.short != null) { const ptr = switch (param.takes_value) { - .none => &flags, - .one => &single_options, - .many => &multi_options, + .none => &_flags, + .one => &_single_options, + .many => &_multi_options, }; index = ptr.*; ptr.* += 1; @@ -32,8 +32,12 @@ pub fn ComptimeClap( .names = param.names, .takes_value = param.takes_value, }; - converted_params = converted_params ++ [_]clap.Param(usize){converted}; + _converted_params = _converted_params ++ [_]clap.Param(usize){converted}; } + const flags = _flags; + const single_options = _single_options; + const multi_options = _multi_options; + const converted_params = _converted_params; return struct { single_options: [single_options]?[]const u8, diff --git a/src/env.zig b/src/env.zig index 2c680867c..117f53e76 100644 --- a/src/env.zig +++ b/src/env.zig @@ -1,13 +1,13 @@ const std = @import("std"); pub const BuildTarget = enum { native, wasm, wasi }; -pub const build_target: BuildTarget = { +pub const build_target: BuildTarget = brk: { if (std.Target.current.isWasm() and std.Target.current.getOsTag() == .wasi) { - return BuildTarget.wasi; + break :brk BuildTarget.wasi; } else if (std.Target.current.isWasm()) { - return BuildTarget.wasm; + break :brk BuildTarget.wasm; } else { - return BuildTarget.native; + break :brk BuildTarget.native; } }; diff --git a/src/fs.zig b/src/fs.zig index 40a99edc7..a0e6e8f42 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -845,11 +845,9 @@ pub const FileSystem = struct { // doNotCacheEntries bool }; - pub const Implementation = { - switch (build_target) { - .wasi, .native => return RealFS, - .wasm => return WasmFS, - } + pub const Implementation = switch (build_target) { + .wasi, .native => RealFS, + .wasm => WasmFS, }; }; diff --git a/src/global.zig b/src/global.zig index 14a919872..9258a0ac8 100644 --- a/src/global.zig +++ b/src/global.zig @@ -137,7 +137,7 @@ pub const Output = struct { fn _pretty(comptime fmt: string, args: anytype, comptime printer: anytype, comptime is_enabled: bool) void { comptime var new_fmt: [fmt.len * 4]u8 = undefined; comptime var new_fmt_i: usize = 0; - comptime const ED = "\x1b["; + const ED = comptime "\x1b["; @setEvalBranchQuota(9999); comptime var i: usize = 0; diff --git a/src/http.zig b/src/http.zig index 59fb6debf..780cce9fe 100644 --- a/src/http.zig +++ b/src/http.zig @@ -655,7 +655,7 @@ pub const RequestContext = struct { pub var javascript_disabled = false; var thread: std.Thread = undefined; pub fn spawnThread(handler: HandlerThread) !void { - _ = try std.Thread.spawn(spawn, handler); + _ = try std.Thread.spawn(.{}, spawn, .{handler}); } pub fn spawn(handler: HandlerThread) void { @@ -1138,7 +1138,7 @@ pub const RequestContext = struct { pub fn handleWebsocket(ctx: *RequestContext) anyerror!void { ctx.controlled = true; var handler = try WebsocketHandler.addWebsocket(ctx); - _ = try std.Thread.spawn(WebsocketHandler.handle, handler); + _ = try std.Thread.spawn(.{}, WebsocketHandler.handle, .{handler}); } pub fn auto500(ctx: *RequestContext) void { diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index 5edb7568c..6d79548f9 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1627342675 +//-- AUTOGENERATED FILE -- 1627346081 #pragma once #include <stddef.h> diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index dd1db277e..a907ec915 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1627342675 +//-- AUTOGENERATED FILE -- 1627346081 #pragma once #include <stddef.h> diff --git a/src/js_ast.zig b/src/js_ast.zig index dd7eedeba..1890f972f 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -20,13 +20,14 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type { } const UnionValueType = [max_size]u8; + const MaxAlign = max_align; return struct { const Allocator = std.mem.Allocator; const Self = @This(); const Block = struct { - items: [count]UnionValueType align(max_align) = undefined, + items: [count]UnionValueType align(MaxAlign) = undefined, used: usize = 0, allocator: *std.mem.Allocator, @@ -775,7 +776,7 @@ pub const Symbol = struct { } }; -pub const OptionalChain = packed enum(u2) { +pub const OptionalChain = enum(u2) { // "a?.b" start, @@ -3356,7 +3357,7 @@ pub const Op = struct { } }; - pub const Level = packed enum(u6) { + pub const Level = enum(u6) { lowest, comma, spread, @@ -3422,7 +3423,7 @@ pub const Op = struct { } pub const TableType: std.EnumArray(Op.Code, Op) = undefined; - pub const Table = { + pub const Table = brk: { var table = std.EnumArray(Op.Code, Op).initUndefined(); // Prefix @@ -3490,7 +3491,7 @@ pub const Op = struct { table.set(Op.Code.bin_logical_or_assign, Op.init(.{ "||=", Level.assign, false })); table.set(Op.Code.bin_logical_and_assign, Op.init(.{ "&&=", Level.assign, false })); - return table; + break :brk table; }; }; @@ -3696,7 +3697,7 @@ pub const NamedExport = struct { alias_loc: logger.Loc, }; -pub const StrictModeKind = packed enum(u7) { +pub const StrictModeKind = enum(u7) { sloppy_mode, explicit_strict_mode, implicit_strict_mode_import, diff --git a/src/js_lexer_tables.zig b/src/js_lexer_tables.zig index 71657a278..0a49a268b 100644 --- a/src/js_lexer_tables.zig +++ b/src/js_lexer_tables.zig @@ -240,7 +240,7 @@ pub const TypeScriptAccessibilityModifier = std.ComptimeStringMap(u1, .{ pub const TokenEnumType = std.EnumArray(T, []u8); -pub const tokenToString = { +pub const tokenToString = brk: { var TEndOfFile = "end of file".*; var TSyntaxError = "syntax error".*; var THashbang = "hashbang comment".*; @@ -489,7 +489,7 @@ pub const tokenToString = { tokenEnums.set(T.t_while, &TWhile); tokenEnums.set(T.t_with, &TWith); - return tokenEnums; + break :brk tokenEnums; }; pub const TypescriptStmtKeyword = enum { diff --git a/src/options.zig b/src/options.zig index 5cb32f4ef..39b3ec0d9 100644 --- a/src/options.zig +++ b/src/options.zig @@ -300,7 +300,7 @@ pub const Platform = enum { } const MAIN_FIELD_NAMES = [_]string{ "browser", "module", "main" }; - pub const DefaultMainFields: std.EnumArray(Platform, []const string) = { + pub const DefaultMainFields: std.EnumArray(Platform, []const string) = brk: { var array = std.EnumArray(Platform, []const string).initUndefined(); // Note that this means if a package specifies "module" and "main", the ES6 @@ -338,7 +338,7 @@ pub const Platform = enum { // fields is empty by default. You must explicitly configure it yourself. array.set(Platform.neutral, &([_]string{})); - return array; + break :brk array; }; }; diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index b4507445a..329b517b0 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -270,8 +270,8 @@ pub const TSConfigExtender = struct { file_dir: string, r: *ThisResolver, - pub fn extends(ctx: *TSConfigExtender, extends: String, range: logger.Range) ?*TSConfigJSON { - Global.notimpl(); + pub fn extends(ctx: *TSConfigExtender, ext: String, range: logger.Range) ?*TSConfigJSON { + unreachable; // if (isPackagePath(extends)) { // // // If this is a package path, try to resolve it to a "node_modules" // // // folder. This doesn't use the normal node module resolution algorithm diff --git a/src/watcher.zig b/src/watcher.zig index ea1ba44ac..50d86781d 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -68,7 +68,7 @@ pub fn NewWatcher(comptime ContextType: type) type { fd: StoredFileDescriptorType, ctx: ContextType, allocator: *std.mem.Allocator, - watchloop_handle: ?u64 = null, + watchloop_handle: ?std.Thread.Id = null, pub fn getHash(filepath: string) u32 { return @truncate(u32, std.hash.Wyhash.hash(0, filepath)); @@ -103,13 +103,12 @@ pub fn NewWatcher(comptime ContextType: type) type { pub fn start(this: *Watcher) !void { _ = try this.getQueue(); std.debug.assert(this.watchloop_handle == null); - - _ = try std.Thread.spawn(Watcher.watchLoop, this); + _ = try std.Thread.spawn(.{}, Watcher.watchLoop, .{this}); } // This must only be called from the watcher thread pub fn watchLoop(this: *Watcher) !void { - this.watchloop_handle = std.Thread.getCurrentThreadId(); + this.watchloop_handle = std.Thread.getCurrentId(); var stdout = std.io.getStdOut(); var stderr = std.io.getStdErr(); var output_source = Output.Source.init(stdout, stderr); |