aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-06-09 01:23:05 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-06-09 01:25:38 +0200
commit2ee1f7898b27447bb9b21d284842415c7459db4b (patch)
tree1e22f27275c7c6ee6928ddd3a7c90f4b66d12ee6 /src/Compilation.zig
parentdd84ccda5daf63373b2b5df3ac02025017b7efbf (diff)
downloadzig-2ee1f7898b27447bb9b21d284842415c7459db4b.tar.gz
zig-2ee1f7898b27447bb9b21d284842415c7459db4b.zip
cc,wasi: store CRTFile enum in wasi_emulated_libs
* then, in `link/Wasm.zig` map `CRTFile` to full emulated libs name * move logic for removing any mention of WASI snapshot `wasi_snapshot_preview1` from `Compilation.zig` into `link/Wasm.zig`
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 1d85182f06..371bcdaf18 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -651,7 +651,7 @@ pub const InitOptions = struct {
/// * getpid
/// * mman
/// * signal
- wasi_emulated_libs: []const []const u8 = &[0][]const u8{},
+ wasi_emulated_libs: []const wasi_libc.CRTFile = &[0]wasi_libc.CRTFile{},
link_libc: bool = false,
link_libcpp: bool = false,
link_libunwind: bool = false,
@@ -1434,11 +1434,11 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
});
}
if (comp.wantBuildWasiLibcFromSource()) {
- try comp.work_queue.ensureUnusedCapacity(6); // worst-case we need all components
const wasi_emulated_libs = comp.bin_file.options.wasi_emulated_libs;
- for (wasi_emulated_libs) |lib_name| {
+ try comp.work_queue.ensureUnusedCapacity(wasi_emulated_libs.len + 2); // worst-case we need all components
+ for (wasi_emulated_libs) |crt_file| {
comp.work_queue.writeItemAssumeCapacity(.{
- .wasi_libc_crt_file = wasi_libc.getEmulatedLibCRTFile(lib_name).?,
+ .wasi_libc_crt_file = crt_file,
});
}
// TODO add logic deciding which crt1 we want here.
@@ -4157,12 +4157,6 @@ pub fn stage1AddLinkLib(comp: *Compilation, lib_name: []const u8) !void {
if (comp.bin_file.options.skip_linker_dependencies) return;
// This happens when an `extern "foo"` function is referenced by the stage1 backend.
- if (comp.getTarget().os.tag == .wasi and mem.eql(u8, "wasi_snapshot_preview1", lib_name)) {
- // Any referenced symbol from this lib, will be undefined until
- // runtime as this lib is provided directly by the runtime.
- return;
- }
-
// If we haven't seen this library yet and we're targeting Windows, we need to queue up
// a work item to produce the DLL import library for this.
const gop = try comp.bin_file.options.system_libs.getOrPut(comp.gpa, lib_name);