From 1e095024a7974f323032f517aeff595e64963301 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Sun, 8 Dec 2024 20:20:28 +0100 Subject: compiler: Check for wasi-libc emulated libraries before libc libraries. This will become useful when we update wasi-libc and get the emulated libdl. --- src/main.zig | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index cf2d37d086..293350bbff 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3824,6 +3824,14 @@ fn createModule( for (create_module.cli_link_inputs.items) |cli_link_input| switch (cli_link_input) { .name_query => |nq| { const lib_name = nq.name; + + if (target.os.tag == .wasi) { + if (wasi_libc.getEmulatedLibCrtFile(lib_name)) |crt_file| { + try create_module.wasi_emulated_libs.append(arena, crt_file); + continue; + } + } + if (std.zig.target.isLibCLibName(target, lib_name)) { create_module.opts.link_libc = true; continue; @@ -3832,6 +3840,7 @@ fn createModule( create_module.opts.link_libcpp = true; continue; } + switch (target_util.classifyCompilerRtLibName(lib_name)) { .none => {}, .only_libunwind, .both => { @@ -3857,12 +3866,6 @@ fn createModule( fatal("cannot use absolute path as a system library: {s}", .{lib_name}); } - if (target.os.tag == .wasi) { - if (wasi_libc.getEmulatedLibCrtFile(lib_name)) |crt_file| { - try create_module.wasi_emulated_libs.append(arena, crt_file); - continue; - } - } unresolved_link_inputs.appendAssumeCapacity(cli_link_input); any_name_queries_remaining = true; }, -- cgit v1.2.3 From f283791a5e72bf32abf65e7c8e67b29c22d76b41 Mon Sep 17 00:00:00 2001 From: Alex Rønne Petersen Date: Sun, 8 Dec 2024 20:22:13 +0100 Subject: compiler: Link libc when we're asked to link to an emulated wasi-libc library. --- src/main.zig | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index 293350bbff..d3a0b4cdef 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3828,6 +3828,7 @@ fn createModule( if (target.os.tag == .wasi) { if (wasi_libc.getEmulatedLibCrtFile(lib_name)) |crt_file| { try create_module.wasi_emulated_libs.append(arena, crt_file); + create_module.opts.link_libc = true; continue; } } -- cgit v1.2.3