aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-05-18 16:00:06 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-05-20 16:54:00 +0200
commit7b74de7d717e2167337ba8a23e73baf99239529f (patch)
tree2eb631f92e8df09ab388b3d3ea226f07f224d69e /src/Compilation.zig
parent782cfedaf6452b00df948132284da65fa3ac8fdd (diff)
downloadzig-7b74de7d717e2167337ba8a23e73baf99239529f.tar.gz
zig-7b74de7d717e2167337ba8a23e73baf99239529f.zip
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.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig21
1 files changed, 21 insertions, 0 deletions
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();
}