aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorTakeshi Yoneda <takeshi@tetrate.io>2021-06-09 17:07:06 +0900
committerTakeshi Yoneda <takeshi@tetrate.io>2021-06-09 17:07:06 +0900
commitbf568ec62a06fcea5f09c725529635425f1b8a76 (patch)
treee30c6d3a7e773aa3a6ad0818c27a8c315475c2e8 /src/Compilation.zig
parenta6ae5a77dac6466617cdf57357aa79c2b79403b3 (diff)
downloadzig-bf568ec62a06fcea5f09c725529635425f1b8a76.tar.gz
zig-bf568ec62a06fcea5f09c725529635425f1b8a76.zip
cc,wasi: support WASI reactors via -mexec-model flag.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 371bcdaf18..e90c635808 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -603,6 +603,11 @@ pub const ClangPreprocessorMode = enum {
stdout,
};
+pub const WasiExecModel = enum {
+ command,
+ reactor,
+};
+
pub const InitOptions = struct {
zig_lib_directory: Directory,
local_cache_directory: Directory,
@@ -725,6 +730,8 @@ pub const InitOptions = struct {
test_filter: ?[]const u8 = null,
test_name_prefix: ?[]const u8 = null,
subsystem: ?std.Target.SubSystem = null,
+ /// WASI-only. Type of WASI execution model ("command" or "reactor").
+ wasi_exec_model: ?WasiExecModel = null,
};
fn addPackageTableToCacheHash(
@@ -1340,6 +1347,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
.disable_lld_caching = options.disable_lld_caching,
.subsystem = options.subsystem,
.is_test = options.is_test,
+ .wasi_exec_model = options.wasi_exec_model,
});
errdefer bin_file.destroy();
comp.* = .{
@@ -1441,9 +1449,14 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
.wasi_libc_crt_file = crt_file,
});
}
- // TODO add logic deciding which crt1 we want here.
+ const crt_file: wasi_libc.CRTFile = if (comp.bin_file.options.wasi_exec_model) |exec_model| crt_file: {
+ switch (exec_model) {
+ .command => break :crt_file wasi_libc.CRTFile.crt1_command_o,
+ .reactor => break :crt_file wasi_libc.CRTFile.crt1_reactor_o,
+ }
+ } else .crt1_o;
comp.work_queue.writeAssumeCapacity(&[_]Job{
- .{ .wasi_libc_crt_file = .crt1_o },
+ .{ .wasi_libc_crt_file = crt_file },
.{ .wasi_libc_crt_file = .libc_a },
});
}
@@ -1868,7 +1881,7 @@ pub fn getAllErrorsAlloc(self: *Compilation) !AllErrors {
for (keys[1..]) |key, i| {
err_msg.notes[i] = .{
- .src_loc = key.nodeOffsetSrcLoc(values[i+1]),
+ .src_loc = key.nodeOffsetSrcLoc(values[i + 1]),
.msg = "also here",
};
}