wasi: Build emulated libraries into libc.a

This matches what we do for small helper libraries like this in MinGW-w64. It
simplifies the compiler a bit, and also means the build system doesn't have to
treat these library names specially.

Closes #24325.
This commit is contained in:
Alex Rønne Petersen
2025-07-06 20:05:18 +02:00
parent b461d07a54
commit 1f1082e36d
4 changed files with 78 additions and 154 deletions

View File

@@ -972,8 +972,6 @@ fn buildOutputType(
.windows_libs = .empty,
.link_inputs = .empty,
.wasi_emulated_libs = .{},
.c_source_files = .{},
.rc_source_files = .{},
@@ -3406,7 +3404,6 @@ fn buildOutputType(
.framework_dirs = create_module.framework_dirs.items,
.frameworks = resolved_frameworks.items,
.windows_lib_names = create_module.windows_libs.keys(),
.wasi_emulated_libs = create_module.wasi_emulated_libs.items,
.want_compiler_rt = want_compiler_rt,
.want_ubsan_rt = want_ubsan_rt,
.hash_style = hash_style,
@@ -3687,8 +3684,6 @@ const CreateModule = struct {
/// output. Allocated with gpa.
link_inputs: std.ArrayListUnmanaged(link.Input),
wasi_emulated_libs: std.ArrayListUnmanaged(wasi_libc.CrtFile),
c_source_files: std.ArrayListUnmanaged(Compilation.CSourceFile),
rc_source_files: std.ArrayListUnmanaged(Compilation.RcSourceFile),
@@ -3819,14 +3814,6 @@ fn createModule(
.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);
create_module.opts.link_libc = true;
continue;
}
}
if (std.zig.target.isLibCLibName(target, lib_name)) {
create_module.opts.link_libc = true;
continue;