authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-02 19:11:04-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-04-02 19:18:41-07:00
log3432e66faf8940bbbfc7ee24d0e17e6127e66bf6
tree585b35e886651c8f47970c1985ea84fd98637c3c
parent843d5adcd6ec0b620fe93e0366aa0e8bb92bd171

stage2: remove dependencies on async functions

This commit removes the tiny amount of dependency on async/await that the self-hosted compiler has so that it can self-host before async/await language features are working.

1 files changed, 15 insertions(+), 28 deletions(-)

src/libc_installation.zig+15-28
......@@ -3,7 +3,6 @@ const builtin = @import("builtin");
33const Target = std.Target;
44const fs = std.fs;
55const Allocator = std.mem.Allocator;
6const Batch = std.event.Batch;
76const build_options = @import("build_options");
87
98const is_darwin = builtin.target.isDarwin();
......@@ -195,40 +194,28 @@ pub const LibCInstallation = struct {
195194 .None => {
196195 defer sdk.free();
197196
198 var batch = Batch(FindError!void, 5, .auto_async).init();
199 batch.add(&async self.findNativeMsvcIncludeDir(args, sdk));
200 batch.add(&async self.findNativeMsvcLibDir(args, sdk));
201 batch.add(&async self.findNativeKernel32LibDir(args, sdk));
202 batch.add(&async self.findNativeIncludeDirWindows(args, sdk));
203 batch.add(&async self.findNativeCrtDirWindows(args, sdk));
204 try batch.wait();
197 try self.findNativeMsvcIncludeDir(args, sdk);
198 try self.findNativeMsvcLibDir(args, sdk);
199 try self.findNativeKernel32LibDir(args, sdk);
200 try self.findNativeIncludeDirWindows(args, sdk);
201 try self.findNativeCrtDirWindows(args, sdk);
205202 },
206203 .OutOfMemory => return error.OutOfMemory,
207204 .NotFound => return error.WindowsSdkNotFound,
208205 .PathTooLong => return error.WindowsSdkNotFound,
209206 }
210207 } else if (is_haiku) {
211 try blk: {
212 var batch = Batch(FindError!void, 2, .auto_async).init();
213 errdefer batch.wait() catch {};
214 batch.add(&async self.findNativeIncludeDirPosix(args));
215 batch.add(&async self.findNativeCrtBeginDirHaiku(args));
216 self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");
217 break :blk batch.wait();
218 };
208 try self.findNativeIncludeDirPosix(args);
209 try self.findNativeCrtBeginDirHaiku(args);
210 self.crt_dir = try args.allocator.dupeZ(u8, "/system/develop/lib");
219211 } else if (std.process.can_spawn) {
220 try blk: {
221 var batch = Batch(FindError!void, 2, .auto_async).init();
222 errdefer batch.wait() catch {};
223 batch.add(&async self.findNativeIncludeDirPosix(args));
224 switch (builtin.target.os.tag) {
225 .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),
226 .solaris => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib/64"),
227 .linux => batch.add(&async self.findNativeCrtDirPosix(args)),
228 else => {},
229 }
230 break :blk batch.wait();
231 };
212 try self.findNativeIncludeDirPosix(args);
213 switch (builtin.target.os.tag) {
214 .freebsd, .netbsd, .openbsd, .dragonfly => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib"),
215 .solaris => self.crt_dir = try args.allocator.dupeZ(u8, "/usr/lib/64"),
216 .linux => try self.findNativeCrtDirPosix(args),
217 else => {},
218 }
232219 } else {
233220 return error.LibCRuntimeNotFound;
234221 }