aboutsummaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/glibc.zig1281
-rw-r--r--src/libs/libcxx.zig578
-rw-r--r--src/libs/libtsan.zig499
-rw-r--r--src/libs/libunwind.zig220
-rw-r--r--src/libs/mingw.zig1038
-rw-r--r--src/libs/musl.zig2313
-rw-r--r--src/libs/wasi_libc.zig1256
7 files changed, 7185 insertions, 0 deletions
diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig
new file mode 100644
index 0000000000..5d1c6f420b
--- /dev/null
+++ b/src/libs/glibc.zig
@@ -0,0 +1,1281 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const mem = std.mem;
+const log = std.log;
+const fs = std.fs;
+const path = fs.path;
+const assert = std.debug.assert;
+const Version = std.SemanticVersion;
+const Path = std.Build.Cache.Path;
+
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+const trace = @import("../tracy.zig").trace;
+const Cache = std.Build.Cache;
+const Module = @import("../Package/Module.zig");
+const link = @import("../link.zig");
+
+pub const Lib = struct {
+ name: []const u8,
+ sover: u8,
+ removed_in: ?Version = null,
+};
+
+pub const ABI = struct {
+ all_versions: []const Version, // all defined versions (one abilist from v2.0.0 up to current)
+ all_targets: []const std.zig.target.ArchOsAbi,
+ /// The bytes from the file verbatim, starting from the u16 number
+ /// of function inclusions.
+ inclusions: []const u8,
+ arena_state: std.heap.ArenaAllocator.State,
+
+ pub fn destroy(abi: *ABI, gpa: Allocator) void {
+ abi.arena_state.promote(gpa).deinit();
+ }
+};
+
+// The order of the elements in this array defines the linking order.
+pub const libs = [_]Lib{
+ .{ .name = "m", .sover = 6 },
+ .{ .name = "pthread", .sover = 0, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
+ .{ .name = "c", .sover = 6 },
+ .{ .name = "dl", .sover = 2, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
+ .{ .name = "rt", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
+ .{ .name = "ld", .sover = 2 },
+ .{ .name = "util", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
+ .{ .name = "resolv", .sover = 2 },
+};
+
+pub const LoadMetaDataError = error{
+ /// The files that ship with the Zig compiler were unable to be read, or otherwise had malformed data.
+ ZigInstallationCorrupt,
+ OutOfMemory,
+};
+
+pub const abilists_path = "libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++ "abilists";
+pub const abilists_max_size = 800 * 1024; // Bigger than this and something is definitely borked.
+
+/// This function will emit a log error when there is a problem with the zig
+/// installation and then return `error.ZigInstallationCorrupt`.
+pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI {
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ errdefer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ var index: usize = 0;
+
+ {
+ const libs_len = contents[index];
+ index += 1;
+
+ var i: u8 = 0;
+ while (i < libs_len) : (i += 1) {
+ const lib_name = mem.sliceTo(contents[index..], 0);
+ index += lib_name.len + 1;
+
+ if (i >= libs.len or !mem.eql(u8, libs[i].name, lib_name)) {
+ log.err("libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++
+ "abilists: invalid library name or index ({d}): '{s}'", .{ i, lib_name });
+ return error.ZigInstallationCorrupt;
+ }
+ }
+ }
+
+ const versions = b: {
+ const versions_len = contents[index];
+ index += 1;
+
+ const versions = try arena.alloc(Version, versions_len);
+ var i: u8 = 0;
+ while (i < versions.len) : (i += 1) {
+ versions[i] = .{
+ .major = contents[index + 0],
+ .minor = contents[index + 1],
+ .patch = contents[index + 2],
+ };
+ index += 3;
+ }
+ break :b versions;
+ };
+
+ const targets = b: {
+ const targets_len = contents[index];
+ index += 1;
+
+ const targets = try arena.alloc(std.zig.target.ArchOsAbi, targets_len);
+ var i: u8 = 0;
+ while (i < targets.len) : (i += 1) {
+ const target_name = mem.sliceTo(contents[index..], 0);
+ index += target_name.len + 1;
+
+ var component_it = mem.tokenizeScalar(u8, target_name, '-');
+ const arch_name = component_it.next() orelse {
+ log.err("abilists: expected arch name", .{});
+ return error.ZigInstallationCorrupt;
+ };
+ const os_name = component_it.next() orelse {
+ log.err("abilists: expected OS name", .{});
+ return error.ZigInstallationCorrupt;
+ };
+ const abi_name = component_it.next() orelse {
+ log.err("abilists: expected ABI name", .{});
+ return error.ZigInstallationCorrupt;
+ };
+ const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
+ log.err("abilists: unrecognized arch: '{s}'", .{arch_name});
+ return error.ZigInstallationCorrupt;
+ };
+ if (!mem.eql(u8, os_name, "linux")) {
+ log.err("abilists: expected OS 'linux', found '{s}'", .{os_name});
+ return error.ZigInstallationCorrupt;
+ }
+ const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
+ log.err("abilists: unrecognized ABI: '{s}'", .{abi_name});
+ return error.ZigInstallationCorrupt;
+ };
+
+ targets[i] = .{
+ .arch = arch_tag,
+ .os = .linux,
+ .abi = abi_tag,
+ };
+ }
+ break :b targets;
+ };
+
+ const abi = try arena.create(ABI);
+ abi.* = .{
+ .all_versions = versions,
+ .all_targets = targets,
+ .inclusions = contents[index..],
+ .arena_state = arena_allocator.state,
+ };
+ return abi;
+}
+
+pub const CrtFile = enum {
+ scrt1_o,
+ libc_nonshared_a,
+};
+
+/// TODO replace anyerror with explicit error set, recording user-friendly errors with
+/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
+pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+ const gpa = comp.gpa;
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const target = comp.root_mod.resolved_target.result;
+ const target_ver = target.os.versionRange().gnuLibCVersion().?;
+ const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt;
+ const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;
+
+ // In all cases in this function, we add the C compiler flags to
+ // cache_exempt_flags rather than extra_flags, because these arguments
+ // depend on only properties that are already covered by the cache
+ // manifest. Including these arguments in the cache could only possibly
+ // waste computation and create false negatives.
+
+ switch (crt_file) {
+ .scrt1_o => {
+ const start_o: Compilation.CSourceFile = blk: {
+ var args = std.ArrayList([]const u8).init(arena);
+ try add_include_dirs(comp, arena, &args);
+ try args.appendSlice(&[_][]const u8{
+ "-D_LIBC_REENTRANT",
+ "-include",
+ try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
+ "-DMODULE_NAME=libc",
+ "-Wno-nonportable-include-path",
+ "-include",
+ try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
+ "-DPIC",
+ "-DSHARED",
+ "-DTOP_NAMESPACE=glibc",
+ "-DASSEMBLER",
+ "-Wa,--noexecstack",
+ });
+ const src_path = if (start_old_init_fini) "start-2.33.S" else "start.S";
+ break :blk .{
+ .src_path = try start_asm_path(comp, arena, src_path),
+ .cache_exempt_flags = args.items,
+ .owner = undefined,
+ };
+ };
+ const abi_note_o: Compilation.CSourceFile = blk: {
+ var args = std.ArrayList([]const u8).init(arena);
+ try args.appendSlice(&[_][]const u8{
+ "-I",
+ try lib_path(comp, arena, lib_libc_glibc ++ "csu"),
+ });
+ try add_include_dirs(comp, arena, &args);
+ try args.appendSlice(&[_][]const u8{
+ "-D_LIBC_REENTRANT",
+ "-DMODULE_NAME=libc",
+ "-DTOP_NAMESPACE=glibc",
+ "-DASSEMBLER",
+ "-Wa,--noexecstack",
+ });
+ break :blk .{
+ .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "abi-note.S"),
+ .cache_exempt_flags = args.items,
+ .owner = undefined,
+ };
+ };
+ const init_o: Compilation.CSourceFile = .{
+ .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),
+ .owner = undefined,
+ };
+ var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
+ const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";
+ return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{});
+ },
+ .libc_nonshared_a => {
+ const s = path.sep_str;
+ const Dep = struct {
+ path: []const u8,
+ include: bool = true,
+ };
+ const deps = [_]Dep{
+ .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c" },
+ .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c" },
+ .{ .path = lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c" },
+ .{ .path = lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c" },
+
+ // libc_nonshared.a redirected stat functions to xstat until glibc 2.33,
+ // when they were finally versioned like other symbols.
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "stat-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "fstat-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "lstat-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "stat64-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "fstat64-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "lstat64-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat64-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "mknodat-2.32.c",
+ .include = nonshared_stat,
+ },
+ .{
+ .path = lib_libc_glibc ++ "io" ++ s ++ "mknod-2.32.c",
+ .include = nonshared_stat,
+ },
+
+ // __libc_start_main used to require statically linked init/fini callbacks
+ // until glibc 2.34 when they were assimilated into the shared library.
+ .{
+ .path = lib_libc_glibc ++ "csu" ++ s ++ "elf-init-2.33.c",
+ .include = start_old_init_fini,
+ },
+ };
+
+ var files_buf: [deps.len]Compilation.CSourceFile = undefined;
+ var files_index: usize = 0;
+
+ for (deps) |dep| {
+ if (!dep.include) continue;
+
+ var args = std.ArrayList([]const u8).init(arena);
+ try args.appendSlice(&[_][]const u8{
+ "-std=gnu11",
+ "-fgnu89-inline",
+ "-fmerge-all-constants",
+ "-frounding-math",
+ "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math.
+ "-fno-common",
+ "-fmath-errno",
+ "-ftls-model=initial-exec",
+ "-Wno-ignored-attributes",
+ "-Qunused-arguments",
+ });
+ try add_include_dirs(comp, arena, &args);
+
+ try args.append("-DNO_INITFINI");
+
+ if (target.cpu.arch == .x86) {
+ // This prevents i386/sysdep.h from trying to do some
+ // silly and unnecessary inline asm hack that uses weird
+ // syntax that clang does not support.
+ try args.append("-DCAN_USE_REGISTER_ASM_EBP");
+ }
+
+ try args.appendSlice(&[_][]const u8{
+ "-D_LIBC_REENTRANT",
+ "-include",
+ try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
+ "-DMODULE_NAME=libc",
+ "-Wno-nonportable-include-path",
+ "-include",
+ try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
+ "-DPIC",
+ "-DLIBC_NONSHARED=1",
+ "-DTOP_NAMESPACE=glibc",
+ });
+ files_buf[files_index] = .{
+ .src_path = try lib_path(comp, arena, dep.path),
+ .cache_exempt_flags = args.items,
+ .owner = undefined,
+ };
+ files_index += 1;
+ }
+ const files = files_buf[0..files_index];
+ return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{});
+ },
+ }
+}
+
+fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
+ const arch = comp.getTarget().cpu.arch;
+ const is_ppc = arch.isPowerPC();
+ const is_aarch64 = arch.isAARCH64();
+ const is_sparc = arch.isSPARC();
+ const is_64 = comp.getTarget().ptrBitWidth() == 64;
+
+ const s = path.sep_str;
+
+ var result = std.ArrayList(u8).init(arena);
+ try result.appendSlice(comp.zig_lib_directory.path.?);
+ try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
+ if (is_sparc) {
+ if (is_64) {
+ try result.appendSlice("sparc" ++ s ++ "sparc64");
+ } else {
+ try result.appendSlice("sparc" ++ s ++ "sparc32");
+ }
+ } else if (arch.isArm()) {
+ try result.appendSlice("arm");
+ } else if (arch.isMIPS()) {
+ try result.appendSlice("mips");
+ } else if (arch == .x86_64) {
+ try result.appendSlice("x86_64");
+ } else if (arch == .x86) {
+ try result.appendSlice("i386");
+ } else if (is_aarch64) {
+ try result.appendSlice("aarch64");
+ } else if (arch.isRISCV()) {
+ try result.appendSlice("riscv");
+ } else if (is_ppc) {
+ if (is_64) {
+ try result.appendSlice("powerpc" ++ s ++ "powerpc64");
+ } else {
+ try result.appendSlice("powerpc" ++ s ++ "powerpc32");
+ }
+ } else if (arch == .s390x) {
+ try result.appendSlice("s390" ++ s ++ "s390-64");
+ } else if (arch.isLoongArch()) {
+ try result.appendSlice("loongarch");
+ } else if (arch == .m68k) {
+ try result.appendSlice("m68k");
+ } else if (arch == .arc) {
+ try result.appendSlice("arc");
+ } else if (arch == .csky) {
+ try result.appendSlice("csky" ++ s ++ "abiv2");
+ }
+
+ try result.appendSlice(s);
+ try result.appendSlice(basename);
+ return result.items;
+}
+
+fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
+ const target = comp.getTarget();
+ const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
+
+ const s = path.sep_str;
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include"));
+
+ if (target.os.tag == .linux) {
+ try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
+ }
+
+ if (opt_nptl) |nptl| {
+ try add_include_dirs_arch(arena, args, target, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
+ }
+
+ if (target.os.tag == .linux) {
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+ "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "generic"));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+ "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "include"));
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
+ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
+ }
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
+ }
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread"));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv"));
+
+ try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
+
+ try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
+
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
+
+ try args.append("-I");
+ try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{
+ comp.zig_lib_directory.path.?, @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi),
+ }));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
+
+ const arch_name = std.zig.target.osArchName(target);
+ try args.append("-I");
+ try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
+ comp.zig_lib_directory.path.?, arch_name,
+ }));
+
+ try args.append("-I");
+ try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "any-linux-any"));
+}
+
+fn add_include_dirs_arch(
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+ target: std.Target,
+ opt_nptl: ?[]const u8,
+ dir: []const u8,
+) error{OutOfMemory}!void {
+ const arch = target.cpu.arch;
+ const is_x86 = arch.isX86();
+ const is_aarch64 = arch.isAARCH64();
+ const is_ppc = arch.isPowerPC();
+ const is_sparc = arch.isSPARC();
+ const is_64 = target.ptrBitWidth() == 64;
+
+ const s = path.sep_str;
+
+ if (is_x86) {
+ if (arch == .x86_64) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", nptl }));
+ } else {
+ if (target.abi == .gnux32) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", "x32" }));
+ }
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64" }));
+ }
+ } else if (arch == .x86) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "i386", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "i386" }));
+ }
+ }
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "x86", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "x86" }));
+ }
+ } else if (arch.isArm()) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "arm", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "arm" }));
+ }
+ } else if (arch.isMIPS()) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "mips", nptl }));
+ } else {
+ if (is_64) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips64" }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips32" }));
+ }
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" }));
+ }
+ } else if (is_sparc) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc", nptl }));
+ } else {
+ if (is_64) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc64" }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc32" }));
+ }
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" }));
+ }
+ } else if (is_aarch64) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64" }));
+ }
+ } else if (is_ppc) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc", nptl }));
+ } else {
+ if (is_64) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc64" }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc32" }));
+ }
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" }));
+ }
+ } else if (arch.isRISCV()) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv" }));
+ }
+ } else if (arch == .s390x) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "s390", nptl }));
+ } else {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" ++ s ++ "s390-64" }));
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" }));
+ }
+ } else if (arch.isLoongArch()) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "loongarch" }));
+ } else if (arch == .m68k) {
+ if (opt_nptl) |nptl| {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k", nptl }));
+ } else {
+ // coldfire ABI support requires: https://github.com/ziglang/zig/issues/20690
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" ++ s ++ "m680x0" }));
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" }));
+ }
+ } else if (arch == .arc) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "arc" }));
+ } else if (arch == .csky) {
+ try args.append("-I");
+ try args.append(try path.join(arena, &[_][]const u8{ dir, "csky" }));
+ }
+}
+
+fn path_from_lib(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
+ return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
+}
+
+const lib_libc = "libc" ++ path.sep_str;
+const lib_libc_glibc = lib_libc ++ "glibc" ++ path.sep_str;
+
+fn lib_path(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
+ return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
+}
+
+pub const BuiltSharedObjects = struct {
+ lock: Cache.Lock,
+ dir_path: Path,
+
+ pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void {
+ self.lock.release();
+ gpa.free(self.dir_path.sub_path);
+ self.* = undefined;
+ }
+};
+
+const all_map_basename = "all.map";
+
+fn wordDirective(target: std.Target) []const u8 {
+ // Based on its description in the GNU `as` manual, you might assume that `.word` is sized
+ // according to the target word size. But no; that would just make too much sense.
+ return if (target.ptrBitWidth() == 64) ".quad" else ".long";
+}
+
+/// TODO replace anyerror with explicit error set, recording user-friendly errors with
+/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
+pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void {
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const gpa = comp.gpa;
+
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const target = comp.getTarget();
+ const target_version = target.os.versionRange().gnuLibCVersion().?;
+
+ // Use the global cache directory.
+ var cache: Cache = .{
+ .gpa = gpa,
+ .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
+ };
+ cache.addPrefix(.{ .path = null, .handle = fs.cwd() });
+ cache.addPrefix(comp.zig_lib_directory);
+ cache.addPrefix(comp.global_cache_directory);
+ defer cache.manifest_dir.close();
+
+ var man = cache.obtain();
+ defer man.deinit();
+ man.hash.addBytes(build_options.version);
+ man.hash.add(target.cpu.arch);
+ man.hash.add(target.abi);
+ man.hash.add(target_version);
+
+ const full_abilists_path = try comp.zig_lib_directory.join(arena, &.{abilists_path});
+ const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);
+
+ if (try man.hit()) {
+ const digest = man.final();
+
+ return queueSharedObjects(comp, .{
+ .lock = man.toOwnedLock(),
+ .dir_path = .{
+ .root_dir = comp.global_cache_directory,
+ .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
+ },
+ });
+ }
+
+ const digest = man.final();
+ const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
+
+ var o_directory: Compilation.Directory = .{
+ .handle = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{}),
+ .path = try comp.global_cache_directory.join(arena, &.{o_sub_path}),
+ };
+ defer o_directory.handle.close();
+
+ const abilists_contents = man.files.keys()[abilists_index].contents.?;
+ const metadata = try loadMetaData(gpa, abilists_contents);
+ defer metadata.destroy(gpa);
+
+ const target_targ_index = for (metadata.all_targets, 0..) |targ, i| {
+ if (targ.arch == target.cpu.arch and
+ targ.os == target.os.tag and
+ targ.abi == target.abi)
+ {
+ break i;
+ }
+ } else {
+ unreachable; // std.zig.target.available_libcs prevents us from getting here
+ };
+
+ const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {
+ switch (ver.order(target_version)) {
+ .eq => break i,
+ .lt => continue,
+ .gt => {
+ // TODO Expose via compile error mechanism instead of log.
+ log.warn("invalid target glibc version: {}", .{target_version});
+ return error.InvalidTargetGLibCVersion;
+ },
+ }
+ } else blk: {
+ const latest_index = metadata.all_versions.len - 1;
+ log.warn("zig cannot build new glibc version {}; providing instead {}", .{
+ target_version, metadata.all_versions[latest_index],
+ });
+ break :blk latest_index;
+ };
+
+ {
+ var map_contents = std.ArrayList(u8).init(arena);
+ for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
+ if (ver.patch == 0) {
+ try map_contents.writer().print("GLIBC_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
+ } else {
+ try map_contents.writer().print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
+ }
+ }
+ try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
+ map_contents.deinit(); // The most recent allocation of an arena can be freed :)
+ }
+
+ var stubs_asm = std.ArrayList(u8).init(gpa);
+ defer stubs_asm.deinit();
+
+ for (libs, 0..) |lib, lib_i| {
+ if (lib.removed_in) |rem_in| {
+ if (target_version.order(rem_in) != .lt) continue;
+ }
+
+ stubs_asm.shrinkRetainingCapacity(0);
+ try stubs_asm.appendSlice(".text\n");
+
+ var sym_i: usize = 0;
+ var sym_name_buf = std.ArrayList(u8).init(arena);
+ var opt_symbol_name: ?[]const u8 = null;
+ var versions_buffer: [32]u8 = undefined;
+ var versions_len: usize = undefined;
+
+ // There can be situations where there are multiple inclusions for the same symbol with
+ // partially overlapping versions, due to different target lists. For example:
+ //
+ // lgammal:
+ // library: libm.so
+ // versions: 2.4 2.23
+ // targets: ... powerpc64-linux-gnu s390x-linux-gnu
+ // lgammal:
+ // library: libm.so
+ // versions: 2.2 2.23
+ // targets: sparc64-linux-gnu s390x-linux-gnu
+ //
+ // If we don't handle this, we end up writing the default `lgammal` symbol for version 2.33
+ // twice, which causes a "duplicate symbol" assembler error.
+ var versions_written = std.AutoArrayHashMap(Version, void).init(arena);
+
+ var inc_fbs = std.io.fixedBufferStream(metadata.inclusions);
+ var inc_reader = inc_fbs.reader();
+
+ const fn_inclusions_len = try inc_reader.readInt(u16, .little);
+
+ while (sym_i < fn_inclusions_len) : (sym_i += 1) {
+ const sym_name = opt_symbol_name orelse n: {
+ sym_name_buf.clearRetainingCapacity();
+ try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
+
+ opt_symbol_name = sym_name_buf.items;
+ versions_buffer = undefined;
+ versions_len = 0;
+
+ break :n sym_name_buf.items;
+ };
+ const targets = try std.leb.readUleb128(u64, inc_reader);
+ var lib_index = try inc_reader.readByte();
+
+ const is_terminal = (lib_index & (1 << 7)) != 0;
+ if (is_terminal) {
+ lib_index &= ~@as(u8, 1 << 7);
+ opt_symbol_name = null;
+ }
+
+ // Test whether the inclusion applies to our current library and target.
+ const ok_lib_and_target =
+ (lib_index == lib_i) and
+ ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
+
+ while (true) {
+ const byte = try inc_reader.readByte();
+ const last = (byte & 0b1000_0000) != 0;
+ const ver_i = @as(u7, @truncate(byte));
+ if (ok_lib_and_target and ver_i <= target_ver_index) {
+ versions_buffer[versions_len] = ver_i;
+ versions_len += 1;
+ }
+ if (last) break;
+ }
+
+ if (!is_terminal) continue;
+
+ // Pick the default symbol version:
+ // - If there are no versions, don't emit it
+ // - Take the greatest one <= than the target one
+ // - If none of them is <= than the
+ // specified one don't pick any default version
+ if (versions_len == 0) continue;
+ var chosen_def_ver_index: u8 = 255;
+ {
+ var ver_buf_i: u8 = 0;
+ while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
+ const ver_index = versions_buffer[ver_buf_i];
+ if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
+ chosen_def_ver_index = ver_index;
+ }
+ }
+ }
+
+ versions_written.clearRetainingCapacity();
+ try versions_written.ensureTotalCapacity(versions_len);
+
+ {
+ var ver_buf_i: u8 = 0;
+ while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
+ // Example:
+ // .balign 4
+ // .globl _Exit_2_2_5
+ // .type _Exit_2_2_5, %function
+ // .symver _Exit_2_2_5, _Exit@@GLIBC_2.2.5, remove
+ // _Exit_2_2_5: .long 0
+ const ver_index = versions_buffer[ver_buf_i];
+ const ver = metadata.all_versions[ver_index];
+
+ if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
+
+ // Default symbol version definition vs normal symbol version definition
+ const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
+ const at_sign_str: []const u8 = if (want_default) "@@" else "@";
+ if (ver.patch == 0) {
+ const sym_plus_ver = try std.fmt.allocPrint(
+ arena,
+ "{s}_{d}_{d}",
+ .{ sym_name, ver.major, ver.minor },
+ );
+ try stubs_asm.writer().print(
+ \\.balign {d}
+ \\.globl {s}
+ \\.type {s}, %function
+ \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
+ \\{s}: {s} 0
+ \\
+ , .{
+ target.ptrBitWidth() / 8,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_name,
+ at_sign_str,
+ ver.major,
+ ver.minor,
+ sym_plus_ver,
+ wordDirective(target),
+ });
+ } else {
+ const sym_plus_ver = try std.fmt.allocPrint(
+ arena,
+ "{s}_{d}_{d}_{d}",
+ .{ sym_name, ver.major, ver.minor, ver.patch },
+ );
+ try stubs_asm.writer().print(
+ \\.balign {d}
+ \\.globl {s}
+ \\.type {s}, %function
+ \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
+ \\{s}: {s} 0
+ \\
+ , .{
+ target.ptrBitWidth() / 8,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_name,
+ at_sign_str,
+ ver.major,
+ ver.minor,
+ ver.patch,
+ sym_plus_ver,
+ wordDirective(target),
+ });
+ }
+ }
+ }
+ }
+
+ try stubs_asm.appendSlice(".rodata\n");
+
+ // For some targets, the real `libc.so.6` will contain a weak reference to `_IO_stdin_used`,
+ // making the linker put the symbol in the dynamic symbol table. We likewise need to emit a
+ // reference to it here for that effect, or it will not show up, which in turn will cause
+ // the real glibc to think that the program was built against an ancient `FILE` structure
+ // (pre-glibc 2.1).
+ //
+ // Note that glibc only compiles in the legacy compatibility code for some targets; it
+ // depends on what is defined in the `shlib-versions` file for the particular architecture
+ // and ABI. Those files are preprocessed by 2 separate tools during the glibc build to get
+ // the final `abi-versions.h`, so it would be quite brittle to try to condition our emission
+ // of the `_IO_stdin_used` reference in the exact same way. The only downside of emitting
+ // the reference unconditionally is that it ends up being unused for newer targets; it
+ // otherwise has no negative effect.
+ //
+ // glibc uses a weak reference because it has to work with programs compiled against pre-2.1
+ // versions where the symbol didn't exist. We only care about modern glibc versions, so use
+ // a strong reference.
+ if (std.mem.eql(u8, lib.name, "c")) {
+ try stubs_asm.writer().print(
+ \\.balign {d}
+ \\.globl _IO_stdin_used
+ \\{s} _IO_stdin_used
+ \\
+ , .{
+ target.ptrBitWidth() / 8,
+ wordDirective(target),
+ });
+ }
+
+ try stubs_asm.appendSlice(".data\n");
+
+ const obj_inclusions_len = try inc_reader.readInt(u16, .little);
+
+ sym_i = 0;
+ opt_symbol_name = null;
+ versions_buffer = undefined;
+ versions_len = undefined;
+ while (sym_i < obj_inclusions_len) : (sym_i += 1) {
+ const sym_name = opt_symbol_name orelse n: {
+ sym_name_buf.clearRetainingCapacity();
+ try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
+
+ opt_symbol_name = sym_name_buf.items;
+ versions_buffer = undefined;
+ versions_len = 0;
+
+ break :n sym_name_buf.items;
+ };
+ const targets = try std.leb.readUleb128(u64, inc_reader);
+ const size = try std.leb.readUleb128(u16, inc_reader);
+ var lib_index = try inc_reader.readByte();
+
+ const is_terminal = (lib_index & (1 << 7)) != 0;
+ if (is_terminal) {
+ lib_index &= ~@as(u8, 1 << 7);
+ opt_symbol_name = null;
+ }
+
+ // Test whether the inclusion applies to our current library and target.
+ const ok_lib_and_target =
+ (lib_index == lib_i) and
+ ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
+
+ while (true) {
+ const byte = try inc_reader.readByte();
+ const last = (byte & 0b1000_0000) != 0;
+ const ver_i = @as(u7, @truncate(byte));
+ if (ok_lib_and_target and ver_i <= target_ver_index) {
+ versions_buffer[versions_len] = ver_i;
+ versions_len += 1;
+ }
+ if (last) break;
+ }
+
+ if (!is_terminal) continue;
+
+ // Pick the default symbol version:
+ // - If there are no versions, don't emit it
+ // - Take the greatest one <= than the target one
+ // - If none of them is <= than the
+ // specified one don't pick any default version
+ if (versions_len == 0) continue;
+ var chosen_def_ver_index: u8 = 255;
+ {
+ var ver_buf_i: u8 = 0;
+ while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
+ const ver_index = versions_buffer[ver_buf_i];
+ if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
+ chosen_def_ver_index = ver_index;
+ }
+ }
+ }
+
+ versions_written.clearRetainingCapacity();
+ try versions_written.ensureTotalCapacity(versions_len);
+
+ {
+ var ver_buf_i: u8 = 0;
+ while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
+ // Example:
+ // .balign 4
+ // .globl environ_2_2_5
+ // .type environ_2_2_5, %object
+ // .size environ_2_2_5, 4
+ // .symver environ_2_2_5, environ@@GLIBC_2.2.5, remove
+ // environ_2_2_5: .fill 4, 1, 0
+ const ver_index = versions_buffer[ver_buf_i];
+ const ver = metadata.all_versions[ver_index];
+
+ if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
+
+ // Default symbol version definition vs normal symbol version definition
+ const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
+ const at_sign_str: []const u8 = if (want_default) "@@" else "@";
+ if (ver.patch == 0) {
+ const sym_plus_ver = try std.fmt.allocPrint(
+ arena,
+ "{s}_{d}_{d}",
+ .{ sym_name, ver.major, ver.minor },
+ );
+ try stubs_asm.writer().print(
+ \\.balign {d}
+ \\.globl {s}
+ \\.type {s}, %object
+ \\.size {s}, {d}
+ \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
+ \\{s}: .fill {d}, 1, 0
+ \\
+ , .{
+ target.ptrBitWidth() / 8,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_plus_ver,
+ size,
+ sym_plus_ver,
+ sym_name,
+ at_sign_str,
+ ver.major,
+ ver.minor,
+ sym_plus_ver,
+ size,
+ });
+ } else {
+ const sym_plus_ver = try std.fmt.allocPrint(
+ arena,
+ "{s}_{d}_{d}_{d}",
+ .{ sym_name, ver.major, ver.minor, ver.patch },
+ );
+ try stubs_asm.writer().print(
+ \\.balign {d}
+ \\.globl {s}
+ \\.type {s}, %object
+ \\.size {s}, {d}
+ \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
+ \\{s}: .fill {d}, 1, 0
+ \\
+ , .{
+ target.ptrBitWidth() / 8,
+ sym_plus_ver,
+ sym_plus_ver,
+ sym_plus_ver,
+ size,
+ sym_plus_ver,
+ sym_name,
+ at_sign_str,
+ ver.major,
+ ver.minor,
+ ver.patch,
+ sym_plus_ver,
+ size,
+ });
+ }
+ }
+ }
+ }
+
+ var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
+ const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
+ try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
+ try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
+ }
+
+ man.writeManifest() catch |err| {
+ log.warn("failed to write cache manifest for glibc stubs: {s}", .{@errorName(err)});
+ };
+
+ return queueSharedObjects(comp, .{
+ .lock = man.toOwnedLock(),
+ .dir_path = .{
+ .root_dir = comp.global_cache_directory,
+ .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
+ },
+ });
+}
+
+pub fn sharedObjectsCount(target: *const std.Target) u8 {
+ const target_version = target.os.versionRange().gnuLibCVersion() orelse return 0;
+ var count: u8 = 0;
+ for (libs) |lib| {
+ if (lib.removed_in) |rem_in| {
+ if (target_version.order(rem_in) != .lt) continue;
+ }
+ count += 1;
+ }
+ return count;
+}
+
+fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
+ const target_version = comp.getTarget().os.versionRange().gnuLibCVersion().?;
+
+ assert(comp.glibc_so_files == null);
+ comp.glibc_so_files = so_files;
+
+ var task_buffer: [libs.len]link.Task = undefined;
+ var task_buffer_i: usize = 0;
+
+ {
+ comp.mutex.lock(); // protect comp.arena
+ defer comp.mutex.unlock();
+
+ for (libs) |lib| {
+ if (lib.removed_in) |rem_in| {
+ if (target_version.order(rem_in) != .lt) continue;
+ }
+ const so_path: Path = .{
+ .root_dir = so_files.dir_path.root_dir,
+ .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{
+ so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover,
+ }) catch return comp.setAllocFailure(),
+ };
+ task_buffer[task_buffer_i] = .{ .load_dso = so_path };
+ task_buffer_i += 1;
+ }
+ }
+
+ comp.queueLinkTasks(task_buffer[0..task_buffer_i]);
+}
+
+fn buildSharedLib(
+ comp: *Compilation,
+ arena: Allocator,
+ zig_cache_directory: Compilation.Directory,
+ bin_directory: Compilation.Directory,
+ asm_file_basename: []const u8,
+ lib: Lib,
+ prog_node: std.Progress.Node,
+) !void {
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover });
+ const emit_bin = Compilation.EmitLoc{
+ .directory = bin_directory,
+ .basename = basename,
+ };
+ const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };
+ const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);
+ const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
+ const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
+
+ const optimize_mode = comp.compilerRtOptMode();
+ const strip = comp.compilerRtStrip();
+ const config = try Compilation.Config.resolve(.{
+ .output_mode = .Lib,
+ .link_mode = .dynamic,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = optimize_mode,
+ .root_strip = strip,
+ .link_libc = false,
+ });
+
+ const root_mod = try Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = strip,
+ .stack_check = false,
+ .stack_protector = 0,
+ .sanitize_c = .off,
+ .sanitize_thread = false,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
+ .valgrind = false,
+ .optimize_mode = optimize_mode,
+ .structured_cfg = comp.root_mod.structured_cfg,
+ },
+ .global = config,
+ .cc_argv = &.{},
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ });
+
+ const c_source_files = [1]Compilation.CSourceFile{
+ .{
+ .src_path = try path.join(arena, &.{ bin_directory.path.?, asm_file_basename }),
+ .owner = root_mod,
+ },
+ };
+
+ const sub_compilation = try Compilation.create(comp.gpa, arena, .{
+ .local_cache_directory = zig_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .thread_pool = comp.thread_pool,
+ .self_exe_path = comp.self_exe_path,
+ .cache_mode = .incremental,
+ .config = config,
+ .root_mod = root_mod,
+ .root_name = lib.name,
+ .libc_installation = comp.libc_installation,
+ .emit_bin = emit_bin,
+ .emit_h = null,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_llvm_bc = comp.verbose_llvm_bc,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .version = version,
+ .version_script = map_file_path,
+ .soname = soname,
+ .c_source_files = &c_source_files,
+ .skip_linker_dependencies = true,
+ });
+ defer sub_compilation.destroy();
+
+ try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
+}
+
+pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
+ return switch (output_mode) {
+ .Obj, .Lib => null,
+ .Exe => .scrt1_o,
+ };
+}
diff --git a/src/libs/libcxx.zig b/src/libs/libcxx.zig
new file mode 100644
index 0000000000..d832868edc
--- /dev/null
+++ b/src/libs/libcxx.zig
@@ -0,0 +1,578 @@
+const std = @import("std");
+const path = std.fs.path;
+const assert = std.debug.assert;
+
+const target_util = @import("../target.zig");
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+const trace = @import("../tracy.zig").trace;
+const Module = @import("../Package/Module.zig");
+
+const libcxxabi_files = [_][]const u8{
+ "src/abort_message.cpp",
+ "src/cxa_aux_runtime.cpp",
+ "src/cxa_default_handlers.cpp",
+ "src/cxa_demangle.cpp",
+ "src/cxa_exception.cpp",
+ "src/cxa_exception_storage.cpp",
+ "src/cxa_guard.cpp",
+ "src/cxa_handlers.cpp",
+ "src/cxa_noexception.cpp",
+ "src/cxa_personality.cpp",
+ "src/cxa_thread_atexit.cpp",
+ "src/cxa_vector.cpp",
+ "src/cxa_virtual.cpp",
+ "src/fallback_malloc.cpp",
+ "src/private_typeinfo.cpp",
+ "src/stdlib_exception.cpp",
+ "src/stdlib_new_delete.cpp",
+ "src/stdlib_stdexcept.cpp",
+ "src/stdlib_typeinfo.cpp",
+};
+
+const libcxx_base_files = [_][]const u8{
+ "src/algorithm.cpp",
+ "src/any.cpp",
+ "src/bind.cpp",
+ "src/call_once.cpp",
+ "src/charconv.cpp",
+ "src/chrono.cpp",
+ "src/error_category.cpp",
+ "src/exception.cpp",
+ "src/expected.cpp",
+ "src/filesystem/directory_entry.cpp",
+ "src/filesystem/directory_iterator.cpp",
+ "src/filesystem/filesystem_clock.cpp",
+ "src/filesystem/filesystem_error.cpp",
+ // omit int128_builtins.cpp because it provides __muloti4 which is already provided
+ // by compiler_rt and crashes on Windows x86_64: https://github.com/ziglang/zig/issues/10719
+ //"src/filesystem/int128_builtins.cpp",
+ "src/filesystem/operations.cpp",
+ "src/filesystem/path.cpp",
+ "src/fstream.cpp",
+ "src/functional.cpp",
+ "src/hash.cpp",
+ "src/ios.cpp",
+ "src/ios.instantiations.cpp",
+ "src/iostream.cpp",
+ "src/locale.cpp",
+ "src/memory.cpp",
+ "src/memory_resource.cpp",
+ "src/new.cpp",
+ "src/new_handler.cpp",
+ "src/new_helpers.cpp",
+ "src/optional.cpp",
+ "src/ostream.cpp",
+ "src/print.cpp",
+ //"src/pstl/libdispatch.cpp",
+ "src/random.cpp",
+ "src/random_shuffle.cpp",
+ "src/regex.cpp",
+ "src/ryu/d2fixed.cpp",
+ "src/ryu/d2s.cpp",
+ "src/ryu/f2s.cpp",
+ "src/stdexcept.cpp",
+ "src/string.cpp",
+ "src/strstream.cpp",
+ "src/support/ibm/mbsnrtowcs.cpp",
+ "src/support/ibm/wcsnrtombs.cpp",
+ "src/support/ibm/xlocale_zos.cpp",
+ "src/support/win32/locale_win32.cpp",
+ "src/support/win32/support.cpp",
+ "src/system_error.cpp",
+ "src/typeinfo.cpp",
+ "src/valarray.cpp",
+ "src/variant.cpp",
+ "src/vector.cpp",
+ "src/verbose_abort.cpp",
+};
+
+const libcxx_thread_files = [_][]const u8{
+ "src/atomic.cpp",
+ "src/barrier.cpp",
+ "src/condition_variable.cpp",
+ "src/condition_variable_destructor.cpp",
+ "src/future.cpp",
+ "src/mutex.cpp",
+ "src/mutex_destructor.cpp",
+ "src/shared_mutex.cpp",
+ "src/support/win32/thread_win32.cpp",
+ "src/thread.cpp",
+};
+
+pub const BuildError = error{
+ OutOfMemory,
+ SubCompilationFailed,
+ ZigCompilerNotBuiltWithLLVMExtensions,
+};
+
+pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const root_name = "c++";
+ const output_mode = .Lib;
+ const link_mode = .static;
+ const target = comp.root_mod.resolved_target.result;
+ const basename = try std.zig.binNameAlloc(arena, .{
+ .root_name = root_name,
+ .target = target,
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ });
+
+ const emit_bin = Compilation.EmitLoc{
+ .directory = null, // Put it in the cache directory.
+ .basename = basename,
+ };
+
+ const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
+ const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
+ const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
+ const cxx_libc_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "libc" });
+
+ const optimize_mode = comp.compilerRtOptMode();
+ const strip = comp.compilerRtStrip();
+
+ const config = Compilation.Config.resolve(.{
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = optimize_mode,
+ .root_strip = strip,
+ .link_libc = true,
+ .lto = comp.config.lto,
+ .any_sanitize_thread = comp.config.any_sanitize_thread,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxx,
+ "unable to build libc++: resolving configuration failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ const root_mod = Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = strip,
+ .stack_check = false,
+ .stack_protector = 0,
+ .sanitize_c = .off,
+ .sanitize_thread = comp.config.any_sanitize_thread,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
+ .valgrind = false,
+ .optimize_mode = optimize_mode,
+ .structured_cfg = comp.root_mod.structured_cfg,
+ .pic = if (target_util.supports_fpic(target)) true else null,
+ .code_model = comp.root_mod.code_model,
+ },
+ .global = config,
+ .cc_argv = &.{},
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxx,
+ "unable to build libc++: creating module failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ const libcxx_files = if (comp.config.any_non_single_threaded)
+ &(libcxx_base_files ++ libcxx_thread_files)
+ else
+ &libcxx_base_files;
+
+ var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
+
+ for (libcxx_files) |cxx_src| {
+ // These don't compile on WASI due to e.g. `fchmod` usage.
+ if (std.mem.startsWith(u8, cxx_src, "src/filesystem/") and target.os.tag == .wasi)
+ continue;
+ if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
+ continue;
+ if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
+ continue;
+
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try addCxxArgs(comp, arena, &cflags);
+
+ try cflags.append("-DNDEBUG");
+ try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
+ try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
+ try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
+ try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
+
+ try cflags.append("-fvisibility=hidden");
+ try cflags.append("-fvisibility-inlines-hidden");
+
+ if (target.os.tag == .zos) {
+ try cflags.append("-fno-aligned-allocation");
+ } else {
+ try cflags.append("-faligned-allocation");
+ }
+
+ try cflags.append("-nostdinc++");
+ try cflags.append("-std=c++23");
+ try cflags.append("-Wno-user-defined-literals");
+ try cflags.append("-Wno-covered-switch-default");
+ try cflags.append("-Wno-suggest-override");
+
+ // These depend on only the zig lib directory file path, which is
+ // purposefully either in the cache or not in the cache. The decision
+ // should not be overridden here.
+ var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxx_include_path);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxxabi_include_path);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxx_src_include_path);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxx_libc_include_path);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }),
+ .extra_flags = cflags.items,
+ .cache_exempt_flags = cache_exempt_flags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const sub_compilation = Compilation.create(comp.gpa, arena, .{
+ .local_cache_directory = comp.global_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .self_exe_path = comp.self_exe_path,
+ .cache_mode = .whole,
+ .config = config,
+ .root_mod = root_mod,
+ .root_name = root_name,
+ .thread_pool = comp.thread_pool,
+ .libc_installation = comp.libc_installation,
+ .emit_bin = emit_bin,
+ .emit_h = null,
+ .c_source_files = c_source_files.items,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_llvm_bc = comp.verbose_llvm_bc,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .skip_linker_dependencies = true,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxx,
+ "unable to build libc++: create compilation failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ defer sub_compilation.destroy();
+
+ comp.updateSubCompilation(sub_compilation, .libcxx, prog_node) catch |err| switch (err) {
+ error.SubCompilationFailed => return error.SubCompilationFailed,
+ else => |e| {
+ comp.setMiscFailure(
+ .libcxx,
+ "unable to build libc++: compilation failed: {s}",
+ .{@errorName(e)},
+ );
+ return error.SubCompilationFailed;
+ },
+ };
+
+ assert(comp.libcxx_static_lib == null);
+ const crt_file = try sub_compilation.toCrtFile();
+ comp.libcxx_static_lib = crt_file;
+ comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
+}
+
+pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const root_name = "c++abi";
+ const output_mode = .Lib;
+ const link_mode = .static;
+ const target = comp.root_mod.resolved_target.result;
+ const basename = try std.zig.binNameAlloc(arena, .{
+ .root_name = root_name,
+ .target = target,
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ });
+
+ const emit_bin = Compilation.EmitLoc{
+ .directory = null, // Put it in the cache directory.
+ .basename = basename,
+ };
+
+ const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
+ const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
+ const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
+
+ const optimize_mode = comp.compilerRtOptMode();
+ const strip = comp.compilerRtStrip();
+ // See the `-fno-exceptions` logic for WASI.
+ // The old 32-bit x86 variant of SEH doesn't use tables.
+ const unwind_tables: std.builtin.UnwindTables =
+ if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .@"async";
+
+ const config = Compilation.Config.resolve(.{
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = optimize_mode,
+ .root_strip = strip,
+ .link_libc = true,
+ .any_unwind_tables = unwind_tables != .none,
+ .lto = comp.config.lto,
+ .any_sanitize_thread = comp.config.any_sanitize_thread,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxxabi,
+ "unable to build libc++abi: resolving configuration failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ const root_mod = Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = strip,
+ .stack_check = false,
+ .stack_protector = 0,
+ .sanitize_c = .off,
+ .sanitize_thread = comp.config.any_sanitize_thread,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
+ .valgrind = false,
+ .optimize_mode = optimize_mode,
+ .structured_cfg = comp.root_mod.structured_cfg,
+ .unwind_tables = unwind_tables,
+ .pic = comp.root_mod.pic,
+ .code_model = comp.root_mod.code_model,
+ },
+ .global = config,
+ .cc_argv = &.{},
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxxabi,
+ "unable to build libc++abi: creating module failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
+
+ for (libcxxabi_files) |cxxabi_src| {
+ if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
+ continue;
+
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try addCxxArgs(comp, arena, &cflags);
+
+ try cflags.append("-DNDEBUG");
+ try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
+ if (!comp.config.any_non_single_threaded) {
+ try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
+ }
+ if (target.abi.isGnu()) {
+ if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
+ try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
+ }
+
+ try cflags.append("-fvisibility=hidden");
+ try cflags.append("-fvisibility-inlines-hidden");
+
+ if (target_util.supports_fpic(target)) {
+ try cflags.append("-fPIC");
+ }
+ try cflags.append("-nostdinc++");
+ try cflags.append("-fstrict-aliasing");
+ try cflags.append("-std=c++23");
+ try cflags.append("-Wno-user-defined-literals");
+ try cflags.append("-Wno-covered-switch-default");
+ try cflags.append("-Wno-suggest-override");
+
+ // These depend on only the zig lib directory file path, which is
+ // purposefully either in the cache or not in the cache. The decision
+ // should not be overridden here.
+ var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxxabi_include_path);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxx_include_path);
+
+ try cache_exempt_flags.append("-I");
+ try cache_exempt_flags.append(cxx_src_include_path);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }),
+ .extra_flags = cflags.items,
+ .cache_exempt_flags = cache_exempt_flags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const sub_compilation = Compilation.create(comp.gpa, arena, .{
+ .local_cache_directory = comp.global_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .self_exe_path = comp.self_exe_path,
+ .cache_mode = .whole,
+ .config = config,
+ .root_mod = root_mod,
+ .root_name = root_name,
+ .thread_pool = comp.thread_pool,
+ .libc_installation = comp.libc_installation,
+ .emit_bin = emit_bin,
+ .emit_h = null,
+ .c_source_files = c_source_files.items,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_llvm_bc = comp.verbose_llvm_bc,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .skip_linker_dependencies = true,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libcxxabi,
+ "unable to build libc++abi: create compilation failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ defer sub_compilation.destroy();
+
+ comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node) catch |err| switch (err) {
+ error.SubCompilationFailed => return error.SubCompilationFailed,
+ else => |e| {
+ comp.setMiscFailure(
+ .libcxxabi,
+ "unable to build libc++abi: compilation failed: {s}",
+ .{@errorName(e)},
+ );
+ return error.SubCompilationFailed;
+ },
+ };
+
+ assert(comp.libcxxabi_static_lib == null);
+ const crt_file = try sub_compilation.toCrtFile();
+ comp.libcxxabi_static_lib = crt_file;
+ comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
+}
+
+pub fn addCxxArgs(
+ comp: *const Compilation,
+ arena: std.mem.Allocator,
+ cflags: *std.ArrayList([]const u8),
+) error{OutOfMemory}!void {
+ const target = comp.getTarget();
+ const optimize_mode = comp.compilerRtOptMode();
+
+ const abi_version: u2 = if (target.os.tag == .emscripten) 2 else 1;
+ try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
+ abi_version,
+ }));
+ try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
+ abi_version,
+ }));
+ try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
+ if (!comp.config.any_non_single_threaded) "NO_" else "",
+ }));
+ try cflags.append("-D_LIBCPP_HAS_MONOTONIC_CLOCK");
+ try cflags.append("-D_LIBCPP_HAS_TERMINAL");
+ try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}MUSL_LIBC", .{
+ if (!target.abi.isMusl()) "NO_" else "",
+ }));
+ try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
+ try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
+ try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
+ try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}FILESYSTEM", .{
+ if (target.os.tag == .wasi) "NO_" else "",
+ }));
+ try cflags.append("-D_LIBCPP_HAS_RANDOM_DEVICE");
+ try cflags.append("-D_LIBCPP_HAS_LOCALIZATION");
+ try cflags.append("-D_LIBCPP_HAS_UNICODE");
+ try cflags.append("-D_LIBCPP_HAS_WIDE_CHARACTERS");
+ try cflags.append("-D_LIBCPP_HAS_NO_STD_MODULES");
+ if (target.os.tag == .linux) {
+ try cflags.append("-D_LIBCPP_HAS_TIME_ZONE_DATABASE");
+ }
+ // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
+ // for potentially enabling some fancy features here, which would
+ // require corresponding changes in libcxx.zig, as well as
+ // Compilation.addCCArgs. This option makes it use serial backend which
+ // is simple and works everywhere.
+ try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
+ try cflags.append(switch (optimize_mode) {
+ .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
+ .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE",
+ .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST",
+ });
+ if (target.isGnuLibC()) {
+ // glibc 2.16 introduced aligned_alloc
+ if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
+ try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
+ }
+ }
+ try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
+}
diff --git a/src/libs/libtsan.zig b/src/libs/libtsan.zig
new file mode 100644
index 0000000000..c2cc82465d
--- /dev/null
+++ b/src/libs/libtsan.zig
@@ -0,0 +1,499 @@
+const std = @import("std");
+const assert = std.debug.assert;
+
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+const trace = @import("../tracy.zig").trace;
+const Module = @import("../Package/Module.zig");
+
+pub const BuildError = error{
+ OutOfMemory,
+ SubCompilationFailed,
+ ZigCompilerNotBuiltWithLLVMExtensions,
+ TSANUnsupportedCPUArchitecture,
+};
+
+pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const target = comp.getTarget();
+ const root_name = switch (target.os.tag) {
+ // On Apple platforms, we use the same name as LLVM because the
+ // TSAN library implementation hard-codes a check for these names.
+ .driverkit, .macos => "clang_rt.tsan_osx_dynamic",
+ .ios => if (target.abi == .simulator) "clang_rt.tsan_iossim_dynamic" else "clang_rt.tsan_ios_dynamic",
+ .tvos => if (target.abi == .simulator) "clang_rt.tsan_tvossim_dynamic" else "clang_rt.tsan_tvos_dynamic",
+ .visionos => if (target.abi == .simulator) "clang_rt.tsan_xrossim_dynamic" else "clang_rt.tsan_xros_dynamic",
+ .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic",
+ else => "tsan",
+ };
+ const link_mode: std.builtin.LinkMode = if (target.os.tag.isDarwin()) .dynamic else .static;
+ const output_mode = .Lib;
+ const basename = try std.zig.binNameAlloc(arena, .{
+ .root_name = root_name,
+ .target = target,
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ });
+
+ const emit_bin = Compilation.EmitLoc{
+ .directory = null, // Put it in the cache directory.
+ .basename = basename,
+ };
+
+ const optimize_mode = comp.compilerRtOptMode();
+ const strip = comp.compilerRtStrip();
+ const unwind_tables: std.builtin.UnwindTables =
+ if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
+ const link_libcpp = target.os.tag.isDarwin();
+
+ const config = Compilation.Config.resolve(.{
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = optimize_mode,
+ .root_strip = strip,
+ .link_libc = true,
+ .link_libcpp = link_libcpp,
+ .any_unwind_tables = unwind_tables != .none,
+ // LLVM disables LTO for its libtsan.
+ .lto = .none,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libtsan,
+ "unable to build thread sanitizer runtime: resolving configuration failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ const common_flags = [_][]const u8{
+ "-DTSAN_CONTAINS_UBSAN=0",
+ };
+
+ const root_mod = Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = strip,
+ .stack_check = false,
+ .stack_protector = 0,
+ .sanitize_c = .off,
+ .sanitize_thread = false,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(),
+ .valgrind = false,
+ .unwind_tables = unwind_tables,
+ .optimize_mode = optimize_mode,
+ .structured_cfg = comp.root_mod.structured_cfg,
+ .pic = true,
+ .no_builtin = true,
+ .code_model = comp.root_mod.code_model,
+ },
+ .global = config,
+ .cc_argv = &common_flags,
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libtsan,
+ "unable to build thread sanitizer runtime: creating module failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
+ try c_source_files.ensureUnusedCapacity(tsan_sources.len);
+
+ const tsan_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{"libtsan"});
+ for (tsan_sources) |tsan_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &.{ "libtsan", tsan_src }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const platform_tsan_sources = switch (target.os.tag) {
+ .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
+ .windows => &windows_tsan_sources,
+ else => &unix_tsan_sources,
+ };
+ try c_source_files.ensureUnusedCapacity(platform_tsan_sources.len);
+ for (platform_tsan_sources) |tsan_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", tsan_src }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+ {
+ const asm_source = switch (target.cpu.arch) {
+ .aarch64, .aarch64_be => "tsan_rtl_aarch64.S",
+ .loongarch64 => "tsan_rtl_loongarch64.S",
+ .mips64, .mips64el => "tsan_rtl_mips64.S",
+ .powerpc64, .powerpc64le => "tsan_rtl_ppc64.S",
+ .riscv64 => "tsan_rtl_riscv64.S",
+ .s390x => "tsan_rtl_s390x.S",
+ .x86_64 => "tsan_rtl_amd64.S",
+ else => return error.TSANUnsupportedCPUArchitecture,
+ };
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try cflags.append("-DNDEBUG");
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", asm_source }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ try c_source_files.ensureUnusedCapacity(sanitizer_common_sources.len);
+ const sanitizer_common_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libtsan", "sanitizer_common",
+ });
+ for (sanitizer_common_sources) |common_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(sanitizer_common_include_path);
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libtsan", "sanitizer_common", common_src,
+ }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const to_c_or_not_to_c_sources = if (comp.config.link_libc)
+ &sanitizer_libcdep_sources
+ else
+ &sanitizer_nolibc_sources;
+ try c_source_files.ensureUnusedCapacity(to_c_or_not_to_c_sources.len);
+ for (to_c_or_not_to_c_sources) |c_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(sanitizer_common_include_path);
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libtsan", "sanitizer_common", c_src,
+ }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ try c_source_files.ensureUnusedCapacity(sanitizer_symbolizer_sources.len);
+ for (sanitizer_symbolizer_sources) |c_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libtsan", "sanitizer_common", c_src,
+ }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const interception_include_path = try comp.zig_lib_directory.join(
+ arena,
+ &[_][]const u8{"interception"},
+ );
+
+ try c_source_files.ensureUnusedCapacity(interception_sources.len);
+ for (interception_sources) |c_src| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ try cflags.append("-I");
+ try cflags.append(interception_include_path);
+
+ try cflags.append("-I");
+ try cflags.append(tsan_include_path);
+
+ try addCcArgs(target, &cflags);
+
+ c_source_files.appendAssumeCapacity(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libtsan", "interception", c_src,
+ }),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ });
+ }
+
+ const skip_linker_dependencies = !target.os.tag.isDarwin();
+ const linker_allow_shlib_undefined = target.os.tag.isDarwin();
+ const install_name = if (target.os.tag.isDarwin())
+ try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename})
+ else
+ null;
+ // Workaround for https://github.com/llvm/llvm-project/issues/97627
+ const headerpad_size: ?u32 = if (target.os.tag.isDarwin()) 32 else null;
+ const sub_compilation = Compilation.create(comp.gpa, arena, .{
+ .local_cache_directory = comp.global_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .thread_pool = comp.thread_pool,
+ .self_exe_path = comp.self_exe_path,
+ .cache_mode = .whole,
+ .config = config,
+ .root_mod = root_mod,
+ .root_name = root_name,
+ .libc_installation = comp.libc_installation,
+ .emit_bin = emit_bin,
+ .emit_h = null,
+ .c_source_files = c_source_files.items,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_llvm_bc = comp.verbose_llvm_bc,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .skip_linker_dependencies = skip_linker_dependencies,
+ .linker_allow_shlib_undefined = linker_allow_shlib_undefined,
+ .install_name = install_name,
+ .headerpad_size = headerpad_size,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libtsan,
+ "unable to build thread sanitizer runtime: create compilation failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ defer sub_compilation.destroy();
+
+ comp.updateSubCompilation(sub_compilation, .libtsan, prog_node) catch |err| switch (err) {
+ error.SubCompilationFailed => return error.SubCompilationFailed,
+ else => |e| {
+ comp.setMiscFailure(
+ .libtsan,
+ "unable to build thread sanitizer runtime: compilation failed: {s}",
+ .{@errorName(e)},
+ );
+ return error.SubCompilationFailed;
+ },
+ };
+
+ const crt_file = try sub_compilation.toCrtFile();
+ comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
+ assert(comp.tsan_lib == null);
+ comp.tsan_lib = crt_file;
+}
+
+fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
+ try args.appendSlice(&[_][]const u8{
+ "-nostdinc++",
+ "-fvisibility=hidden",
+ "-fvisibility-inlines-hidden",
+ "-std=c++17",
+ "-fno-rtti",
+ "-fno-exceptions",
+ });
+
+ if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) {
+ try args.append("-fno-emulated-tls");
+ }
+
+ if (target.isMinGW()) {
+ try args.append("-fms-extensions");
+ }
+}
+
+const tsan_sources = [_][]const u8{
+ "tsan_debugging.cpp",
+ "tsan_external.cpp",
+ "tsan_fd.cpp",
+ "tsan_flags.cpp",
+ "tsan_ignoreset.cpp",
+ "tsan_interceptors_memintrinsics.cpp",
+ "tsan_interceptors_posix.cpp",
+ "tsan_interface.cpp",
+ "tsan_interface_ann.cpp",
+ "tsan_interface_atomic.cpp",
+ "tsan_interface_java.cpp",
+ "tsan_malloc_mac.cpp",
+ "tsan_md5.cpp",
+ "tsan_mman.cpp",
+ "tsan_mutexset.cpp",
+ "tsan_new_delete.cpp",
+ "tsan_platform_windows.cpp",
+ "tsan_preinit.cpp",
+ "tsan_report.cpp",
+ "tsan_rtl.cpp",
+ "tsan_rtl_access.cpp",
+ "tsan_rtl_mutex.cpp",
+ "tsan_rtl_proc.cpp",
+ "tsan_rtl_report.cpp",
+ "tsan_rtl_thread.cpp",
+ "tsan_stack_trace.cpp",
+ "tsan_suppressions.cpp",
+ "tsan_symbolize.cpp",
+ "tsan_sync.cpp",
+ "tsan_vector_clock.cpp",
+};
+
+const darwin_tsan_sources = [_][]const u8{
+ "tsan_interceptors_mac.cpp",
+ "tsan_interceptors_mach_vm.cpp",
+ "tsan_platform_mac.cpp",
+ "tsan_platform_posix.cpp",
+};
+
+const unix_tsan_sources = [_][]const u8{
+ "tsan_platform_linux.cpp",
+ "tsan_platform_posix.cpp",
+};
+
+const windows_tsan_sources = [_][]const u8{
+ "tsan_platform_windows.cpp",
+};
+
+const sanitizer_common_sources = [_][]const u8{
+ "sanitizer_allocator.cpp",
+ "sanitizer_chained_origin_depot.cpp",
+ "sanitizer_common.cpp",
+ "sanitizer_deadlock_detector1.cpp",
+ "sanitizer_deadlock_detector2.cpp",
+ "sanitizer_errno.cpp",
+ "sanitizer_file.cpp",
+ "sanitizer_flag_parser.cpp",
+ "sanitizer_flags.cpp",
+ "sanitizer_fuchsia.cpp",
+ "sanitizer_libc.cpp",
+ "sanitizer_libignore.cpp",
+ "sanitizer_linux.cpp",
+ "sanitizer_linux_s390.cpp",
+ "sanitizer_mac.cpp",
+ "sanitizer_mutex.cpp",
+ "sanitizer_netbsd.cpp",
+ "sanitizer_platform_limits_freebsd.cpp",
+ "sanitizer_platform_limits_linux.cpp",
+ "sanitizer_platform_limits_netbsd.cpp",
+ "sanitizer_platform_limits_posix.cpp",
+ "sanitizer_platform_limits_solaris.cpp",
+ "sanitizer_posix.cpp",
+ "sanitizer_printf.cpp",
+ "sanitizer_procmaps_bsd.cpp",
+ "sanitizer_procmaps_common.cpp",
+ "sanitizer_procmaps_fuchsia.cpp",
+ "sanitizer_procmaps_linux.cpp",
+ "sanitizer_procmaps_mac.cpp",
+ "sanitizer_procmaps_solaris.cpp",
+ "sanitizer_range.cpp",
+ "sanitizer_solaris.cpp",
+ "sanitizer_stoptheworld_fuchsia.cpp",
+ "sanitizer_stoptheworld_mac.cpp",
+ "sanitizer_stoptheworld_win.cpp",
+ "sanitizer_suppressions.cpp",
+ "sanitizer_termination.cpp",
+ "sanitizer_thread_arg_retval.cpp",
+ "sanitizer_thread_registry.cpp",
+ "sanitizer_tls_get_addr.cpp",
+ "sanitizer_type_traits.cpp",
+ "sanitizer_win.cpp",
+ "sanitizer_win_interception.cpp",
+};
+
+const sanitizer_nolibc_sources = [_][]const u8{
+ "sanitizer_common_nolibc.cpp",
+};
+
+const sanitizer_libcdep_sources = [_][]const u8{
+ "sanitizer_common_libcdep.cpp",
+ "sanitizer_allocator_checks.cpp",
+ "sanitizer_dl.cpp",
+ "sanitizer_linux_libcdep.cpp",
+ "sanitizer_mac_libcdep.cpp",
+ "sanitizer_posix_libcdep.cpp",
+ "sanitizer_stoptheworld_linux_libcdep.cpp",
+ "sanitizer_stoptheworld_netbsd_libcdep.cpp",
+};
+
+const sanitizer_symbolizer_sources = [_][]const u8{
+ "sanitizer_allocator_report.cpp",
+ "sanitizer_stack_store.cpp",
+ "sanitizer_stackdepot.cpp",
+ "sanitizer_stacktrace.cpp",
+ "sanitizer_stacktrace_libcdep.cpp",
+ "sanitizer_stacktrace_printer.cpp",
+ "sanitizer_stacktrace_sparc.cpp",
+ "sanitizer_symbolizer.cpp",
+ "sanitizer_symbolizer_libbacktrace.cpp",
+ "sanitizer_symbolizer_libcdep.cpp",
+ "sanitizer_symbolizer_mac.cpp",
+ "sanitizer_symbolizer_markup.cpp",
+ "sanitizer_symbolizer_markup_fuchsia.cpp",
+ "sanitizer_symbolizer_posix_libcdep.cpp",
+ "sanitizer_symbolizer_report.cpp",
+ "sanitizer_symbolizer_report_fuchsia.cpp",
+ "sanitizer_symbolizer_win.cpp",
+ "sanitizer_thread_history.cpp",
+ "sanitizer_unwind_linux_libcdep.cpp",
+ "sanitizer_unwind_fuchsia.cpp",
+ "sanitizer_unwind_win.cpp",
+};
+
+const interception_sources = [_][]const u8{
+ "interception_linux.cpp",
+ "interception_mac.cpp",
+ "interception_win.cpp",
+ "interception_type_test.cpp",
+};
diff --git a/src/libs/libunwind.zig b/src/libs/libunwind.zig
new file mode 100644
index 0000000000..c453aca42c
--- /dev/null
+++ b/src/libs/libunwind.zig
@@ -0,0 +1,220 @@
+const std = @import("std");
+const path = std.fs.path;
+const assert = std.debug.assert;
+
+const target_util = @import("../target.zig");
+const Compilation = @import("../Compilation.zig");
+const Module = @import("../Package/Module.zig");
+const build_options = @import("build_options");
+const trace = @import("../tracy.zig").trace;
+
+pub const BuildError = error{
+ OutOfMemory,
+ SubCompilationFailed,
+ ZigCompilerNotBuiltWithLLVMExtensions,
+};
+
+pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const tracy = trace(@src());
+ defer tracy.end();
+
+ var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const output_mode = .Lib;
+ const target = comp.root_mod.resolved_target.result;
+ const unwind_tables: std.builtin.UnwindTables =
+ if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
+ const config = Compilation.Config.resolve(.{
+ .output_mode = .Lib,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = comp.compilerRtOptMode(),
+ .root_strip = comp.compilerRtStrip(),
+ .link_libc = true,
+ .any_unwind_tables = unwind_tables != .none,
+ .lto = comp.config.lto,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: resolving configuration failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ const root_mod = Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = comp.compilerRtStrip(),
+ .stack_check = false,
+ .stack_protector = 0,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
+ .valgrind = false,
+ .sanitize_c = .off,
+ .sanitize_thread = false,
+ // necessary so that libunwind can unwind through its own stack frames
+ // The old 32-bit x86 variant of SEH doesn't use tables.
+ .unwind_tables = unwind_tables,
+ .pic = if (target_util.supports_fpic(target)) true else null,
+ .optimize_mode = comp.compilerRtOptMode(),
+ .code_model = comp.root_mod.code_model,
+ },
+ .global = config,
+ .cc_argv = &.{},
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: creating module failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+
+ const root_name = "unwind";
+ const link_mode = .static;
+ const basename = try std.zig.binNameAlloc(arena, .{
+ .root_name = root_name,
+ .target = target,
+ .output_mode = output_mode,
+ .link_mode = link_mode,
+ });
+ const emit_bin = Compilation.EmitLoc{
+ .directory = null, // Put it in the cache directory.
+ .basename = basename,
+ };
+ var c_source_files: [unwind_src_list.len]Compilation.CSourceFile = undefined;
+ for (unwind_src_list, 0..) |unwind_src, i| {
+ var cflags = std.ArrayList([]const u8).init(arena);
+
+ switch (Compilation.classifyFileExt(unwind_src)) {
+ .c => {
+ try cflags.appendSlice(&.{
+ "-std=c99",
+ "-fexceptions",
+ });
+ },
+ .cpp => {
+ try cflags.append("-fno-exceptions");
+ try cflags.append("-fno-rtti");
+ },
+ .assembly_with_cpp => {},
+ else => unreachable, // See `unwind_src_list`.
+ }
+ try cflags.append("-I");
+ try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));
+ try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");
+ try cflags.append("-Wa,--noexecstack");
+ try cflags.append("-fvisibility=hidden");
+ try cflags.append("-fvisibility-inlines-hidden");
+ try cflags.append("-fvisibility-global-new-delete=force-hidden");
+
+ // This is intentionally always defined because the macro definition means, should it only
+ // build for the target specified by compiler defines. Since we pass -target the compiler
+ // defines will be correct.
+ try cflags.append("-D_LIBUNWIND_IS_NATIVE_ONLY");
+
+ if (comp.root_mod.optimize_mode == .Debug) {
+ try cflags.append("-D_DEBUG");
+ }
+ if (!comp.config.any_non_single_threaded) {
+ try cflags.append("-D_LIBUNWIND_HAS_NO_THREADS");
+ }
+ if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
+ try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
+ }
+ try cflags.append("-Wno-bitwise-conditional-parentheses");
+ try cflags.append("-Wno-visibility");
+ try cflags.append("-Wno-incompatible-pointer-types");
+
+ if (target.os.tag == .windows) {
+ try cflags.append("-Wno-dll-attribute-on-redeclaration");
+ }
+
+ c_source_files[i] = .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{unwind_src}),
+ .extra_flags = cflags.items,
+ .owner = root_mod,
+ };
+ }
+ const sub_compilation = Compilation.create(comp.gpa, arena, .{
+ .self_exe_path = comp.self_exe_path,
+ .local_cache_directory = comp.global_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .config = config,
+ .root_mod = root_mod,
+ .cache_mode = .whole,
+ .root_name = root_name,
+ .main_mod = null,
+ .thread_pool = comp.thread_pool,
+ .libc_installation = comp.libc_installation,
+ .emit_bin = emit_bin,
+ .function_sections = comp.function_sections,
+ .c_source_files = &c_source_files,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_llvm_bc = comp.verbose_llvm_bc,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .skip_linker_dependencies = true,
+ }) catch |err| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: create compilation failed: {s}",
+ .{@errorName(err)},
+ );
+ return error.SubCompilationFailed;
+ };
+ defer sub_compilation.destroy();
+
+ comp.updateSubCompilation(sub_compilation, .libunwind, prog_node) catch |err| switch (err) {
+ error.SubCompilationFailed => return error.SubCompilationFailed,
+ else => |e| {
+ comp.setMiscFailure(
+ .libunwind,
+ "unable to build libunwind: compilation failed: {s}",
+ .{@errorName(e)},
+ );
+ return error.SubCompilationFailed;
+ },
+ };
+
+ const crt_file = try sub_compilation.toCrtFile();
+ comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
+ assert(comp.libunwind_static_lib == null);
+ comp.libunwind_static_lib = crt_file;
+}
+
+const unwind_src_list = [_][]const u8{
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "libunwind.cpp",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-EHABI.cpp",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-seh.cpp",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1.c",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1-gcc-ext.c",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-sjlj.c",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-wasm.c",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersRestore.S",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersSave.S",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind_AIXExtras.cpp",
+ "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "gcc_personality_v0.c",
+};
diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig
new file mode 100644
index 0000000000..2049b0f6b7
--- /dev/null
+++ b/src/libs/mingw.zig
@@ -0,0 +1,1038 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const mem = std.mem;
+const path = std.fs.path;
+const assert = std.debug.assert;
+const log = std.log.scoped(.mingw);
+
+const builtin = @import("builtin");
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+const Cache = std.Build.Cache;
+const dev = @import("../dev.zig");
+
+pub const CrtFile = enum {
+ crt2_o,
+ dllcrt2_o,
+ libmingw32_lib,
+};
+
+/// TODO replace anyerror with explicit error set, recording user-friendly errors with
+/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
+pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+ var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+ const target = comp.getTarget();
+
+ // The old 32-bit x86 variant of SEH doesn't use tables.
+ const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .@"async" else .none;
+
+ switch (crt_file) {
+ .crt2_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCrtCcArgs(comp, arena, &args);
+ if (comp.mingw_unicode_entry_point) {
+ try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" });
+ }
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", "crt", "crtexe.c",
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files, .{
+ .unwind_tables = unwind_tables,
+ });
+ },
+
+ .dllcrt2_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCrtCcArgs(comp, arena, &args);
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", "crt", "crtdll.c",
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files, .{
+ .unwind_tables = unwind_tables,
+ });
+ },
+
+ .libmingw32_lib => {
+ var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
+
+ {
+ var crt_args = std.ArrayList([]const u8).init(arena);
+ try addCrtCcArgs(comp, arena, &crt_args);
+
+ for (mingw32_generic_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ if (target.cpu.arch.isX86()) {
+ for (mingw32_x86_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ if (target.cpu.arch == .x86) {
+ for (mingw32_x86_32_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ }
+ } else if (target.cpu.arch == .thumb) {
+ for (mingw32_arm_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ for (mingw32_arm32_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ } else if (target.cpu.arch == .aarch64) {
+ for (mingw32_arm_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ for (mingw32_arm64_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = crt_args.items,
+ .owner = undefined,
+ });
+ }
+ } else {
+ @panic("unsupported arch");
+ }
+ }
+
+ {
+ var winpthreads_args = std.ArrayList([]const u8).init(arena);
+ try addCcArgs(comp, arena, &winpthreads_args);
+ try winpthreads_args.appendSlice(&[_][]const u8{
+ "-DIN_WINPTHREAD",
+ "-DWIN32_LEAN_AND_MEAN",
+ });
+
+ switch (comp.compilerRtOptMode()) {
+ .Debug, .ReleaseSafe => try winpthreads_args.append("-DWINPTHREAD_DBG"),
+ .ReleaseFast, .ReleaseSmall => {},
+ }
+
+ for (mingw32_winpthreads_src) |dep| {
+ try c_source_files.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "mingw", dep,
+ }),
+ .extra_flags = winpthreads_args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ return comp.build_crt_file("libmingw32", .Lib, .@"mingw-w64 libmingw32.lib", prog_node, c_source_files.items, .{
+ .unwind_tables = unwind_tables,
+ // https://github.com/llvm/llvm-project/issues/43698#issuecomment-2542660611
+ .allow_lto = false,
+ });
+ },
+ }
+}
+
+fn addCcArgs(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+) error{OutOfMemory}!void {
+ try args.appendSlice(&[_][]const u8{
+ "-std=gnu11",
+ "-D__USE_MINGW_ANSI_STDIO=0",
+
+ "-isystem",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
+ });
+}
+
+fn addCrtCcArgs(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+) error{OutOfMemory}!void {
+ try addCcArgs(comp, arena, args);
+
+ if (comp.getTarget().cpu.arch == .thumb) {
+ try args.append("-mfpu=vfp");
+ }
+
+ try args.appendSlice(&[_][]const u8{
+ // According to Martin Storsjö,
+ // > the files under mingw-w64-crt are designed to always
+ // be built with __MSVCRT_VERSION__=0x700
+ "-D__MSVCRT_VERSION__=0x700",
+ "-D_CRTBLD",
+ "-D_SYSCRT=1",
+ "-D_WIN32_WINNT=0x0f00",
+ "-DCRTDLL=1",
+ "-DHAVE_CONFIG_H",
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "include" }),
+ });
+}
+
+pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
+ dev.check(.build_import_lib);
+
+ const gpa = comp.gpa;
+
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ const def_file_path = findDef(arena, comp.getTarget(), comp.zig_lib_directory, lib_name) catch |err| switch (err) {
+ error.FileNotFound => {
+ log.debug("no {s}.def file available to make a DLL import {s}.lib", .{ lib_name, lib_name });
+ // In this case we will end up putting foo.lib onto the linker line and letting the linker
+ // use its library paths to look for libraries and report any problems.
+ return;
+ },
+ else => |e| return e,
+ };
+
+ const target = comp.getTarget();
+
+ // Use the global cache directory.
+ var cache: Cache = .{
+ .gpa = gpa,
+ .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
+ };
+ cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
+ cache.addPrefix(comp.zig_lib_directory);
+ cache.addPrefix(comp.global_cache_directory);
+ defer cache.manifest_dir.close();
+
+ cache.hash.addBytes(build_options.version);
+ cache.hash.addOptionalBytes(comp.zig_lib_directory.path);
+ cache.hash.add(target.cpu.arch);
+
+ var man = cache.obtain();
+ defer man.deinit();
+
+ _ = try man.addFile(def_file_path, null);
+
+ const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name});
+ errdefer gpa.free(final_lib_basename);
+
+ if (try man.hit()) {
+ const digest = man.final();
+ const sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
+ errdefer gpa.free(sub_path);
+
+ comp.mutex.lock();
+ defer comp.mutex.unlock();
+ try comp.crt_files.ensureUnusedCapacity(gpa, 1);
+ comp.crt_files.putAssumeCapacityNoClobber(final_lib_basename, .{
+ .full_object_path = .{
+ .root_dir = comp.global_cache_directory,
+ .sub_path = sub_path,
+ },
+ .lock = man.toOwnedLock(),
+ });
+ return;
+ }
+
+ const digest = man.final();
+ const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
+ var o_dir = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{});
+ defer o_dir.close();
+
+ const final_def_basename = try std.fmt.allocPrint(arena, "{s}.def", .{lib_name});
+ const def_final_path = try comp.global_cache_directory.join(arena, &[_][]const u8{
+ "o", &digest, final_def_basename,
+ });
+
+ const target_defines = switch (target.cpu.arch) {
+ .thumb => "#define DEF_ARM32\n",
+ .aarch64 => "#define DEF_ARM64\n",
+ .x86 => "#define DEF_I386\n",
+ .x86_64 => "#define DEF_X64\n",
+ else => unreachable,
+ };
+
+ const aro = @import("aro");
+ var aro_comp = aro.Compilation.init(gpa, std.fs.cwd());
+ defer aro_comp.deinit();
+
+ const include_dir = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "def-include" });
+
+ if (comp.verbose_cc) print: {
+ std.debug.lockStdErr();
+ defer std.debug.unlockStdErr();
+ const stderr = std.io.getStdErr().writer();
+ nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print;
+ nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print;
+ nosuspend stderr.print("output path: {s}\n", .{def_final_path}) catch break :print;
+ }
+
+ try aro_comp.include_dirs.append(gpa, include_dir);
+
+ const builtin_macros = try aro_comp.generateBuiltinMacros(.include_system_defines);
+ const user_macros = try aro_comp.addSourceFromBuffer("<command line>", target_defines);
+ const def_file_source = try aro_comp.addSourceFromPath(def_file_path);
+
+ var pp = aro.Preprocessor.init(&aro_comp);
+ defer pp.deinit();
+ pp.linemarkers = .none;
+ pp.preserve_whitespace = true;
+
+ try pp.preprocessSources(&.{ def_file_source, builtin_macros, user_macros });
+
+ for (aro_comp.diagnostics.list.items) |diagnostic| {
+ if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") {
+ aro.Diagnostics.render(&aro_comp, std.io.tty.detectConfig(std.io.getStdErr()));
+ return error.AroPreprocessorFailed;
+ }
+ }
+
+ {
+ // new scope to ensure definition file is written before passing the path to WriteImportLibrary
+ const def_final_file = try o_dir.createFile(final_def_basename, .{ .truncate = true });
+ defer def_final_file.close();
+ try pp.prettyPrintTokens(def_final_file.writer(), .result_only);
+ }
+
+ const lib_final_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
+ errdefer gpa.free(lib_final_path);
+
+ if (!build_options.have_llvm) return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ const llvm_bindings = @import("../codegen/llvm/bindings.zig");
+ const def_final_path_z = try arena.dupeZ(u8, def_final_path);
+ const lib_final_path_z = try comp.global_cache_directory.joinZ(arena, &.{lib_final_path});
+ if (llvm_bindings.WriteImportLibrary(
+ def_final_path_z.ptr,
+ @intFromEnum(target.toCoffMachine()),
+ lib_final_path_z.ptr,
+ true,
+ )) {
+ // TODO surface a proper error here
+ log.err("unable to turn {s}.def into {s}.lib", .{ lib_name, lib_name });
+ return error.WritingImportLibFailed;
+ }
+
+ man.writeManifest() catch |err| {
+ log.warn("failed to write cache manifest for DLL import {s}.lib: {s}", .{ lib_name, @errorName(err) });
+ };
+
+ comp.mutex.lock();
+ defer comp.mutex.unlock();
+ try comp.crt_files.putNoClobber(gpa, final_lib_basename, .{
+ .full_object_path = .{
+ .root_dir = comp.global_cache_directory,
+ .sub_path = lib_final_path,
+ },
+ .lock = man.toOwnedLock(),
+ });
+}
+
+pub fn libExists(
+ allocator: Allocator,
+ target: std.Target,
+ zig_lib_directory: Cache.Directory,
+ lib_name: []const u8,
+) !bool {
+ const s = findDef(allocator, target, zig_lib_directory, lib_name) catch |err| switch (err) {
+ error.FileNotFound => return false,
+ else => |e| return e,
+ };
+ defer allocator.free(s);
+ return true;
+}
+
+/// This function body is verbose but all it does is test 3 different paths and
+/// see if a .def file exists.
+fn findDef(
+ allocator: Allocator,
+ target: std.Target,
+ zig_lib_directory: Cache.Directory,
+ lib_name: []const u8,
+) ![]u8 {
+ const lib_path = switch (target.cpu.arch) {
+ .thumb => "libarm32",
+ .aarch64 => "libarm64",
+ .x86 => "lib32",
+ .x86_64 => "lib64",
+ else => unreachable,
+ };
+
+ var override_path = std.ArrayList(u8).init(allocator);
+ defer override_path.deinit();
+
+ const s = path.sep_str;
+
+ {
+ // Try the archtecture-specific path first.
+ const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";
+ if (zig_lib_directory.path) |p| {
+ try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });
+ } else {
+ try override_path.writer().print(fmt_path, .{ lib_path, lib_name });
+ }
+ if (std.fs.cwd().access(override_path.items, .{})) |_| {
+ return override_path.toOwnedSlice();
+ } else |err| switch (err) {
+ error.FileNotFound => {},
+ else => |e| return e,
+ }
+ }
+
+ {
+ // Try the generic version.
+ override_path.shrinkRetainingCapacity(0);
+ const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def";
+ if (zig_lib_directory.path) |p| {
+ try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
+ } else {
+ try override_path.writer().print(fmt_path, .{lib_name});
+ }
+ if (std.fs.cwd().access(override_path.items, .{})) |_| {
+ return override_path.toOwnedSlice();
+ } else |err| switch (err) {
+ error.FileNotFound => {},
+ else => |e| return e,
+ }
+ }
+
+ {
+ // Try the generic version and preprocess it.
+ override_path.shrinkRetainingCapacity(0);
+ const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";
+ if (zig_lib_directory.path) |p| {
+ try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
+ } else {
+ try override_path.writer().print(fmt_path, .{lib_name});
+ }
+ if (std.fs.cwd().access(override_path.items, .{})) |_| {
+ return override_path.toOwnedSlice();
+ } else |err| switch (err) {
+ error.FileNotFound => {},
+ else => |e| return e,
+ }
+ }
+
+ return error.FileNotFound;
+}
+
+const mingw32_generic_src = [_][]const u8{
+ // mingw32
+ "crt" ++ path.sep_str ++ "crtexewin.c",
+ "crt" ++ path.sep_str ++ "dll_argv.c",
+ "crt" ++ path.sep_str ++ "gccmain.c",
+ "crt" ++ path.sep_str ++ "natstart.c",
+ "crt" ++ path.sep_str ++ "pseudo-reloc-list.c",
+ "crt" ++ path.sep_str ++ "wildcard.c",
+ "crt" ++ path.sep_str ++ "charmax.c",
+ "crt" ++ path.sep_str ++ "ucrtexewin.c",
+ "crt" ++ path.sep_str ++ "dllargv.c",
+ "crt" ++ path.sep_str ++ "_newmode.c",
+ "crt" ++ path.sep_str ++ "tlssup.c",
+ "crt" ++ path.sep_str ++ "xncommod.c",
+ "crt" ++ path.sep_str ++ "cinitexe.c",
+ "crt" ++ path.sep_str ++ "merr.c",
+ "crt" ++ path.sep_str ++ "usermatherr.c",
+ "crt" ++ path.sep_str ++ "pesect.c",
+ "crt" ++ path.sep_str ++ "udllargc.c",
+ "crt" ++ path.sep_str ++ "xthdloc.c",
+ "crt" ++ path.sep_str ++ "CRT_fp10.c",
+ "crt" ++ path.sep_str ++ "mingw_helpers.c",
+ "crt" ++ path.sep_str ++ "pseudo-reloc.c",
+ "crt" ++ path.sep_str ++ "udll_argv.c",
+ "crt" ++ path.sep_str ++ "xtxtmode.c",
+ "crt" ++ path.sep_str ++ "crt_handler.c",
+ "crt" ++ path.sep_str ++ "tlsthrd.c",
+ "crt" ++ path.sep_str ++ "tlsmthread.c",
+ "crt" ++ path.sep_str ++ "tlsmcrt.c",
+ "crt" ++ path.sep_str ++ "cxa_atexit.c",
+ "crt" ++ path.sep_str ++ "cxa_thread_atexit.c",
+ "crt" ++ path.sep_str ++ "tls_atexit.c",
+ "intrincs" ++ path.sep_str ++ "RtlSecureZeroMemory.c",
+ // mingwex
+ "cfguard" ++ path.sep_str ++ "mingw_cfguard_support.c",
+ "complex" ++ path.sep_str ++ "_cabs.c",
+ "complex" ++ path.sep_str ++ "cabs.c",
+ "complex" ++ path.sep_str ++ "cabsf.c",
+ "complex" ++ path.sep_str ++ "cabsl.c",
+ "complex" ++ path.sep_str ++ "cacos.c",
+ "complex" ++ path.sep_str ++ "cacosf.c",
+ "complex" ++ path.sep_str ++ "cacosl.c",
+ "complex" ++ path.sep_str ++ "carg.c",
+ "complex" ++ path.sep_str ++ "cargf.c",
+ "complex" ++ path.sep_str ++ "cargl.c",
+ "complex" ++ path.sep_str ++ "casin.c",
+ "complex" ++ path.sep_str ++ "casinf.c",
+ "complex" ++ path.sep_str ++ "casinl.c",
+ "complex" ++ path.sep_str ++ "catan.c",
+ "complex" ++ path.sep_str ++ "catanf.c",
+ "complex" ++ path.sep_str ++ "catanl.c",
+ "complex" ++ path.sep_str ++ "ccos.c",
+ "complex" ++ path.sep_str ++ "ccosf.c",
+ "complex" ++ path.sep_str ++ "ccosl.c",
+ "complex" ++ path.sep_str ++ "cexp.c",
+ "complex" ++ path.sep_str ++ "cexpf.c",
+ "complex" ++ path.sep_str ++ "cexpl.c",
+ "complex" ++ path.sep_str ++ "cimag.c",
+ "complex" ++ path.sep_str ++ "cimagf.c",
+ "complex" ++ path.sep_str ++ "cimagl.c",
+ "complex" ++ path.sep_str ++ "clog.c",
+ "complex" ++ path.sep_str ++ "clog10.c",
+ "complex" ++ path.sep_str ++ "clog10f.c",
+ "complex" ++ path.sep_str ++ "clog10l.c",
+ "complex" ++ path.sep_str ++ "clogf.c",
+ "complex" ++ path.sep_str ++ "clogl.c",
+ "complex" ++ path.sep_str ++ "conj.c",
+ "complex" ++ path.sep_str ++ "conjf.c",
+ "complex" ++ path.sep_str ++ "conjl.c",
+ "complex" ++ path.sep_str ++ "cpow.c",
+ "complex" ++ path.sep_str ++ "cpowf.c",
+ "complex" ++ path.sep_str ++ "cpowl.c",
+ "complex" ++ path.sep_str ++ "cproj.c",
+ "complex" ++ path.sep_str ++ "cprojf.c",
+ "complex" ++ path.sep_str ++ "cprojl.c",
+ "complex" ++ path.sep_str ++ "creal.c",
+ "complex" ++ path.sep_str ++ "crealf.c",
+ "complex" ++ path.sep_str ++ "creall.c",
+ "complex" ++ path.sep_str ++ "csin.c",
+ "complex" ++ path.sep_str ++ "csinf.c",
+ "complex" ++ path.sep_str ++ "csinl.c",
+ "complex" ++ path.sep_str ++ "csqrt.c",
+ "complex" ++ path.sep_str ++ "csqrtf.c",
+ "complex" ++ path.sep_str ++ "csqrtl.c",
+ "complex" ++ path.sep_str ++ "ctan.c",
+ "complex" ++ path.sep_str ++ "ctanf.c",
+ "complex" ++ path.sep_str ++ "ctanl.c",
+ "gdtoa" ++ path.sep_str ++ "arithchk.c",
+ "gdtoa" ++ path.sep_str ++ "dmisc.c",
+ "gdtoa" ++ path.sep_str ++ "dtoa.c",
+ "gdtoa" ++ path.sep_str ++ "g__fmt.c",
+ "gdtoa" ++ path.sep_str ++ "g_dfmt.c",
+ "gdtoa" ++ path.sep_str ++ "g_ffmt.c",
+ "gdtoa" ++ path.sep_str ++ "g_xfmt.c",
+ "gdtoa" ++ path.sep_str ++ "gdtoa.c",
+ "gdtoa" ++ path.sep_str ++ "gethex.c",
+ "gdtoa" ++ path.sep_str ++ "gmisc.c",
+ "gdtoa" ++ path.sep_str ++ "hd_init.c",
+ "gdtoa" ++ path.sep_str ++ "hexnan.c",
+ "gdtoa" ++ path.sep_str ++ "misc.c",
+ "gdtoa" ++ path.sep_str ++ "qnan.c",
+ "gdtoa" ++ path.sep_str ++ "smisc.c",
+ "gdtoa" ++ path.sep_str ++ "strtodg.c",
+ "gdtoa" ++ path.sep_str ++ "strtodnrp.c",
+ "gdtoa" ++ path.sep_str ++ "strtof.c",
+ "gdtoa" ++ path.sep_str ++ "strtopx.c",
+ "gdtoa" ++ path.sep_str ++ "sum.c",
+ "gdtoa" ++ path.sep_str ++ "ulp.c",
+ "math" ++ path.sep_str ++ "coshl.c",
+ "math" ++ path.sep_str ++ "fabsl.c",
+ "math" ++ path.sep_str ++ "fp_consts.c",
+ "math" ++ path.sep_str ++ "fp_constsf.c",
+ "math" ++ path.sep_str ++ "fp_constsl.c",
+ "math" ++ path.sep_str ++ "fpclassify.c",
+ "math" ++ path.sep_str ++ "fpclassifyf.c",
+ "math" ++ path.sep_str ++ "fpclassifyl.c",
+ "math" ++ path.sep_str ++ "frexpf.c",
+ "math" ++ path.sep_str ++ "frexpl.c",
+ "math" ++ path.sep_str ++ "hypotf.c",
+ "math" ++ path.sep_str ++ "hypotl.c",
+ "math" ++ path.sep_str ++ "isnan.c",
+ "math" ++ path.sep_str ++ "isnanf.c",
+ "math" ++ path.sep_str ++ "isnanl.c",
+ "math" ++ path.sep_str ++ "ldexpf.c",
+ "math" ++ path.sep_str ++ "lgamma.c",
+ "math" ++ path.sep_str ++ "lgammaf.c",
+ "math" ++ path.sep_str ++ "lgammal.c",
+ "math" ++ path.sep_str ++ "modfl.c",
+ "math" ++ path.sep_str ++ "powi.c",
+ "math" ++ path.sep_str ++ "powif.c",
+ "math" ++ path.sep_str ++ "powil.c",
+ "math" ++ path.sep_str ++ "signbit.c",
+ "math" ++ path.sep_str ++ "signbitf.c",
+ "math" ++ path.sep_str ++ "signbitl.c",
+ "math" ++ path.sep_str ++ "signgam.c",
+ "math" ++ path.sep_str ++ "sinhl.c",
+ "math" ++ path.sep_str ++ "sqrtl.c",
+ "math" ++ path.sep_str ++ "tanhl.c",
+ "misc" ++ path.sep_str ++ "alarm.c",
+ "misc" ++ path.sep_str ++ "btowc.c",
+ "misc" ++ path.sep_str ++ "delay-f.c",
+ "misc" ++ path.sep_str ++ "delay-n.c",
+ "misc" ++ path.sep_str ++ "delayimp.c",
+ "misc" ++ path.sep_str ++ "dirent.c",
+ "misc" ++ path.sep_str ++ "dirname.c",
+ "misc" ++ path.sep_str ++ "dllentrypoint.c",
+ "misc" ++ path.sep_str ++ "dllmain.c",
+ "misc" ++ path.sep_str ++ "feclearexcept.c",
+ "misc" ++ path.sep_str ++ "fegetenv.c",
+ "misc" ++ path.sep_str ++ "fegetexceptflag.c",
+ "misc" ++ path.sep_str ++ "fegetround.c",
+ "misc" ++ path.sep_str ++ "feholdexcept.c",
+ "misc" ++ path.sep_str ++ "feraiseexcept.c",
+ "misc" ++ path.sep_str ++ "fesetenv.c",
+ "misc" ++ path.sep_str ++ "fesetexceptflag.c",
+ "misc" ++ path.sep_str ++ "fesetround.c",
+ "misc" ++ path.sep_str ++ "fetestexcept.c",
+ "misc" ++ path.sep_str ++ "feupdateenv.c",
+ "misc" ++ path.sep_str ++ "ftruncate.c",
+ "misc" ++ path.sep_str ++ "ftw.c",
+ "misc" ++ path.sep_str ++ "ftw64.c",
+ "misc" ++ path.sep_str ++ "fwide.c",
+ "misc" ++ path.sep_str ++ "getlogin.c",
+ "misc" ++ path.sep_str ++ "getopt.c",
+ "misc" ++ path.sep_str ++ "gettimeofday.c",
+ "misc" ++ path.sep_str ++ "mempcpy.c",
+ "misc" ++ path.sep_str ++ "mingw-access.c",
+ "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c",
+ "misc" ++ path.sep_str ++ "mingw_getsp.S",
+ "misc" ++ path.sep_str ++ "mingw_longjmp.S",
+ "misc" ++ path.sep_str ++ "mingw_matherr.c",
+ "misc" ++ path.sep_str ++ "mingw_mbwc_convert.c",
+ "misc" ++ path.sep_str ++ "mingw_usleep.c",
+ "misc" ++ path.sep_str ++ "mingw_wcstod.c",
+ "misc" ++ path.sep_str ++ "mingw_wcstof.c",
+ "misc" ++ path.sep_str ++ "mingw_wcstold.c",
+ "misc" ++ path.sep_str ++ "mkstemp.c",
+ "misc" ++ path.sep_str ++ "sleep.c",
+ "misc" ++ path.sep_str ++ "strnlen.c",
+ "misc" ++ path.sep_str ++ "strsafe.c",
+ "misc" ++ path.sep_str ++ "tdelete.c",
+ "misc" ++ path.sep_str ++ "tdestroy.c",
+ "misc" ++ path.sep_str ++ "tfind.c",
+ "misc" ++ path.sep_str ++ "tsearch.c",
+ "misc" ++ path.sep_str ++ "twalk.c",
+ "misc" ++ path.sep_str ++ "wcsnlen.c",
+ "misc" ++ path.sep_str ++ "wcstof.c",
+ "misc" ++ path.sep_str ++ "wcstoimax.c",
+ "misc" ++ path.sep_str ++ "wcstold.c",
+ "misc" ++ path.sep_str ++ "wcstoumax.c",
+ "misc" ++ path.sep_str ++ "wctob.c",
+ "misc" ++ path.sep_str ++ "wdirent.c",
+ "misc" ++ path.sep_str ++ "winbs_uint64.c",
+ "misc" ++ path.sep_str ++ "winbs_ulong.c",
+ "misc" ++ path.sep_str ++ "winbs_ushort.c",
+ "misc" ++ path.sep_str ++ "wmemchr.c",
+ "misc" ++ path.sep_str ++ "wmemcmp.c",
+ "misc" ++ path.sep_str ++ "wmemcpy.c",
+ "misc" ++ path.sep_str ++ "wmemmove.c",
+ "misc" ++ path.sep_str ++ "wmempcpy.c",
+ "misc" ++ path.sep_str ++ "wmemset.c",
+ "stdio" ++ path.sep_str ++ "_Exit.c",
+ "stdio" ++ path.sep_str ++ "_findfirst64i32.c",
+ "stdio" ++ path.sep_str ++ "_findnext64i32.c",
+ "stdio" ++ path.sep_str ++ "_fstat64i32.c",
+ "stdio" ++ path.sep_str ++ "_stat.c",
+ "stdio" ++ path.sep_str ++ "_stat64i32.c",
+ "stdio" ++ path.sep_str ++ "_wfindfirst64i32.c",
+ "stdio" ++ path.sep_str ++ "_wfindnext64i32.c",
+ "stdio" ++ path.sep_str ++ "_wstat.c",
+ "stdio" ++ path.sep_str ++ "_wstat64i32.c",
+ "stdio" ++ path.sep_str ++ "asprintf.c",
+ "stdio" ++ path.sep_str ++ "fopen64.c",
+ "stdio" ++ path.sep_str ++ "fseeko32.c",
+ "stdio" ++ path.sep_str ++ "fseeko64.c",
+ "stdio" ++ path.sep_str ++ "ftello.c",
+ "stdio" ++ path.sep_str ++ "ftello64.c",
+ "stdio" ++ path.sep_str ++ "ftruncate64.c",
+ "stdio" ++ path.sep_str ++ "lltoa.c",
+ "stdio" ++ path.sep_str ++ "lltow.c",
+ "stdio" ++ path.sep_str ++ "lseek64.c",
+ "stdio" ++ path.sep_str ++ "mingw_asprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_fprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_fwprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_fscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_fwscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_pformat.c",
+ "stdio" ++ path.sep_str ++ "mingw_sformat.c",
+ "stdio" ++ path.sep_str ++ "mingw_swformat.c",
+ "stdio" ++ path.sep_str ++ "mingw_wpformat.c",
+ "stdio" ++ path.sep_str ++ "mingw_printf.c",
+ "stdio" ++ path.sep_str ++ "mingw_wprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_scanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_snprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_snwprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_sprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_swprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_sscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_swscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vasprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vfprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vfwprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vfscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vsscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vwprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vsnprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vsnwprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vsprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vswprintf.c",
+ "stdio" ++ path.sep_str ++ "mingw_wscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vfwscanf.c",
+ "stdio" ++ path.sep_str ++ "mingw_vswscanf.c",
+ "stdio" ++ path.sep_str ++ "snprintf.c",
+ "stdio" ++ path.sep_str ++ "snwprintf.c",
+ "stdio" ++ path.sep_str ++ "strtok_r.c",
+ "stdio" ++ path.sep_str ++ "truncate.c",
+ "stdio" ++ path.sep_str ++ "ulltoa.c",
+ "stdio" ++ path.sep_str ++ "ulltow.c",
+ "stdio" ++ path.sep_str ++ "vasprintf.c",
+ "stdio" ++ path.sep_str ++ "vsnprintf.c",
+ "stdio" ++ path.sep_str ++ "vsnwprintf.c",
+ "stdio" ++ path.sep_str ++ "wtoll.c",
+ // mingwthrd
+ "libsrc" ++ path.sep_str ++ "mingwthrd_mt.c",
+ // ucrtbase
+ "math" ++ path.sep_str ++ "_huge.c",
+ "misc" ++ path.sep_str ++ "__initenv.c",
+ "misc" ++ path.sep_str ++ "__winitenv.c",
+ "misc" ++ path.sep_str ++ "__p___initenv.c",
+ "misc" ++ path.sep_str ++ "__p___winitenv.c",
+ "misc" ++ path.sep_str ++ "_onexit.c",
+ "misc" ++ path.sep_str ++ "ucrt-access.c",
+ "misc" ++ path.sep_str ++ "ucrt__getmainargs.c",
+ "misc" ++ path.sep_str ++ "ucrt__wgetmainargs.c",
+ "misc" ++ path.sep_str ++ "ucrt_amsg_exit.c",
+ "misc" ++ path.sep_str ++ "ucrt_at_quick_exit.c",
+ "misc" ++ path.sep_str ++ "ucrt_tzset.c",
+ "stdio" ++ path.sep_str ++ "ucrt__scprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__snprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__snscanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__snwprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_fprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_fscanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_ms_fprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_ms_fwprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_printf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_scanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_snprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_sprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_sscanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vscanf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c",
+ "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c",
+ "string" ++ path.sep_str ++ "ucrt__wcstok.c",
+ // uuid
+ "libsrc" ++ path.sep_str ++ "ativscp-uuid.c",
+ "libsrc" ++ path.sep_str ++ "atsmedia-uuid.c",
+ "libsrc" ++ path.sep_str ++ "bth-uuid.c",
+ "libsrc" ++ path.sep_str ++ "cguid-uuid.c",
+ "libsrc" ++ path.sep_str ++ "comcat-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ctxtcall-uuid.c",
+ "libsrc" ++ path.sep_str ++ "devguid.c",
+ "libsrc" ++ path.sep_str ++ "docobj-uuid.c",
+ "libsrc" ++ path.sep_str ++ "dxva-uuid.c",
+ "libsrc" ++ path.sep_str ++ "exdisp-uuid.c",
+ "libsrc" ++ path.sep_str ++ "extras-uuid.c",
+ "libsrc" ++ path.sep_str ++ "fwp-uuid.c",
+ "libsrc" ++ path.sep_str ++ "guid_nul.c",
+ "libsrc" ++ path.sep_str ++ "hlguids-uuid.c",
+ "libsrc" ++ path.sep_str ++ "hlink-uuid.c",
+ "libsrc" ++ path.sep_str ++ "mlang-uuid.c",
+ "libsrc" ++ path.sep_str ++ "msctf-uuid.c",
+ "libsrc" ++ path.sep_str ++ "mshtmhst-uuid.c",
+ "libsrc" ++ path.sep_str ++ "mshtml-uuid.c",
+ "libsrc" ++ path.sep_str ++ "msxml-uuid.c",
+ "libsrc" ++ path.sep_str ++ "netcfg-uuid.c",
+ "libsrc" ++ path.sep_str ++ "netcon-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddkbd-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddmou-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddpar-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddscsi-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddser-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddstor-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ntddvdeo-uuid.c",
+ "libsrc" ++ path.sep_str ++ "oaidl-uuid.c",
+ "libsrc" ++ path.sep_str ++ "objidl-uuid.c",
+ "libsrc" ++ path.sep_str ++ "objsafe-uuid.c",
+ "libsrc" ++ path.sep_str ++ "ocidl-uuid.c",
+ "libsrc" ++ path.sep_str ++ "oleacc-uuid.c",
+ "libsrc" ++ path.sep_str ++ "olectlid-uuid.c",
+ "libsrc" ++ path.sep_str ++ "oleidl-uuid.c",
+ "libsrc" ++ path.sep_str ++ "power-uuid.c",
+ "libsrc" ++ path.sep_str ++ "powrprof-uuid.c",
+ "libsrc" ++ path.sep_str ++ "uianimation-uuid.c",
+ "libsrc" ++ path.sep_str ++ "usbcamdi-uuid.c",
+ "libsrc" ++ path.sep_str ++ "usbiodef-uuid.c",
+ "libsrc" ++ path.sep_str ++ "uuid.c",
+ "libsrc" ++ path.sep_str ++ "vds-uuid.c",
+ "libsrc" ++ path.sep_str ++ "virtdisk-uuid.c",
+ "libsrc" ++ path.sep_str ++ "vss-uuid.c",
+ "libsrc" ++ path.sep_str ++ "wia-uuid.c",
+ "libsrc" ++ path.sep_str ++ "windowscodecs.c",
+ // ws2_32
+ "libsrc" ++ path.sep_str ++ "ws2_32.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_addr_equal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isany.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isloopback.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setany.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setloopback.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_linklocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_loopback.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_global.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_linklocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_nodelocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_orglocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_sitelocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_multicast.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_sitelocal.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_unspecified.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4compat.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4mapped.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_loopback.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_unspecified.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorA.c",
+ "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorW.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiStrdup.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiParseV4Address.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiNewAddrInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiQueryDNS.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLookupNode.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiClone.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyFreeAddrInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetAddrInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetNameInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLoad.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetAddrInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetNameInfo.c",
+ "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiFreeAddrInfo.c",
+ // dinput
+ "libsrc" ++ path.sep_str ++ "dinput_kbd.c",
+ "libsrc" ++ path.sep_str ++ "dinput_joy.c",
+ "libsrc" ++ path.sep_str ++ "dinput_joy2.c",
+ "libsrc" ++ path.sep_str ++ "dinput_mouse.c",
+ "libsrc" ++ path.sep_str ++ "dinput_mouse2.c",
+ // dloadhelper
+ "libsrc" ++ path.sep_str ++ "dloadhelper.c",
+ "misc" ++ path.sep_str ++ "delay-f.c",
+ // misc.
+ "libsrc" ++ path.sep_str ++ "bits.c",
+ "libsrc" ++ path.sep_str ++ "shell32.c",
+ "libsrc" ++ path.sep_str ++ "dmoguids.c",
+ "libsrc" ++ path.sep_str ++ "dxerr8.c",
+ "libsrc" ++ path.sep_str ++ "dxerr8w.c",
+ "libsrc" ++ path.sep_str ++ "dxerr9.c",
+ "libsrc" ++ path.sep_str ++ "dxerr9w.c",
+ "libsrc" ++ path.sep_str ++ "mfuuid.c",
+ "libsrc" ++ path.sep_str ++ "msxml2.c",
+ "libsrc" ++ path.sep_str ++ "msxml6.c",
+ "libsrc" ++ path.sep_str ++ "amstrmid.c",
+ "libsrc" ++ path.sep_str ++ "wbemuuid.c",
+ "libsrc" ++ path.sep_str ++ "wmcodecdspuuid.c",
+ "libsrc" ++ path.sep_str ++ "windowscodecs.c",
+ "libsrc" ++ path.sep_str ++ "dxguid.c",
+ "libsrc" ++ path.sep_str ++ "ksuser.c",
+ "libsrc" ++ path.sep_str ++ "largeint.c",
+ "libsrc" ++ path.sep_str ++ "locationapi.c",
+ "libsrc" ++ path.sep_str ++ "sapi.c",
+ "libsrc" ++ path.sep_str ++ "sensorsapi.c",
+ "libsrc" ++ path.sep_str ++ "portabledeviceguids.c",
+ "libsrc" ++ path.sep_str ++ "taskschd.c",
+ "libsrc" ++ path.sep_str ++ "scrnsave.c",
+ "libsrc" ++ path.sep_str ++ "strmiids.c",
+ "libsrc" ++ path.sep_str ++ "gdiplus.c",
+ "libsrc" ++ path.sep_str ++ "activeds-uuid.c",
+};
+
+const mingw32_x86_src = [_][]const u8{
+ // mingwex
+ "math" ++ path.sep_str ++ "cbrtl.c",
+ "math" ++ path.sep_str ++ "erfl.c",
+ "math" ++ path.sep_str ++ "fdiml.c",
+ "math" ++ path.sep_str ++ "fmal.c",
+ "math" ++ path.sep_str ++ "fmaxl.c",
+ "math" ++ path.sep_str ++ "fminl.c",
+ "math" ++ path.sep_str ++ "llrintl.c",
+ "math" ++ path.sep_str ++ "llroundl.c",
+ "math" ++ path.sep_str ++ "lrintl.c",
+ "math" ++ path.sep_str ++ "lroundl.c",
+ "math" ++ path.sep_str ++ "rintl.c",
+ "math" ++ path.sep_str ++ "roundl.c",
+ "math" ++ path.sep_str ++ "tgammal.c",
+ "math" ++ path.sep_str ++ "truncl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "_chgsignl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acoshl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinhl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceill.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossin.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expm1l.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fucom.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ilogbl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "internal_logl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexp.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexpl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log10l.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log1pl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log2l.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logbl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "nearbyintl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "powl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remainderl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remquol.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbn.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnf.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnl.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl_internal.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanl.S",
+ // ucrtbase
+ "math" ++ path.sep_str ++ "fabsf.c",
+ "math" ++ path.sep_str ++ "nextafterl.c",
+ "math" ++ path.sep_str ++ "nexttoward.c",
+ "math" ++ path.sep_str ++ "nexttowardf.c",
+};
+
+const mingw32_x86_32_src = [_][]const u8{
+ // ucrtbase
+ "math" ++ path.sep_str ++ "coshf.c",
+ "math" ++ path.sep_str ++ "expf.c",
+ "math" ++ path.sep_str ++ "log10f.c",
+ "math" ++ path.sep_str ++ "logf.c",
+ "math" ++ path.sep_str ++ "modff.c",
+ "math" ++ path.sep_str ++ "powf.c",
+ "math" ++ path.sep_str ++ "sinhf.c",
+ "math" ++ path.sep_str ++ "sqrtf.c",
+ "math" ++ path.sep_str ++ "tanhf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorf.S",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinf.c",
+ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanf.c",
+};
+
+const mingw32_arm_src = [_][]const u8{
+ // mingwex
+ "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c",
+};
+
+const mingw32_arm32_src = [_][]const u8{
+ // mingwex
+ "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S",
+ "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c",
+ "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c",
+ "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S",
+ "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincosf.S",
+};
+
+const mingw32_arm64_src = [_][]const u8{
+ // mingwex
+ "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S",
+ "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c",
+ "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c",
+ "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S",
+ "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincosf.S",
+};
+
+const mingw32_winpthreads_src = [_][]const u8{
+ // winpthreads
+ "winpthreads" ++ path.sep_str ++ "barrier.c",
+ "winpthreads" ++ path.sep_str ++ "clock.c",
+ "winpthreads" ++ path.sep_str ++ "cond.c",
+ "winpthreads" ++ path.sep_str ++ "misc.c",
+ "winpthreads" ++ path.sep_str ++ "mutex.c",
+ "winpthreads" ++ path.sep_str ++ "nanosleep.c",
+ "winpthreads" ++ path.sep_str ++ "ref.c",
+ "winpthreads" ++ path.sep_str ++ "rwlock.c",
+ "winpthreads" ++ path.sep_str ++ "sched.c",
+ "winpthreads" ++ path.sep_str ++ "sem.c",
+ "winpthreads" ++ path.sep_str ++ "spinlock.c",
+ "winpthreads" ++ path.sep_str ++ "thread.c",
+};
+
+pub const always_link_libs = [_][]const u8{
+ "api-ms-win-crt-conio-l1-1-0",
+ "api-ms-win-crt-convert-l1-1-0",
+ "api-ms-win-crt-environment-l1-1-0",
+ "api-ms-win-crt-filesystem-l1-1-0",
+ "api-ms-win-crt-heap-l1-1-0",
+ "api-ms-win-crt-locale-l1-1-0",
+ "api-ms-win-crt-math-l1-1-0",
+ "api-ms-win-crt-multibyte-l1-1-0",
+ "api-ms-win-crt-private-l1-1-0",
+ "api-ms-win-crt-process-l1-1-0",
+ "api-ms-win-crt-runtime-l1-1-0",
+ "api-ms-win-crt-stdio-l1-1-0",
+ "api-ms-win-crt-string-l1-1-0",
+ "api-ms-win-crt-time-l1-1-0",
+ "api-ms-win-crt-utility-l1-1-0",
+ "advapi32",
+ "kernel32",
+ "ntdll",
+ "shell32",
+ "user32",
+};
diff --git a/src/libs/musl.zig b/src/libs/musl.zig
new file mode 100644
index 0000000000..bc89e20c21
--- /dev/null
+++ b/src/libs/musl.zig
@@ -0,0 +1,2313 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+const mem = std.mem;
+const path = std.fs.path;
+const assert = std.debug.assert;
+const Module = @import("../Package/Module.zig");
+
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+
+pub const CrtFile = enum {
+ crt1_o,
+ rcrt1_o,
+ scrt1_o,
+ libc_a,
+ libc_so,
+};
+
+/// TODO replace anyerror with explicit error set, recording user-friendly errors with
+/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
+pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+ const gpa = comp.gpa;
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ switch (in_crt_file) {
+ .crt1_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCcArgs(comp, arena, &args, false);
+ try args.append("-DCRT");
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "musl", "crt", "crt1.c",
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
+ .function_sections = true,
+ .data_sections = true,
+ .omit_frame_pointer = true,
+ .no_builtin = true,
+ });
+ },
+ .rcrt1_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCcArgs(comp, arena, &args, false);
+ try args.append("-DCRT");
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "musl", "crt", "rcrt1.c",
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
+ .function_sections = true,
+ .data_sections = true,
+ .omit_frame_pointer = true,
+ .pic = true,
+ .no_builtin = true,
+ });
+ },
+ .scrt1_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCcArgs(comp, arena, &args, false);
+ try args.append("-DCRT");
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "musl", "crt", "Scrt1.c",
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
+ .function_sections = true,
+ .data_sections = true,
+ .omit_frame_pointer = true,
+ .pic = true,
+ .no_builtin = true,
+ });
+ },
+ .libc_a => {
+ // When there is a src/<arch>/foo.* then it should substitute for src/foo.*
+ // Even a .s file can substitute for a .c file.
+ const target = comp.getTarget();
+ const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
+ var source_table = std.StringArrayHashMap(Ext).init(comp.gpa);
+ defer source_table.deinit();
+
+ try source_table.ensureTotalCapacity(compat_time32_files.len + src_files.len);
+
+ for (src_files) |src_file| {
+ try addSrcFile(arena, &source_table, src_file);
+ }
+
+ for (time32_compat_arch_list) |time32_compat_arch| {
+ if (mem.eql(u8, arch_name, time32_compat_arch)) {
+ for (compat_time32_files) |compat_time32_file| {
+ try addSrcFile(arena, &source_table, compat_time32_file);
+ }
+ }
+ }
+
+ var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);
+ defer c_source_files.deinit();
+
+ var override_path = std.ArrayList(u8).init(comp.gpa);
+ defer override_path.deinit();
+
+ const s = path.sep_str;
+
+ var it = source_table.iterator();
+ while (it.next()) |entry| {
+ const src_file = entry.key_ptr.*;
+ const ext = entry.value_ptr.*;
+
+ const dirname = path.dirname(src_file).?;
+ const basename = path.basename(src_file);
+ const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
+ const dirbasename = path.basename(dirname);
+
+ var is_arch_specific = false;
+ // Architecture-specific implementations are under a <arch>/ folder.
+ if (isArchName(dirbasename)) {
+ if (!mem.eql(u8, dirbasename, arch_name))
+ continue; // Not the architecture we're compiling for.
+ is_arch_specific = true;
+ }
+ if (!is_arch_specific) {
+ // Look for an arch specific override.
+ override_path.shrinkRetainingCapacity(0);
+ try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
+ dirname, arch_name, noextbasename,
+ });
+ if (source_table.contains(override_path.items))
+ continue;
+
+ override_path.shrinkRetainingCapacity(0);
+ try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
+ dirname, arch_name, noextbasename,
+ });
+ if (source_table.contains(override_path.items))
+ continue;
+
+ override_path.shrinkRetainingCapacity(0);
+ try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
+ dirname, arch_name, noextbasename,
+ });
+ if (source_table.contains(override_path.items))
+ continue;
+ }
+
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCcArgs(comp, arena, &args, ext == .o3);
+ const c_source_file = try c_source_files.addOne();
+ c_source_file.* = .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", src_file }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ };
+ }
+ return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
+ .function_sections = true,
+ .data_sections = true,
+ .omit_frame_pointer = true,
+ .no_builtin = true,
+ });
+ },
+ .libc_so => {
+ const optimize_mode = comp.compilerRtOptMode();
+ const strip = comp.compilerRtStrip();
+ const output_mode: std.builtin.OutputMode = .Lib;
+ const config = try Compilation.Config.resolve(.{
+ .output_mode = output_mode,
+ .link_mode = .dynamic,
+ .resolved_target = comp.root_mod.resolved_target,
+ .is_test = false,
+ .have_zcu = false,
+ .emit_bin = true,
+ .root_optimize_mode = optimize_mode,
+ .root_strip = strip,
+ .link_libc = false,
+ });
+
+ const target = comp.root_mod.resolved_target.result;
+ const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
+ const time32 = for (time32_compat_arch_list) |time32_compat_arch| {
+ if (mem.eql(u8, arch_name, time32_compat_arch)) break true;
+ } else false;
+ const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{arch_name});
+ const family_define = switch (target.cpu.arch) {
+ .arm, .armeb, .thumb, .thumbeb => "-DFAMILY_arm",
+ .aarch64, .aarch64_be => "-DFAMILY_aarch64",
+ .hexagon => "-DFAMILY_hexagon",
+ .loongarch64 => "-DFAMILY_loongarch",
+ .m68k => "-DFAMILY_m68k",
+ .mips, .mipsel, .mips64, .mips64el => "-DFAMILY_mips",
+ .powerpc, .powerpc64, .powerpc64le => "-DFAMILY_powerpc",
+ .riscv32, .riscv64 => "-DFAMILY_riscv",
+ .s390x => "-DFAMILY_s390x",
+ .x86, .x86_64 => "-DFAMILY_x86",
+ else => unreachable,
+ };
+ const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64)
+ &.{ "-DPTR64", arch_define, family_define }
+ else if (time32)
+ &.{ "-DTIME32", arch_define, family_define }
+ else
+ &.{ arch_define, family_define };
+
+ const root_mod = try Module.create(arena, .{
+ .global_cache_directory = comp.global_cache_directory,
+ .paths = .{
+ .root = .{ .root_dir = comp.zig_lib_directory },
+ .root_src_path = "",
+ },
+ .fully_qualified_name = "root",
+ .inherited = .{
+ .resolved_target = comp.root_mod.resolved_target,
+ .strip = strip,
+ .stack_check = false,
+ .stack_protector = 0,
+ .sanitize_c = .off,
+ .sanitize_thread = false,
+ .red_zone = comp.root_mod.red_zone,
+ .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
+ .valgrind = false,
+ .optimize_mode = optimize_mode,
+ .structured_cfg = comp.root_mod.structured_cfg,
+ },
+ .global = config,
+ .cc_argv = cc_argv,
+ .parent = null,
+ .builtin_mod = null,
+ .builtin_modules = null, // there is only one module in this compilation
+ });
+
+ const sub_compilation = try Compilation.create(comp.gpa, arena, .{
+ .local_cache_directory = comp.global_cache_directory,
+ .global_cache_directory = comp.global_cache_directory,
+ .zig_lib_directory = comp.zig_lib_directory,
+ .self_exe_path = comp.self_exe_path,
+ .cache_mode = .whole,
+ .config = config,
+ .root_mod = root_mod,
+ .thread_pool = comp.thread_pool,
+ .root_name = "c",
+ .libc_installation = comp.libc_installation,
+ .emit_bin = .{ .directory = null, .basename = "libc.so" },
+ .emit_h = null,
+ .verbose_cc = comp.verbose_cc,
+ .verbose_link = comp.verbose_link,
+ .verbose_air = comp.verbose_air,
+ .verbose_llvm_ir = comp.verbose_llvm_ir,
+ .verbose_cimport = comp.verbose_cimport,
+ .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
+ .clang_passthrough_mode = comp.clang_passthrough_mode,
+ .c_source_files = &[_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &.{ "libc", "musl", "libc.S" }),
+ .owner = root_mod,
+ },
+ },
+ .skip_linker_dependencies = true,
+ .soname = "libc.so",
+ });
+ defer sub_compilation.destroy();
+
+ try comp.updateSubCompilation(sub_compilation, .@"musl libc.so", prog_node);
+
+ const basename = try comp.gpa.dupe(u8, "libc.so");
+ errdefer comp.gpa.free(basename);
+
+ const crt_file = try sub_compilation.toCrtFile();
+ comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
+ {
+ comp.mutex.lock();
+ defer comp.mutex.unlock();
+ try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
+ comp.crt_files.putAssumeCapacityNoClobber(basename, crt_file);
+ }
+ },
+ }
+}
+
+pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
+ return switch (output_mode) {
+ .Obj, .Lib => null,
+ .Exe => switch (link_mode) {
+ .dynamic => if (pie) .scrt1_o else .crt1_o,
+ .static => if (pie) .rcrt1_o else .crt1_o,
+ },
+ };
+}
+
+const time32_compat_arch_list = [_][]const u8{
+ "arm",
+ "i386",
+ "m68k",
+ "microblaze",
+ "mips",
+ "mipsn32",
+ "or1k",
+ "powerpc",
+ "sh",
+};
+
+fn isArchName(name: []const u8) bool {
+ const musl_arch_names = [_][]const u8{
+ "aarch64",
+ "arm",
+ "generic",
+ "hexagon",
+ "i386",
+ "loongarch64",
+ "m68k",
+ "microblaze",
+ "mips",
+ "mips64",
+ "mipsn32",
+ "or1k",
+ "powerpc",
+ "powerpc64",
+ "riscv32",
+ "riscv64",
+ "s390x",
+ "sh",
+ "x32",
+ "x86_64",
+ };
+ for (musl_arch_names) |musl_arch_name| {
+ if (mem.eql(u8, musl_arch_name, name)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+const Ext = enum {
+ assembly,
+ o3,
+};
+
+fn addSrcFile(arena: Allocator, source_table: *std.StringArrayHashMap(Ext), file_path: []const u8) !void {
+ const ext: Ext = ext: {
+ if (mem.endsWith(u8, file_path, ".c")) {
+ if (mem.startsWith(u8, file_path, "musl/src/malloc/") or
+ mem.startsWith(u8, file_path, "musl/src/string/") or
+ mem.startsWith(u8, file_path, "musl/src/internal/"))
+ {
+ break :ext .o3;
+ } else {
+ break :ext .assembly;
+ }
+ } else if (mem.endsWith(u8, file_path, ".s") or mem.endsWith(u8, file_path, ".S")) {
+ break :ext .assembly;
+ } else {
+ unreachable;
+ }
+ };
+ // TODO do this at comptime on the comptime data rather than at runtime
+ // probably best to wait until self-hosted is done and our comptime execution
+ // is faster and uses less memory.
+ const key = if (path.sep != '/') blk: {
+ const mutable_file_path = try arena.dupe(u8, file_path);
+ for (mutable_file_path) |*c| {
+ if (c.* == '/') {
+ c.* = path.sep;
+ }
+ }
+ break :blk mutable_file_path;
+ } else file_path;
+ source_table.putAssumeCapacityNoClobber(key, ext);
+}
+
+fn addCcArgs(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+ want_O3: bool,
+) error{OutOfMemory}!void {
+ const target = comp.getTarget();
+ const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
+ const os_name = @tagName(target.os.tag);
+ const triple = try std.fmt.allocPrint(arena, "{s}-{s}-{s}", .{
+ std.zig.target.muslArchNameHeaders(target.cpu.arch),
+ os_name,
+ std.zig.target.muslAbiNameHeaders(target.abi),
+ });
+ const o_arg = if (want_O3) "-O3" else "-Os";
+
+ try args.appendSlice(&[_][]const u8{
+ "-std=c99",
+ "-ffreestanding",
+ "-fexcess-precision=standard",
+ "-frounding-math",
+ "-ffp-contract=off",
+ "-fno-strict-aliasing",
+ "-Wa,--noexecstack",
+ "-D_XOPEN_SOURCE=700",
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", arch_name }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", "generic" }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "include" }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "internal" }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "include" }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
+
+ o_arg,
+
+ "-Qunused-arguments",
+ "-w", // disable all warnings
+ });
+
+ if (target.cpu.arch.isThumb()) {
+ try args.append("-mimplicit-it=always");
+ }
+}
+
+fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
+ const target = comp.getTarget();
+ return comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", "musl", "crt", std.zig.target.muslArchName(target.cpu.arch, target.abi), basename,
+ });
+}
+
+const src_files = [_][]const u8{
+ "musl/src/aio/aio.c",
+ "musl/src/aio/aio_suspend.c",
+ "musl/src/aio/lio_listio.c",
+ "musl/src/complex/cabs.c",
+ "musl/src/complex/cabsf.c",
+ "musl/src/complex/cabsl.c",
+ "musl/src/complex/cacos.c",
+ "musl/src/complex/cacosf.c",
+ "musl/src/complex/cacosh.c",
+ "musl/src/complex/cacoshf.c",
+ "musl/src/complex/cacoshl.c",
+ "musl/src/complex/cacosl.c",
+ "musl/src/complex/carg.c",
+ "musl/src/complex/cargf.c",
+ "musl/src/complex/cargl.c",
+ "musl/src/complex/casin.c",
+ "musl/src/complex/casinf.c",
+ "musl/src/complex/casinh.c",
+ "musl/src/complex/casinhf.c",
+ "musl/src/complex/casinhl.c",
+ "musl/src/complex/casinl.c",
+ "musl/src/complex/catan.c",
+ "musl/src/complex/catanf.c",
+ "musl/src/complex/catanh.c",
+ "musl/src/complex/catanhf.c",
+ "musl/src/complex/catanhl.c",
+ "musl/src/complex/catanl.c",
+ "musl/src/complex/ccos.c",
+ "musl/src/complex/ccosf.c",
+ "musl/src/complex/ccosh.c",
+ "musl/src/complex/ccoshf.c",
+ "musl/src/complex/ccoshl.c",
+ "musl/src/complex/ccosl.c",
+ "musl/src/complex/__cexp.c",
+ "musl/src/complex/cexp.c",
+ "musl/src/complex/__cexpf.c",
+ "musl/src/complex/cexpf.c",
+ "musl/src/complex/cexpl.c",
+ "musl/src/complex/cimag.c",
+ "musl/src/complex/cimagf.c",
+ "musl/src/complex/cimagl.c",
+ "musl/src/complex/clog.c",
+ "musl/src/complex/clogf.c",
+ "musl/src/complex/clogl.c",
+ "musl/src/complex/conj.c",
+ "musl/src/complex/conjf.c",
+ "musl/src/complex/conjl.c",
+ "musl/src/complex/cpow.c",
+ "musl/src/complex/cpowf.c",
+ "musl/src/complex/cpowl.c",
+ "musl/src/complex/cproj.c",
+ "musl/src/complex/cprojf.c",
+ "musl/src/complex/cprojl.c",
+ "musl/src/complex/creal.c",
+ "musl/src/complex/crealf.c",
+ "musl/src/complex/creall.c",
+ "musl/src/complex/csin.c",
+ "musl/src/complex/csinf.c",
+ "musl/src/complex/csinh.c",
+ "musl/src/complex/csinhf.c",
+ "musl/src/complex/csinhl.c",
+ "musl/src/complex/csinl.c",
+ "musl/src/complex/csqrt.c",
+ "musl/src/complex/csqrtf.c",
+ "musl/src/complex/csqrtl.c",
+ "musl/src/complex/ctan.c",
+ "musl/src/complex/ctanf.c",
+ "musl/src/complex/ctanh.c",
+ "musl/src/complex/ctanhf.c",
+ "musl/src/complex/ctanhl.c",
+ "musl/src/complex/ctanl.c",
+ "musl/src/conf/confstr.c",
+ "musl/src/conf/fpathconf.c",
+ "musl/src/conf/legacy.c",
+ "musl/src/conf/pathconf.c",
+ "musl/src/conf/sysconf.c",
+ "musl/src/crypt/crypt_blowfish.c",
+ "musl/src/crypt/crypt.c",
+ "musl/src/crypt/crypt_des.c",
+ "musl/src/crypt/crypt_md5.c",
+ "musl/src/crypt/crypt_r.c",
+ "musl/src/crypt/crypt_sha256.c",
+ "musl/src/crypt/crypt_sha512.c",
+ "musl/src/crypt/encrypt.c",
+ "musl/src/ctype/__ctype_b_loc.c",
+ "musl/src/ctype/__ctype_get_mb_cur_max.c",
+ "musl/src/ctype/__ctype_tolower_loc.c",
+ "musl/src/ctype/__ctype_toupper_loc.c",
+ "musl/src/ctype/isalnum.c",
+ "musl/src/ctype/isalpha.c",
+ "musl/src/ctype/isascii.c",
+ "musl/src/ctype/isblank.c",
+ "musl/src/ctype/iscntrl.c",
+ "musl/src/ctype/isdigit.c",
+ "musl/src/ctype/isgraph.c",
+ "musl/src/ctype/islower.c",
+ "musl/src/ctype/isprint.c",
+ "musl/src/ctype/ispunct.c",
+ "musl/src/ctype/isspace.c",
+ "musl/src/ctype/isupper.c",
+ "musl/src/ctype/iswalnum.c",
+ "musl/src/ctype/iswalpha.c",
+ "musl/src/ctype/iswblank.c",
+ "musl/src/ctype/iswcntrl.c",
+ "musl/src/ctype/iswctype.c",
+ "musl/src/ctype/iswdigit.c",
+ "musl/src/ctype/iswgraph.c",
+ "musl/src/ctype/iswlower.c",
+ "musl/src/ctype/iswprint.c",
+ "musl/src/ctype/iswpunct.c",
+ "musl/src/ctype/iswspace.c",
+ "musl/src/ctype/iswupper.c",
+ "musl/src/ctype/iswxdigit.c",
+ "musl/src/ctype/isxdigit.c",
+ "musl/src/ctype/toascii.c",
+ "musl/src/ctype/tolower.c",
+ "musl/src/ctype/toupper.c",
+ "musl/src/ctype/towctrans.c",
+ "musl/src/ctype/wcswidth.c",
+ "musl/src/ctype/wctrans.c",
+ "musl/src/ctype/wcwidth.c",
+ "musl/src/dirent/alphasort.c",
+ "musl/src/dirent/closedir.c",
+ "musl/src/dirent/dirfd.c",
+ "musl/src/dirent/fdopendir.c",
+ "musl/src/dirent/opendir.c",
+ "musl/src/dirent/readdir.c",
+ "musl/src/dirent/readdir_r.c",
+ "musl/src/dirent/rewinddir.c",
+ "musl/src/dirent/scandir.c",
+ "musl/src/dirent/seekdir.c",
+ "musl/src/dirent/telldir.c",
+ "musl/src/dirent/versionsort.c",
+ "musl/src/env/clearenv.c",
+ "musl/src/env/__environ.c",
+ "musl/src/env/getenv.c",
+ "musl/src/env/__init_tls.c",
+ "musl/src/env/__libc_start_main.c",
+ "musl/src/env/putenv.c",
+ "musl/src/env/__reset_tls.c",
+ "musl/src/env/secure_getenv.c",
+ "musl/src/env/setenv.c",
+ "musl/src/env/__stack_chk_fail.c",
+ "musl/src/env/unsetenv.c",
+ "musl/src/errno/__errno_location.c",
+ "musl/src/errno/strerror.c",
+ "musl/src/exit/abort.c",
+ "musl/src/exit/abort_lock.c",
+ "musl/src/exit/arm/__aeabi_atexit.c",
+ "musl/src/exit/assert.c",
+ "musl/src/exit/atexit.c",
+ "musl/src/exit/at_quick_exit.c",
+ "musl/src/exit/exit.c",
+ "musl/src/exit/_Exit.c",
+ "musl/src/exit/quick_exit.c",
+ "musl/src/fcntl/creat.c",
+ "musl/src/fcntl/fcntl.c",
+ "musl/src/fcntl/openat.c",
+ "musl/src/fcntl/open.c",
+ "musl/src/fcntl/posix_fadvise.c",
+ "musl/src/fcntl/posix_fallocate.c",
+ "musl/src/fenv/aarch64/fenv.s",
+ "musl/src/fenv/arm/fenv.c",
+ "musl/src/fenv/arm/fenv-hf.S",
+ "musl/src/fenv/fegetexceptflag.c",
+ "musl/src/fenv/feholdexcept.c",
+ "musl/src/fenv/fenv.c",
+ "musl/src/fenv/fesetexceptflag.c",
+ "musl/src/fenv/fesetround.c",
+ "musl/src/fenv/feupdateenv.c",
+ "musl/src/fenv/__flt_rounds.c",
+ "musl/src/fenv/hexagon/fenv.S",
+ "musl/src/fenv/i386/fenv.s",
+ "musl/src/fenv/loongarch64/fenv.S",
+ "musl/src/fenv/m68k/fenv.c",
+ "musl/src/fenv/mips64/fenv.S",
+ "musl/src/fenv/mips64/fenv-sf.c",
+ "musl/src/fenv/mips/fenv.S",
+ "musl/src/fenv/mips/fenv-sf.c",
+ "musl/src/fenv/mipsn32/fenv.S",
+ "musl/src/fenv/mipsn32/fenv-sf.c",
+ "musl/src/fenv/powerpc64/fenv.c",
+ "musl/src/fenv/powerpc/fenv.S",
+ "musl/src/fenv/powerpc/fenv-sf.c",
+ "musl/src/fenv/riscv32/fenv.S",
+ "musl/src/fenv/riscv32/fenv-sf.c",
+ "musl/src/fenv/riscv64/fenv.S",
+ "musl/src/fenv/riscv64/fenv-sf.c",
+ "musl/src/fenv/s390x/fenv.c",
+ "musl/src/fenv/x32/fenv.s",
+ "musl/src/fenv/x86_64/fenv.s",
+ "musl/src/internal/defsysinfo.c",
+ "musl/src/internal/emulate_wait4.c",
+ "musl/src/internal/floatscan.c",
+ "musl/src/internal/i386/defsysinfo.s",
+ "musl/src/internal/intscan.c",
+ "musl/src/internal/libc.c",
+ "musl/src/internal/procfdname.c",
+ "musl/src/internal/shgetc.c",
+ "musl/src/internal/syscall_ret.c",
+ "musl/src/internal/vdso.c",
+ "musl/src/internal/version.c",
+ "musl/src/ipc/ftok.c",
+ "musl/src/ipc/msgctl.c",
+ "musl/src/ipc/msgget.c",
+ "musl/src/ipc/msgrcv.c",
+ "musl/src/ipc/msgsnd.c",
+ "musl/src/ipc/semctl.c",
+ "musl/src/ipc/semget.c",
+ "musl/src/ipc/semop.c",
+ "musl/src/ipc/semtimedop.c",
+ "musl/src/ipc/shmat.c",
+ "musl/src/ipc/shmctl.c",
+ "musl/src/ipc/shmdt.c",
+ "musl/src/ipc/shmget.c",
+ "musl/src/ldso/aarch64/dlsym.s",
+ "musl/src/ldso/aarch64/tlsdesc.s",
+ "musl/src/ldso/arm/dlsym.s",
+ "musl/src/ldso/arm/dlsym_time64.S",
+ "musl/src/ldso/arm/find_exidx.c",
+ "musl/src/ldso/arm/tlsdesc.S",
+ "musl/src/ldso/dladdr.c",
+ "musl/src/ldso/dlclose.c",
+ "musl/src/ldso/dlerror.c",
+ "musl/src/ldso/dlinfo.c",
+ "musl/src/ldso/dl_iterate_phdr.c",
+ "musl/src/ldso/dlopen.c",
+ "musl/src/ldso/__dlsym.c",
+ "musl/src/ldso/dlsym.c",
+ "musl/src/ldso/i386/dlsym.s",
+ "musl/src/ldso/i386/dlsym_time64.S",
+ "musl/src/ldso/i386/tlsdesc.s",
+ "musl/src/ldso/loongarch64/dlsym.s",
+ "musl/src/ldso/m68k/dlsym.s",
+ "musl/src/ldso/m68k/dlsym_time64.S",
+ "musl/src/ldso/mips64/dlsym.s",
+ "musl/src/ldso/mips/dlsym.s",
+ "musl/src/ldso/mips/dlsym_time64.S",
+ "musl/src/ldso/mipsn32/dlsym.s",
+ "musl/src/ldso/mipsn32/dlsym_time64.S",
+ "musl/src/ldso/powerpc64/dlsym.s",
+ "musl/src/ldso/powerpc/dlsym.s",
+ "musl/src/ldso/powerpc/dlsym_time64.S",
+ "musl/src/ldso/riscv32/dlsym.s",
+ "musl/src/ldso/riscv64/dlsym.s",
+ "musl/src/ldso/riscv64/tlsdesc.s",
+ "musl/src/ldso/s390x/dlsym.s",
+ "musl/src/ldso/tlsdesc.c",
+ "musl/src/ldso/x32/dlsym.s",
+ "musl/src/ldso/x86_64/dlsym.s",
+ "musl/src/ldso/x86_64/tlsdesc.s",
+ "musl/src/legacy/cuserid.c",
+ "musl/src/legacy/daemon.c",
+ "musl/src/legacy/err.c",
+ "musl/src/legacy/euidaccess.c",
+ "musl/src/legacy/ftw.c",
+ "musl/src/legacy/futimes.c",
+ "musl/src/legacy/getdtablesize.c",
+ "musl/src/legacy/getloadavg.c",
+ "musl/src/legacy/getpagesize.c",
+ "musl/src/legacy/getpass.c",
+ "musl/src/legacy/getusershell.c",
+ "musl/src/legacy/isastream.c",
+ "musl/src/legacy/lutimes.c",
+ "musl/src/legacy/ulimit.c",
+ "musl/src/legacy/utmpx.c",
+ "musl/src/legacy/valloc.c",
+ "musl/src/linux/adjtime.c",
+ "musl/src/linux/adjtimex.c",
+ "musl/src/linux/arch_prctl.c",
+ "musl/src/linux/brk.c",
+ "musl/src/linux/cache.c",
+ "musl/src/linux/cap.c",
+ "musl/src/linux/chroot.c",
+ "musl/src/linux/clock_adjtime.c",
+ "musl/src/linux/clone.c",
+ "musl/src/linux/copy_file_range.c",
+ "musl/src/linux/epoll.c",
+ "musl/src/linux/eventfd.c",
+ "musl/src/linux/fallocate.c",
+ "musl/src/linux/fanotify.c",
+ "musl/src/linux/flock.c",
+ "musl/src/linux/getdents.c",
+ "musl/src/linux/getrandom.c",
+ "musl/src/linux/gettid.c",
+ "musl/src/linux/inotify.c",
+ "musl/src/linux/ioperm.c",
+ "musl/src/linux/iopl.c",
+ "musl/src/linux/klogctl.c",
+ "musl/src/linux/membarrier.c",
+ "musl/src/linux/memfd_create.c",
+ "musl/src/linux/mlock2.c",
+ "musl/src/linux/module.c",
+ "musl/src/linux/mount.c",
+ "musl/src/linux/name_to_handle_at.c",
+ "musl/src/linux/open_by_handle_at.c",
+ "musl/src/linux/personality.c",
+ "musl/src/linux/pivot_root.c",
+ "musl/src/linux/prctl.c",
+ "musl/src/linux/preadv2.c",
+ "musl/src/linux/prlimit.c",
+ "musl/src/linux/process_vm.c",
+ "musl/src/linux/ptrace.c",
+ "musl/src/linux/pwritev2.c",
+ "musl/src/linux/quotactl.c",
+ "musl/src/linux/readahead.c",
+ "musl/src/linux/reboot.c",
+ "musl/src/linux/remap_file_pages.c",
+ "musl/src/linux/sbrk.c",
+ "musl/src/linux/sendfile.c",
+ "musl/src/linux/setfsgid.c",
+ "musl/src/linux/setfsuid.c",
+ "musl/src/linux/setgroups.c",
+ "musl/src/linux/sethostname.c",
+ "musl/src/linux/setns.c",
+ "musl/src/linux/settimeofday.c",
+ "musl/src/linux/signalfd.c",
+ "musl/src/linux/splice.c",
+ "musl/src/linux/statx.c",
+ "musl/src/linux/stime.c",
+ "musl/src/linux/swap.c",
+ "musl/src/linux/sync_file_range.c",
+ "musl/src/linux/syncfs.c",
+ "musl/src/linux/sysinfo.c",
+ "musl/src/linux/tee.c",
+ "musl/src/linux/timerfd.c",
+ "musl/src/linux/unshare.c",
+ "musl/src/linux/utimes.c",
+ "musl/src/linux/vhangup.c",
+ "musl/src/linux/vmsplice.c",
+ "musl/src/linux/wait3.c",
+ "musl/src/linux/wait4.c",
+ "musl/src/linux/x32/sysinfo.c",
+ "musl/src/linux/xattr.c",
+ "musl/src/locale/bind_textdomain_codeset.c",
+ "musl/src/locale/catclose.c",
+ "musl/src/locale/catgets.c",
+ "musl/src/locale/catopen.c",
+ "musl/src/locale/c_locale.c",
+ "musl/src/locale/dcngettext.c",
+ "musl/src/locale/duplocale.c",
+ "musl/src/locale/freelocale.c",
+ "musl/src/locale/iconv.c",
+ "musl/src/locale/iconv_close.c",
+ "musl/src/locale/langinfo.c",
+ "musl/src/locale/__lctrans.c",
+ "musl/src/locale/localeconv.c",
+ "musl/src/locale/locale_map.c",
+ "musl/src/locale/__mo_lookup.c",
+ "musl/src/locale/newlocale.c",
+ "musl/src/locale/pleval.c",
+ "musl/src/locale/setlocale.c",
+ "musl/src/locale/strcoll.c",
+ "musl/src/locale/strfmon.c",
+ "musl/src/locale/strtod_l.c",
+ "musl/src/locale/strxfrm.c",
+ "musl/src/locale/textdomain.c",
+ "musl/src/locale/uselocale.c",
+ "musl/src/locale/wcscoll.c",
+ "musl/src/locale/wcsxfrm.c",
+ "musl/src/malloc/calloc.c",
+ "musl/src/malloc/free.c",
+ "musl/src/malloc/libc_calloc.c",
+ "musl/src/malloc/lite_malloc.c",
+ "musl/src/malloc/mallocng/aligned_alloc.c",
+ "musl/src/malloc/mallocng/donate.c",
+ "musl/src/malloc/mallocng/free.c",
+ "musl/src/malloc/mallocng/malloc.c",
+ "musl/src/malloc/mallocng/malloc_usable_size.c",
+ "musl/src/malloc/mallocng/realloc.c",
+ "musl/src/malloc/memalign.c",
+ "musl/src/malloc/oldmalloc/aligned_alloc.c",
+ "musl/src/malloc/oldmalloc/malloc.c",
+ "musl/src/malloc/oldmalloc/malloc_usable_size.c",
+ "musl/src/malloc/posix_memalign.c",
+ "musl/src/malloc/reallocarray.c",
+ "musl/src/malloc/realloc.c",
+ "musl/src/malloc/replaced.c",
+ "musl/src/math/aarch64/ceil.c",
+ "musl/src/math/aarch64/ceilf.c",
+ "musl/src/math/aarch64/fabs.c",
+ "musl/src/math/aarch64/fabsf.c",
+ "musl/src/math/aarch64/floor.c",
+ "musl/src/math/aarch64/floorf.c",
+ "musl/src/math/aarch64/fma.c",
+ "musl/src/math/aarch64/fmaf.c",
+ "musl/src/math/aarch64/fmax.c",
+ "musl/src/math/aarch64/fmaxf.c",
+ "musl/src/math/aarch64/fmin.c",
+ "musl/src/math/aarch64/fminf.c",
+ "musl/src/math/aarch64/llrint.c",
+ "musl/src/math/aarch64/llrintf.c",
+ "musl/src/math/aarch64/llround.c",
+ "musl/src/math/aarch64/llroundf.c",
+ "musl/src/math/aarch64/lrint.c",
+ "musl/src/math/aarch64/lrintf.c",
+ "musl/src/math/aarch64/lround.c",
+ "musl/src/math/aarch64/lroundf.c",
+ "musl/src/math/aarch64/nearbyint.c",
+ "musl/src/math/aarch64/nearbyintf.c",
+ "musl/src/math/aarch64/rint.c",
+ "musl/src/math/aarch64/rintf.c",
+ "musl/src/math/aarch64/round.c",
+ "musl/src/math/aarch64/roundf.c",
+ "musl/src/math/aarch64/sqrt.c",
+ "musl/src/math/aarch64/sqrtf.c",
+ "musl/src/math/aarch64/trunc.c",
+ "musl/src/math/aarch64/truncf.c",
+ "musl/src/math/acos.c",
+ "musl/src/math/acosf.c",
+ "musl/src/math/acosh.c",
+ "musl/src/math/acoshf.c",
+ "musl/src/math/acoshl.c",
+ "musl/src/math/acosl.c",
+ "musl/src/math/arm/fabs.c",
+ "musl/src/math/arm/fabsf.c",
+ "musl/src/math/arm/fma.c",
+ "musl/src/math/arm/fmaf.c",
+ "musl/src/math/arm/sqrt.c",
+ "musl/src/math/arm/sqrtf.c",
+ "musl/src/math/asin.c",
+ "musl/src/math/asinf.c",
+ "musl/src/math/asinh.c",
+ "musl/src/math/asinhf.c",
+ "musl/src/math/asinhl.c",
+ "musl/src/math/asinl.c",
+ "musl/src/math/atan2.c",
+ "musl/src/math/atan2f.c",
+ "musl/src/math/atan2l.c",
+ "musl/src/math/atan.c",
+ "musl/src/math/atanf.c",
+ "musl/src/math/atanh.c",
+ "musl/src/math/atanhf.c",
+ "musl/src/math/atanhl.c",
+ "musl/src/math/atanl.c",
+ "musl/src/math/cbrt.c",
+ "musl/src/math/cbrtf.c",
+ "musl/src/math/cbrtl.c",
+ "musl/src/math/ceil.c",
+ "musl/src/math/ceilf.c",
+ "musl/src/math/ceill.c",
+ "musl/src/math/copysign.c",
+ "musl/src/math/copysignf.c",
+ "musl/src/math/copysignl.c",
+ "musl/src/math/__cos.c",
+ "musl/src/math/cos.c",
+ "musl/src/math/__cosdf.c",
+ "musl/src/math/cosf.c",
+ "musl/src/math/cosh.c",
+ "musl/src/math/coshf.c",
+ "musl/src/math/coshl.c",
+ "musl/src/math/__cosl.c",
+ "musl/src/math/cosl.c",
+ "musl/src/math/erf.c",
+ "musl/src/math/erff.c",
+ "musl/src/math/erfl.c",
+ "musl/src/math/exp10.c",
+ "musl/src/math/exp10f.c",
+ "musl/src/math/exp10l.c",
+ "musl/src/math/exp2.c",
+ "musl/src/math/exp2f.c",
+ "musl/src/math/exp2f_data.c",
+ "musl/src/math/exp2l.c",
+ "musl/src/math/exp.c",
+ "musl/src/math/exp_data.c",
+ "musl/src/math/expf.c",
+ "musl/src/math/expl.c",
+ "musl/src/math/expm1.c",
+ "musl/src/math/expm1f.c",
+ "musl/src/math/expm1l.c",
+ "musl/src/math/__expo2.c",
+ "musl/src/math/__expo2f.c",
+ "musl/src/math/fabs.c",
+ "musl/src/math/fabsf.c",
+ "musl/src/math/fabsl.c",
+ "musl/src/math/fdim.c",
+ "musl/src/math/fdimf.c",
+ "musl/src/math/fdiml.c",
+ "musl/src/math/finite.c",
+ "musl/src/math/finitef.c",
+ "musl/src/math/floor.c",
+ "musl/src/math/floorf.c",
+ "musl/src/math/floorl.c",
+ "musl/src/math/fma.c",
+ "musl/src/math/fmaf.c",
+ "musl/src/math/fmal.c",
+ "musl/src/math/fmax.c",
+ "musl/src/math/fmaxf.c",
+ "musl/src/math/fmaxl.c",
+ "musl/src/math/fmin.c",
+ "musl/src/math/fminf.c",
+ "musl/src/math/fminl.c",
+ "musl/src/math/fmod.c",
+ "musl/src/math/fmodf.c",
+ "musl/src/math/fmodl.c",
+ "musl/src/math/__fpclassify.c",
+ "musl/src/math/__fpclassifyf.c",
+ "musl/src/math/__fpclassifyl.c",
+ "musl/src/math/frexp.c",
+ "musl/src/math/frexpf.c",
+ "musl/src/math/frexpl.c",
+ "musl/src/math/hypot.c",
+ "musl/src/math/hypotf.c",
+ "musl/src/math/hypotl.c",
+ "musl/src/math/i386/acosf.s",
+ "musl/src/math/i386/acosl.s",
+ "musl/src/math/i386/acos.s",
+ "musl/src/math/i386/asinf.s",
+ "musl/src/math/i386/asinl.s",
+ "musl/src/math/i386/asin.s",
+ "musl/src/math/i386/atan2f.s",
+ "musl/src/math/i386/atan2l.s",
+ "musl/src/math/i386/atan2.s",
+ "musl/src/math/i386/atanf.s",
+ "musl/src/math/i386/atanl.s",
+ "musl/src/math/i386/atan.s",
+ "musl/src/math/i386/ceilf.s",
+ "musl/src/math/i386/ceill.s",
+ "musl/src/math/i386/ceil.s",
+ "musl/src/math/i386/exp2l.s",
+ "musl/src/math/i386/exp_ld.s",
+ "musl/src/math/i386/expl.s",
+ "musl/src/math/i386/expm1l.s",
+ "musl/src/math/i386/fabs.c",
+ "musl/src/math/i386/fabsf.c",
+ "musl/src/math/i386/fabsl.c",
+ "musl/src/math/i386/floorf.s",
+ "musl/src/math/i386/floorl.s",
+ "musl/src/math/i386/floor.s",
+ "musl/src/math/i386/fmod.c",
+ "musl/src/math/i386/fmodf.c",
+ "musl/src/math/i386/fmodl.c",
+ "musl/src/math/i386/hypotf.s",
+ "musl/src/math/i386/hypot.s",
+ "musl/src/math/i386/__invtrigl.s",
+ "musl/src/math/i386/ldexpf.s",
+ "musl/src/math/i386/ldexpl.s",
+ "musl/src/math/i386/ldexp.s",
+ "musl/src/math/i386/llrint.c",
+ "musl/src/math/i386/llrintf.c",
+ "musl/src/math/i386/llrintl.c",
+ "musl/src/math/i386/log10f.s",
+ "musl/src/math/i386/log10l.s",
+ "musl/src/math/i386/log10.s",
+ "musl/src/math/i386/log1pf.s",
+ "musl/src/math/i386/log1pl.s",
+ "musl/src/math/i386/log1p.s",
+ "musl/src/math/i386/log2f.s",
+ "musl/src/math/i386/log2l.s",
+ "musl/src/math/i386/log2.s",
+ "musl/src/math/i386/logf.s",
+ "musl/src/math/i386/logl.s",
+ "musl/src/math/i386/log.s",
+ "musl/src/math/i386/lrint.c",
+ "musl/src/math/i386/lrintf.c",
+ "musl/src/math/i386/lrintl.c",
+ "musl/src/math/i386/remainder.c",
+ "musl/src/math/i386/remainderf.c",
+ "musl/src/math/i386/remainderl.c",
+ "musl/src/math/i386/remquof.s",
+ "musl/src/math/i386/remquol.s",
+ "musl/src/math/i386/remquo.s",
+ "musl/src/math/i386/rint.c",
+ "musl/src/math/i386/rintf.c",
+ "musl/src/math/i386/rintl.c",
+ "musl/src/math/i386/scalblnf.s",
+ "musl/src/math/i386/scalblnl.s",
+ "musl/src/math/i386/scalbln.s",
+ "musl/src/math/i386/scalbnf.s",
+ "musl/src/math/i386/scalbnl.s",
+ "musl/src/math/i386/scalbn.s",
+ "musl/src/math/i386/sqrt.c",
+ "musl/src/math/i386/sqrtf.c",
+ "musl/src/math/i386/sqrtl.c",
+ "musl/src/math/i386/truncf.s",
+ "musl/src/math/i386/truncl.s",
+ "musl/src/math/i386/trunc.s",
+ "musl/src/math/ilogb.c",
+ "musl/src/math/ilogbf.c",
+ "musl/src/math/ilogbl.c",
+ "musl/src/math/__invtrigl.c",
+ "musl/src/math/j0.c",
+ "musl/src/math/j0f.c",
+ "musl/src/math/j1.c",
+ "musl/src/math/j1f.c",
+ "musl/src/math/jn.c",
+ "musl/src/math/jnf.c",
+ "musl/src/math/ldexp.c",
+ "musl/src/math/ldexpf.c",
+ "musl/src/math/ldexpl.c",
+ "musl/src/math/lgamma.c",
+ "musl/src/math/lgammaf.c",
+ "musl/src/math/lgammaf_r.c",
+ "musl/src/math/lgammal.c",
+ "musl/src/math/lgamma_r.c",
+ "musl/src/math/llrint.c",
+ "musl/src/math/llrintf.c",
+ "musl/src/math/llrintl.c",
+ "musl/src/math/llround.c",
+ "musl/src/math/llroundf.c",
+ "musl/src/math/llroundl.c",
+ "musl/src/math/log10.c",
+ "musl/src/math/log10f.c",
+ "musl/src/math/log10l.c",
+ "musl/src/math/log1p.c",
+ "musl/src/math/log1pf.c",
+ "musl/src/math/log1pl.c",
+ "musl/src/math/log2.c",
+ "musl/src/math/log2_data.c",
+ "musl/src/math/log2f.c",
+ "musl/src/math/log2f_data.c",
+ "musl/src/math/log2l.c",
+ "musl/src/math/logb.c",
+ "musl/src/math/logbf.c",
+ "musl/src/math/logbl.c",
+ "musl/src/math/log.c",
+ "musl/src/math/log_data.c",
+ "musl/src/math/logf.c",
+ "musl/src/math/logf_data.c",
+ "musl/src/math/logl.c",
+ "musl/src/math/lrint.c",
+ "musl/src/math/lrintf.c",
+ "musl/src/math/lrintl.c",
+ "musl/src/math/lround.c",
+ "musl/src/math/lroundf.c",
+ "musl/src/math/lroundl.c",
+ "musl/src/math/m68k/sqrtl.c",
+ "musl/src/math/__math_divzero.c",
+ "musl/src/math/__math_divzerof.c",
+ "musl/src/math/__math_invalid.c",
+ "musl/src/math/__math_invalidf.c",
+ "musl/src/math/__math_invalidl.c",
+ "musl/src/math/__math_oflow.c",
+ "musl/src/math/__math_oflowf.c",
+ "musl/src/math/__math_uflow.c",
+ "musl/src/math/__math_uflowf.c",
+ "musl/src/math/__math_xflow.c",
+ "musl/src/math/__math_xflowf.c",
+ "musl/src/math/mips/fabs.c",
+ "musl/src/math/mips/fabsf.c",
+ "musl/src/math/mips/sqrt.c",
+ "musl/src/math/mips/sqrtf.c",
+ "musl/src/math/modf.c",
+ "musl/src/math/modff.c",
+ "musl/src/math/modfl.c",
+ "musl/src/math/nan.c",
+ "musl/src/math/nanf.c",
+ "musl/src/math/nanl.c",
+ "musl/src/math/nearbyint.c",
+ "musl/src/math/nearbyintf.c",
+ "musl/src/math/nearbyintl.c",
+ "musl/src/math/nextafter.c",
+ "musl/src/math/nextafterf.c",
+ "musl/src/math/nextafterl.c",
+ "musl/src/math/nexttoward.c",
+ "musl/src/math/nexttowardf.c",
+ "musl/src/math/nexttowardl.c",
+ "musl/src/math/__polevll.c",
+ "musl/src/math/pow.c",
+ "musl/src/math/pow_data.c",
+ "musl/src/math/powerpc64/ceil.c",
+ "musl/src/math/powerpc64/ceilf.c",
+ "musl/src/math/powerpc64/fabs.c",
+ "musl/src/math/powerpc64/fabsf.c",
+ "musl/src/math/powerpc64/floor.c",
+ "musl/src/math/powerpc64/floorf.c",
+ "musl/src/math/powerpc64/fma.c",
+ "musl/src/math/powerpc64/fmaf.c",
+ "musl/src/math/powerpc64/fmax.c",
+ "musl/src/math/powerpc64/fmaxf.c",
+ "musl/src/math/powerpc64/fmin.c",
+ "musl/src/math/powerpc64/fminf.c",
+ "musl/src/math/powerpc64/lrint.c",
+ "musl/src/math/powerpc64/lrintf.c",
+ "musl/src/math/powerpc64/lround.c",
+ "musl/src/math/powerpc64/lroundf.c",
+ "musl/src/math/powerpc64/round.c",
+ "musl/src/math/powerpc64/roundf.c",
+ "musl/src/math/powerpc64/sqrt.c",
+ "musl/src/math/powerpc64/sqrtf.c",
+ "musl/src/math/powerpc64/trunc.c",
+ "musl/src/math/powerpc64/truncf.c",
+ "musl/src/math/powerpc/fabs.c",
+ "musl/src/math/powerpc/fabsf.c",
+ "musl/src/math/powerpc/fma.c",
+ "musl/src/math/powerpc/fmaf.c",
+ "musl/src/math/powerpc/sqrt.c",
+ "musl/src/math/powerpc/sqrtf.c",
+ "musl/src/math/powf.c",
+ "musl/src/math/powf_data.c",
+ "musl/src/math/powl.c",
+ "musl/src/math/remainder.c",
+ "musl/src/math/remainderf.c",
+ "musl/src/math/remainderl.c",
+ "musl/src/math/__rem_pio2.c",
+ "musl/src/math/__rem_pio2f.c",
+ "musl/src/math/__rem_pio2_large.c",
+ "musl/src/math/__rem_pio2l.c",
+ "musl/src/math/remquo.c",
+ "musl/src/math/remquof.c",
+ "musl/src/math/remquol.c",
+ "musl/src/math/rint.c",
+ "musl/src/math/rintf.c",
+ "musl/src/math/rintl.c",
+ "musl/src/math/riscv32/copysign.c",
+ "musl/src/math/riscv32/copysignf.c",
+ "musl/src/math/riscv32/fabs.c",
+ "musl/src/math/riscv32/fabsf.c",
+ "musl/src/math/riscv32/fma.c",
+ "musl/src/math/riscv32/fmaf.c",
+ "musl/src/math/riscv32/fmax.c",
+ "musl/src/math/riscv32/fmaxf.c",
+ "musl/src/math/riscv32/fmin.c",
+ "musl/src/math/riscv32/fminf.c",
+ "musl/src/math/riscv32/sqrt.c",
+ "musl/src/math/riscv32/sqrtf.c",
+ "musl/src/math/riscv64/copysign.c",
+ "musl/src/math/riscv64/copysignf.c",
+ "musl/src/math/riscv64/fabs.c",
+ "musl/src/math/riscv64/fabsf.c",
+ "musl/src/math/riscv64/fma.c",
+ "musl/src/math/riscv64/fmaf.c",
+ "musl/src/math/riscv64/fmax.c",
+ "musl/src/math/riscv64/fmaxf.c",
+ "musl/src/math/riscv64/fmin.c",
+ "musl/src/math/riscv64/fminf.c",
+ "musl/src/math/riscv64/sqrt.c",
+ "musl/src/math/riscv64/sqrtf.c",
+ "musl/src/math/round.c",
+ "musl/src/math/roundf.c",
+ "musl/src/math/roundl.c",
+ "musl/src/math/s390x/ceil.c",
+ "musl/src/math/s390x/ceilf.c",
+ "musl/src/math/s390x/ceill.c",
+ "musl/src/math/s390x/fabs.c",
+ "musl/src/math/s390x/fabsf.c",
+ "musl/src/math/s390x/fabsl.c",
+ "musl/src/math/s390x/floor.c",
+ "musl/src/math/s390x/floorf.c",
+ "musl/src/math/s390x/floorl.c",
+ "musl/src/math/s390x/fma.c",
+ "musl/src/math/s390x/fmaf.c",
+ "musl/src/math/s390x/nearbyint.c",
+ "musl/src/math/s390x/nearbyintf.c",
+ "musl/src/math/s390x/nearbyintl.c",
+ "musl/src/math/s390x/rint.c",
+ "musl/src/math/s390x/rintf.c",
+ "musl/src/math/s390x/rintl.c",
+ "musl/src/math/s390x/round.c",
+ "musl/src/math/s390x/roundf.c",
+ "musl/src/math/s390x/roundl.c",
+ "musl/src/math/s390x/sqrt.c",
+ "musl/src/math/s390x/sqrtf.c",
+ "musl/src/math/s390x/sqrtl.c",
+ "musl/src/math/s390x/trunc.c",
+ "musl/src/math/s390x/truncf.c",
+ "musl/src/math/s390x/truncl.c",
+ "musl/src/math/scalb.c",
+ "musl/src/math/scalbf.c",
+ "musl/src/math/scalbln.c",
+ "musl/src/math/scalblnf.c",
+ "musl/src/math/scalblnl.c",
+ "musl/src/math/scalbn.c",
+ "musl/src/math/scalbnf.c",
+ "musl/src/math/scalbnl.c",
+ "musl/src/math/__signbit.c",
+ "musl/src/math/__signbitf.c",
+ "musl/src/math/__signbitl.c",
+ "musl/src/math/signgam.c",
+ "musl/src/math/significand.c",
+ "musl/src/math/significandf.c",
+ "musl/src/math/__sin.c",
+ "musl/src/math/sin.c",
+ "musl/src/math/sincos.c",
+ "musl/src/math/sincosf.c",
+ "musl/src/math/sincosl.c",
+ "musl/src/math/__sindf.c",
+ "musl/src/math/sinf.c",
+ "musl/src/math/sinh.c",
+ "musl/src/math/sinhf.c",
+ "musl/src/math/sinhl.c",
+ "musl/src/math/__sinl.c",
+ "musl/src/math/sinl.c",
+ "musl/src/math/sqrt.c",
+ "musl/src/math/sqrt_data.c",
+ "musl/src/math/sqrtf.c",
+ "musl/src/math/sqrtl.c",
+ "musl/src/math/__tan.c",
+ "musl/src/math/tan.c",
+ "musl/src/math/__tandf.c",
+ "musl/src/math/tanf.c",
+ "musl/src/math/tanh.c",
+ "musl/src/math/tanhf.c",
+ "musl/src/math/tanhl.c",
+ "musl/src/math/__tanl.c",
+ "musl/src/math/tanl.c",
+ "musl/src/math/tgamma.c",
+ "musl/src/math/tgammaf.c",
+ "musl/src/math/tgammal.c",
+ "musl/src/math/trunc.c",
+ "musl/src/math/truncf.c",
+ "musl/src/math/truncl.c",
+ "musl/src/math/x32/acosl.s",
+ "musl/src/math/x32/asinl.s",
+ "musl/src/math/x32/atan2l.s",
+ "musl/src/math/x32/atanl.s",
+ "musl/src/math/x32/ceill.s",
+ "musl/src/math/x32/exp2l.s",
+ "musl/src/math/x32/expl.s",
+ "musl/src/math/x32/expm1l.s",
+ "musl/src/math/x32/fabsf.s",
+ "musl/src/math/x32/fabsl.s",
+ "musl/src/math/x32/fabs.s",
+ "musl/src/math/x32/floorl.s",
+ "musl/src/math/x32/fma.c",
+ "musl/src/math/x32/fmaf.c",
+ "musl/src/math/x32/fmodl.s",
+ "musl/src/math/x32/__invtrigl.s",
+ "musl/src/math/x32/llrintf.s",
+ "musl/src/math/x32/llrintl.s",
+ "musl/src/math/x32/llrint.s",
+ "musl/src/math/x32/log10l.s",
+ "musl/src/math/x32/log1pl.s",
+ "musl/src/math/x32/log2l.s",
+ "musl/src/math/x32/logl.s",
+ "musl/src/math/x32/lrintf.s",
+ "musl/src/math/x32/lrintl.s",
+ "musl/src/math/x32/lrint.s",
+ "musl/src/math/x32/remainderl.s",
+ "musl/src/math/x32/rintl.s",
+ "musl/src/math/x32/sqrtf.s",
+ "musl/src/math/x32/sqrtl.s",
+ "musl/src/math/x32/sqrt.s",
+ "musl/src/math/x32/truncl.s",
+ "musl/src/math/x86_64/acosl.s",
+ "musl/src/math/x86_64/asinl.s",
+ "musl/src/math/x86_64/atan2l.s",
+ "musl/src/math/x86_64/atanl.s",
+ "musl/src/math/x86_64/ceill.s",
+ "musl/src/math/x86_64/exp2l.s",
+ "musl/src/math/x86_64/expl.s",
+ "musl/src/math/x86_64/expm1l.s",
+ "musl/src/math/x86_64/fabs.c",
+ "musl/src/math/x86_64/fabsf.c",
+ "musl/src/math/x86_64/fabsl.c",
+ "musl/src/math/x86_64/floorl.s",
+ "musl/src/math/x86_64/fma.c",
+ "musl/src/math/x86_64/fmaf.c",
+ "musl/src/math/x86_64/fmodl.c",
+ "musl/src/math/x86_64/__invtrigl.s",
+ "musl/src/math/x86_64/llrint.c",
+ "musl/src/math/x86_64/llrintf.c",
+ "musl/src/math/x86_64/llrintl.c",
+ "musl/src/math/x86_64/log10l.s",
+ "musl/src/math/x86_64/log1pl.s",
+ "musl/src/math/x86_64/log2l.s",
+ "musl/src/math/x86_64/logl.s",
+ "musl/src/math/x86_64/lrint.c",
+ "musl/src/math/x86_64/lrintf.c",
+ "musl/src/math/x86_64/lrintl.c",
+ "musl/src/math/x86_64/remainderl.c",
+ "musl/src/math/x86_64/remquol.c",
+ "musl/src/math/x86_64/rintl.c",
+ "musl/src/math/x86_64/sqrt.c",
+ "musl/src/math/x86_64/sqrtf.c",
+ "musl/src/math/x86_64/sqrtl.c",
+ "musl/src/math/x86_64/truncl.s",
+ "musl/src/misc/a64l.c",
+ "musl/src/misc/basename.c",
+ "musl/src/misc/dirname.c",
+ "musl/src/misc/ffs.c",
+ "musl/src/misc/ffsl.c",
+ "musl/src/misc/ffsll.c",
+ "musl/src/misc/fmtmsg.c",
+ "musl/src/misc/forkpty.c",
+ "musl/src/misc/getauxval.c",
+ "musl/src/misc/get_current_dir_name.c",
+ "musl/src/misc/getdomainname.c",
+ "musl/src/misc/getentropy.c",
+ "musl/src/misc/gethostid.c",
+ "musl/src/misc/getopt.c",
+ "musl/src/misc/getopt_long.c",
+ "musl/src/misc/getpriority.c",
+ "musl/src/misc/getresgid.c",
+ "musl/src/misc/getresuid.c",
+ "musl/src/misc/getrlimit.c",
+ "musl/src/misc/getrusage.c",
+ "musl/src/misc/getsubopt.c",
+ "musl/src/misc/initgroups.c",
+ "musl/src/misc/ioctl.c",
+ "musl/src/misc/issetugid.c",
+ "musl/src/misc/lockf.c",
+ "musl/src/misc/login_tty.c",
+ "musl/src/misc/mntent.c",
+ "musl/src/misc/nftw.c",
+ "musl/src/misc/openpty.c",
+ "musl/src/misc/ptsname.c",
+ "musl/src/misc/pty.c",
+ "musl/src/misc/realpath.c",
+ "musl/src/misc/setdomainname.c",
+ "musl/src/misc/setpriority.c",
+ "musl/src/misc/setrlimit.c",
+ "musl/src/misc/syscall.c",
+ "musl/src/misc/syslog.c",
+ "musl/src/misc/uname.c",
+ "musl/src/misc/wordexp.c",
+ "musl/src/mman/madvise.c",
+ "musl/src/mman/mincore.c",
+ "musl/src/mman/mlockall.c",
+ "musl/src/mman/mlock.c",
+ "musl/src/mman/mmap.c",
+ "musl/src/mman/mprotect.c",
+ "musl/src/mman/mremap.c",
+ "musl/src/mman/msync.c",
+ "musl/src/mman/munlockall.c",
+ "musl/src/mman/munlock.c",
+ "musl/src/mman/munmap.c",
+ "musl/src/mman/posix_madvise.c",
+ "musl/src/mman/shm_open.c",
+ "musl/src/mq/mq_close.c",
+ "musl/src/mq/mq_getattr.c",
+ "musl/src/mq/mq_notify.c",
+ "musl/src/mq/mq_open.c",
+ "musl/src/mq/mq_receive.c",
+ "musl/src/mq/mq_send.c",
+ "musl/src/mq/mq_setattr.c",
+ "musl/src/mq/mq_timedreceive.c",
+ "musl/src/mq/mq_timedsend.c",
+ "musl/src/mq/mq_unlink.c",
+ "musl/src/multibyte/btowc.c",
+ "musl/src/multibyte/c16rtomb.c",
+ "musl/src/multibyte/c32rtomb.c",
+ "musl/src/multibyte/internal.c",
+ "musl/src/multibyte/mblen.c",
+ "musl/src/multibyte/mbrlen.c",
+ "musl/src/multibyte/mbrtoc16.c",
+ "musl/src/multibyte/mbrtoc32.c",
+ "musl/src/multibyte/mbrtowc.c",
+ "musl/src/multibyte/mbsinit.c",
+ "musl/src/multibyte/mbsnrtowcs.c",
+ "musl/src/multibyte/mbsrtowcs.c",
+ "musl/src/multibyte/mbstowcs.c",
+ "musl/src/multibyte/mbtowc.c",
+ "musl/src/multibyte/wcrtomb.c",
+ "musl/src/multibyte/wcsnrtombs.c",
+ "musl/src/multibyte/wcsrtombs.c",
+ "musl/src/multibyte/wcstombs.c",
+ "musl/src/multibyte/wctob.c",
+ "musl/src/multibyte/wctomb.c",
+ "musl/src/network/accept4.c",
+ "musl/src/network/accept.c",
+ "musl/src/network/bind.c",
+ "musl/src/network/connect.c",
+ "musl/src/network/dn_comp.c",
+ "musl/src/network/dn_expand.c",
+ "musl/src/network/dn_skipname.c",
+ "musl/src/network/dns_parse.c",
+ "musl/src/network/ent.c",
+ "musl/src/network/ether.c",
+ "musl/src/network/freeaddrinfo.c",
+ "musl/src/network/gai_strerror.c",
+ "musl/src/network/getaddrinfo.c",
+ "musl/src/network/gethostbyaddr.c",
+ "musl/src/network/gethostbyaddr_r.c",
+ "musl/src/network/gethostbyname2.c",
+ "musl/src/network/gethostbyname2_r.c",
+ "musl/src/network/gethostbyname.c",
+ "musl/src/network/gethostbyname_r.c",
+ "musl/src/network/getifaddrs.c",
+ "musl/src/network/getnameinfo.c",
+ "musl/src/network/getpeername.c",
+ "musl/src/network/getservbyname.c",
+ "musl/src/network/getservbyname_r.c",
+ "musl/src/network/getservbyport.c",
+ "musl/src/network/getservbyport_r.c",
+ "musl/src/network/getsockname.c",
+ "musl/src/network/getsockopt.c",
+ "musl/src/network/h_errno.c",
+ "musl/src/network/herror.c",
+ "musl/src/network/hstrerror.c",
+ "musl/src/network/htonl.c",
+ "musl/src/network/htons.c",
+ "musl/src/network/if_freenameindex.c",
+ "musl/src/network/if_indextoname.c",
+ "musl/src/network/if_nameindex.c",
+ "musl/src/network/if_nametoindex.c",
+ "musl/src/network/in6addr_any.c",
+ "musl/src/network/in6addr_loopback.c",
+ "musl/src/network/inet_addr.c",
+ "musl/src/network/inet_aton.c",
+ "musl/src/network/inet_legacy.c",
+ "musl/src/network/inet_ntoa.c",
+ "musl/src/network/inet_ntop.c",
+ "musl/src/network/inet_pton.c",
+ "musl/src/network/listen.c",
+ "musl/src/network/lookup_ipliteral.c",
+ "musl/src/network/lookup_name.c",
+ "musl/src/network/lookup_serv.c",
+ "musl/src/network/netlink.c",
+ "musl/src/network/netname.c",
+ "musl/src/network/ns_parse.c",
+ "musl/src/network/ntohl.c",
+ "musl/src/network/ntohs.c",
+ "musl/src/network/proto.c",
+ "musl/src/network/recv.c",
+ "musl/src/network/recvfrom.c",
+ "musl/src/network/recvmmsg.c",
+ "musl/src/network/recvmsg.c",
+ "musl/src/network/res_init.c",
+ "musl/src/network/res_mkquery.c",
+ "musl/src/network/res_msend.c",
+ "musl/src/network/resolvconf.c",
+ "musl/src/network/res_query.c",
+ "musl/src/network/res_querydomain.c",
+ "musl/src/network/res_send.c",
+ "musl/src/network/res_state.c",
+ "musl/src/network/send.c",
+ "musl/src/network/sendmmsg.c",
+ "musl/src/network/sendmsg.c",
+ "musl/src/network/sendto.c",
+ "musl/src/network/serv.c",
+ "musl/src/network/setsockopt.c",
+ "musl/src/network/shutdown.c",
+ "musl/src/network/sockatmark.c",
+ "musl/src/network/socket.c",
+ "musl/src/network/socketpair.c",
+ "musl/src/passwd/fgetgrent.c",
+ "musl/src/passwd/fgetpwent.c",
+ "musl/src/passwd/fgetspent.c",
+ "musl/src/passwd/getgr_a.c",
+ "musl/src/passwd/getgrent_a.c",
+ "musl/src/passwd/getgrent.c",
+ "musl/src/passwd/getgrouplist.c",
+ "musl/src/passwd/getgr_r.c",
+ "musl/src/passwd/getpw_a.c",
+ "musl/src/passwd/getpwent_a.c",
+ "musl/src/passwd/getpwent.c",
+ "musl/src/passwd/getpw_r.c",
+ "musl/src/passwd/getspent.c",
+ "musl/src/passwd/getspnam.c",
+ "musl/src/passwd/getspnam_r.c",
+ "musl/src/passwd/lckpwdf.c",
+ "musl/src/passwd/nscd_query.c",
+ "musl/src/passwd/putgrent.c",
+ "musl/src/passwd/putpwent.c",
+ "musl/src/passwd/putspent.c",
+ "musl/src/prng/drand48.c",
+ "musl/src/prng/lcong48.c",
+ "musl/src/prng/lrand48.c",
+ "musl/src/prng/mrand48.c",
+ "musl/src/prng/__rand48_step.c",
+ "musl/src/prng/rand.c",
+ "musl/src/prng/random.c",
+ "musl/src/prng/rand_r.c",
+ "musl/src/prng/__seed48.c",
+ "musl/src/prng/seed48.c",
+ "musl/src/prng/srand48.c",
+ "musl/src/process/aarch64/vfork.s",
+ "musl/src/process/arm/vfork.s",
+ "musl/src/process/execl.c",
+ "musl/src/process/execle.c",
+ "musl/src/process/execlp.c",
+ "musl/src/process/execv.c",
+ "musl/src/process/execve.c",
+ "musl/src/process/execvp.c",
+ "musl/src/process/fexecve.c",
+ "musl/src/process/fork.c",
+ "musl/src/process/_Fork.c",
+ "musl/src/process/i386/vfork.s",
+ "musl/src/process/posix_spawnattr_destroy.c",
+ "musl/src/process/posix_spawnattr_getflags.c",
+ "musl/src/process/posix_spawnattr_getpgroup.c",
+ "musl/src/process/posix_spawnattr_getsigdefault.c",
+ "musl/src/process/posix_spawnattr_getsigmask.c",
+ "musl/src/process/posix_spawnattr_init.c",
+ "musl/src/process/posix_spawnattr_sched.c",
+ "musl/src/process/posix_spawnattr_setflags.c",
+ "musl/src/process/posix_spawnattr_setpgroup.c",
+ "musl/src/process/posix_spawnattr_setsigdefault.c",
+ "musl/src/process/posix_spawnattr_setsigmask.c",
+ "musl/src/process/posix_spawn.c",
+ "musl/src/process/posix_spawn_file_actions_addchdir.c",
+ "musl/src/process/posix_spawn_file_actions_addclose.c",
+ "musl/src/process/posix_spawn_file_actions_adddup2.c",
+ "musl/src/process/posix_spawn_file_actions_addfchdir.c",
+ "musl/src/process/posix_spawn_file_actions_addopen.c",
+ "musl/src/process/posix_spawn_file_actions_destroy.c",
+ "musl/src/process/posix_spawn_file_actions_init.c",
+ "musl/src/process/posix_spawnp.c",
+ "musl/src/process/riscv64/vfork.s",
+ "musl/src/process/s390x/vfork.s",
+ "musl/src/process/system.c",
+ "musl/src/process/vfork.c",
+ "musl/src/process/wait.c",
+ "musl/src/process/waitid.c",
+ "musl/src/process/waitpid.c",
+ "musl/src/process/x32/vfork.s",
+ "musl/src/process/x86_64/vfork.s",
+ "musl/src/regex/fnmatch.c",
+ "musl/src/regex/glob.c",
+ "musl/src/regex/regcomp.c",
+ "musl/src/regex/regerror.c",
+ "musl/src/regex/regexec.c",
+ "musl/src/regex/tre-mem.c",
+ "musl/src/sched/affinity.c",
+ "musl/src/sched/sched_cpucount.c",
+ "musl/src/sched/sched_getcpu.c",
+ "musl/src/sched/sched_getparam.c",
+ "musl/src/sched/sched_get_priority_max.c",
+ "musl/src/sched/sched_getscheduler.c",
+ "musl/src/sched/sched_rr_get_interval.c",
+ "musl/src/sched/sched_setparam.c",
+ "musl/src/sched/sched_setscheduler.c",
+ "musl/src/sched/sched_yield.c",
+ "musl/src/search/hsearch.c",
+ "musl/src/search/insque.c",
+ "musl/src/search/lsearch.c",
+ "musl/src/search/tdelete.c",
+ "musl/src/search/tdestroy.c",
+ "musl/src/search/tfind.c",
+ "musl/src/search/tsearch.c",
+ "musl/src/search/twalk.c",
+ "musl/src/select/poll.c",
+ "musl/src/select/ppoll.c",
+ "musl/src/select/pselect.c",
+ "musl/src/select/select.c",
+ "musl/src/setjmp/aarch64/longjmp.s",
+ "musl/src/setjmp/aarch64/setjmp.s",
+ "musl/src/setjmp/arm/longjmp.S",
+ "musl/src/setjmp/arm/setjmp.S",
+ "musl/src/setjmp/hexagon/longjmp.s",
+ "musl/src/setjmp/hexagon/setjmp.s",
+ "musl/src/setjmp/i386/longjmp.s",
+ "musl/src/setjmp/i386/setjmp.s",
+ "musl/src/setjmp/longjmp.c",
+ "musl/src/setjmp/loongarch64/longjmp.S",
+ "musl/src/setjmp/loongarch64/setjmp.S",
+ "musl/src/setjmp/m68k/longjmp.s",
+ "musl/src/setjmp/m68k/setjmp.s",
+ "musl/src/setjmp/mips64/longjmp.S",
+ "musl/src/setjmp/mips64/setjmp.S",
+ "musl/src/setjmp/mips/longjmp.S",
+ "musl/src/setjmp/mipsn32/longjmp.S",
+ "musl/src/setjmp/mipsn32/setjmp.S",
+ "musl/src/setjmp/mips/setjmp.S",
+ "musl/src/setjmp/powerpc64/longjmp.s",
+ "musl/src/setjmp/powerpc64/setjmp.s",
+ "musl/src/setjmp/powerpc/longjmp.S",
+ "musl/src/setjmp/powerpc/setjmp.S",
+ "musl/src/setjmp/riscv32/longjmp.S",
+ "musl/src/setjmp/riscv32/setjmp.S",
+ "musl/src/setjmp/riscv64/longjmp.S",
+ "musl/src/setjmp/riscv64/setjmp.S",
+ "musl/src/setjmp/s390x/longjmp.s",
+ "musl/src/setjmp/s390x/setjmp.s",
+ "musl/src/setjmp/setjmp.c",
+ "musl/src/setjmp/x32/longjmp.s",
+ "musl/src/setjmp/x32/setjmp.s",
+ "musl/src/setjmp/x86_64/longjmp.s",
+ "musl/src/setjmp/x86_64/setjmp.s",
+ "musl/src/signal/aarch64/restore.s",
+ "musl/src/signal/aarch64/sigsetjmp.s",
+ "musl/src/signal/arm/restore.s",
+ "musl/src/signal/arm/sigsetjmp.s",
+ "musl/src/signal/block.c",
+ "musl/src/signal/getitimer.c",
+ "musl/src/signal/hexagon/restore.s",
+ "musl/src/signal/hexagon/sigsetjmp.s",
+ "musl/src/signal/i386/restore.s",
+ "musl/src/signal/i386/sigsetjmp.s",
+ "musl/src/signal/kill.c",
+ "musl/src/signal/killpg.c",
+ "musl/src/signal/loongarch64/restore.s",
+ "musl/src/signal/loongarch64/sigsetjmp.s",
+ "musl/src/signal/m68k/sigsetjmp.s",
+ "musl/src/signal/mips64/sigsetjmp.s",
+ "musl/src/signal/mipsn32/sigsetjmp.s",
+ "musl/src/signal/mips/sigsetjmp.s",
+ "musl/src/signal/powerpc64/restore.s",
+ "musl/src/signal/powerpc64/sigsetjmp.s",
+ "musl/src/signal/powerpc/restore.s",
+ "musl/src/signal/powerpc/sigsetjmp.s",
+ "musl/src/signal/psiginfo.c",
+ "musl/src/signal/psignal.c",
+ "musl/src/signal/raise.c",
+ "musl/src/signal/restore.c",
+ "musl/src/signal/riscv32/restore.s",
+ "musl/src/signal/riscv32/sigsetjmp.s",
+ "musl/src/signal/riscv64/restore.s",
+ "musl/src/signal/riscv64/sigsetjmp.s",
+ "musl/src/signal/s390x/restore.s",
+ "musl/src/signal/s390x/sigsetjmp.s",
+ "musl/src/signal/setitimer.c",
+ "musl/src/signal/sigaction.c",
+ "musl/src/signal/sigaddset.c",
+ "musl/src/signal/sigaltstack.c",
+ "musl/src/signal/sigandset.c",
+ "musl/src/signal/sigdelset.c",
+ "musl/src/signal/sigemptyset.c",
+ "musl/src/signal/sigfillset.c",
+ "musl/src/signal/sighold.c",
+ "musl/src/signal/sigignore.c",
+ "musl/src/signal/siginterrupt.c",
+ "musl/src/signal/sigisemptyset.c",
+ "musl/src/signal/sigismember.c",
+ "musl/src/signal/siglongjmp.c",
+ "musl/src/signal/signal.c",
+ "musl/src/signal/sigorset.c",
+ "musl/src/signal/sigpause.c",
+ "musl/src/signal/sigpending.c",
+ "musl/src/signal/sigprocmask.c",
+ "musl/src/signal/sigqueue.c",
+ "musl/src/signal/sigrelse.c",
+ "musl/src/signal/sigrtmax.c",
+ "musl/src/signal/sigrtmin.c",
+ "musl/src/signal/sigset.c",
+ "musl/src/signal/sigsetjmp.c",
+ "musl/src/signal/sigsetjmp_tail.c",
+ "musl/src/signal/sigsuspend.c",
+ "musl/src/signal/sigtimedwait.c",
+ "musl/src/signal/sigwait.c",
+ "musl/src/signal/sigwaitinfo.c",
+ "musl/src/signal/x32/getitimer.c",
+ "musl/src/signal/x32/restore.s",
+ "musl/src/signal/x32/setitimer.c",
+ "musl/src/signal/x32/sigsetjmp.s",
+ "musl/src/signal/x86_64/restore.s",
+ "musl/src/signal/x86_64/sigsetjmp.s",
+ "musl/src/stat/chmod.c",
+ "musl/src/stat/fchmodat.c",
+ "musl/src/stat/fchmod.c",
+ "musl/src/stat/fstatat.c",
+ "musl/src/stat/fstat.c",
+ "musl/src/stat/futimens.c",
+ "musl/src/stat/futimesat.c",
+ "musl/src/stat/lchmod.c",
+ "musl/src/stat/lstat.c",
+ "musl/src/stat/mkdirat.c",
+ "musl/src/stat/mkdir.c",
+ "musl/src/stat/mkfifoat.c",
+ "musl/src/stat/mkfifo.c",
+ "musl/src/stat/mknodat.c",
+ "musl/src/stat/mknod.c",
+ "musl/src/stat/stat.c",
+ "musl/src/stat/statvfs.c",
+ "musl/src/stat/umask.c",
+ "musl/src/stat/utimensat.c",
+ "musl/src/stat/__xstat.c",
+ "musl/src/stdio/asprintf.c",
+ "musl/src/stdio/clearerr.c",
+ "musl/src/stdio/dprintf.c",
+ "musl/src/stdio/ext2.c",
+ "musl/src/stdio/ext.c",
+ "musl/src/stdio/fclose.c",
+ "musl/src/stdio/__fclose_ca.c",
+ "musl/src/stdio/__fdopen.c",
+ "musl/src/stdio/feof.c",
+ "musl/src/stdio/ferror.c",
+ "musl/src/stdio/fflush.c",
+ "musl/src/stdio/fgetc.c",
+ "musl/src/stdio/fgetln.c",
+ "musl/src/stdio/fgetpos.c",
+ "musl/src/stdio/fgets.c",
+ "musl/src/stdio/fgetwc.c",
+ "musl/src/stdio/fgetws.c",
+ "musl/src/stdio/fileno.c",
+ "musl/src/stdio/flockfile.c",
+ "musl/src/stdio/fmemopen.c",
+ "musl/src/stdio/__fmodeflags.c",
+ "musl/src/stdio/fopen.c",
+ "musl/src/stdio/fopencookie.c",
+ "musl/src/stdio/__fopen_rb_ca.c",
+ "musl/src/stdio/fprintf.c",
+ "musl/src/stdio/fputc.c",
+ "musl/src/stdio/fputs.c",
+ "musl/src/stdio/fputwc.c",
+ "musl/src/stdio/fputws.c",
+ "musl/src/stdio/fread.c",
+ "musl/src/stdio/freopen.c",
+ "musl/src/stdio/fscanf.c",
+ "musl/src/stdio/fseek.c",
+ "musl/src/stdio/fsetpos.c",
+ "musl/src/stdio/ftell.c",
+ "musl/src/stdio/ftrylockfile.c",
+ "musl/src/stdio/funlockfile.c",
+ "musl/src/stdio/fwide.c",
+ "musl/src/stdio/fwprintf.c",
+ "musl/src/stdio/fwrite.c",
+ "musl/src/stdio/fwscanf.c",
+ "musl/src/stdio/getc.c",
+ "musl/src/stdio/getchar.c",
+ "musl/src/stdio/getchar_unlocked.c",
+ "musl/src/stdio/getc_unlocked.c",
+ "musl/src/stdio/getdelim.c",
+ "musl/src/stdio/getline.c",
+ "musl/src/stdio/gets.c",
+ "musl/src/stdio/getw.c",
+ "musl/src/stdio/getwc.c",
+ "musl/src/stdio/getwchar.c",
+ "musl/src/stdio/__lockfile.c",
+ "musl/src/stdio/ofl_add.c",
+ "musl/src/stdio/ofl.c",
+ "musl/src/stdio/open_memstream.c",
+ "musl/src/stdio/open_wmemstream.c",
+ "musl/src/stdio/__overflow.c",
+ "musl/src/stdio/pclose.c",
+ "musl/src/stdio/perror.c",
+ "musl/src/stdio/popen.c",
+ "musl/src/stdio/printf.c",
+ "musl/src/stdio/putc.c",
+ "musl/src/stdio/putchar.c",
+ "musl/src/stdio/putchar_unlocked.c",
+ "musl/src/stdio/putc_unlocked.c",
+ "musl/src/stdio/puts.c",
+ "musl/src/stdio/putw.c",
+ "musl/src/stdio/putwc.c",
+ "musl/src/stdio/putwchar.c",
+ "musl/src/stdio/remove.c",
+ "musl/src/stdio/rename.c",
+ "musl/src/stdio/rewind.c",
+ "musl/src/stdio/scanf.c",
+ "musl/src/stdio/setbuf.c",
+ "musl/src/stdio/setbuffer.c",
+ "musl/src/stdio/setlinebuf.c",
+ "musl/src/stdio/setvbuf.c",
+ "musl/src/stdio/snprintf.c",
+ "musl/src/stdio/sprintf.c",
+ "musl/src/stdio/sscanf.c",
+ "musl/src/stdio/stderr.c",
+ "musl/src/stdio/stdin.c",
+ "musl/src/stdio/__stdio_close.c",
+ "musl/src/stdio/__stdio_exit.c",
+ "musl/src/stdio/__stdio_read.c",
+ "musl/src/stdio/__stdio_seek.c",
+ "musl/src/stdio/__stdio_write.c",
+ "musl/src/stdio/stdout.c",
+ "musl/src/stdio/__stdout_write.c",
+ "musl/src/stdio/swprintf.c",
+ "musl/src/stdio/swscanf.c",
+ "musl/src/stdio/tempnam.c",
+ "musl/src/stdio/tmpfile.c",
+ "musl/src/stdio/tmpnam.c",
+ "musl/src/stdio/__toread.c",
+ "musl/src/stdio/__towrite.c",
+ "musl/src/stdio/__uflow.c",
+ "musl/src/stdio/ungetc.c",
+ "musl/src/stdio/ungetwc.c",
+ "musl/src/stdio/vasprintf.c",
+ "musl/src/stdio/vdprintf.c",
+ "musl/src/stdio/vfprintf.c",
+ "musl/src/stdio/vfscanf.c",
+ "musl/src/stdio/vfwprintf.c",
+ "musl/src/stdio/vfwscanf.c",
+ "musl/src/stdio/vprintf.c",
+ "musl/src/stdio/vscanf.c",
+ "musl/src/stdio/vsnprintf.c",
+ "musl/src/stdio/vsprintf.c",
+ "musl/src/stdio/vsscanf.c",
+ "musl/src/stdio/vswprintf.c",
+ "musl/src/stdio/vswscanf.c",
+ "musl/src/stdio/vwprintf.c",
+ "musl/src/stdio/vwscanf.c",
+ "musl/src/stdio/wprintf.c",
+ "musl/src/stdio/wscanf.c",
+ "musl/src/stdlib/abs.c",
+ "musl/src/stdlib/atof.c",
+ "musl/src/stdlib/atoi.c",
+ "musl/src/stdlib/atol.c",
+ "musl/src/stdlib/atoll.c",
+ "musl/src/stdlib/bsearch.c",
+ "musl/src/stdlib/div.c",
+ "musl/src/stdlib/ecvt.c",
+ "musl/src/stdlib/fcvt.c",
+ "musl/src/stdlib/gcvt.c",
+ "musl/src/stdlib/imaxabs.c",
+ "musl/src/stdlib/imaxdiv.c",
+ "musl/src/stdlib/labs.c",
+ "musl/src/stdlib/ldiv.c",
+ "musl/src/stdlib/llabs.c",
+ "musl/src/stdlib/lldiv.c",
+ "musl/src/stdlib/qsort.c",
+ "musl/src/stdlib/qsort_nr.c",
+ "musl/src/stdlib/strtod.c",
+ "musl/src/stdlib/strtol.c",
+ "musl/src/stdlib/wcstod.c",
+ "musl/src/stdlib/wcstol.c",
+ "musl/src/string/aarch64/memset.S",
+ "musl/src/string/arm/__aeabi_memset.s",
+ "musl/src/string/bcmp.c",
+ "musl/src/string/bcopy.c",
+ "musl/src/string/explicit_bzero.c",
+ "musl/src/string/i386/memset.s",
+ "musl/src/string/index.c",
+ "musl/src/string/memccpy.c",
+ "musl/src/string/memchr.c",
+ "musl/src/string/memcmp.c",
+ "musl/src/string/memmem.c",
+ "musl/src/string/mempcpy.c",
+ "musl/src/string/memrchr.c",
+ "musl/src/string/memset.c",
+ "musl/src/string/rindex.c",
+ "musl/src/string/stpcpy.c",
+ "musl/src/string/stpncpy.c",
+ "musl/src/string/strcasecmp.c",
+ "musl/src/string/strcasestr.c",
+ "musl/src/string/strcat.c",
+ "musl/src/string/strchr.c",
+ "musl/src/string/strchrnul.c",
+ "musl/src/string/strcpy.c",
+ "musl/src/string/strcspn.c",
+ "musl/src/string/strdup.c",
+ "musl/src/string/strerror_r.c",
+ "musl/src/string/strlcat.c",
+ "musl/src/string/strlcpy.c",
+ "musl/src/string/strncasecmp.c",
+ "musl/src/string/strncat.c",
+ "musl/src/string/strncpy.c",
+ "musl/src/string/strndup.c",
+ "musl/src/string/strnlen.c",
+ "musl/src/string/strpbrk.c",
+ "musl/src/string/strrchr.c",
+ "musl/src/string/strsep.c",
+ "musl/src/string/strsignal.c",
+ "musl/src/string/strspn.c",
+ "musl/src/string/strstr.c",
+ "musl/src/string/strtok.c",
+ "musl/src/string/strtok_r.c",
+ "musl/src/string/strverscmp.c",
+ "musl/src/string/swab.c",
+ "musl/src/string/wcpcpy.c",
+ "musl/src/string/wcpncpy.c",
+ "musl/src/string/wcscasecmp.c",
+ "musl/src/string/wcscasecmp_l.c",
+ "musl/src/string/wcscat.c",
+ "musl/src/string/wcschr.c",
+ "musl/src/string/wcscmp.c",
+ "musl/src/string/wcscpy.c",
+ "musl/src/string/wcscspn.c",
+ "musl/src/string/wcsdup.c",
+ "musl/src/string/wcslen.c",
+ "musl/src/string/wcsncasecmp.c",
+ "musl/src/string/wcsncasecmp_l.c",
+ "musl/src/string/wcsncat.c",
+ "musl/src/string/wcsncmp.c",
+ "musl/src/string/wcsncpy.c",
+ "musl/src/string/wcsnlen.c",
+ "musl/src/string/wcspbrk.c",
+ "musl/src/string/wcsrchr.c",
+ "musl/src/string/wcsspn.c",
+ "musl/src/string/wcsstr.c",
+ "musl/src/string/wcstok.c",
+ "musl/src/string/wcswcs.c",
+ "musl/src/string/wmemchr.c",
+ "musl/src/string/wmemcmp.c",
+ "musl/src/string/wmemcpy.c",
+ "musl/src/string/wmemmove.c",
+ "musl/src/string/wmemset.c",
+ "musl/src/string/x86_64/memset.s",
+ "musl/src/temp/mkdtemp.c",
+ "musl/src/temp/mkostemp.c",
+ "musl/src/temp/mkostemps.c",
+ "musl/src/temp/mkstemp.c",
+ "musl/src/temp/mkstemps.c",
+ "musl/src/temp/mktemp.c",
+ "musl/src/temp/__randname.c",
+ "musl/src/termios/cfgetospeed.c",
+ "musl/src/termios/cfmakeraw.c",
+ "musl/src/termios/cfsetospeed.c",
+ "musl/src/termios/tcdrain.c",
+ "musl/src/termios/tcflow.c",
+ "musl/src/termios/tcflush.c",
+ "musl/src/termios/tcgetattr.c",
+ "musl/src/termios/tcgetsid.c",
+ "musl/src/termios/tcgetwinsize.c",
+ "musl/src/termios/tcsendbreak.c",
+ "musl/src/termios/tcsetattr.c",
+ "musl/src/termios/tcsetwinsize.c",
+ "musl/src/thread/aarch64/clone.s",
+ "musl/src/thread/aarch64/__set_thread_area.s",
+ "musl/src/thread/aarch64/syscall_cp.s",
+ "musl/src/thread/aarch64/__unmapself.s",
+ "musl/src/thread/arm/__aeabi_read_tp.s",
+ "musl/src/thread/arm/atomics.s",
+ "musl/src/thread/arm/clone.s",
+ "musl/src/thread/arm/__set_thread_area.c",
+ "musl/src/thread/arm/syscall_cp.s",
+ "musl/src/thread/arm/__unmapself.s",
+ "musl/src/thread/call_once.c",
+ "musl/src/thread/clone.c",
+ "musl/src/thread/cnd_broadcast.c",
+ "musl/src/thread/cnd_destroy.c",
+ "musl/src/thread/cnd_init.c",
+ "musl/src/thread/cnd_signal.c",
+ "musl/src/thread/cnd_timedwait.c",
+ "musl/src/thread/cnd_wait.c",
+ "musl/src/thread/default_attr.c",
+ "musl/src/thread/hexagon/clone.s",
+ "musl/src/thread/hexagon/__set_thread_area.s",
+ "musl/src/thread/hexagon/syscall_cp.s",
+ "musl/src/thread/hexagon/__unmapself.s",
+ "musl/src/thread/i386/clone.s",
+ "musl/src/thread/i386/__set_thread_area.s",
+ "musl/src/thread/i386/syscall_cp.s",
+ "musl/src/thread/i386/tls.s",
+ "musl/src/thread/i386/__unmapself.s",
+ "musl/src/thread/__lock.c",
+ "musl/src/thread/lock_ptc.c",
+ "musl/src/thread/loongarch64/clone.s",
+ "musl/src/thread/loongarch64/__set_thread_area.s",
+ "musl/src/thread/loongarch64/syscall_cp.s",
+ "musl/src/thread/loongarch64/__unmapself.s",
+ "musl/src/thread/m68k/clone.s",
+ "musl/src/thread/m68k/__m68k_read_tp.s",
+ "musl/src/thread/m68k/syscall_cp.s",
+ "musl/src/thread/mips64/clone.s",
+ "musl/src/thread/mips64/syscall_cp.s",
+ "musl/src/thread/mips64/__unmapself.s",
+ "musl/src/thread/mips/clone.s",
+ "musl/src/thread/mipsn32/clone.s",
+ "musl/src/thread/mipsn32/syscall_cp.s",
+ "musl/src/thread/mipsn32/__unmapself.s",
+ "musl/src/thread/mips/syscall_cp.s",
+ "musl/src/thread/mips/__unmapself.s",
+ "musl/src/thread/mtx_destroy.c",
+ "musl/src/thread/mtx_init.c",
+ "musl/src/thread/mtx_lock.c",
+ "musl/src/thread/mtx_timedlock.c",
+ "musl/src/thread/mtx_trylock.c",
+ "musl/src/thread/mtx_unlock.c",
+ "musl/src/thread/powerpc64/clone.s",
+ "musl/src/thread/powerpc64/__set_thread_area.s",
+ "musl/src/thread/powerpc64/syscall_cp.s",
+ "musl/src/thread/powerpc64/__unmapself.s",
+ "musl/src/thread/powerpc/clone.s",
+ "musl/src/thread/powerpc/__set_thread_area.s",
+ "musl/src/thread/powerpc/syscall_cp.s",
+ "musl/src/thread/powerpc/__unmapself.s",
+ "musl/src/thread/pthread_atfork.c",
+ "musl/src/thread/pthread_attr_destroy.c",
+ "musl/src/thread/pthread_attr_get.c",
+ "musl/src/thread/pthread_attr_init.c",
+ "musl/src/thread/pthread_attr_setdetachstate.c",
+ "musl/src/thread/pthread_attr_setguardsize.c",
+ "musl/src/thread/pthread_attr_setinheritsched.c",
+ "musl/src/thread/pthread_attr_setschedparam.c",
+ "musl/src/thread/pthread_attr_setschedpolicy.c",
+ "musl/src/thread/pthread_attr_setscope.c",
+ "musl/src/thread/pthread_attr_setstack.c",
+ "musl/src/thread/pthread_attr_setstacksize.c",
+ "musl/src/thread/pthread_barrierattr_destroy.c",
+ "musl/src/thread/pthread_barrierattr_init.c",
+ "musl/src/thread/pthread_barrierattr_setpshared.c",
+ "musl/src/thread/pthread_barrier_destroy.c",
+ "musl/src/thread/pthread_barrier_init.c",
+ "musl/src/thread/pthread_barrier_wait.c",
+ "musl/src/thread/pthread_cancel.c",
+ "musl/src/thread/pthread_cleanup_push.c",
+ "musl/src/thread/pthread_condattr_destroy.c",
+ "musl/src/thread/pthread_condattr_init.c",
+ "musl/src/thread/pthread_condattr_setclock.c",
+ "musl/src/thread/pthread_condattr_setpshared.c",
+ "musl/src/thread/pthread_cond_broadcast.c",
+ "musl/src/thread/pthread_cond_destroy.c",
+ "musl/src/thread/pthread_cond_init.c",
+ "musl/src/thread/pthread_cond_signal.c",
+ "musl/src/thread/pthread_cond_timedwait.c",
+ "musl/src/thread/pthread_cond_wait.c",
+ "musl/src/thread/pthread_create.c",
+ "musl/src/thread/pthread_detach.c",
+ "musl/src/thread/pthread_equal.c",
+ "musl/src/thread/pthread_getattr_np.c",
+ "musl/src/thread/pthread_getconcurrency.c",
+ "musl/src/thread/pthread_getcpuclockid.c",
+ "musl/src/thread/pthread_getname_np.c",
+ "musl/src/thread/pthread_getschedparam.c",
+ "musl/src/thread/pthread_getspecific.c",
+ "musl/src/thread/pthread_join.c",
+ "musl/src/thread/pthread_key_create.c",
+ "musl/src/thread/pthread_kill.c",
+ "musl/src/thread/pthread_mutexattr_destroy.c",
+ "musl/src/thread/pthread_mutexattr_init.c",
+ "musl/src/thread/pthread_mutexattr_setprotocol.c",
+ "musl/src/thread/pthread_mutexattr_setpshared.c",
+ "musl/src/thread/pthread_mutexattr_setrobust.c",
+ "musl/src/thread/pthread_mutexattr_settype.c",
+ "musl/src/thread/pthread_mutex_consistent.c",
+ "musl/src/thread/pthread_mutex_destroy.c",
+ "musl/src/thread/pthread_mutex_getprioceiling.c",
+ "musl/src/thread/pthread_mutex_init.c",
+ "musl/src/thread/pthread_mutex_lock.c",
+ "musl/src/thread/pthread_mutex_setprioceiling.c",
+ "musl/src/thread/pthread_mutex_timedlock.c",
+ "musl/src/thread/pthread_mutex_trylock.c",
+ "musl/src/thread/pthread_mutex_unlock.c",
+ "musl/src/thread/pthread_once.c",
+ "musl/src/thread/pthread_rwlockattr_destroy.c",
+ "musl/src/thread/pthread_rwlockattr_init.c",
+ "musl/src/thread/pthread_rwlockattr_setpshared.c",
+ "musl/src/thread/pthread_rwlock_destroy.c",
+ "musl/src/thread/pthread_rwlock_init.c",
+ "musl/src/thread/pthread_rwlock_rdlock.c",
+ "musl/src/thread/pthread_rwlock_timedrdlock.c",
+ "musl/src/thread/pthread_rwlock_timedwrlock.c",
+ "musl/src/thread/pthread_rwlock_tryrdlock.c",
+ "musl/src/thread/pthread_rwlock_trywrlock.c",
+ "musl/src/thread/pthread_rwlock_unlock.c",
+ "musl/src/thread/pthread_rwlock_wrlock.c",
+ "musl/src/thread/pthread_self.c",
+ "musl/src/thread/pthread_setattr_default_np.c",
+ "musl/src/thread/pthread_setcancelstate.c",
+ "musl/src/thread/pthread_setcanceltype.c",
+ "musl/src/thread/pthread_setconcurrency.c",
+ "musl/src/thread/pthread_setname_np.c",
+ "musl/src/thread/pthread_setschedparam.c",
+ "musl/src/thread/pthread_setschedprio.c",
+ "musl/src/thread/pthread_setspecific.c",
+ "musl/src/thread/pthread_sigmask.c",
+ "musl/src/thread/pthread_spin_destroy.c",
+ "musl/src/thread/pthread_spin_init.c",
+ "musl/src/thread/pthread_spin_lock.c",
+ "musl/src/thread/pthread_spin_trylock.c",
+ "musl/src/thread/pthread_spin_unlock.c",
+ "musl/src/thread/pthread_testcancel.c",
+ "musl/src/thread/riscv32/clone.s",
+ "musl/src/thread/riscv32/__set_thread_area.s",
+ "musl/src/thread/riscv32/syscall_cp.s",
+ "musl/src/thread/riscv32/__unmapself.s",
+ "musl/src/thread/riscv64/clone.s",
+ "musl/src/thread/riscv64/__set_thread_area.s",
+ "musl/src/thread/riscv64/syscall_cp.s",
+ "musl/src/thread/riscv64/__unmapself.s",
+ "musl/src/thread/s390x/clone.s",
+ "musl/src/thread/s390x/__set_thread_area.s",
+ "musl/src/thread/s390x/syscall_cp.s",
+ "musl/src/thread/s390x/__tls_get_offset.s",
+ "musl/src/thread/s390x/__unmapself.s",
+ "musl/src/thread/sem_destroy.c",
+ "musl/src/thread/sem_getvalue.c",
+ "musl/src/thread/sem_init.c",
+ "musl/src/thread/sem_open.c",
+ "musl/src/thread/sem_post.c",
+ "musl/src/thread/sem_timedwait.c",
+ "musl/src/thread/sem_trywait.c",
+ "musl/src/thread/sem_unlink.c",
+ "musl/src/thread/sem_wait.c",
+ "musl/src/thread/__set_thread_area.c",
+ "musl/src/thread/synccall.c",
+ "musl/src/thread/__syscall_cp.c",
+ "musl/src/thread/syscall_cp.c",
+ "musl/src/thread/thrd_create.c",
+ "musl/src/thread/thrd_exit.c",
+ "musl/src/thread/thrd_join.c",
+ "musl/src/thread/thrd_sleep.c",
+ "musl/src/thread/thrd_yield.c",
+ "musl/src/thread/__timedwait.c",
+ "musl/src/thread/tls.c",
+ "musl/src/thread/__tls_get_addr.c",
+ "musl/src/thread/tss_create.c",
+ "musl/src/thread/tss_delete.c",
+ "musl/src/thread/tss_set.c",
+ "musl/src/thread/__unmapself.c",
+ "musl/src/thread/vmlock.c",
+ "musl/src/thread/__wait.c",
+ "musl/src/thread/x32/clone.s",
+ "musl/src/thread/x32/__set_thread_area.s",
+ "musl/src/thread/x32/syscall_cp.s",
+ "musl/src/thread/x32/__unmapself.s",
+ "musl/src/thread/x86_64/clone.s",
+ "musl/src/thread/x86_64/__set_thread_area.s",
+ "musl/src/thread/x86_64/syscall_cp.s",
+ "musl/src/thread/x86_64/__unmapself.s",
+ "musl/src/time/asctime.c",
+ "musl/src/time/asctime_r.c",
+ "musl/src/time/clock.c",
+ "musl/src/time/clock_getcpuclockid.c",
+ "musl/src/time/clock_getres.c",
+ "musl/src/time/clock_gettime.c",
+ "musl/src/time/clock_nanosleep.c",
+ "musl/src/time/clock_settime.c",
+ "musl/src/time/ctime.c",
+ "musl/src/time/ctime_r.c",
+ "musl/src/time/difftime.c",
+ "musl/src/time/ftime.c",
+ "musl/src/time/getdate.c",
+ "musl/src/time/gettimeofday.c",
+ "musl/src/time/gmtime.c",
+ "musl/src/time/gmtime_r.c",
+ "musl/src/time/localtime.c",
+ "musl/src/time/localtime_r.c",
+ "musl/src/time/__map_file.c",
+ "musl/src/time/mktime.c",
+ "musl/src/time/__month_to_secs.c",
+ "musl/src/time/nanosleep.c",
+ "musl/src/time/__secs_to_tm.c",
+ "musl/src/time/strftime.c",
+ "musl/src/time/strptime.c",
+ "musl/src/time/time.c",
+ "musl/src/time/timegm.c",
+ "musl/src/time/timer_create.c",
+ "musl/src/time/timer_delete.c",
+ "musl/src/time/timer_getoverrun.c",
+ "musl/src/time/timer_gettime.c",
+ "musl/src/time/timer_settime.c",
+ "musl/src/time/times.c",
+ "musl/src/time/timespec_get.c",
+ "musl/src/time/__tm_to_secs.c",
+ "musl/src/time/__tz.c",
+ "musl/src/time/utime.c",
+ "musl/src/time/wcsftime.c",
+ "musl/src/time/__year_to_secs.c",
+ "musl/src/unistd/access.c",
+ "musl/src/unistd/acct.c",
+ "musl/src/unistd/alarm.c",
+ "musl/src/unistd/chdir.c",
+ "musl/src/unistd/chown.c",
+ "musl/src/unistd/close.c",
+ "musl/src/unistd/ctermid.c",
+ "musl/src/unistd/dup2.c",
+ "musl/src/unistd/dup3.c",
+ "musl/src/unistd/dup.c",
+ "musl/src/unistd/_exit.c",
+ "musl/src/unistd/faccessat.c",
+ "musl/src/unistd/fchdir.c",
+ "musl/src/unistd/fchownat.c",
+ "musl/src/unistd/fchown.c",
+ "musl/src/unistd/fdatasync.c",
+ "musl/src/unistd/fsync.c",
+ "musl/src/unistd/ftruncate.c",
+ "musl/src/unistd/getcwd.c",
+ "musl/src/unistd/getegid.c",
+ "musl/src/unistd/geteuid.c",
+ "musl/src/unistd/getgid.c",
+ "musl/src/unistd/getgroups.c",
+ "musl/src/unistd/gethostname.c",
+ "musl/src/unistd/getlogin.c",
+ "musl/src/unistd/getlogin_r.c",
+ "musl/src/unistd/getpgid.c",
+ "musl/src/unistd/getpgrp.c",
+ "musl/src/unistd/getpid.c",
+ "musl/src/unistd/getppid.c",
+ "musl/src/unistd/getsid.c",
+ "musl/src/unistd/getuid.c",
+ "musl/src/unistd/isatty.c",
+ "musl/src/unistd/lchown.c",
+ "musl/src/unistd/linkat.c",
+ "musl/src/unistd/link.c",
+ "musl/src/unistd/lseek.c",
+ "musl/src/unistd/mips64/pipe.s",
+ "musl/src/unistd/mipsn32/lseek.c",
+ "musl/src/unistd/mipsn32/pipe.s",
+ "musl/src/unistd/mips/pipe.s",
+ "musl/src/unistd/nice.c",
+ "musl/src/unistd/pause.c",
+ "musl/src/unistd/pipe2.c",
+ "musl/src/unistd/pipe.c",
+ "musl/src/unistd/posix_close.c",
+ "musl/src/unistd/pread.c",
+ "musl/src/unistd/preadv.c",
+ "musl/src/unistd/pwrite.c",
+ "musl/src/unistd/pwritev.c",
+ "musl/src/unistd/read.c",
+ "musl/src/unistd/readlinkat.c",
+ "musl/src/unistd/readlink.c",
+ "musl/src/unistd/readv.c",
+ "musl/src/unistd/renameat.c",
+ "musl/src/unistd/rmdir.c",
+ "musl/src/unistd/setegid.c",
+ "musl/src/unistd/seteuid.c",
+ "musl/src/unistd/setgid.c",
+ "musl/src/unistd/setpgid.c",
+ "musl/src/unistd/setpgrp.c",
+ "musl/src/unistd/setregid.c",
+ "musl/src/unistd/setresgid.c",
+ "musl/src/unistd/setresuid.c",
+ "musl/src/unistd/setreuid.c",
+ "musl/src/unistd/setsid.c",
+ "musl/src/unistd/setuid.c",
+ "musl/src/unistd/setxid.c",
+ "musl/src/unistd/sleep.c",
+ "musl/src/unistd/symlinkat.c",
+ "musl/src/unistd/symlink.c",
+ "musl/src/unistd/sync.c",
+ "musl/src/unistd/tcgetpgrp.c",
+ "musl/src/unistd/tcsetpgrp.c",
+ "musl/src/unistd/truncate.c",
+ "musl/src/unistd/ttyname.c",
+ "musl/src/unistd/ttyname_r.c",
+ "musl/src/unistd/ualarm.c",
+ "musl/src/unistd/unlinkat.c",
+ "musl/src/unistd/unlink.c",
+ "musl/src/unistd/usleep.c",
+ "musl/src/unistd/write.c",
+ "musl/src/unistd/writev.c",
+ "musl/src/unistd/x32/lseek.c",
+};
+
+const compat_time32_files = [_][]const u8{
+ "musl/compat/time32/adjtime32.c",
+ "musl/compat/time32/adjtimex_time32.c",
+ "musl/compat/time32/aio_suspend_time32.c",
+ "musl/compat/time32/clock_adjtime32.c",
+ "musl/compat/time32/clock_getres_time32.c",
+ "musl/compat/time32/clock_gettime32.c",
+ "musl/compat/time32/clock_nanosleep_time32.c",
+ "musl/compat/time32/clock_settime32.c",
+ "musl/compat/time32/cnd_timedwait_time32.c",
+ "musl/compat/time32/ctime32.c",
+ "musl/compat/time32/ctime32_r.c",
+ "musl/compat/time32/difftime32.c",
+ "musl/compat/time32/fstatat_time32.c",
+ "musl/compat/time32/fstat_time32.c",
+ "musl/compat/time32/ftime32.c",
+ "musl/compat/time32/futimens_time32.c",
+ "musl/compat/time32/futimesat_time32.c",
+ "musl/compat/time32/futimes_time32.c",
+ "musl/compat/time32/getitimer_time32.c",
+ "musl/compat/time32/getrusage_time32.c",
+ "musl/compat/time32/gettimeofday_time32.c",
+ "musl/compat/time32/gmtime32.c",
+ "musl/compat/time32/gmtime32_r.c",
+ "musl/compat/time32/localtime32.c",
+ "musl/compat/time32/localtime32_r.c",
+ "musl/compat/time32/lstat_time32.c",
+ "musl/compat/time32/lutimes_time32.c",
+ "musl/compat/time32/mktime32.c",
+ "musl/compat/time32/mq_timedreceive_time32.c",
+ "musl/compat/time32/mq_timedsend_time32.c",
+ "musl/compat/time32/mtx_timedlock_time32.c",
+ "musl/compat/time32/nanosleep_time32.c",
+ "musl/compat/time32/ppoll_time32.c",
+ "musl/compat/time32/pselect_time32.c",
+ "musl/compat/time32/pthread_cond_timedwait_time32.c",
+ "musl/compat/time32/pthread_mutex_timedlock_time32.c",
+ "musl/compat/time32/pthread_rwlock_timedrdlock_time32.c",
+ "musl/compat/time32/pthread_rwlock_timedwrlock_time32.c",
+ "musl/compat/time32/pthread_timedjoin_np_time32.c",
+ "musl/compat/time32/recvmmsg_time32.c",
+ "musl/compat/time32/sched_rr_get_interval_time32.c",
+ "musl/compat/time32/select_time32.c",
+ "musl/compat/time32/semtimedop_time32.c",
+ "musl/compat/time32/sem_timedwait_time32.c",
+ "musl/compat/time32/setitimer_time32.c",
+ "musl/compat/time32/settimeofday_time32.c",
+ "musl/compat/time32/sigtimedwait_time32.c",
+ "musl/compat/time32/stat_time32.c",
+ "musl/compat/time32/stime32.c",
+ "musl/compat/time32/thrd_sleep_time32.c",
+ "musl/compat/time32/time32.c",
+ "musl/compat/time32/time32gm.c",
+ "musl/compat/time32/timerfd_gettime32.c",
+ "musl/compat/time32/timerfd_settime32.c",
+ "musl/compat/time32/timer_gettime32.c",
+ "musl/compat/time32/timer_settime32.c",
+ "musl/compat/time32/timespec_get_time32.c",
+ "musl/compat/time32/utimensat_time32.c",
+ "musl/compat/time32/utimes_time32.c",
+ "musl/compat/time32/utime_time32.c",
+ "musl/compat/time32/wait3_time32.c",
+ "musl/compat/time32/wait4_time32.c",
+ "musl/compat/time32/__xstat.c",
+};
diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig
new file mode 100644
index 0000000000..2657c2e1f8
--- /dev/null
+++ b/src/libs/wasi_libc.zig
@@ -0,0 +1,1256 @@
+const std = @import("std");
+const mem = std.mem;
+const path = std.fs.path;
+
+const Allocator = std.mem.Allocator;
+const Compilation = @import("../Compilation.zig");
+const build_options = @import("build_options");
+
+pub const CrtFile = enum {
+ crt1_reactor_o,
+ crt1_command_o,
+ libc_a,
+ libdl_a,
+ libwasi_emulated_process_clocks_a,
+ libwasi_emulated_getpid_a,
+ libwasi_emulated_mman_a,
+ libwasi_emulated_signal_a,
+};
+
+pub fn getEmulatedLibCrtFile(lib_name: []const u8) ?CrtFile {
+ if (mem.eql(u8, lib_name, "dl")) {
+ return .libdl_a;
+ }
+ if (mem.eql(u8, lib_name, "wasi-emulated-process-clocks")) {
+ return .libwasi_emulated_process_clocks_a;
+ }
+ if (mem.eql(u8, lib_name, "wasi-emulated-getpid")) {
+ return .libwasi_emulated_getpid_a;
+ }
+ if (mem.eql(u8, lib_name, "wasi-emulated-mman")) {
+ return .libwasi_emulated_mman_a;
+ }
+ if (mem.eql(u8, lib_name, "wasi-emulated-signal")) {
+ return .libwasi_emulated_signal_a;
+ }
+ return null;
+}
+
+pub fn emulatedLibCRFileLibName(crt_file: CrtFile) []const u8 {
+ return switch (crt_file) {
+ .libdl_a => "libdl.a",
+ .libwasi_emulated_process_clocks_a => "libwasi-emulated-process-clocks.a",
+ .libwasi_emulated_getpid_a => "libwasi-emulated-getpid.a",
+ .libwasi_emulated_mman_a => "libwasi-emulated-mman.a",
+ .libwasi_emulated_signal_a => "libwasi-emulated-signal.a",
+ else => unreachable,
+ };
+}
+
+pub fn execModelCrtFile(wasi_exec_model: std.builtin.WasiExecModel) CrtFile {
+ return switch (wasi_exec_model) {
+ .reactor => CrtFile.crt1_reactor_o,
+ .command => CrtFile.crt1_command_o,
+ };
+}
+
+pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []const u8 {
+ return switch (execModelCrtFile(wasi_exec_model)) {
+ .crt1_reactor_o => "crt1-reactor.o",
+ .crt1_command_o => "crt1-command.o",
+ else => unreachable,
+ };
+}
+
+/// TODO replace anyerror with explicit error set, recording user-friendly errors with
+/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
+pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
+ if (!build_options.have_llvm) {
+ return error.ZigCompilerNotBuiltWithLLVMExtensions;
+ }
+
+ const gpa = comp.gpa;
+ var arena_allocator = std.heap.ArenaAllocator.init(gpa);
+ defer arena_allocator.deinit();
+ const arena = arena_allocator.allocator();
+
+ switch (crt_file) {
+ .crt1_reactor_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{});
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, crt1_reactor_src_file),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &files, .{});
+ },
+ .crt1_command_o => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{});
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+ var files = [_]Compilation.CSourceFile{
+ .{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, crt1_command_src_file),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ },
+ };
+ return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &files, .{});
+ },
+ .libc_a => {
+ var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+
+ {
+ // Compile emmalloc.
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true, .no_strict_aliasing = true });
+ for (emmalloc_src_files) |file_path| {
+ try libc_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ {
+ // Compile libc-bottom-half.
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+
+ for (libc_bottom_half_src_files) |file_path| {
+ try libc_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ {
+ // Compile libc-top-half.
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcTopHalfIncludes(comp, arena, &args);
+
+ for (libc_top_half_src_files) |file_path| {
+ try libc_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items, .{});
+ },
+
+ .libdl_a => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+
+ var emu_dl_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+ for (emulated_dl_src_files) |file_path| {
+ try emu_dl_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ try comp.build_crt_file("dl", .Lib, .@"wasi libdl.a", prog_node, emu_dl_sources.items, .{});
+ },
+
+ .libwasi_emulated_process_clocks_a => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+
+ var emu_clocks_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+ for (emulated_process_clocks_src_files) |file_path| {
+ try emu_clocks_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items, .{});
+ },
+ .libwasi_emulated_getpid_a => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+
+ var emu_getpid_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+ for (emulated_getpid_src_files) |file_path| {
+ try emu_getpid_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items, .{});
+ },
+ .libwasi_emulated_mman_a => {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcBottomHalfIncludes(comp, arena, &args);
+
+ var emu_mman_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+ for (emulated_mman_src_files) |file_path| {
+ try emu_mman_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items, .{});
+ },
+ .libwasi_emulated_signal_a => {
+ var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
+
+ {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+
+ for (emulated_signal_bottom_half_src_files) |file_path| {
+ try emu_signal_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ {
+ var args = std.ArrayList([]const u8).init(arena);
+ try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
+ try addLibcTopHalfIncludes(comp, arena, &args);
+ try args.append("-D_WASI_EMULATED_SIGNAL");
+
+ for (emulated_signal_top_half_src_files) |file_path| {
+ try emu_signal_sources.append(.{
+ .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc", try sanitize(arena, file_path),
+ }),
+ .extra_flags = args.items,
+ .owner = undefined,
+ });
+ }
+ }
+
+ try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items, .{});
+ },
+ }
+}
+
+fn sanitize(arena: Allocator, file_path: []const u8) ![]const u8 {
+ // TODO do this at comptime on the comptime data rather than at runtime
+ // probably best to wait until self-hosted is done and our comptime execution
+ // is faster and uses less memory.
+ const out_path = if (path.sep != '/') blk: {
+ const mutable_file_path = try arena.dupe(u8, file_path);
+ for (mutable_file_path) |*c| {
+ if (c.* == '/') {
+ c.* = path.sep;
+ }
+ }
+ break :blk mutable_file_path;
+ } else file_path;
+ return out_path;
+}
+
+const CCOptions = struct {
+ want_O3: bool = false,
+ no_strict_aliasing: bool = false,
+};
+
+fn addCCArgs(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+ options: CCOptions,
+) error{OutOfMemory}!void {
+ const target = comp.getTarget();
+ const arch_name = std.zig.target.muslArchNameHeaders(target.cpu.arch);
+ const os_name = @tagName(target.os.tag);
+ const triple = try std.fmt.allocPrint(arena, "{s}-{s}-musl", .{ arch_name, os_name });
+ const o_arg = if (options.want_O3) "-O3" else "-Os";
+
+ try args.appendSlice(&[_][]const u8{
+ "-std=gnu17",
+ "-fno-trapping-math",
+ "-w", // ignore all warnings
+
+ o_arg,
+
+ "-mthread-model",
+ "single",
+
+ "-isysroot",
+ "/",
+
+ "-iwithsysroot",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
+
+ "-iwithsysroot",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
+
+ "-DBULK_MEMORY_THRESHOLD=32",
+ });
+
+ if (options.no_strict_aliasing) {
+ try args.appendSlice(&[_][]const u8{"-fno-strict-aliasing"});
+ }
+}
+
+fn addLibcBottomHalfIncludes(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+) error{OutOfMemory}!void {
+ try args.appendSlice(&[_][]const u8{
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-bottom-half",
+ "headers",
+ "private",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-bottom-half",
+ "cloudlibc",
+ "src",
+ "include",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-bottom-half",
+ "cloudlibc",
+ "src",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "musl",
+ "src",
+ "include",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "musl",
+ "src",
+ "include",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "musl",
+ "src",
+ "internal",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "musl",
+ "src",
+ "internal",
+ }),
+ });
+}
+
+fn addLibcTopHalfIncludes(
+ comp: *Compilation,
+ arena: Allocator,
+ args: *std.ArrayList([]const u8),
+) error{OutOfMemory}!void {
+ try args.appendSlice(&[_][]const u8{
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "musl",
+ "src",
+ "include",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "musl",
+ "src",
+ "include",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "musl",
+ "src",
+ "internal",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "musl",
+ "src",
+ "internal",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "musl",
+ "arch",
+ "wasm32",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "musl",
+ "arch",
+ "generic",
+ }),
+
+ "-I",
+ try comp.zig_lib_directory.join(arena, &[_][]const u8{
+ "libc",
+ "wasi",
+ "libc-top-half",
+ "headers",
+ "private",
+ }),
+ });
+}
+
+const emmalloc_src_files = [_][]const u8{
+ "wasi/emmalloc/emmalloc.c",
+};
+
+const libc_bottom_half_src_files = [_][]const u8{
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/closedir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/dirfd.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdclosedir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/opendirat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/rewinddir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/scandirat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/seekdir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/telldir.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/errno/errno.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fadvise.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fallocate.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/stdlib/_Exit.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/select.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/getsockopt.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/futimens.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/time/gettimeofday.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/readv.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/writev.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_MONOTONIC.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_REALTIME.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_getres.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_gettime.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/time/time.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fdatasync.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fsync.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/ftruncate.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pread.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/read.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/sleep.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/usleep.c",
+ "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/write.c",
+ "wasi/libc-bottom-half/sources/__errno_location.c",
+ "wasi/libc-bottom-half/sources/__main_void.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_dt.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_environ.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_initialize_environ.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_real.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_rmdirat.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_tell.c",
+ "wasi/libc-bottom-half/sources/__wasilibc_unlinkat.c",
+ "wasi/libc-bottom-half/sources/abort.c",
+ "wasi/libc-bottom-half/sources/accept-wasip1.c",
+ "wasi/libc-bottom-half/sources/at_fdcwd.c",
+ "wasi/libc-bottom-half/sources/complex-builtins.c",
+ "wasi/libc-bottom-half/sources/environ.c",
+ "wasi/libc-bottom-half/sources/errno.c",
+ "wasi/libc-bottom-half/sources/getcwd.c",
+ "wasi/libc-bottom-half/sources/getentropy.c",
+ "wasi/libc-bottom-half/sources/isatty.c",
+ "wasi/libc-bottom-half/sources/math/fmin-fmax.c",
+ "wasi/libc-bottom-half/sources/math/math-builtins.c",
+ "wasi/libc-bottom-half/sources/posix.c",
+ "wasi/libc-bottom-half/sources/preopens.c",
+ "wasi/libc-bottom-half/sources/reallocarray.c",
+ "wasi/libc-bottom-half/sources/sbrk.c",
+ "wasi/libc-bottom-half/sources/truncate.c",
+ "wasi/libc-bottom-half/sources/chdir.c",
+};
+
+const libc_top_half_src_files = [_][]const u8{
+ "musl/src/complex/cabs.c",
+ "musl/src/complex/cabsf.c",
+ "musl/src/complex/cabsl.c",
+ "musl/src/complex/cacos.c",
+ "musl/src/complex/cacosf.c",
+ "musl/src/complex/cacosh.c",
+ "musl/src/complex/cacoshf.c",
+ "musl/src/complex/cacoshl.c",
+ "musl/src/complex/cacosl.c",
+ "musl/src/complex/carg.c",
+ "musl/src/complex/cargf.c",
+ "musl/src/complex/cargl.c",
+ "musl/src/complex/casin.c",
+ "musl/src/complex/casinf.c",
+ "musl/src/complex/casinh.c",
+ "musl/src/complex/casinhf.c",
+ "musl/src/complex/casinhl.c",
+ "musl/src/complex/casinl.c",
+ "musl/src/complex/catan.c",
+ "musl/src/complex/catanf.c",
+ "musl/src/complex/catanh.c",
+ "musl/src/complex/catanhf.c",
+ "musl/src/complex/catanhl.c",
+ "musl/src/complex/catanl.c",
+ "musl/src/complex/ccos.c",
+ "musl/src/complex/ccosf.c",
+ "musl/src/complex/ccosh.c",
+ "musl/src/complex/ccoshf.c",
+ "musl/src/complex/ccoshl.c",
+ "musl/src/complex/ccosl.c",
+ "musl/src/complex/__cexp.c",
+ "musl/src/complex/cexp.c",
+ "musl/src/complex/__cexpf.c",
+ "musl/src/complex/cexpf.c",
+ "musl/src/complex/cexpl.c",
+ "musl/src/complex/clog.c",
+ "musl/src/complex/clogf.c",
+ "musl/src/complex/clogl.c",
+ "musl/src/complex/conj.c",
+ "musl/src/complex/conjf.c",
+ "musl/src/complex/conjl.c",
+ "musl/src/complex/cpow.c",
+ "musl/src/complex/cpowf.c",
+ "musl/src/complex/cpowl.c",
+ "musl/src/complex/cproj.c",
+ "musl/src/complex/cprojf.c",
+ "musl/src/complex/cprojl.c",
+ "musl/src/complex/csin.c",
+ "musl/src/complex/csinf.c",
+ "musl/src/complex/csinh.c",
+ "musl/src/complex/csinhf.c",
+ "musl/src/complex/csinhl.c",
+ "musl/src/complex/csinl.c",
+ "musl/src/complex/csqrt.c",
+ "musl/src/complex/csqrtf.c",
+ "musl/src/complex/csqrtl.c",
+ "musl/src/complex/ctan.c",
+ "musl/src/complex/ctanf.c",
+ "musl/src/complex/ctanh.c",
+ "musl/src/complex/ctanhf.c",
+ "musl/src/complex/ctanhl.c",
+ "musl/src/complex/ctanl.c",
+ "musl/src/conf/legacy.c",
+ "musl/src/conf/pathconf.c",
+ "musl/src/crypt/crypt_blowfish.c",
+ "musl/src/crypt/crypt.c",
+ "musl/src/crypt/crypt_des.c",
+ "musl/src/crypt/crypt_md5.c",
+ "musl/src/crypt/crypt_r.c",
+ "musl/src/crypt/crypt_sha256.c",
+ "musl/src/crypt/crypt_sha512.c",
+ "musl/src/crypt/encrypt.c",
+ "musl/src/ctype/__ctype_b_loc.c",
+ "musl/src/ctype/__ctype_get_mb_cur_max.c",
+ "musl/src/ctype/__ctype_tolower_loc.c",
+ "musl/src/ctype/__ctype_toupper_loc.c",
+ "musl/src/ctype/isalnum.c",
+ "musl/src/ctype/isalpha.c",
+ "musl/src/ctype/isascii.c",
+ "musl/src/ctype/isblank.c",
+ "musl/src/ctype/iscntrl.c",
+ "musl/src/ctype/isdigit.c",
+ "musl/src/ctype/isgraph.c",
+ "musl/src/ctype/islower.c",
+ "musl/src/ctype/isprint.c",
+ "musl/src/ctype/ispunct.c",
+ "musl/src/ctype/isspace.c",
+ "musl/src/ctype/isupper.c",
+ "musl/src/ctype/iswalnum.c",
+ "musl/src/ctype/iswalpha.c",
+ "musl/src/ctype/iswblank.c",
+ "musl/src/ctype/iswcntrl.c",
+ "musl/src/ctype/iswctype.c",
+ "musl/src/ctype/iswdigit.c",
+ "musl/src/ctype/iswgraph.c",
+ "musl/src/ctype/iswlower.c",
+ "musl/src/ctype/iswprint.c",
+ "musl/src/ctype/iswpunct.c",
+ "musl/src/ctype/iswspace.c",
+ "musl/src/ctype/iswupper.c",
+ "musl/src/ctype/iswxdigit.c",
+ "musl/src/ctype/isxdigit.c",
+ "musl/src/ctype/toascii.c",
+ "musl/src/ctype/tolower.c",
+ "musl/src/ctype/toupper.c",
+ "musl/src/ctype/towctrans.c",
+ "musl/src/ctype/wcswidth.c",
+ "musl/src/ctype/wctrans.c",
+ "musl/src/ctype/wcwidth.c",
+ "musl/src/env/setenv.c",
+ "musl/src/exit/assert.c",
+ "musl/src/exit/quick_exit.c",
+ "musl/src/fenv/fegetexceptflag.c",
+ "musl/src/fenv/feholdexcept.c",
+ "musl/src/fenv/fenv.c",
+ "musl/src/fenv/fesetexceptflag.c",
+ "musl/src/fenv/fesetround.c",
+ "musl/src/fenv/feupdateenv.c",
+ "musl/src/legacy/getpagesize.c",
+ "musl/src/locale/c_locale.c",
+ "musl/src/locale/duplocale.c",
+ "musl/src/locale/freelocale.c",
+ "musl/src/locale/iconv.c",
+ "musl/src/locale/iconv_close.c",
+ "musl/src/locale/langinfo.c",
+ "musl/src/locale/__lctrans.c",
+ "musl/src/locale/localeconv.c",
+ "musl/src/locale/__mo_lookup.c",
+ "musl/src/locale/pleval.c",
+ "musl/src/locale/setlocale.c",
+ "musl/src/locale/strcoll.c",
+ "musl/src/locale/strfmon.c",
+ "musl/src/locale/strtod_l.c",
+ "musl/src/locale/strxfrm.c",
+ "musl/src/locale/wcscoll.c",
+ "musl/src/locale/wcsxfrm.c",
+ "musl/src/math/acos.c",
+ "musl/src/math/acosf.c",
+ "musl/src/math/acosh.c",
+ "musl/src/math/acoshf.c",
+ "musl/src/math/acoshl.c",
+ "musl/src/math/acosl.c",
+ "musl/src/math/asin.c",
+ "musl/src/math/asinf.c",
+ "musl/src/math/asinh.c",
+ "musl/src/math/asinhf.c",
+ "musl/src/math/asinhl.c",
+ "musl/src/math/asinl.c",
+ "musl/src/math/atan2.c",
+ "musl/src/math/atan2f.c",
+ "musl/src/math/atan2l.c",
+ "musl/src/math/atan.c",
+ "musl/src/math/atanf.c",
+ "musl/src/math/atanh.c",
+ "musl/src/math/atanhf.c",
+ "musl/src/math/atanhl.c",
+ "musl/src/math/atanl.c",
+ "musl/src/math/cbrt.c",
+ "musl/src/math/cbrtf.c",
+ "musl/src/math/cbrtl.c",
+ "musl/src/math/ceill.c",
+ "musl/src/math/copysignl.c",
+ "musl/src/math/__cos.c",
+ "musl/src/math/cos.c",
+ "musl/src/math/__cosdf.c",
+ "musl/src/math/cosf.c",
+ "musl/src/math/coshl.c",
+ "musl/src/math/__cosl.c",
+ "musl/src/math/cosl.c",
+ "musl/src/math/erf.c",
+ "musl/src/math/erff.c",
+ "musl/src/math/erfl.c",
+ "musl/src/math/exp10.c",
+ "musl/src/math/exp10f.c",
+ "musl/src/math/exp10l.c",
+ "musl/src/math/exp2.c",
+ "musl/src/math/exp2f.c",
+ "musl/src/math/exp2f_data.c",
+ "musl/src/math/exp2l.c",
+ "musl/src/math/exp.c",
+ "musl/src/math/exp_data.c",
+ "musl/src/math/expf.c",
+ "musl/src/math/expl.c",
+ "musl/src/math/expm1.c",
+ "musl/src/math/expm1f.c",
+ "musl/src/math/expm1l.c",
+ "musl/src/math/fabsl.c",
+ "musl/src/math/fdim.c",
+ "musl/src/math/fdimf.c",
+ "musl/src/math/fdiml.c",
+ "musl/src/math/finite.c",
+ "musl/src/math/finitef.c",
+ "musl/src/math/floorl.c",
+ "musl/src/math/fma.c",
+ "musl/src/math/fmaf.c",
+ "musl/src/math/fmaxl.c",
+ "musl/src/math/fminl.c",
+ "musl/src/math/fmod.c",
+ "musl/src/math/fmodf.c",
+ "musl/src/math/fmodl.c",
+ "musl/src/math/frexp.c",
+ "musl/src/math/frexpf.c",
+ "musl/src/math/frexpl.c",
+ "musl/src/math/hypot.c",
+ "musl/src/math/hypotf.c",
+ "musl/src/math/hypotl.c",
+ "musl/src/math/ilogb.c",
+ "musl/src/math/ilogbf.c",
+ "musl/src/math/ilogbl.c",
+ "musl/src/math/__invtrigl.c",
+ "musl/src/math/j0.c",
+ "musl/src/math/j0f.c",
+ "musl/src/math/j1.c",
+ "musl/src/math/j1f.c",
+ "musl/src/math/jn.c",
+ "musl/src/math/jnf.c",
+ "musl/src/math/ldexp.c",
+ "musl/src/math/ldexpf.c",
+ "musl/src/math/ldexpl.c",
+ "musl/src/math/lgamma.c",
+ "musl/src/math/lgammaf.c",
+ "musl/src/math/lgammaf_r.c",
+ "musl/src/math/lgammal.c",
+ "musl/src/math/lgamma_r.c",
+ "musl/src/math/llrint.c",
+ "musl/src/math/llrintf.c",
+ "musl/src/math/llrintl.c",
+ "musl/src/math/llround.c",
+ "musl/src/math/llroundf.c",
+ "musl/src/math/llroundl.c",
+ "musl/src/math/log10.c",
+ "musl/src/math/log10f.c",
+ "musl/src/math/log10l.c",
+ "musl/src/math/log1p.c",
+ "musl/src/math/log1pf.c",
+ "musl/src/math/log1pl.c",
+ "musl/src/math/log2.c",
+ "musl/src/math/log2_data.c",
+ "musl/src/math/log2f.c",
+ "musl/src/math/log2f_data.c",
+ "musl/src/math/log2l.c",
+ "musl/src/math/logb.c",
+ "musl/src/math/logbf.c",
+ "musl/src/math/logbl.c",
+ "musl/src/math/log.c",
+ "musl/src/math/log_data.c",
+ "musl/src/math/logf.c",
+ "musl/src/math/logf_data.c",
+ "musl/src/math/logl.c",
+ "musl/src/math/lrint.c",
+ "musl/src/math/lrintf.c",
+ "musl/src/math/lrintl.c",
+ "musl/src/math/lround.c",
+ "musl/src/math/lroundf.c",
+ "musl/src/math/lroundl.c",
+ "musl/src/math/__math_divzero.c",
+ "musl/src/math/__math_divzerof.c",
+ "musl/src/math/__math_invalid.c",
+ "musl/src/math/__math_invalidf.c",
+ "musl/src/math/__math_invalidl.c",
+ "musl/src/math/__math_oflow.c",
+ "musl/src/math/__math_oflowf.c",
+ "musl/src/math/__math_uflow.c",
+ "musl/src/math/__math_uflowf.c",
+ "musl/src/math/__math_xflow.c",
+ "musl/src/math/__math_xflowf.c",
+ "musl/src/math/modf.c",
+ "musl/src/math/modff.c",
+ "musl/src/math/modfl.c",
+ "musl/src/math/nan.c",
+ "musl/src/math/nanf.c",
+ "musl/src/math/nanl.c",
+ "musl/src/math/nearbyintl.c",
+ "musl/src/math/nextafter.c",
+ "musl/src/math/nextafterf.c",
+ "musl/src/math/nextafterl.c",
+ "musl/src/math/nexttoward.c",
+ "musl/src/math/nexttowardf.c",
+ "musl/src/math/nexttowardl.c",
+ "musl/src/math/__polevll.c",
+ "musl/src/math/pow.c",
+ "musl/src/math/pow_data.c",
+ "musl/src/math/powf.c",
+ "musl/src/math/powf_data.c",
+ "musl/src/math/remainder.c",
+ "musl/src/math/remainderf.c",
+ "musl/src/math/remainderl.c",
+ "musl/src/math/__rem_pio2_large.c",
+ "musl/src/math/remquo.c",
+ "musl/src/math/remquof.c",
+ "musl/src/math/remquol.c",
+ "musl/src/math/rintl.c",
+ "musl/src/math/round.c",
+ "musl/src/math/roundf.c",
+ "musl/src/math/roundl.c",
+ "musl/src/math/scalb.c",
+ "musl/src/math/scalbf.c",
+ "musl/src/math/scalbln.c",
+ "musl/src/math/scalblnf.c",
+ "musl/src/math/scalblnl.c",
+ "musl/src/math/scalbn.c",
+ "musl/src/math/scalbnf.c",
+ "musl/src/math/scalbnl.c",
+ "musl/src/math/signgam.c",
+ "musl/src/math/significand.c",
+ "musl/src/math/significandf.c",
+ "musl/src/math/__sin.c",
+ "musl/src/math/sin.c",
+ "musl/src/math/sincos.c",
+ "musl/src/math/sincosf.c",
+ "musl/src/math/sincosl.c",
+ "musl/src/math/__sindf.c",
+ "musl/src/math/sinf.c",
+ "musl/src/math/sinhl.c",
+ "musl/src/math/__sinl.c",
+ "musl/src/math/sinl.c",
+ "musl/src/math/sqrt_data.c",
+ "musl/src/math/sqrtl.c",
+ "musl/src/math/__tan.c",
+ "musl/src/math/tan.c",
+ "musl/src/math/__tandf.c",
+ "musl/src/math/tanf.c",
+ "musl/src/math/tanh.c",
+ "musl/src/math/tanhf.c",
+ "musl/src/math/tanhl.c",
+ "musl/src/math/__tanl.c",
+ "musl/src/math/tanl.c",
+ "musl/src/math/tgamma.c",
+ "musl/src/math/tgammaf.c",
+ "musl/src/math/tgammal.c",
+ "musl/src/math/truncl.c",
+ "musl/src/misc/a64l.c",
+ "musl/src/misc/basename.c",
+ "musl/src/misc/dirname.c",
+ "musl/src/misc/ffs.c",
+ "musl/src/misc/ffsl.c",
+ "musl/src/misc/ffsll.c",
+ "musl/src/misc/getdomainname.c",
+ "musl/src/misc/gethostid.c",
+ "musl/src/misc/getopt.c",
+ "musl/src/misc/getopt_long.c",
+ "musl/src/misc/getsubopt.c",
+ "musl/src/misc/realpath.c",
+ "musl/src/multibyte/btowc.c",
+ "musl/src/multibyte/c16rtomb.c",
+ "musl/src/multibyte/c32rtomb.c",
+ "musl/src/multibyte/internal.c",
+ "musl/src/multibyte/mblen.c",
+ "musl/src/multibyte/mbrlen.c",
+ "musl/src/multibyte/mbrtoc16.c",
+ "musl/src/multibyte/mbrtoc32.c",
+ "musl/src/multibyte/mbrtowc.c",
+ "musl/src/multibyte/mbsinit.c",
+ "musl/src/multibyte/mbsnrtowcs.c",
+ "musl/src/multibyte/mbsrtowcs.c",
+ "musl/src/multibyte/mbstowcs.c",
+ "musl/src/multibyte/mbtowc.c",
+ "musl/src/multibyte/wcrtomb.c",
+ "musl/src/multibyte/wcsnrtombs.c",
+ "musl/src/multibyte/wcsrtombs.c",
+ "musl/src/multibyte/wcstombs.c",
+ "musl/src/multibyte/wctob.c",
+ "musl/src/multibyte/wctomb.c",
+ "musl/src/network/htonl.c",
+ "musl/src/network/htons.c",
+ "musl/src/network/in6addr_any.c",
+ "musl/src/network/in6addr_loopback.c",
+ "musl/src/network/inet_aton.c",
+ "musl/src/network/inet_ntop.c",
+ "musl/src/network/inet_pton.c",
+ "musl/src/network/ntohl.c",
+ "musl/src/network/ntohs.c",
+ "musl/src/prng/drand48.c",
+ "musl/src/prng/lcong48.c",
+ "musl/src/prng/lrand48.c",
+ "musl/src/prng/mrand48.c",
+ "musl/src/prng/__rand48_step.c",
+ "musl/src/prng/rand.c",
+ "musl/src/prng/rand_r.c",
+ "musl/src/prng/__seed48.c",
+ "musl/src/prng/seed48.c",
+ "musl/src/prng/srand48.c",
+ "musl/src/regex/fnmatch.c",
+ "musl/src/regex/regerror.c",
+ "musl/src/search/hsearch.c",
+ "musl/src/search/insque.c",
+ "musl/src/search/lsearch.c",
+ "musl/src/search/tdelete.c",
+ "musl/src/search/tdestroy.c",
+ "musl/src/search/tfind.c",
+ "musl/src/search/tsearch.c",
+ "musl/src/search/twalk.c",
+ "musl/src/stdio/asprintf.c",
+ "musl/src/stdio/clearerr.c",
+ "musl/src/stdio/dprintf.c",
+ "musl/src/stdio/ext2.c",
+ "musl/src/stdio/ext.c",
+ "musl/src/stdio/fclose.c",
+ "musl/src/stdio/__fclose_ca.c",
+ "musl/src/stdio/feof.c",
+ "musl/src/stdio/ferror.c",
+ "musl/src/stdio/fflush.c",
+ "musl/src/stdio/fgetln.c",
+ "musl/src/stdio/fgets.c",
+ "musl/src/stdio/fgetwc.c",
+ "musl/src/stdio/fgetws.c",
+ "musl/src/stdio/fileno.c",
+ "musl/src/stdio/__fmodeflags.c",
+ "musl/src/stdio/fopencookie.c",
+ "musl/src/stdio/fprintf.c",
+ "musl/src/stdio/fputs.c",
+ "musl/src/stdio/fputwc.c",
+ "musl/src/stdio/fputws.c",
+ "musl/src/stdio/fread.c",
+ "musl/src/stdio/fscanf.c",
+ "musl/src/stdio/fwide.c",
+ "musl/src/stdio/fwprintf.c",
+ "musl/src/stdio/fwrite.c",
+ "musl/src/stdio/fwscanf.c",
+ "musl/src/stdio/getchar_unlocked.c",
+ "musl/src/stdio/getc_unlocked.c",
+ "musl/src/stdio/getdelim.c",
+ "musl/src/stdio/getline.c",
+ "musl/src/stdio/getw.c",
+ "musl/src/stdio/getwc.c",
+ "musl/src/stdio/getwchar.c",
+ "musl/src/stdio/ofl_add.c",
+ "musl/src/stdio/__overflow.c",
+ "musl/src/stdio/perror.c",
+ "musl/src/stdio/putchar_unlocked.c",
+ "musl/src/stdio/putc_unlocked.c",
+ "musl/src/stdio/puts.c",
+ "musl/src/stdio/putw.c",
+ "musl/src/stdio/putwc.c",
+ "musl/src/stdio/putwchar.c",
+ "musl/src/stdio/rewind.c",
+ "musl/src/stdio/scanf.c",
+ "musl/src/stdio/setbuf.c",
+ "musl/src/stdio/setbuffer.c",
+ "musl/src/stdio/setlinebuf.c",
+ "musl/src/stdio/setvbuf.c",
+ "musl/src/stdio/snprintf.c",
+ "musl/src/stdio/sprintf.c",
+ "musl/src/stdio/sscanf.c",
+ "musl/src/stdio/__stdio_exit.c",
+ "musl/src/stdio/swprintf.c",
+ "musl/src/stdio/swscanf.c",
+ "musl/src/stdio/__toread.c",
+ "musl/src/stdio/__towrite.c",
+ "musl/src/stdio/__uflow.c",
+ "musl/src/stdio/ungetwc.c",
+ "musl/src/stdio/vasprintf.c",
+ "musl/src/stdio/vprintf.c",
+ "musl/src/stdio/vscanf.c",
+ "musl/src/stdio/vsprintf.c",
+ "musl/src/stdio/vwprintf.c",
+ "musl/src/stdio/vwscanf.c",
+ "musl/src/stdio/wprintf.c",
+ "musl/src/stdio/wscanf.c",
+ "musl/src/stdlib/abs.c",
+ "musl/src/stdlib/atof.c",
+ "musl/src/stdlib/atoi.c",
+ "musl/src/stdlib/atol.c",
+ "musl/src/stdlib/atoll.c",
+ "musl/src/stdlib/bsearch.c",
+ "musl/src/stdlib/div.c",
+ "musl/src/stdlib/ecvt.c",
+ "musl/src/stdlib/fcvt.c",
+ "musl/src/stdlib/gcvt.c",
+ "musl/src/stdlib/imaxabs.c",
+ "musl/src/stdlib/imaxdiv.c",
+ "musl/src/stdlib/labs.c",
+ "musl/src/stdlib/ldiv.c",
+ "musl/src/stdlib/llabs.c",
+ "musl/src/stdlib/lldiv.c",
+ "musl/src/stdlib/qsort.c",
+ "musl/src/stdlib/qsort_nr.c",
+ "musl/src/string/bcmp.c",
+ "musl/src/string/bcopy.c",
+ "musl/src/string/explicit_bzero.c",
+ "musl/src/string/index.c",
+ "musl/src/string/memccpy.c",
+ "musl/src/string/memchr.c",
+ "musl/src/string/memcmp.c",
+ "musl/src/string/memmem.c",
+ "musl/src/string/mempcpy.c",
+ "musl/src/string/memrchr.c",
+ "musl/src/string/rindex.c",
+ "musl/src/string/stpcpy.c",
+ "musl/src/string/stpncpy.c",
+ "musl/src/string/strcasecmp.c",
+ "musl/src/string/strcasestr.c",
+ "musl/src/string/strcat.c",
+ "musl/src/string/strchr.c",
+ "musl/src/string/strchrnul.c",
+ "musl/src/string/strcpy.c",
+ "musl/src/string/strcspn.c",
+ "musl/src/string/strdup.c",
+ "musl/src/string/strerror_r.c",
+ "musl/src/string/strlcat.c",
+ "musl/src/string/strlcpy.c",
+ "musl/src/string/strncasecmp.c",
+ "musl/src/string/strncat.c",
+ "musl/src/string/strncpy.c",
+ "musl/src/string/strndup.c",
+ "musl/src/string/strnlen.c",
+ "musl/src/string/strpbrk.c",
+ "musl/src/string/strrchr.c",
+ "musl/src/string/strsep.c",
+ "musl/src/string/strspn.c",
+ "musl/src/string/strstr.c",
+ "musl/src/string/strtok.c",
+ "musl/src/string/strtok_r.c",
+ "musl/src/string/strverscmp.c",
+ "musl/src/string/swab.c",
+ "musl/src/string/wcpcpy.c",
+ "musl/src/string/wcpncpy.c",
+ "musl/src/string/wcscasecmp.c",
+ "musl/src/string/wcscasecmp_l.c",
+ "musl/src/string/wcscat.c",
+ "musl/src/string/wcschr.c",
+ "musl/src/string/wcscmp.c",
+ "musl/src/string/wcscpy.c",
+ "musl/src/string/wcscspn.c",
+ "musl/src/string/wcsdup.c",
+ "musl/src/string/wcslen.c",
+ "musl/src/string/wcsncasecmp.c",
+ "musl/src/string/wcsncasecmp_l.c",
+ "musl/src/string/wcsncat.c",
+ "musl/src/string/wcsncmp.c",
+ "musl/src/string/wcsncpy.c",
+ "musl/src/string/wcsnlen.c",
+ "musl/src/string/wcspbrk.c",
+ "musl/src/string/wcsrchr.c",
+ "musl/src/string/wcsspn.c",
+ "musl/src/string/wcsstr.c",
+ "musl/src/string/wcstok.c",
+ "musl/src/string/wcswcs.c",
+ "musl/src/string/wmemchr.c",
+ "musl/src/string/wmemcmp.c",
+ "musl/src/string/wmemcpy.c",
+ "musl/src/string/wmemmove.c",
+ "musl/src/string/wmemset.c",
+ "musl/src/thread/thrd_sleep.c",
+ "musl/src/time/asctime.c",
+ "musl/src/time/asctime_r.c",
+ "musl/src/time/ctime.c",
+ "musl/src/time/ctime_r.c",
+ "musl/src/time/difftime.c",
+ "musl/src/time/ftime.c",
+ "musl/src/time/__month_to_secs.c",
+ "musl/src/time/strptime.c",
+ "musl/src/time/timespec_get.c",
+ "musl/src/time/__year_to_secs.c",
+ "musl/src/unistd/posix_close.c",
+
+ "wasi/libc-top-half/musl/src/conf/confstr.c",
+ "wasi/libc-top-half/musl/src/conf/fpathconf.c",
+ "wasi/libc-top-half/musl/src/conf/sysconf.c",
+ "wasi/libc-top-half/musl/src/dirent/alphasort.c",
+ "wasi/libc-top-half/musl/src/dirent/versionsort.c",
+ "wasi/libc-top-half/musl/src/env/clearenv.c",
+ "wasi/libc-top-half/musl/src/env/getenv.c",
+ "wasi/libc-top-half/musl/src/env/putenv.c",
+ "wasi/libc-top-half/musl/src/env/__stack_chk_fail.c",
+ "wasi/libc-top-half/musl/src/env/unsetenv.c",
+ "wasi/libc-top-half/musl/src/errno/strerror.c",
+ "wasi/libc-top-half/musl/src/exit/atexit.c",
+ "wasi/libc-top-half/musl/src/exit/at_quick_exit.c",
+ "wasi/libc-top-half/musl/src/exit/exit.c",
+ "wasi/libc-top-half/musl/src/fcntl/creat.c",
+ "wasi/libc-top-half/musl/src/internal/defsysinfo.c",
+ "wasi/libc-top-half/musl/src/internal/floatscan.c",
+ "wasi/libc-top-half/musl/src/internal/intscan.c",
+ "wasi/libc-top-half/musl/src/internal/libc.c",
+ "wasi/libc-top-half/musl/src/internal/shgetc.c",
+ "wasi/libc-top-half/musl/src/locale/catclose.c",
+ "wasi/libc-top-half/musl/src/locale/catgets.c",
+ "wasi/libc-top-half/musl/src/locale/catopen.c",
+ "wasi/libc-top-half/musl/src/locale/locale_map.c",
+ "wasi/libc-top-half/musl/src/locale/newlocale.c",
+ "wasi/libc-top-half/musl/src/locale/uselocale.c",
+ "wasi/libc-top-half/musl/src/math/cosh.c",
+ "wasi/libc-top-half/musl/src/math/coshf.c",
+ "wasi/libc-top-half/musl/src/math/__expo2.c",
+ "wasi/libc-top-half/musl/src/math/__expo2f.c",
+ "wasi/libc-top-half/musl/src/math/fmal.c",
+ "wasi/libc-top-half/musl/src/math/powl.c",
+ "wasi/libc-top-half/musl/src/math/__rem_pio2.c",
+ "wasi/libc-top-half/musl/src/math/__rem_pio2f.c",
+ "wasi/libc-top-half/musl/src/math/__rem_pio2l.c",
+ "wasi/libc-top-half/musl/src/math/sinh.c",
+ "wasi/libc-top-half/musl/src/math/sinhf.c",
+ "wasi/libc-top-half/musl/src/misc/fmtmsg.c",
+ "wasi/libc-top-half/musl/src/misc/nftw.c",
+ "wasi/libc-top-half/musl/src/misc/uname.c",
+ "wasi/libc-top-half/musl/src/prng/random.c",
+ "wasi/libc-top-half/musl/src/regex/regcomp.c",
+ "wasi/libc-top-half/musl/src/regex/regexec.c",
+ "wasi/libc-top-half/musl/src/regex/glob.c",
+ "wasi/libc-top-half/musl/src/regex/tre-mem.c",
+ "wasi/libc-top-half/musl/src/stat/futimesat.c",
+ "wasi/libc-top-half/musl/src/stdio/__fdopen.c",
+ "wasi/libc-top-half/musl/src/stdio/fgetc.c",
+ "wasi/libc-top-half/musl/src/stdio/fgetpos.c",
+ "wasi/libc-top-half/musl/src/stdio/fmemopen.c",
+ "wasi/libc-top-half/musl/src/stdio/fopen.c",
+ "wasi/libc-top-half/musl/src/stdio/__fopen_rb_ca.c",
+ "wasi/libc-top-half/musl/src/stdio/fputc.c",
+ "wasi/libc-top-half/musl/src/stdio/freopen.c",
+ "wasi/libc-top-half/musl/src/stdio/fseek.c",
+ "wasi/libc-top-half/musl/src/stdio/fsetpos.c",
+ "wasi/libc-top-half/musl/src/stdio/ftell.c",
+ "wasi/libc-top-half/musl/src/stdio/getc.c",
+ "wasi/libc-top-half/musl/src/stdio/getchar.c",
+ "wasi/libc-top-half/musl/src/stdio/ofl.c",
+ "wasi/libc-top-half/musl/src/stdio/open_memstream.c",
+ "wasi/libc-top-half/musl/src/stdio/open_wmemstream.c",
+ "wasi/libc-top-half/musl/src/stdio/printf.c",
+ "wasi/libc-top-half/musl/src/stdio/putc.c",
+ "wasi/libc-top-half/musl/src/stdio/putchar.c",
+ "wasi/libc-top-half/musl/src/stdio/stderr.c",
+ "wasi/libc-top-half/musl/src/stdio/stdin.c",
+ "wasi/libc-top-half/musl/src/stdio/__stdio_close.c",
+ "wasi/libc-top-half/musl/src/stdio/__stdio_read.c",
+ "wasi/libc-top-half/musl/src/stdio/__stdio_seek.c",
+ "wasi/libc-top-half/musl/src/stdio/__stdio_write.c",
+ "wasi/libc-top-half/musl/src/stdio/stdout.c",
+ "wasi/libc-top-half/musl/src/stdio/__stdout_write.c",
+ "wasi/libc-top-half/musl/src/stdio/ungetc.c",
+ "wasi/libc-top-half/musl/src/stdio/vdprintf.c",
+ "wasi/libc-top-half/musl/src/stdio/vfprintf.c",
+ "wasi/libc-top-half/musl/src/stdio/vfscanf.c",
+ "wasi/libc-top-half/musl/src/stdio/vfwprintf.c",
+ "wasi/libc-top-half/musl/src/stdio/vfwscanf.c",
+ "wasi/libc-top-half/musl/src/stdio/vsnprintf.c",
+ "wasi/libc-top-half/musl/src/stdio/vsscanf.c",
+ "wasi/libc-top-half/musl/src/stdio/vswprintf.c",
+ "wasi/libc-top-half/musl/src/stdio/vswscanf.c",
+ "wasi/libc-top-half/musl/src/stdlib/strtod.c",
+ "wasi/libc-top-half/musl/src/stdlib/strtol.c",
+ "wasi/libc-top-half/musl/src/stdlib/wcstod.c",
+ "wasi/libc-top-half/musl/src/stdlib/wcstol.c",
+ "wasi/libc-top-half/musl/src/string/memset.c",
+ "wasi/libc-top-half/musl/src/time/getdate.c",
+ "wasi/libc-top-half/musl/src/time/gmtime.c",
+ "wasi/libc-top-half/musl/src/time/gmtime_r.c",
+ "wasi/libc-top-half/musl/src/time/localtime.c",
+ "wasi/libc-top-half/musl/src/time/localtime_r.c",
+ "wasi/libc-top-half/musl/src/time/mktime.c",
+ "wasi/libc-top-half/musl/src/time/__secs_to_tm.c",
+ "wasi/libc-top-half/musl/src/time/strftime.c",
+ "wasi/libc-top-half/musl/src/time/timegm.c",
+ "wasi/libc-top-half/musl/src/time/__tm_to_secs.c",
+ "wasi/libc-top-half/musl/src/time/__tz.c",
+ "wasi/libc-top-half/musl/src/time/wcsftime.c",
+
+ "wasi/libc-top-half/sources/arc4random.c",
+};
+
+const crt1_command_src_file = "wasi/libc-bottom-half/crt/crt1-command.c";
+const crt1_reactor_src_file = "wasi/libc-bottom-half/crt/crt1-reactor.c";
+
+const emulated_dl_src_files = &[_][]const u8{
+ "wasi/libc-top-half/musl/src/misc/dl.c",
+};
+
+const emulated_process_clocks_src_files = &[_][]const u8{
+ "wasi/libc-bottom-half/clocks/clock.c",
+ "wasi/libc-bottom-half/clocks/getrusage.c",
+ "wasi/libc-bottom-half/clocks/times.c",
+};
+
+const emulated_getpid_src_files = &[_][]const u8{
+ "wasi/libc-bottom-half/getpid/getpid.c",
+};
+
+const emulated_mman_src_files = &[_][]const u8{
+ "wasi/libc-bottom-half/mman/mman.c",
+};
+
+const emulated_signal_bottom_half_src_files = &[_][]const u8{
+ "wasi/libc-bottom-half/signal/signal.c",
+};
+
+const emulated_signal_top_half_src_files = &[_][]const u8{
+ "musl/src/signal/psignal.c",
+ "musl/src/string/strsignal.c",
+};