From 7b74de7d717e2167337ba8a23e73baf99239529f Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 18 May 2021 16:00:06 +0200 Subject: wasi,cc: fix naming and add stubs for building Rename include dir to match the convention: from `wasm32-wasi` to `wasm-wasi-musl` Add building stubs which will be used to build and cache WASI libc sysroot. --- src/Compilation.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/Compilation.zig') diff --git a/src/Compilation.zig b/src/Compilation.zig index ff36df198a..5c856b6217 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -21,6 +21,7 @@ const musl = @import("musl.zig"); const mingw = @import("mingw.zig"); const libunwind = @import("libunwind.zig"); const libcxx = @import("libcxx.zig"); +const wasi_libc = @import("wasi_libc.zig"); const fatal = @import("main.zig").fatal; const Module = @import("Module.zig"); const Cache = @import("Cache.zig"); @@ -202,6 +203,8 @@ const Job = union(enum) { /// needed when not linking libc and using LLVM for code generation because it generates /// calls to, for example, memcpy and memset. zig_libc: void, + /// WASI libc sysroot + wasi_libc_sysroot: void, /// Use stage1 C++ code to compile zig code into an object file. stage1_module: void, @@ -276,6 +279,7 @@ pub const MiscTask = enum { libcxx, libcxxabi, libtsan, + wasi_libc_sysroot, compiler_rt, libssp, zig_libc, @@ -1414,6 +1418,9 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { }, }); } + if (comp.wantBuildWASILibcSysrootFromSource()) { + try comp.work_queue.write(&[_]Job{.{ .wasi_libc_sysroot = {} }}); + } if (comp.wantBuildMinGWFromSource()) { const static_lib_jobs = [_]Job{ .{ .mingw_crt_file = .mingw32_lib }, @@ -2139,6 +2146,16 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor ); }; }, + .wasi_libc_sysroot => { + wasi_libc.buildWASILibcSysroot(self) catch |err| { + // TODO Surface more error details. + try self.setMiscFailure( + .wasi_libc_sysroot, + "unable to build WASI libc sysroot: {s}", + .{@errorName(err)}, + ); + }; + }, .compiler_rt_lib => { self.buildOutputFromZig( "compiler_rt.zig", @@ -3285,6 +3302,10 @@ fn wantBuildMuslFromSource(comp: Compilation) bool { !comp.getTarget().isWasm(); } +fn wantBuildWASILibcSysrootFromSource(comp: Compilation) bool { + return comp.wantBuildLibCFromSource() and comp.getTarget().isWasm(); +} + fn wantBuildMinGWFromSource(comp: Compilation) bool { return comp.wantBuildLibCFromSource() and comp.getTarget().isMinGW(); } -- cgit v1.2.3