From 128034481ab6eb02da4114b4d49ec3cfd4f8451c Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Tue, 26 Nov 2019 10:34:38 +0200 Subject: solve recursion in self hosted --- lib/std/event/fs.zig | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'lib/std/event') diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig index 0bbc710dfc..5d55805e35 100644 --- a/lib/std/event/fs.zig +++ b/lib/std/event/fs.zig @@ -735,24 +735,26 @@ pub fn Watch(comptime V: type) type { allocator: *Allocator, const OsData = switch (builtin.os) { - .macosx, .freebsd, .netbsd, .dragonfly => struct { - file_table: FileTable, - table_lock: event.Lock, - - const FileTable = std.StringHashMap(*Put); - const Put = struct { - putter_frame: @Frame(kqPutEvents), - cancelled: bool = false, - value: V, - }; - }, - + // TODO https://github.com/ziglang/zig/issues/3778 + .macosx, .freebsd, .netbsd, .dragonfly => KqOsData, .linux => LinuxOsData, .windows => WindowsOsData, else => @compileError("Unsupported OS"), }; + const KqOsData = struct { + file_table: FileTable, + table_lock: event.Lock, + + const FileTable = std.StringHashMap(*Put); + const Put = struct { + putter_frame: @Frame(kqPutEvents), + cancelled: bool = false, + value: V, + }; + }; + const WindowsOsData = struct { table_lock: event.Lock, dir_table: DirTable, -- cgit v1.2.3 From 4d8a8e65df79ddd5edf52f961552036ccfca6e8e Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Wed, 27 Nov 2019 10:17:37 +0200 Subject: add more workarounds --- lib/std/event/fs.zig | 2 +- src-self-hosted/compilation.zig | 6 +++++- src-self-hosted/main.zig | 3 ++- src-self-hosted/test.zig | 15 ++++++++------- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'lib/std/event') diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig index 5d55805e35..346d0f294a 100644 --- a/lib/std/event/fs.zig +++ b/lib/std/event/fs.zig @@ -1293,7 +1293,7 @@ pub fn Watch(comptime V: type) type { os.linux.EINVAL => unreachable, os.linux.EFAULT => unreachable, os.linux.EAGAIN => { - global_event_loop.linuxWaitFd(self.os_data.inotify_fd, os.linux.EPOLLET | os.linux.EPOLLIN); + global_event_loop.linuxWaitFd(self.os_data.inotify_fd, os.linux.EPOLLET | os.linux.EPOLLIN | os.EPOLLONESHOT); }, else => unreachable, } diff --git a/src-self-hosted/compilation.zig b/src-self-hosted/compilation.zig index 259cfd602f..a43d4ebc83 100644 --- a/src-self-hosted/compilation.zig +++ b/src-self-hosted/compilation.zig @@ -363,7 +363,11 @@ pub const Compilation = struct { is_static, zig_lib_dir, ); - return optional_comp orelse if (await frame) |_| unreachable else |err| err; + // TODO causes segfault + // return optional_comp orelse if (await frame) |_| unreachable else |err| err; + if (optional_comp) |comp| { + return comp; + } else if (await frame) |_| unreachable else |err| return err; } async fn createAsync( diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index 7906c9daa7..4288c4ea9a 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -56,7 +56,8 @@ pub fn main() !void { // This allocator needs to be thread-safe because we use it for the event.Loop // which multiplexes async functions onto kernel threads. // libc allocator is guaranteed to have this property. - const allocator = std.heap.c_allocator; + // TODO https://github.com/ziglang/zig/issues/3783 + const allocator = std.heap.page_allocator; stdout = &std.io.getStdOut().outStream().stream; diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 4c1ed6ad45..62b7914dbc 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -26,7 +26,8 @@ test "stage2" { } const file1 = "1.zig"; -const allocator = std.heap.c_allocator; +// TODO https://github.com/ziglang/zig/issues/3783 +const allocator = std.heap.page_allocator; pub const TestContext = struct { zig_compiler: ZigCompiler, @@ -94,8 +95,8 @@ pub const TestContext = struct { &self.zig_compiler, "test", file1_path, - Target.Native, - Compilation.Kind.Obj, + .Native, + .Obj, .Debug, true, // is_static self.zig_lib_dir, @@ -128,8 +129,8 @@ pub const TestContext = struct { &self.zig_compiler, "test", file1_path, - Target.Native, - Compilation.Kind.Exe, + .Native, + .Exe, .Debug, false, self.zig_lib_dir, @@ -170,13 +171,13 @@ pub const TestContext = struct { return error.OutputMismatch; } }, - .Error => |err| return err, + .Error => @panic("Cannot return error: https://github.com/ziglang/zig/issues/3190"), // |err| return err, .Fail => |msgs| { const stderr = std.io.getStdErr(); try stderr.write("build incorrectly failed:\n"); for (msgs) |msg| { defer msg.destroy(); - try msg.printToFile(stderr, errmsg.Color.Auto); + try msg.printToFile(stderr, .Auto); } }, } -- cgit v1.2.3