authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-21 07:05:02+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-10 12:19:26+02:00
log610d3cf9deabb06a9729b54df4e9123d98a3c386
treeb57c33e05de7f4eef2ee7d3a2697400c86c0b253
parent309ff9c34ea28b89a02ef69b11c610cd5e062ca2
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: Move vendored library support to `libs` subdirectory.


21 files changed, 7206 insertions(+), 7206 deletions(-)

CMakeLists.txt+7-7
...@@ -586,11 +586,11 @@ set(ZIG_STAGE2_SOURCES...@@ -586,11 +586,11 @@ set(ZIG_STAGE2_SOURCES
586 src/codegen/spirv/spec.zig586 src/codegen/spirv/spec.zig
587 src/crash_report.zig587 src/crash_report.zig
588 src/dev.zig588 src/dev.zig
589 src/glibc.zig589 src/libs/glibc.zig
590 src/introspect.zig590 src/introspect.zig
591 src/libcxx.zig591 src/libs/libcxx.zig
592 src/libtsan.zig592 src/libs/libtsan.zig
593 src/libunwind.zig593 src/libs/libunwind.zig
594 src/link.zig594 src/link.zig
595 src/link/C.zig595 src/link/C.zig
596 src/link/Coff.zig596 src/link/Coff.zig
...@@ -664,8 +664,8 @@ set(ZIG_STAGE2_SOURCES...@@ -664,8 +664,8 @@ set(ZIG_STAGE2_SOURCES
664 src/link/tapi/yaml.zig664 src/link/tapi/yaml.zig
665 src/link/tapi/yaml/test.zig665 src/link/tapi/yaml/test.zig
666 src/main.zig666 src/main.zig
667 src/mingw.zig667 src/libs/mingw.zig
668 src/musl.zig668 src/libs/musl.zig
669 src/mutable_value.zig669 src/mutable_value.zig
670 src/print_air.zig670 src/print_air.zig
671 src/print_env.zig671 src/print_env.zig
...@@ -676,7 +676,7 @@ set(ZIG_STAGE2_SOURCES...@@ -676,7 +676,7 @@ set(ZIG_STAGE2_SOURCES
676 src/target.zig676 src/target.zig
677 src/tracy.zig677 src/tracy.zig
678 src/translate_c.zig678 src/translate_c.zig
679 src/wasi_libc.zig679 src/libs/wasi_libc.zig
680)680)
681681
682if(MSVC)682if(MSVC)
src/Compilation.zig+7-7
...@@ -21,12 +21,12 @@ const tracy = @import("tracy.zig");...@@ -21,12 +21,12 @@ const tracy = @import("tracy.zig");
21const trace = tracy.trace;21const trace = tracy.trace;
22const build_options = @import("build_options");22const build_options = @import("build_options");
23const LibCInstallation = std.zig.LibCInstallation;23const LibCInstallation = std.zig.LibCInstallation;
24const glibc = @import("glibc.zig");24const glibc = @import("libs/glibc.zig");
25const musl = @import("musl.zig");25const musl = @import("libs/musl.zig");
26const mingw = @import("mingw.zig");26const mingw = @import("libs/mingw.zig");
27const libunwind = @import("libunwind.zig");27const libunwind = @import("libs/libunwind.zig");
28const libcxx = @import("libcxx.zig");28const libcxx = @import("libs/libcxx.zig");
29const wasi_libc = @import("wasi_libc.zig");29const wasi_libc = @import("libs/wasi_libc.zig");
30const fatal = @import("main.zig").fatal;30const fatal = @import("main.zig").fatal;
31const clangMain = @import("main.zig").clangMain;31const clangMain = @import("main.zig").clangMain;
32const Zcu = @import("Zcu.zig");32const Zcu = @import("Zcu.zig");
...@@ -34,7 +34,7 @@ const Sema = @import("Sema.zig");...@@ -34,7 +34,7 @@ const Sema = @import("Sema.zig");
34const InternPool = @import("InternPool.zig");34const InternPool = @import("InternPool.zig");
35const Cache = std.Build.Cache;35const Cache = std.Build.Cache;
36const c_codegen = @import("codegen/c.zig");36const c_codegen = @import("codegen/c.zig");
37const libtsan = @import("libtsan.zig");37const libtsan = @import("libs/libtsan.zig");
38const Zir = std.zig.Zir;38const Zir = std.zig.Zir;
39const Air = @import("Air.zig");39const Air = @import("Air.zig");
40const Builtin = @import("Builtin.zig");40const Builtin = @import("Builtin.zig");
src/glibc.zig deleted-1281
...@@ -1,1281 +0,0 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const log = std.log;
5const fs = std.fs;
6const path = fs.path;
7const assert = std.debug.assert;
8const Version = std.SemanticVersion;
9const Path = std.Build.Cache.Path;
10
11const Compilation = @import("Compilation.zig");
12const build_options = @import("build_options");
13const trace = @import("tracy.zig").trace;
14const Cache = std.Build.Cache;
15const Module = @import("Package/Module.zig");
16const link = @import("link.zig");
17
18pub const Lib = struct {
19 name: []const u8,
20 sover: u8,
21 removed_in: ?Version = null,
22};
23
24pub const ABI = struct {
25 all_versions: []const Version, // all defined versions (one abilist from v2.0.0 up to current)
26 all_targets: []const std.zig.target.ArchOsAbi,
27 /// The bytes from the file verbatim, starting from the u16 number
28 /// of function inclusions.
29 inclusions: []const u8,
30 arena_state: std.heap.ArenaAllocator.State,
31
32 pub fn destroy(abi: *ABI, gpa: Allocator) void {
33 abi.arena_state.promote(gpa).deinit();
34 }
35};
36
37// The order of the elements in this array defines the linking order.
38pub const libs = [_]Lib{
39 .{ .name = "m", .sover = 6 },
40 .{ .name = "pthread", .sover = 0, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
41 .{ .name = "c", .sover = 6 },
42 .{ .name = "dl", .sover = 2, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
43 .{ .name = "rt", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
44 .{ .name = "ld", .sover = 2 },
45 .{ .name = "util", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
46 .{ .name = "resolv", .sover = 2 },
47};
48
49pub const LoadMetaDataError = error{
50 /// The files that ship with the Zig compiler were unable to be read, or otherwise had malformed data.
51 ZigInstallationCorrupt,
52 OutOfMemory,
53};
54
55pub const abilists_path = "libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++ "abilists";
56pub const abilists_max_size = 800 * 1024; // Bigger than this and something is definitely borked.
57
58/// This function will emit a log error when there is a problem with the zig
59/// installation and then return `error.ZigInstallationCorrupt`.
60pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI {
61 const tracy = trace(@src());
62 defer tracy.end();
63
64 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
65 errdefer arena_allocator.deinit();
66 const arena = arena_allocator.allocator();
67
68 var index: usize = 0;
69
70 {
71 const libs_len = contents[index];
72 index += 1;
73
74 var i: u8 = 0;
75 while (i < libs_len) : (i += 1) {
76 const lib_name = mem.sliceTo(contents[index..], 0);
77 index += lib_name.len + 1;
78
79 if (i >= libs.len or !mem.eql(u8, libs[i].name, lib_name)) {
80 log.err("libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++
81 "abilists: invalid library name or index ({d}): '{s}'", .{ i, lib_name });
82 return error.ZigInstallationCorrupt;
83 }
84 }
85 }
86
87 const versions = b: {
88 const versions_len = contents[index];
89 index += 1;
90
91 const versions = try arena.alloc(Version, versions_len);
92 var i: u8 = 0;
93 while (i < versions.len) : (i += 1) {
94 versions[i] = .{
95 .major = contents[index + 0],
96 .minor = contents[index + 1],
97 .patch = contents[index + 2],
98 };
99 index += 3;
100 }
101 break :b versions;
102 };
103
104 const targets = b: {
105 const targets_len = contents[index];
106 index += 1;
107
108 const targets = try arena.alloc(std.zig.target.ArchOsAbi, targets_len);
109 var i: u8 = 0;
110 while (i < targets.len) : (i += 1) {
111 const target_name = mem.sliceTo(contents[index..], 0);
112 index += target_name.len + 1;
113
114 var component_it = mem.tokenizeScalar(u8, target_name, '-');
115 const arch_name = component_it.next() orelse {
116 log.err("abilists: expected arch name", .{});
117 return error.ZigInstallationCorrupt;
118 };
119 const os_name = component_it.next() orelse {
120 log.err("abilists: expected OS name", .{});
121 return error.ZigInstallationCorrupt;
122 };
123 const abi_name = component_it.next() orelse {
124 log.err("abilists: expected ABI name", .{});
125 return error.ZigInstallationCorrupt;
126 };
127 const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
128 log.err("abilists: unrecognized arch: '{s}'", .{arch_name});
129 return error.ZigInstallationCorrupt;
130 };
131 if (!mem.eql(u8, os_name, "linux")) {
132 log.err("abilists: expected OS 'linux', found '{s}'", .{os_name});
133 return error.ZigInstallationCorrupt;
134 }
135 const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
136 log.err("abilists: unrecognized ABI: '{s}'", .{abi_name});
137 return error.ZigInstallationCorrupt;
138 };
139
140 targets[i] = .{
141 .arch = arch_tag,
142 .os = .linux,
143 .abi = abi_tag,
144 };
145 }
146 break :b targets;
147 };
148
149 const abi = try arena.create(ABI);
150 abi.* = .{
151 .all_versions = versions,
152 .all_targets = targets,
153 .inclusions = contents[index..],
154 .arena_state = arena_allocator.state,
155 };
156 return abi;
157}
158
159pub const CrtFile = enum {
160 scrt1_o,
161 libc_nonshared_a,
162};
163
164/// TODO replace anyerror with explicit error set, recording user-friendly errors with
165/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
166pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
167 if (!build_options.have_llvm) {
168 return error.ZigCompilerNotBuiltWithLLVMExtensions;
169 }
170 const gpa = comp.gpa;
171 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
172 defer arena_allocator.deinit();
173 const arena = arena_allocator.allocator();
174
175 const target = comp.root_mod.resolved_target.result;
176 const target_ver = target.os.versionRange().gnuLibCVersion().?;
177 const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt;
178 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;
179
180 // In all cases in this function, we add the C compiler flags to
181 // cache_exempt_flags rather than extra_flags, because these arguments
182 // depend on only properties that are already covered by the cache
183 // manifest. Including these arguments in the cache could only possibly
184 // waste computation and create false negatives.
185
186 switch (crt_file) {
187 .scrt1_o => {
188 const start_o: Compilation.CSourceFile = blk: {
189 var args = std.ArrayList([]const u8).init(arena);
190 try add_include_dirs(comp, arena, &args);
191 try args.appendSlice(&[_][]const u8{
192 "-D_LIBC_REENTRANT",
193 "-include",
194 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
195 "-DMODULE_NAME=libc",
196 "-Wno-nonportable-include-path",
197 "-include",
198 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
199 "-DPIC",
200 "-DSHARED",
201 "-DTOP_NAMESPACE=glibc",
202 "-DASSEMBLER",
203 "-Wa,--noexecstack",
204 });
205 const src_path = if (start_old_init_fini) "start-2.33.S" else "start.S";
206 break :blk .{
207 .src_path = try start_asm_path(comp, arena, src_path),
208 .cache_exempt_flags = args.items,
209 .owner = undefined,
210 };
211 };
212 const abi_note_o: Compilation.CSourceFile = blk: {
213 var args = std.ArrayList([]const u8).init(arena);
214 try args.appendSlice(&[_][]const u8{
215 "-I",
216 try lib_path(comp, arena, lib_libc_glibc ++ "csu"),
217 });
218 try add_include_dirs(comp, arena, &args);
219 try args.appendSlice(&[_][]const u8{
220 "-D_LIBC_REENTRANT",
221 "-DMODULE_NAME=libc",
222 "-DTOP_NAMESPACE=glibc",
223 "-DASSEMBLER",
224 "-Wa,--noexecstack",
225 });
226 break :blk .{
227 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "abi-note.S"),
228 .cache_exempt_flags = args.items,
229 .owner = undefined,
230 };
231 };
232 const init_o: Compilation.CSourceFile = .{
233 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),
234 .owner = undefined,
235 };
236 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
237 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";
238 return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{});
239 },
240 .libc_nonshared_a => {
241 const s = path.sep_str;
242 const Dep = struct {
243 path: []const u8,
244 include: bool = true,
245 };
246 const deps = [_]Dep{
247 .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c" },
248 .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c" },
249 .{ .path = lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c" },
250 .{ .path = lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c" },
251
252 // libc_nonshared.a redirected stat functions to xstat until glibc 2.33,
253 // when they were finally versioned like other symbols.
254 .{
255 .path = lib_libc_glibc ++ "io" ++ s ++ "stat-2.32.c",
256 .include = nonshared_stat,
257 },
258 .{
259 .path = lib_libc_glibc ++ "io" ++ s ++ "fstat-2.32.c",
260 .include = nonshared_stat,
261 },
262 .{
263 .path = lib_libc_glibc ++ "io" ++ s ++ "lstat-2.32.c",
264 .include = nonshared_stat,
265 },
266 .{
267 .path = lib_libc_glibc ++ "io" ++ s ++ "stat64-2.32.c",
268 .include = nonshared_stat,
269 },
270 .{
271 .path = lib_libc_glibc ++ "io" ++ s ++ "fstat64-2.32.c",
272 .include = nonshared_stat,
273 },
274 .{
275 .path = lib_libc_glibc ++ "io" ++ s ++ "lstat64-2.32.c",
276 .include = nonshared_stat,
277 },
278 .{
279 .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat-2.32.c",
280 .include = nonshared_stat,
281 },
282 .{
283 .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat64-2.32.c",
284 .include = nonshared_stat,
285 },
286 .{
287 .path = lib_libc_glibc ++ "io" ++ s ++ "mknodat-2.32.c",
288 .include = nonshared_stat,
289 },
290 .{
291 .path = lib_libc_glibc ++ "io" ++ s ++ "mknod-2.32.c",
292 .include = nonshared_stat,
293 },
294
295 // __libc_start_main used to require statically linked init/fini callbacks
296 // until glibc 2.34 when they were assimilated into the shared library.
297 .{
298 .path = lib_libc_glibc ++ "csu" ++ s ++ "elf-init-2.33.c",
299 .include = start_old_init_fini,
300 },
301 };
302
303 var files_buf: [deps.len]Compilation.CSourceFile = undefined;
304 var files_index: usize = 0;
305
306 for (deps) |dep| {
307 if (!dep.include) continue;
308
309 var args = std.ArrayList([]const u8).init(arena);
310 try args.appendSlice(&[_][]const u8{
311 "-std=gnu11",
312 "-fgnu89-inline",
313 "-fmerge-all-constants",
314 "-frounding-math",
315 "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math.
316 "-fno-common",
317 "-fmath-errno",
318 "-ftls-model=initial-exec",
319 "-Wno-ignored-attributes",
320 "-Qunused-arguments",
321 });
322 try add_include_dirs(comp, arena, &args);
323
324 try args.append("-DNO_INITFINI");
325
326 if (target.cpu.arch == .x86) {
327 // This prevents i386/sysdep.h from trying to do some
328 // silly and unnecessary inline asm hack that uses weird
329 // syntax that clang does not support.
330 try args.append("-DCAN_USE_REGISTER_ASM_EBP");
331 }
332
333 try args.appendSlice(&[_][]const u8{
334 "-D_LIBC_REENTRANT",
335 "-include",
336 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
337 "-DMODULE_NAME=libc",
338 "-Wno-nonportable-include-path",
339 "-include",
340 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
341 "-DPIC",
342 "-DLIBC_NONSHARED=1",
343 "-DTOP_NAMESPACE=glibc",
344 });
345 files_buf[files_index] = .{
346 .src_path = try lib_path(comp, arena, dep.path),
347 .cache_exempt_flags = args.items,
348 .owner = undefined,
349 };
350 files_index += 1;
351 }
352 const files = files_buf[0..files_index];
353 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{});
354 },
355 }
356}
357
358fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
359 const arch = comp.getTarget().cpu.arch;
360 const is_ppc = arch.isPowerPC();
361 const is_aarch64 = arch.isAARCH64();
362 const is_sparc = arch.isSPARC();
363 const is_64 = comp.getTarget().ptrBitWidth() == 64;
364
365 const s = path.sep_str;
366
367 var result = std.ArrayList(u8).init(arena);
368 try result.appendSlice(comp.zig_lib_directory.path.?);
369 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
370 if (is_sparc) {
371 if (is_64) {
372 try result.appendSlice("sparc" ++ s ++ "sparc64");
373 } else {
374 try result.appendSlice("sparc" ++ s ++ "sparc32");
375 }
376 } else if (arch.isArm()) {
377 try result.appendSlice("arm");
378 } else if (arch.isMIPS()) {
379 try result.appendSlice("mips");
380 } else if (arch == .x86_64) {
381 try result.appendSlice("x86_64");
382 } else if (arch == .x86) {
383 try result.appendSlice("i386");
384 } else if (is_aarch64) {
385 try result.appendSlice("aarch64");
386 } else if (arch.isRISCV()) {
387 try result.appendSlice("riscv");
388 } else if (is_ppc) {
389 if (is_64) {
390 try result.appendSlice("powerpc" ++ s ++ "powerpc64");
391 } else {
392 try result.appendSlice("powerpc" ++ s ++ "powerpc32");
393 }
394 } else if (arch == .s390x) {
395 try result.appendSlice("s390" ++ s ++ "s390-64");
396 } else if (arch.isLoongArch()) {
397 try result.appendSlice("loongarch");
398 } else if (arch == .m68k) {
399 try result.appendSlice("m68k");
400 } else if (arch == .arc) {
401 try result.appendSlice("arc");
402 } else if (arch == .csky) {
403 try result.appendSlice("csky" ++ s ++ "abiv2");
404 }
405
406 try result.appendSlice(s);
407 try result.appendSlice(basename);
408 return result.items;
409}
410
411fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
412 const target = comp.getTarget();
413 const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
414
415 const s = path.sep_str;
416
417 try args.append("-I");
418 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include"));
419
420 if (target.os.tag == .linux) {
421 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
422 }
423
424 if (opt_nptl) |nptl| {
425 try add_include_dirs_arch(arena, args, target, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
426 }
427
428 if (target.os.tag == .linux) {
429 try args.append("-I");
430 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
431 "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "generic"));
432
433 try args.append("-I");
434 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
435 "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "include"));
436 try args.append("-I");
437 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
438 "unix" ++ s ++ "sysv" ++ s ++ "linux"));
439 }
440 if (opt_nptl) |nptl| {
441 try args.append("-I");
442 try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
443 }
444
445 try args.append("-I");
446 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread"));
447
448 try args.append("-I");
449 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv"));
450
451 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
452
453 try args.append("-I");
454 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
455
456 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
457
458 try args.append("-I");
459 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
460
461 try args.append("-I");
462 try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
463
464 try args.append("-I");
465 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{
466 comp.zig_lib_directory.path.?, @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi),
467 }));
468
469 try args.append("-I");
470 try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
471
472 const arch_name = std.zig.target.osArchName(target);
473 try args.append("-I");
474 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
475 comp.zig_lib_directory.path.?, arch_name,
476 }));
477
478 try args.append("-I");
479 try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "any-linux-any"));
480}
481
482fn add_include_dirs_arch(
483 arena: Allocator,
484 args: *std.ArrayList([]const u8),
485 target: std.Target,
486 opt_nptl: ?[]const u8,
487 dir: []const u8,
488) error{OutOfMemory}!void {
489 const arch = target.cpu.arch;
490 const is_x86 = arch.isX86();
491 const is_aarch64 = arch.isAARCH64();
492 const is_ppc = arch.isPowerPC();
493 const is_sparc = arch.isSPARC();
494 const is_64 = target.ptrBitWidth() == 64;
495
496 const s = path.sep_str;
497
498 if (is_x86) {
499 if (arch == .x86_64) {
500 if (opt_nptl) |nptl| {
501 try args.append("-I");
502 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", nptl }));
503 } else {
504 if (target.abi == .gnux32) {
505 try args.append("-I");
506 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", "x32" }));
507 }
508 try args.append("-I");
509 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64" }));
510 }
511 } else if (arch == .x86) {
512 if (opt_nptl) |nptl| {
513 try args.append("-I");
514 try args.append(try path.join(arena, &[_][]const u8{ dir, "i386", nptl }));
515 } else {
516 try args.append("-I");
517 try args.append(try path.join(arena, &[_][]const u8{ dir, "i386" }));
518 }
519 }
520 if (opt_nptl) |nptl| {
521 try args.append("-I");
522 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86", nptl }));
523 } else {
524 try args.append("-I");
525 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86" }));
526 }
527 } else if (arch.isArm()) {
528 if (opt_nptl) |nptl| {
529 try args.append("-I");
530 try args.append(try path.join(arena, &[_][]const u8{ dir, "arm", nptl }));
531 } else {
532 try args.append("-I");
533 try args.append(try path.join(arena, &[_][]const u8{ dir, "arm" }));
534 }
535 } else if (arch.isMIPS()) {
536 if (opt_nptl) |nptl| {
537 try args.append("-I");
538 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips", nptl }));
539 } else {
540 if (is_64) {
541 try args.append("-I");
542 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips64" }));
543 } else {
544 try args.append("-I");
545 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips32" }));
546 }
547 try args.append("-I");
548 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" }));
549 }
550 } else if (is_sparc) {
551 if (opt_nptl) |nptl| {
552 try args.append("-I");
553 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc", nptl }));
554 } else {
555 if (is_64) {
556 try args.append("-I");
557 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc64" }));
558 } else {
559 try args.append("-I");
560 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc32" }));
561 }
562 try args.append("-I");
563 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" }));
564 }
565 } else if (is_aarch64) {
566 if (opt_nptl) |nptl| {
567 try args.append("-I");
568 try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64", nptl }));
569 } else {
570 try args.append("-I");
571 try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64" }));
572 }
573 } else if (is_ppc) {
574 if (opt_nptl) |nptl| {
575 try args.append("-I");
576 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc", nptl }));
577 } else {
578 if (is_64) {
579 try args.append("-I");
580 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc64" }));
581 } else {
582 try args.append("-I");
583 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc32" }));
584 }
585 try args.append("-I");
586 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" }));
587 }
588 } else if (arch.isRISCV()) {
589 if (opt_nptl) |nptl| {
590 try args.append("-I");
591 try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv", nptl }));
592 } else {
593 try args.append("-I");
594 try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv" }));
595 }
596 } else if (arch == .s390x) {
597 if (opt_nptl) |nptl| {
598 try args.append("-I");
599 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390", nptl }));
600 } else {
601 try args.append("-I");
602 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" ++ s ++ "s390-64" }));
603 try args.append("-I");
604 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" }));
605 }
606 } else if (arch.isLoongArch()) {
607 try args.append("-I");
608 try args.append(try path.join(arena, &[_][]const u8{ dir, "loongarch" }));
609 } else if (arch == .m68k) {
610 if (opt_nptl) |nptl| {
611 try args.append("-I");
612 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k", nptl }));
613 } else {
614 // coldfire ABI support requires: https://github.com/ziglang/zig/issues/20690
615 try args.append("-I");
616 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" ++ s ++ "m680x0" }));
617 try args.append("-I");
618 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" }));
619 }
620 } else if (arch == .arc) {
621 try args.append("-I");
622 try args.append(try path.join(arena, &[_][]const u8{ dir, "arc" }));
623 } else if (arch == .csky) {
624 try args.append("-I");
625 try args.append(try path.join(arena, &[_][]const u8{ dir, "csky" }));
626 }
627}
628
629fn path_from_lib(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
630 return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
631}
632
633const lib_libc = "libc" ++ path.sep_str;
634const lib_libc_glibc = lib_libc ++ "glibc" ++ path.sep_str;
635
636fn lib_path(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
637 return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
638}
639
640pub const BuiltSharedObjects = struct {
641 lock: Cache.Lock,
642 dir_path: Path,
643
644 pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void {
645 self.lock.release();
646 gpa.free(self.dir_path.sub_path);
647 self.* = undefined;
648 }
649};
650
651const all_map_basename = "all.map";
652
653fn wordDirective(target: std.Target) []const u8 {
654 // Based on its description in the GNU `as` manual, you might assume that `.word` is sized
655 // according to the target word size. But no; that would just make too much sense.
656 return if (target.ptrBitWidth() == 64) ".quad" else ".long";
657}
658
659/// TODO replace anyerror with explicit error set, recording user-friendly errors with
660/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
661pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void {
662 const tracy = trace(@src());
663 defer tracy.end();
664
665 if (!build_options.have_llvm) {
666 return error.ZigCompilerNotBuiltWithLLVMExtensions;
667 }
668
669 const gpa = comp.gpa;
670
671 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
672 defer arena_allocator.deinit();
673 const arena = arena_allocator.allocator();
674
675 const target = comp.getTarget();
676 const target_version = target.os.versionRange().gnuLibCVersion().?;
677
678 // Use the global cache directory.
679 var cache: Cache = .{
680 .gpa = gpa,
681 .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
682 };
683 cache.addPrefix(.{ .path = null, .handle = fs.cwd() });
684 cache.addPrefix(comp.zig_lib_directory);
685 cache.addPrefix(comp.global_cache_directory);
686 defer cache.manifest_dir.close();
687
688 var man = cache.obtain();
689 defer man.deinit();
690 man.hash.addBytes(build_options.version);
691 man.hash.add(target.cpu.arch);
692 man.hash.add(target.abi);
693 man.hash.add(target_version);
694
695 const full_abilists_path = try comp.zig_lib_directory.join(arena, &.{abilists_path});
696 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);
697
698 if (try man.hit()) {
699 const digest = man.final();
700
701 return queueSharedObjects(comp, .{
702 .lock = man.toOwnedLock(),
703 .dir_path = .{
704 .root_dir = comp.global_cache_directory,
705 .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
706 },
707 });
708 }
709
710 const digest = man.final();
711 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
712
713 var o_directory: Compilation.Directory = .{
714 .handle = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{}),
715 .path = try comp.global_cache_directory.join(arena, &.{o_sub_path}),
716 };
717 defer o_directory.handle.close();
718
719 const abilists_contents = man.files.keys()[abilists_index].contents.?;
720 const metadata = try loadMetaData(gpa, abilists_contents);
721 defer metadata.destroy(gpa);
722
723 const target_targ_index = for (metadata.all_targets, 0..) |targ, i| {
724 if (targ.arch == target.cpu.arch and
725 targ.os == target.os.tag and
726 targ.abi == target.abi)
727 {
728 break i;
729 }
730 } else {
731 unreachable; // std.zig.target.available_libcs prevents us from getting here
732 };
733
734 const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {
735 switch (ver.order(target_version)) {
736 .eq => break i,
737 .lt => continue,
738 .gt => {
739 // TODO Expose via compile error mechanism instead of log.
740 log.warn("invalid target glibc version: {}", .{target_version});
741 return error.InvalidTargetGLibCVersion;
742 },
743 }
744 } else blk: {
745 const latest_index = metadata.all_versions.len - 1;
746 log.warn("zig cannot build new glibc version {}; providing instead {}", .{
747 target_version, metadata.all_versions[latest_index],
748 });
749 break :blk latest_index;
750 };
751
752 {
753 var map_contents = std.ArrayList(u8).init(arena);
754 for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
755 if (ver.patch == 0) {
756 try map_contents.writer().print("GLIBC_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
757 } else {
758 try map_contents.writer().print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
759 }
760 }
761 try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
762 map_contents.deinit(); // The most recent allocation of an arena can be freed :)
763 }
764
765 var stubs_asm = std.ArrayList(u8).init(gpa);
766 defer stubs_asm.deinit();
767
768 for (libs, 0..) |lib, lib_i| {
769 if (lib.removed_in) |rem_in| {
770 if (target_version.order(rem_in) != .lt) continue;
771 }
772
773 stubs_asm.shrinkRetainingCapacity(0);
774 try stubs_asm.appendSlice(".text\n");
775
776 var sym_i: usize = 0;
777 var sym_name_buf = std.ArrayList(u8).init(arena);
778 var opt_symbol_name: ?[]const u8 = null;
779 var versions_buffer: [32]u8 = undefined;
780 var versions_len: usize = undefined;
781
782 // There can be situations where there are multiple inclusions for the same symbol with
783 // partially overlapping versions, due to different target lists. For example:
784 //
785 // lgammal:
786 // library: libm.so
787 // versions: 2.4 2.23
788 // targets: ... powerpc64-linux-gnu s390x-linux-gnu
789 // lgammal:
790 // library: libm.so
791 // versions: 2.2 2.23
792 // targets: sparc64-linux-gnu s390x-linux-gnu
793 //
794 // If we don't handle this, we end up writing the default `lgammal` symbol for version 2.33
795 // twice, which causes a "duplicate symbol" assembler error.
796 var versions_written = std.AutoArrayHashMap(Version, void).init(arena);
797
798 var inc_fbs = std.io.fixedBufferStream(metadata.inclusions);
799 var inc_reader = inc_fbs.reader();
800
801 const fn_inclusions_len = try inc_reader.readInt(u16, .little);
802
803 while (sym_i < fn_inclusions_len) : (sym_i += 1) {
804 const sym_name = opt_symbol_name orelse n: {
805 sym_name_buf.clearRetainingCapacity();
806 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
807
808 opt_symbol_name = sym_name_buf.items;
809 versions_buffer = undefined;
810 versions_len = 0;
811
812 break :n sym_name_buf.items;
813 };
814 const targets = try std.leb.readUleb128(u64, inc_reader);
815 var lib_index = try inc_reader.readByte();
816
817 const is_terminal = (lib_index & (1 << 7)) != 0;
818 if (is_terminal) {
819 lib_index &= ~@as(u8, 1 << 7);
820 opt_symbol_name = null;
821 }
822
823 // Test whether the inclusion applies to our current library and target.
824 const ok_lib_and_target =
825 (lib_index == lib_i) and
826 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
827
828 while (true) {
829 const byte = try inc_reader.readByte();
830 const last = (byte & 0b1000_0000) != 0;
831 const ver_i = @as(u7, @truncate(byte));
832 if (ok_lib_and_target and ver_i <= target_ver_index) {
833 versions_buffer[versions_len] = ver_i;
834 versions_len += 1;
835 }
836 if (last) break;
837 }
838
839 if (!is_terminal) continue;
840
841 // Pick the default symbol version:
842 // - If there are no versions, don't emit it
843 // - Take the greatest one <= than the target one
844 // - If none of them is <= than the
845 // specified one don't pick any default version
846 if (versions_len == 0) continue;
847 var chosen_def_ver_index: u8 = 255;
848 {
849 var ver_buf_i: u8 = 0;
850 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
851 const ver_index = versions_buffer[ver_buf_i];
852 if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
853 chosen_def_ver_index = ver_index;
854 }
855 }
856 }
857
858 versions_written.clearRetainingCapacity();
859 try versions_written.ensureTotalCapacity(versions_len);
860
861 {
862 var ver_buf_i: u8 = 0;
863 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
864 // Example:
865 // .balign 4
866 // .globl _Exit_2_2_5
867 // .type _Exit_2_2_5, %function
868 // .symver _Exit_2_2_5, _Exit@@GLIBC_2.2.5, remove
869 // _Exit_2_2_5: .long 0
870 const ver_index = versions_buffer[ver_buf_i];
871 const ver = metadata.all_versions[ver_index];
872
873 if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
874
875 // Default symbol version definition vs normal symbol version definition
876 const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
877 const at_sign_str: []const u8 = if (want_default) "@@" else "@";
878 if (ver.patch == 0) {
879 const sym_plus_ver = try std.fmt.allocPrint(
880 arena,
881 "{s}_{d}_{d}",
882 .{ sym_name, ver.major, ver.minor },
883 );
884 try stubs_asm.writer().print(
885 \\.balign {d}
886 \\.globl {s}
887 \\.type {s}, %function
888 \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
889 \\{s}: {s} 0
890 \\
891 , .{
892 target.ptrBitWidth() / 8,
893 sym_plus_ver,
894 sym_plus_ver,
895 sym_plus_ver,
896 sym_name,
897 at_sign_str,
898 ver.major,
899 ver.minor,
900 sym_plus_ver,
901 wordDirective(target),
902 });
903 } else {
904 const sym_plus_ver = try std.fmt.allocPrint(
905 arena,
906 "{s}_{d}_{d}_{d}",
907 .{ sym_name, ver.major, ver.minor, ver.patch },
908 );
909 try stubs_asm.writer().print(
910 \\.balign {d}
911 \\.globl {s}
912 \\.type {s}, %function
913 \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
914 \\{s}: {s} 0
915 \\
916 , .{
917 target.ptrBitWidth() / 8,
918 sym_plus_ver,
919 sym_plus_ver,
920 sym_plus_ver,
921 sym_name,
922 at_sign_str,
923 ver.major,
924 ver.minor,
925 ver.patch,
926 sym_plus_ver,
927 wordDirective(target),
928 });
929 }
930 }
931 }
932 }
933
934 try stubs_asm.appendSlice(".rodata\n");
935
936 // For some targets, the real `libc.so.6` will contain a weak reference to `_IO_stdin_used`,
937 // making the linker put the symbol in the dynamic symbol table. We likewise need to emit a
938 // reference to it here for that effect, or it will not show up, which in turn will cause
939 // the real glibc to think that the program was built against an ancient `FILE` structure
940 // (pre-glibc 2.1).
941 //
942 // Note that glibc only compiles in the legacy compatibility code for some targets; it
943 // depends on what is defined in the `shlib-versions` file for the particular architecture
944 // and ABI. Those files are preprocessed by 2 separate tools during the glibc build to get
945 // the final `abi-versions.h`, so it would be quite brittle to try to condition our emission
946 // of the `_IO_stdin_used` reference in the exact same way. The only downside of emitting
947 // the reference unconditionally is that it ends up being unused for newer targets; it
948 // otherwise has no negative effect.
949 //
950 // glibc uses a weak reference because it has to work with programs compiled against pre-2.1
951 // versions where the symbol didn't exist. We only care about modern glibc versions, so use
952 // a strong reference.
953 if (std.mem.eql(u8, lib.name, "c")) {
954 try stubs_asm.writer().print(
955 \\.balign {d}
956 \\.globl _IO_stdin_used
957 \\{s} _IO_stdin_used
958 \\
959 , .{
960 target.ptrBitWidth() / 8,
961 wordDirective(target),
962 });
963 }
964
965 try stubs_asm.appendSlice(".data\n");
966
967 const obj_inclusions_len = try inc_reader.readInt(u16, .little);
968
969 sym_i = 0;
970 opt_symbol_name = null;
971 versions_buffer = undefined;
972 versions_len = undefined;
973 while (sym_i < obj_inclusions_len) : (sym_i += 1) {
974 const sym_name = opt_symbol_name orelse n: {
975 sym_name_buf.clearRetainingCapacity();
976 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
977
978 opt_symbol_name = sym_name_buf.items;
979 versions_buffer = undefined;
980 versions_len = 0;
981
982 break :n sym_name_buf.items;
983 };
984 const targets = try std.leb.readUleb128(u64, inc_reader);
985 const size = try std.leb.readUleb128(u16, inc_reader);
986 var lib_index = try inc_reader.readByte();
987
988 const is_terminal = (lib_index & (1 << 7)) != 0;
989 if (is_terminal) {
990 lib_index &= ~@as(u8, 1 << 7);
991 opt_symbol_name = null;
992 }
993
994 // Test whether the inclusion applies to our current library and target.
995 const ok_lib_and_target =
996 (lib_index == lib_i) and
997 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
998
999 while (true) {
1000 const byte = try inc_reader.readByte();
1001 const last = (byte & 0b1000_0000) != 0;
1002 const ver_i = @as(u7, @truncate(byte));
1003 if (ok_lib_and_target and ver_i <= target_ver_index) {
1004 versions_buffer[versions_len] = ver_i;
1005 versions_len += 1;
1006 }
1007 if (last) break;
1008 }
1009
1010 if (!is_terminal) continue;
1011
1012 // Pick the default symbol version:
1013 // - If there are no versions, don't emit it
1014 // - Take the greatest one <= than the target one
1015 // - If none of them is <= than the
1016 // specified one don't pick any default version
1017 if (versions_len == 0) continue;
1018 var chosen_def_ver_index: u8 = 255;
1019 {
1020 var ver_buf_i: u8 = 0;
1021 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
1022 const ver_index = versions_buffer[ver_buf_i];
1023 if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
1024 chosen_def_ver_index = ver_index;
1025 }
1026 }
1027 }
1028
1029 versions_written.clearRetainingCapacity();
1030 try versions_written.ensureTotalCapacity(versions_len);
1031
1032 {
1033 var ver_buf_i: u8 = 0;
1034 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
1035 // Example:
1036 // .balign 4
1037 // .globl environ_2_2_5
1038 // .type environ_2_2_5, %object
1039 // .size environ_2_2_5, 4
1040 // .symver environ_2_2_5, environ@@GLIBC_2.2.5, remove
1041 // environ_2_2_5: .fill 4, 1, 0
1042 const ver_index = versions_buffer[ver_buf_i];
1043 const ver = metadata.all_versions[ver_index];
1044
1045 if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
1046
1047 // Default symbol version definition vs normal symbol version definition
1048 const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
1049 const at_sign_str: []const u8 = if (want_default) "@@" else "@";
1050 if (ver.patch == 0) {
1051 const sym_plus_ver = try std.fmt.allocPrint(
1052 arena,
1053 "{s}_{d}_{d}",
1054 .{ sym_name, ver.major, ver.minor },
1055 );
1056 try stubs_asm.writer().print(
1057 \\.balign {d}
1058 \\.globl {s}
1059 \\.type {s}, %object
1060 \\.size {s}, {d}
1061 \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
1062 \\{s}: .fill {d}, 1, 0
1063 \\
1064 , .{
1065 target.ptrBitWidth() / 8,
1066 sym_plus_ver,
1067 sym_plus_ver,
1068 sym_plus_ver,
1069 size,
1070 sym_plus_ver,
1071 sym_name,
1072 at_sign_str,
1073 ver.major,
1074 ver.minor,
1075 sym_plus_ver,
1076 size,
1077 });
1078 } else {
1079 const sym_plus_ver = try std.fmt.allocPrint(
1080 arena,
1081 "{s}_{d}_{d}_{d}",
1082 .{ sym_name, ver.major, ver.minor, ver.patch },
1083 );
1084 try stubs_asm.writer().print(
1085 \\.balign {d}
1086 \\.globl {s}
1087 \\.type {s}, %object
1088 \\.size {s}, {d}
1089 \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
1090 \\{s}: .fill {d}, 1, 0
1091 \\
1092 , .{
1093 target.ptrBitWidth() / 8,
1094 sym_plus_ver,
1095 sym_plus_ver,
1096 sym_plus_ver,
1097 size,
1098 sym_plus_ver,
1099 sym_name,
1100 at_sign_str,
1101 ver.major,
1102 ver.minor,
1103 ver.patch,
1104 sym_plus_ver,
1105 size,
1106 });
1107 }
1108 }
1109 }
1110 }
1111
1112 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
1113 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1114 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
1115 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
1116 }
1117
1118 man.writeManifest() catch |err| {
1119 log.warn("failed to write cache manifest for glibc stubs: {s}", .{@errorName(err)});
1120 };
1121
1122 return queueSharedObjects(comp, .{
1123 .lock = man.toOwnedLock(),
1124 .dir_path = .{
1125 .root_dir = comp.global_cache_directory,
1126 .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
1127 },
1128 });
1129}
1130
1131pub fn sharedObjectsCount(target: *const std.Target) u8 {
1132 const target_version = target.os.versionRange().gnuLibCVersion() orelse return 0;
1133 var count: u8 = 0;
1134 for (libs) |lib| {
1135 if (lib.removed_in) |rem_in| {
1136 if (target_version.order(rem_in) != .lt) continue;
1137 }
1138 count += 1;
1139 }
1140 return count;
1141}
1142
1143fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
1144 const target_version = comp.getTarget().os.versionRange().gnuLibCVersion().?;
1145
1146 assert(comp.glibc_so_files == null);
1147 comp.glibc_so_files = so_files;
1148
1149 var task_buffer: [libs.len]link.Task = undefined;
1150 var task_buffer_i: usize = 0;
1151
1152 {
1153 comp.mutex.lock(); // protect comp.arena
1154 defer comp.mutex.unlock();
1155
1156 for (libs) |lib| {
1157 if (lib.removed_in) |rem_in| {
1158 if (target_version.order(rem_in) != .lt) continue;
1159 }
1160 const so_path: Path = .{
1161 .root_dir = so_files.dir_path.root_dir,
1162 .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{
1163 so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover,
1164 }) catch return comp.setAllocFailure(),
1165 };
1166 task_buffer[task_buffer_i] = .{ .load_dso = so_path };
1167 task_buffer_i += 1;
1168 }
1169 }
1170
1171 comp.queueLinkTasks(task_buffer[0..task_buffer_i]);
1172}
1173
1174fn buildSharedLib(
1175 comp: *Compilation,
1176 arena: Allocator,
1177 zig_cache_directory: Compilation.Directory,
1178 bin_directory: Compilation.Directory,
1179 asm_file_basename: []const u8,
1180 lib: Lib,
1181 prog_node: std.Progress.Node,
1182) !void {
1183 const tracy = trace(@src());
1184 defer tracy.end();
1185
1186 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover });
1187 const emit_bin = Compilation.EmitLoc{
1188 .directory = bin_directory,
1189 .basename = basename,
1190 };
1191 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };
1192 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);
1193 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
1194 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
1195
1196 const optimize_mode = comp.compilerRtOptMode();
1197 const strip = comp.compilerRtStrip();
1198 const config = try Compilation.Config.resolve(.{
1199 .output_mode = .Lib,
1200 .link_mode = .dynamic,
1201 .resolved_target = comp.root_mod.resolved_target,
1202 .is_test = false,
1203 .have_zcu = false,
1204 .emit_bin = true,
1205 .root_optimize_mode = optimize_mode,
1206 .root_strip = strip,
1207 .link_libc = false,
1208 });
1209
1210 const root_mod = try Module.create(arena, .{
1211 .global_cache_directory = comp.global_cache_directory,
1212 .paths = .{
1213 .root = .{ .root_dir = comp.zig_lib_directory },
1214 .root_src_path = "",
1215 },
1216 .fully_qualified_name = "root",
1217 .inherited = .{
1218 .resolved_target = comp.root_mod.resolved_target,
1219 .strip = strip,
1220 .stack_check = false,
1221 .stack_protector = 0,
1222 .sanitize_c = .off,
1223 .sanitize_thread = false,
1224 .red_zone = comp.root_mod.red_zone,
1225 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
1226 .valgrind = false,
1227 .optimize_mode = optimize_mode,
1228 .structured_cfg = comp.root_mod.structured_cfg,
1229 },
1230 .global = config,
1231 .cc_argv = &.{},
1232 .parent = null,
1233 .builtin_mod = null,
1234 .builtin_modules = null, // there is only one module in this compilation
1235 });
1236
1237 const c_source_files = [1]Compilation.CSourceFile{
1238 .{
1239 .src_path = try path.join(arena, &.{ bin_directory.path.?, asm_file_basename }),
1240 .owner = root_mod,
1241 },
1242 };
1243
1244 const sub_compilation = try Compilation.create(comp.gpa, arena, .{
1245 .local_cache_directory = zig_cache_directory,
1246 .global_cache_directory = comp.global_cache_directory,
1247 .zig_lib_directory = comp.zig_lib_directory,
1248 .thread_pool = comp.thread_pool,
1249 .self_exe_path = comp.self_exe_path,
1250 .cache_mode = .incremental,
1251 .config = config,
1252 .root_mod = root_mod,
1253 .root_name = lib.name,
1254 .libc_installation = comp.libc_installation,
1255 .emit_bin = emit_bin,
1256 .emit_h = null,
1257 .verbose_cc = comp.verbose_cc,
1258 .verbose_link = comp.verbose_link,
1259 .verbose_air = comp.verbose_air,
1260 .verbose_llvm_ir = comp.verbose_llvm_ir,
1261 .verbose_llvm_bc = comp.verbose_llvm_bc,
1262 .verbose_cimport = comp.verbose_cimport,
1263 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
1264 .clang_passthrough_mode = comp.clang_passthrough_mode,
1265 .version = version,
1266 .version_script = map_file_path,
1267 .soname = soname,
1268 .c_source_files = &c_source_files,
1269 .skip_linker_dependencies = true,
1270 });
1271 defer sub_compilation.destroy();
1272
1273 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
1274}
1275
1276pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
1277 return switch (output_mode) {
1278 .Obj, .Lib => null,
1279 .Exe => .scrt1_o,
1280 };
1281}
src/libcxx.zig deleted-578
...@@ -1,578 +0,0 @@
1const std = @import("std");
2const path = std.fs.path;
3const assert = std.debug.assert;
4
5const target_util = @import("target.zig");
6const Compilation = @import("Compilation.zig");
7const build_options = @import("build_options");
8const trace = @import("tracy.zig").trace;
9const Module = @import("Package/Module.zig");
10
11const libcxxabi_files = [_][]const u8{
12 "src/abort_message.cpp",
13 "src/cxa_aux_runtime.cpp",
14 "src/cxa_default_handlers.cpp",
15 "src/cxa_demangle.cpp",
16 "src/cxa_exception.cpp",
17 "src/cxa_exception_storage.cpp",
18 "src/cxa_guard.cpp",
19 "src/cxa_handlers.cpp",
20 "src/cxa_noexception.cpp",
21 "src/cxa_personality.cpp",
22 "src/cxa_thread_atexit.cpp",
23 "src/cxa_vector.cpp",
24 "src/cxa_virtual.cpp",
25 "src/fallback_malloc.cpp",
26 "src/private_typeinfo.cpp",
27 "src/stdlib_exception.cpp",
28 "src/stdlib_new_delete.cpp",
29 "src/stdlib_stdexcept.cpp",
30 "src/stdlib_typeinfo.cpp",
31};
32
33const libcxx_base_files = [_][]const u8{
34 "src/algorithm.cpp",
35 "src/any.cpp",
36 "src/bind.cpp",
37 "src/call_once.cpp",
38 "src/charconv.cpp",
39 "src/chrono.cpp",
40 "src/error_category.cpp",
41 "src/exception.cpp",
42 "src/expected.cpp",
43 "src/filesystem/directory_entry.cpp",
44 "src/filesystem/directory_iterator.cpp",
45 "src/filesystem/filesystem_clock.cpp",
46 "src/filesystem/filesystem_error.cpp",
47 // omit int128_builtins.cpp because it provides __muloti4 which is already provided
48 // by compiler_rt and crashes on Windows x86_64: https://github.com/ziglang/zig/issues/10719
49 //"src/filesystem/int128_builtins.cpp",
50 "src/filesystem/operations.cpp",
51 "src/filesystem/path.cpp",
52 "src/fstream.cpp",
53 "src/functional.cpp",
54 "src/hash.cpp",
55 "src/ios.cpp",
56 "src/ios.instantiations.cpp",
57 "src/iostream.cpp",
58 "src/locale.cpp",
59 "src/memory.cpp",
60 "src/memory_resource.cpp",
61 "src/new.cpp",
62 "src/new_handler.cpp",
63 "src/new_helpers.cpp",
64 "src/optional.cpp",
65 "src/ostream.cpp",
66 "src/print.cpp",
67 //"src/pstl/libdispatch.cpp",
68 "src/random.cpp",
69 "src/random_shuffle.cpp",
70 "src/regex.cpp",
71 "src/ryu/d2fixed.cpp",
72 "src/ryu/d2s.cpp",
73 "src/ryu/f2s.cpp",
74 "src/stdexcept.cpp",
75 "src/string.cpp",
76 "src/strstream.cpp",
77 "src/support/ibm/mbsnrtowcs.cpp",
78 "src/support/ibm/wcsnrtombs.cpp",
79 "src/support/ibm/xlocale_zos.cpp",
80 "src/support/win32/locale_win32.cpp",
81 "src/support/win32/support.cpp",
82 "src/system_error.cpp",
83 "src/typeinfo.cpp",
84 "src/valarray.cpp",
85 "src/variant.cpp",
86 "src/vector.cpp",
87 "src/verbose_abort.cpp",
88};
89
90const libcxx_thread_files = [_][]const u8{
91 "src/atomic.cpp",
92 "src/barrier.cpp",
93 "src/condition_variable.cpp",
94 "src/condition_variable_destructor.cpp",
95 "src/future.cpp",
96 "src/mutex.cpp",
97 "src/mutex_destructor.cpp",
98 "src/shared_mutex.cpp",
99 "src/support/win32/thread_win32.cpp",
100 "src/thread.cpp",
101};
102
103pub const BuildError = error{
104 OutOfMemory,
105 SubCompilationFailed,
106 ZigCompilerNotBuiltWithLLVMExtensions,
107};
108
109pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
110 if (!build_options.have_llvm) {
111 return error.ZigCompilerNotBuiltWithLLVMExtensions;
112 }
113
114 const tracy = trace(@src());
115 defer tracy.end();
116
117 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
118 defer arena_allocator.deinit();
119 const arena = arena_allocator.allocator();
120
121 const root_name = "c++";
122 const output_mode = .Lib;
123 const link_mode = .static;
124 const target = comp.root_mod.resolved_target.result;
125 const basename = try std.zig.binNameAlloc(arena, .{
126 .root_name = root_name,
127 .target = target,
128 .output_mode = output_mode,
129 .link_mode = link_mode,
130 });
131
132 const emit_bin = Compilation.EmitLoc{
133 .directory = null, // Put it in the cache directory.
134 .basename = basename,
135 };
136
137 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
138 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
139 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
140 const cxx_libc_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "libc" });
141
142 const optimize_mode = comp.compilerRtOptMode();
143 const strip = comp.compilerRtStrip();
144
145 const config = Compilation.Config.resolve(.{
146 .output_mode = output_mode,
147 .link_mode = link_mode,
148 .resolved_target = comp.root_mod.resolved_target,
149 .is_test = false,
150 .have_zcu = false,
151 .emit_bin = true,
152 .root_optimize_mode = optimize_mode,
153 .root_strip = strip,
154 .link_libc = true,
155 .lto = comp.config.lto,
156 .any_sanitize_thread = comp.config.any_sanitize_thread,
157 }) catch |err| {
158 comp.setMiscFailure(
159 .libcxx,
160 "unable to build libc++: resolving configuration failed: {s}",
161 .{@errorName(err)},
162 );
163 return error.SubCompilationFailed;
164 };
165
166 const root_mod = Module.create(arena, .{
167 .global_cache_directory = comp.global_cache_directory,
168 .paths = .{
169 .root = .{ .root_dir = comp.zig_lib_directory },
170 .root_src_path = "",
171 },
172 .fully_qualified_name = "root",
173 .inherited = .{
174 .resolved_target = comp.root_mod.resolved_target,
175 .strip = strip,
176 .stack_check = false,
177 .stack_protector = 0,
178 .sanitize_c = .off,
179 .sanitize_thread = comp.config.any_sanitize_thread,
180 .red_zone = comp.root_mod.red_zone,
181 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
182 .valgrind = false,
183 .optimize_mode = optimize_mode,
184 .structured_cfg = comp.root_mod.structured_cfg,
185 .pic = if (target_util.supports_fpic(target)) true else null,
186 .code_model = comp.root_mod.code_model,
187 },
188 .global = config,
189 .cc_argv = &.{},
190 .parent = null,
191 .builtin_mod = null,
192 .builtin_modules = null, // there is only one module in this compilation
193 }) catch |err| {
194 comp.setMiscFailure(
195 .libcxx,
196 "unable to build libc++: creating module failed: {s}",
197 .{@errorName(err)},
198 );
199 return error.SubCompilationFailed;
200 };
201
202 const libcxx_files = if (comp.config.any_non_single_threaded)
203 &(libcxx_base_files ++ libcxx_thread_files)
204 else
205 &libcxx_base_files;
206
207 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
208
209 for (libcxx_files) |cxx_src| {
210 // These don't compile on WASI due to e.g. `fchmod` usage.
211 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/") and target.os.tag == .wasi)
212 continue;
213 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
214 continue;
215 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
216 continue;
217
218 var cflags = std.ArrayList([]const u8).init(arena);
219
220 try addCxxArgs(comp, arena, &cflags);
221
222 try cflags.append("-DNDEBUG");
223 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
224 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
225 try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
226 try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
227
228 try cflags.append("-fvisibility=hidden");
229 try cflags.append("-fvisibility-inlines-hidden");
230
231 if (target.os.tag == .zos) {
232 try cflags.append("-fno-aligned-allocation");
233 } else {
234 try cflags.append("-faligned-allocation");
235 }
236
237 try cflags.append("-nostdinc++");
238 try cflags.append("-std=c++23");
239 try cflags.append("-Wno-user-defined-literals");
240 try cflags.append("-Wno-covered-switch-default");
241 try cflags.append("-Wno-suggest-override");
242
243 // These depend on only the zig lib directory file path, which is
244 // purposefully either in the cache or not in the cache. The decision
245 // should not be overridden here.
246 var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
247
248 try cache_exempt_flags.append("-I");
249 try cache_exempt_flags.append(cxx_include_path);
250
251 try cache_exempt_flags.append("-I");
252 try cache_exempt_flags.append(cxxabi_include_path);
253
254 try cache_exempt_flags.append("-I");
255 try cache_exempt_flags.append(cxx_src_include_path);
256
257 try cache_exempt_flags.append("-I");
258 try cache_exempt_flags.append(cxx_libc_include_path);
259
260 c_source_files.appendAssumeCapacity(.{
261 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }),
262 .extra_flags = cflags.items,
263 .cache_exempt_flags = cache_exempt_flags.items,
264 .owner = root_mod,
265 });
266 }
267
268 const sub_compilation = Compilation.create(comp.gpa, arena, .{
269 .local_cache_directory = comp.global_cache_directory,
270 .global_cache_directory = comp.global_cache_directory,
271 .zig_lib_directory = comp.zig_lib_directory,
272 .self_exe_path = comp.self_exe_path,
273 .cache_mode = .whole,
274 .config = config,
275 .root_mod = root_mod,
276 .root_name = root_name,
277 .thread_pool = comp.thread_pool,
278 .libc_installation = comp.libc_installation,
279 .emit_bin = emit_bin,
280 .emit_h = null,
281 .c_source_files = c_source_files.items,
282 .verbose_cc = comp.verbose_cc,
283 .verbose_link = comp.verbose_link,
284 .verbose_air = comp.verbose_air,
285 .verbose_llvm_ir = comp.verbose_llvm_ir,
286 .verbose_llvm_bc = comp.verbose_llvm_bc,
287 .verbose_cimport = comp.verbose_cimport,
288 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
289 .clang_passthrough_mode = comp.clang_passthrough_mode,
290 .skip_linker_dependencies = true,
291 }) catch |err| {
292 comp.setMiscFailure(
293 .libcxx,
294 "unable to build libc++: create compilation failed: {s}",
295 .{@errorName(err)},
296 );
297 return error.SubCompilationFailed;
298 };
299 defer sub_compilation.destroy();
300
301 comp.updateSubCompilation(sub_compilation, .libcxx, prog_node) catch |err| switch (err) {
302 error.SubCompilationFailed => return error.SubCompilationFailed,
303 else => |e| {
304 comp.setMiscFailure(
305 .libcxx,
306 "unable to build libc++: compilation failed: {s}",
307 .{@errorName(e)},
308 );
309 return error.SubCompilationFailed;
310 },
311 };
312
313 assert(comp.libcxx_static_lib == null);
314 const crt_file = try sub_compilation.toCrtFile();
315 comp.libcxx_static_lib = crt_file;
316 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
317}
318
319pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
320 if (!build_options.have_llvm) {
321 return error.ZigCompilerNotBuiltWithLLVMExtensions;
322 }
323
324 const tracy = trace(@src());
325 defer tracy.end();
326
327 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
328 defer arena_allocator.deinit();
329 const arena = arena_allocator.allocator();
330
331 const root_name = "c++abi";
332 const output_mode = .Lib;
333 const link_mode = .static;
334 const target = comp.root_mod.resolved_target.result;
335 const basename = try std.zig.binNameAlloc(arena, .{
336 .root_name = root_name,
337 .target = target,
338 .output_mode = output_mode,
339 .link_mode = link_mode,
340 });
341
342 const emit_bin = Compilation.EmitLoc{
343 .directory = null, // Put it in the cache directory.
344 .basename = basename,
345 };
346
347 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
348 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
349 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
350
351 const optimize_mode = comp.compilerRtOptMode();
352 const strip = comp.compilerRtStrip();
353 // See the `-fno-exceptions` logic for WASI.
354 // The old 32-bit x86 variant of SEH doesn't use tables.
355 const unwind_tables: std.builtin.UnwindTables =
356 if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .@"async";
357
358 const config = Compilation.Config.resolve(.{
359 .output_mode = output_mode,
360 .link_mode = link_mode,
361 .resolved_target = comp.root_mod.resolved_target,
362 .is_test = false,
363 .have_zcu = false,
364 .emit_bin = true,
365 .root_optimize_mode = optimize_mode,
366 .root_strip = strip,
367 .link_libc = true,
368 .any_unwind_tables = unwind_tables != .none,
369 .lto = comp.config.lto,
370 .any_sanitize_thread = comp.config.any_sanitize_thread,
371 }) catch |err| {
372 comp.setMiscFailure(
373 .libcxxabi,
374 "unable to build libc++abi: resolving configuration failed: {s}",
375 .{@errorName(err)},
376 );
377 return error.SubCompilationFailed;
378 };
379
380 const root_mod = Module.create(arena, .{
381 .global_cache_directory = comp.global_cache_directory,
382 .paths = .{
383 .root = .{ .root_dir = comp.zig_lib_directory },
384 .root_src_path = "",
385 },
386 .fully_qualified_name = "root",
387 .inherited = .{
388 .resolved_target = comp.root_mod.resolved_target,
389 .strip = strip,
390 .stack_check = false,
391 .stack_protector = 0,
392 .sanitize_c = .off,
393 .sanitize_thread = comp.config.any_sanitize_thread,
394 .red_zone = comp.root_mod.red_zone,
395 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
396 .valgrind = false,
397 .optimize_mode = optimize_mode,
398 .structured_cfg = comp.root_mod.structured_cfg,
399 .unwind_tables = unwind_tables,
400 .pic = comp.root_mod.pic,
401 .code_model = comp.root_mod.code_model,
402 },
403 .global = config,
404 .cc_argv = &.{},
405 .parent = null,
406 .builtin_mod = null,
407 .builtin_modules = null, // there is only one module in this compilation
408 }) catch |err| {
409 comp.setMiscFailure(
410 .libcxxabi,
411 "unable to build libc++abi: creating module failed: {s}",
412 .{@errorName(err)},
413 );
414 return error.SubCompilationFailed;
415 };
416
417 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
418
419 for (libcxxabi_files) |cxxabi_src| {
420 if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
421 continue;
422
423 var cflags = std.ArrayList([]const u8).init(arena);
424
425 try addCxxArgs(comp, arena, &cflags);
426
427 try cflags.append("-DNDEBUG");
428 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
429 if (!comp.config.any_non_single_threaded) {
430 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
431 }
432 if (target.abi.isGnu()) {
433 if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
434 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
435 }
436
437 try cflags.append("-fvisibility=hidden");
438 try cflags.append("-fvisibility-inlines-hidden");
439
440 if (target_util.supports_fpic(target)) {
441 try cflags.append("-fPIC");
442 }
443 try cflags.append("-nostdinc++");
444 try cflags.append("-fstrict-aliasing");
445 try cflags.append("-std=c++23");
446 try cflags.append("-Wno-user-defined-literals");
447 try cflags.append("-Wno-covered-switch-default");
448 try cflags.append("-Wno-suggest-override");
449
450 // These depend on only the zig lib directory file path, which is
451 // purposefully either in the cache or not in the cache. The decision
452 // should not be overridden here.
453 var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
454
455 try cache_exempt_flags.append("-I");
456 try cache_exempt_flags.append(cxxabi_include_path);
457
458 try cache_exempt_flags.append("-I");
459 try cache_exempt_flags.append(cxx_include_path);
460
461 try cache_exempt_flags.append("-I");
462 try cache_exempt_flags.append(cxx_src_include_path);
463
464 c_source_files.appendAssumeCapacity(.{
465 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }),
466 .extra_flags = cflags.items,
467 .cache_exempt_flags = cache_exempt_flags.items,
468 .owner = root_mod,
469 });
470 }
471
472 const sub_compilation = Compilation.create(comp.gpa, arena, .{
473 .local_cache_directory = comp.global_cache_directory,
474 .global_cache_directory = comp.global_cache_directory,
475 .zig_lib_directory = comp.zig_lib_directory,
476 .self_exe_path = comp.self_exe_path,
477 .cache_mode = .whole,
478 .config = config,
479 .root_mod = root_mod,
480 .root_name = root_name,
481 .thread_pool = comp.thread_pool,
482 .libc_installation = comp.libc_installation,
483 .emit_bin = emit_bin,
484 .emit_h = null,
485 .c_source_files = c_source_files.items,
486 .verbose_cc = comp.verbose_cc,
487 .verbose_link = comp.verbose_link,
488 .verbose_air = comp.verbose_air,
489 .verbose_llvm_ir = comp.verbose_llvm_ir,
490 .verbose_llvm_bc = comp.verbose_llvm_bc,
491 .verbose_cimport = comp.verbose_cimport,
492 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
493 .clang_passthrough_mode = comp.clang_passthrough_mode,
494 .skip_linker_dependencies = true,
495 }) catch |err| {
496 comp.setMiscFailure(
497 .libcxxabi,
498 "unable to build libc++abi: create compilation failed: {s}",
499 .{@errorName(err)},
500 );
501 return error.SubCompilationFailed;
502 };
503 defer sub_compilation.destroy();
504
505 comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node) catch |err| switch (err) {
506 error.SubCompilationFailed => return error.SubCompilationFailed,
507 else => |e| {
508 comp.setMiscFailure(
509 .libcxxabi,
510 "unable to build libc++abi: compilation failed: {s}",
511 .{@errorName(e)},
512 );
513 return error.SubCompilationFailed;
514 },
515 };
516
517 assert(comp.libcxxabi_static_lib == null);
518 const crt_file = try sub_compilation.toCrtFile();
519 comp.libcxxabi_static_lib = crt_file;
520 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
521}
522
523pub fn addCxxArgs(
524 comp: *const Compilation,
525 arena: std.mem.Allocator,
526 cflags: *std.ArrayList([]const u8),
527) error{OutOfMemory}!void {
528 const target = comp.getTarget();
529 const optimize_mode = comp.compilerRtOptMode();
530
531 const abi_version: u2 = if (target.os.tag == .emscripten) 2 else 1;
532 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
533 abi_version,
534 }));
535 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
536 abi_version,
537 }));
538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
539 if (!comp.config.any_non_single_threaded) "NO_" else "",
540 }));
541 try cflags.append("-D_LIBCPP_HAS_MONOTONIC_CLOCK");
542 try cflags.append("-D_LIBCPP_HAS_TERMINAL");
543 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}MUSL_LIBC", .{
544 if (!target.abi.isMusl()) "NO_" else "",
545 }));
546 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
547 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
548 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
549 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}FILESYSTEM", .{
550 if (target.os.tag == .wasi) "NO_" else "",
551 }));
552 try cflags.append("-D_LIBCPP_HAS_RANDOM_DEVICE");
553 try cflags.append("-D_LIBCPP_HAS_LOCALIZATION");
554 try cflags.append("-D_LIBCPP_HAS_UNICODE");
555 try cflags.append("-D_LIBCPP_HAS_WIDE_CHARACTERS");
556 try cflags.append("-D_LIBCPP_HAS_NO_STD_MODULES");
557 if (target.os.tag == .linux) {
558 try cflags.append("-D_LIBCPP_HAS_TIME_ZONE_DATABASE");
559 }
560 // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
561 // for potentially enabling some fancy features here, which would
562 // require corresponding changes in libcxx.zig, as well as
563 // Compilation.addCCArgs. This option makes it use serial backend which
564 // is simple and works everywhere.
565 try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
566 try cflags.append(switch (optimize_mode) {
567 .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
568 .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE",
569 .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST",
570 });
571 if (target.isGnuLibC()) {
572 // glibc 2.16 introduced aligned_alloc
573 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
574 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
575 }
576 }
577 try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
578}
src/libs/glibc.zig created+1281
...@@ -0,0 +1,1281 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const log = std.log;
5const fs = std.fs;
6const path = fs.path;
7const assert = std.debug.assert;
8const Version = std.SemanticVersion;
9const Path = std.Build.Cache.Path;
10
11const Compilation = @import("../Compilation.zig");
12const build_options = @import("build_options");
13const trace = @import("../tracy.zig").trace;
14const Cache = std.Build.Cache;
15const Module = @import("../Package/Module.zig");
16const link = @import("../link.zig");
17
18pub const Lib = struct {
19 name: []const u8,
20 sover: u8,
21 removed_in: ?Version = null,
22};
23
24pub const ABI = struct {
25 all_versions: []const Version, // all defined versions (one abilist from v2.0.0 up to current)
26 all_targets: []const std.zig.target.ArchOsAbi,
27 /// The bytes from the file verbatim, starting from the u16 number
28 /// of function inclusions.
29 inclusions: []const u8,
30 arena_state: std.heap.ArenaAllocator.State,
31
32 pub fn destroy(abi: *ABI, gpa: Allocator) void {
33 abi.arena_state.promote(gpa).deinit();
34 }
35};
36
37// The order of the elements in this array defines the linking order.
38pub const libs = [_]Lib{
39 .{ .name = "m", .sover = 6 },
40 .{ .name = "pthread", .sover = 0, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
41 .{ .name = "c", .sover = 6 },
42 .{ .name = "dl", .sover = 2, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
43 .{ .name = "rt", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
44 .{ .name = "ld", .sover = 2 },
45 .{ .name = "util", .sover = 1, .removed_in = .{ .major = 2, .minor = 34, .patch = 0 } },
46 .{ .name = "resolv", .sover = 2 },
47};
48
49pub const LoadMetaDataError = error{
50 /// The files that ship with the Zig compiler were unable to be read, or otherwise had malformed data.
51 ZigInstallationCorrupt,
52 OutOfMemory,
53};
54
55pub const abilists_path = "libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++ "abilists";
56pub const abilists_max_size = 800 * 1024; // Bigger than this and something is definitely borked.
57
58/// This function will emit a log error when there is a problem with the zig
59/// installation and then return `error.ZigInstallationCorrupt`.
60pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI {
61 const tracy = trace(@src());
62 defer tracy.end();
63
64 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
65 errdefer arena_allocator.deinit();
66 const arena = arena_allocator.allocator();
67
68 var index: usize = 0;
69
70 {
71 const libs_len = contents[index];
72 index += 1;
73
74 var i: u8 = 0;
75 while (i < libs_len) : (i += 1) {
76 const lib_name = mem.sliceTo(contents[index..], 0);
77 index += lib_name.len + 1;
78
79 if (i >= libs.len or !mem.eql(u8, libs[i].name, lib_name)) {
80 log.err("libc" ++ path.sep_str ++ "glibc" ++ path.sep_str ++
81 "abilists: invalid library name or index ({d}): '{s}'", .{ i, lib_name });
82 return error.ZigInstallationCorrupt;
83 }
84 }
85 }
86
87 const versions = b: {
88 const versions_len = contents[index];
89 index += 1;
90
91 const versions = try arena.alloc(Version, versions_len);
92 var i: u8 = 0;
93 while (i < versions.len) : (i += 1) {
94 versions[i] = .{
95 .major = contents[index + 0],
96 .minor = contents[index + 1],
97 .patch = contents[index + 2],
98 };
99 index += 3;
100 }
101 break :b versions;
102 };
103
104 const targets = b: {
105 const targets_len = contents[index];
106 index += 1;
107
108 const targets = try arena.alloc(std.zig.target.ArchOsAbi, targets_len);
109 var i: u8 = 0;
110 while (i < targets.len) : (i += 1) {
111 const target_name = mem.sliceTo(contents[index..], 0);
112 index += target_name.len + 1;
113
114 var component_it = mem.tokenizeScalar(u8, target_name, '-');
115 const arch_name = component_it.next() orelse {
116 log.err("abilists: expected arch name", .{});
117 return error.ZigInstallationCorrupt;
118 };
119 const os_name = component_it.next() orelse {
120 log.err("abilists: expected OS name", .{});
121 return error.ZigInstallationCorrupt;
122 };
123 const abi_name = component_it.next() orelse {
124 log.err("abilists: expected ABI name", .{});
125 return error.ZigInstallationCorrupt;
126 };
127 const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
128 log.err("abilists: unrecognized arch: '{s}'", .{arch_name});
129 return error.ZigInstallationCorrupt;
130 };
131 if (!mem.eql(u8, os_name, "linux")) {
132 log.err("abilists: expected OS 'linux', found '{s}'", .{os_name});
133 return error.ZigInstallationCorrupt;
134 }
135 const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
136 log.err("abilists: unrecognized ABI: '{s}'", .{abi_name});
137 return error.ZigInstallationCorrupt;
138 };
139
140 targets[i] = .{
141 .arch = arch_tag,
142 .os = .linux,
143 .abi = abi_tag,
144 };
145 }
146 break :b targets;
147 };
148
149 const abi = try arena.create(ABI);
150 abi.* = .{
151 .all_versions = versions,
152 .all_targets = targets,
153 .inclusions = contents[index..],
154 .arena_state = arena_allocator.state,
155 };
156 return abi;
157}
158
159pub const CrtFile = enum {
160 scrt1_o,
161 libc_nonshared_a,
162};
163
164/// TODO replace anyerror with explicit error set, recording user-friendly errors with
165/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
166pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
167 if (!build_options.have_llvm) {
168 return error.ZigCompilerNotBuiltWithLLVMExtensions;
169 }
170 const gpa = comp.gpa;
171 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
172 defer arena_allocator.deinit();
173 const arena = arena_allocator.allocator();
174
175 const target = comp.root_mod.resolved_target.result;
176 const target_ver = target.os.versionRange().gnuLibCVersion().?;
177 const nonshared_stat = target_ver.order(.{ .major = 2, .minor = 32, .patch = 0 }) != .gt;
178 const start_old_init_fini = target_ver.order(.{ .major = 2, .minor = 33, .patch = 0 }) != .gt;
179
180 // In all cases in this function, we add the C compiler flags to
181 // cache_exempt_flags rather than extra_flags, because these arguments
182 // depend on only properties that are already covered by the cache
183 // manifest. Including these arguments in the cache could only possibly
184 // waste computation and create false negatives.
185
186 switch (crt_file) {
187 .scrt1_o => {
188 const start_o: Compilation.CSourceFile = blk: {
189 var args = std.ArrayList([]const u8).init(arena);
190 try add_include_dirs(comp, arena, &args);
191 try args.appendSlice(&[_][]const u8{
192 "-D_LIBC_REENTRANT",
193 "-include",
194 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
195 "-DMODULE_NAME=libc",
196 "-Wno-nonportable-include-path",
197 "-include",
198 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
199 "-DPIC",
200 "-DSHARED",
201 "-DTOP_NAMESPACE=glibc",
202 "-DASSEMBLER",
203 "-Wa,--noexecstack",
204 });
205 const src_path = if (start_old_init_fini) "start-2.33.S" else "start.S";
206 break :blk .{
207 .src_path = try start_asm_path(comp, arena, src_path),
208 .cache_exempt_flags = args.items,
209 .owner = undefined,
210 };
211 };
212 const abi_note_o: Compilation.CSourceFile = blk: {
213 var args = std.ArrayList([]const u8).init(arena);
214 try args.appendSlice(&[_][]const u8{
215 "-I",
216 try lib_path(comp, arena, lib_libc_glibc ++ "csu"),
217 });
218 try add_include_dirs(comp, arena, &args);
219 try args.appendSlice(&[_][]const u8{
220 "-D_LIBC_REENTRANT",
221 "-DMODULE_NAME=libc",
222 "-DTOP_NAMESPACE=glibc",
223 "-DASSEMBLER",
224 "-Wa,--noexecstack",
225 });
226 break :blk .{
227 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "abi-note.S"),
228 .cache_exempt_flags = args.items,
229 .owner = undefined,
230 };
231 };
232 const init_o: Compilation.CSourceFile = .{
233 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "init.c"),
234 .owner = undefined,
235 };
236 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
237 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";
238 return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{});
239 },
240 .libc_nonshared_a => {
241 const s = path.sep_str;
242 const Dep = struct {
243 path: []const u8,
244 include: bool = true,
245 };
246 const deps = [_]Dep{
247 .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "atexit.c" },
248 .{ .path = lib_libc_glibc ++ "stdlib" ++ s ++ "at_quick_exit.c" },
249 .{ .path = lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread" ++ s ++ "pthread_atfork.c" },
250 .{ .path = lib_libc_glibc ++ "debug" ++ s ++ "stack_chk_fail_local.c" },
251
252 // libc_nonshared.a redirected stat functions to xstat until glibc 2.33,
253 // when they were finally versioned like other symbols.
254 .{
255 .path = lib_libc_glibc ++ "io" ++ s ++ "stat-2.32.c",
256 .include = nonshared_stat,
257 },
258 .{
259 .path = lib_libc_glibc ++ "io" ++ s ++ "fstat-2.32.c",
260 .include = nonshared_stat,
261 },
262 .{
263 .path = lib_libc_glibc ++ "io" ++ s ++ "lstat-2.32.c",
264 .include = nonshared_stat,
265 },
266 .{
267 .path = lib_libc_glibc ++ "io" ++ s ++ "stat64-2.32.c",
268 .include = nonshared_stat,
269 },
270 .{
271 .path = lib_libc_glibc ++ "io" ++ s ++ "fstat64-2.32.c",
272 .include = nonshared_stat,
273 },
274 .{
275 .path = lib_libc_glibc ++ "io" ++ s ++ "lstat64-2.32.c",
276 .include = nonshared_stat,
277 },
278 .{
279 .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat-2.32.c",
280 .include = nonshared_stat,
281 },
282 .{
283 .path = lib_libc_glibc ++ "io" ++ s ++ "fstatat64-2.32.c",
284 .include = nonshared_stat,
285 },
286 .{
287 .path = lib_libc_glibc ++ "io" ++ s ++ "mknodat-2.32.c",
288 .include = nonshared_stat,
289 },
290 .{
291 .path = lib_libc_glibc ++ "io" ++ s ++ "mknod-2.32.c",
292 .include = nonshared_stat,
293 },
294
295 // __libc_start_main used to require statically linked init/fini callbacks
296 // until glibc 2.34 when they were assimilated into the shared library.
297 .{
298 .path = lib_libc_glibc ++ "csu" ++ s ++ "elf-init-2.33.c",
299 .include = start_old_init_fini,
300 },
301 };
302
303 var files_buf: [deps.len]Compilation.CSourceFile = undefined;
304 var files_index: usize = 0;
305
306 for (deps) |dep| {
307 if (!dep.include) continue;
308
309 var args = std.ArrayList([]const u8).init(arena);
310 try args.appendSlice(&[_][]const u8{
311 "-std=gnu11",
312 "-fgnu89-inline",
313 "-fmerge-all-constants",
314 "-frounding-math",
315 "-Wno-unsupported-floating-point-opt", // For targets that don't support -frounding-math.
316 "-fno-common",
317 "-fmath-errno",
318 "-ftls-model=initial-exec",
319 "-Wno-ignored-attributes",
320 "-Qunused-arguments",
321 });
322 try add_include_dirs(comp, arena, &args);
323
324 try args.append("-DNO_INITFINI");
325
326 if (target.cpu.arch == .x86) {
327 // This prevents i386/sysdep.h from trying to do some
328 // silly and unnecessary inline asm hack that uses weird
329 // syntax that clang does not support.
330 try args.append("-DCAN_USE_REGISTER_ASM_EBP");
331 }
332
333 try args.appendSlice(&[_][]const u8{
334 "-D_LIBC_REENTRANT",
335 "-include",
336 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
337 "-DMODULE_NAME=libc",
338 "-Wno-nonportable-include-path",
339 "-include",
340 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
341 "-DPIC",
342 "-DLIBC_NONSHARED=1",
343 "-DTOP_NAMESPACE=glibc",
344 });
345 files_buf[files_index] = .{
346 .src_path = try lib_path(comp, arena, dep.path),
347 .cache_exempt_flags = args.items,
348 .owner = undefined,
349 };
350 files_index += 1;
351 }
352 const files = files_buf[0..files_index];
353 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{});
354 },
355 }
356}
357
358fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
359 const arch = comp.getTarget().cpu.arch;
360 const is_ppc = arch.isPowerPC();
361 const is_aarch64 = arch.isAARCH64();
362 const is_sparc = arch.isSPARC();
363 const is_64 = comp.getTarget().ptrBitWidth() == 64;
364
365 const s = path.sep_str;
366
367 var result = std.ArrayList(u8).init(arena);
368 try result.appendSlice(comp.zig_lib_directory.path.?);
369 try result.appendSlice(s ++ "libc" ++ s ++ "glibc" ++ s ++ "sysdeps" ++ s);
370 if (is_sparc) {
371 if (is_64) {
372 try result.appendSlice("sparc" ++ s ++ "sparc64");
373 } else {
374 try result.appendSlice("sparc" ++ s ++ "sparc32");
375 }
376 } else if (arch.isArm()) {
377 try result.appendSlice("arm");
378 } else if (arch.isMIPS()) {
379 try result.appendSlice("mips");
380 } else if (arch == .x86_64) {
381 try result.appendSlice("x86_64");
382 } else if (arch == .x86) {
383 try result.appendSlice("i386");
384 } else if (is_aarch64) {
385 try result.appendSlice("aarch64");
386 } else if (arch.isRISCV()) {
387 try result.appendSlice("riscv");
388 } else if (is_ppc) {
389 if (is_64) {
390 try result.appendSlice("powerpc" ++ s ++ "powerpc64");
391 } else {
392 try result.appendSlice("powerpc" ++ s ++ "powerpc32");
393 }
394 } else if (arch == .s390x) {
395 try result.appendSlice("s390" ++ s ++ "s390-64");
396 } else if (arch.isLoongArch()) {
397 try result.appendSlice("loongarch");
398 } else if (arch == .m68k) {
399 try result.appendSlice("m68k");
400 } else if (arch == .arc) {
401 try result.appendSlice("arc");
402 } else if (arch == .csky) {
403 try result.appendSlice("csky" ++ s ++ "abiv2");
404 }
405
406 try result.appendSlice(s);
407 try result.appendSlice(basename);
408 return result.items;
409}
410
411fn add_include_dirs(comp: *Compilation, arena: Allocator, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
412 const target = comp.getTarget();
413 const opt_nptl: ?[]const u8 = if (target.os.tag == .linux) "nptl" else "htl";
414
415 const s = path.sep_str;
416
417 try args.append("-I");
418 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "include"));
419
420 if (target.os.tag == .linux) {
421 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv" ++ s ++ "linux"));
422 }
423
424 if (opt_nptl) |nptl| {
425 try add_include_dirs_arch(arena, args, target, nptl, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
426 }
427
428 if (target.os.tag == .linux) {
429 try args.append("-I");
430 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
431 "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "generic"));
432
433 try args.append("-I");
434 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
435 "unix" ++ s ++ "sysv" ++ s ++ "linux" ++ s ++ "include"));
436 try args.append("-I");
437 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++
438 "unix" ++ s ++ "sysv" ++ s ++ "linux"));
439 }
440 if (opt_nptl) |nptl| {
441 try args.append("-I");
442 try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc_glibc ++ "sysdeps", nptl }));
443 }
444
445 try args.append("-I");
446 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "pthread"));
447
448 try args.append("-I");
449 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix" ++ s ++ "sysv"));
450
451 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
452
453 try args.append("-I");
454 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "unix"));
455
456 try add_include_dirs_arch(arena, args, target, null, try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps"));
457
458 try args.append("-I");
459 try args.append(try lib_path(comp, arena, lib_libc_glibc ++ "sysdeps" ++ s ++ "generic"));
460
461 try args.append("-I");
462 try args.append(try path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, lib_libc ++ "glibc" }));
463
464 try args.append("-I");
465 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-{s}-{s}", .{
466 comp.zig_lib_directory.path.?, @tagName(target.cpu.arch), @tagName(target.os.tag), @tagName(target.abi),
467 }));
468
469 try args.append("-I");
470 try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "generic-glibc"));
471
472 const arch_name = std.zig.target.osArchName(target);
473 try args.append("-I");
474 try args.append(try std.fmt.allocPrint(arena, "{s}" ++ s ++ "libc" ++ s ++ "include" ++ s ++ "{s}-linux-any", .{
475 comp.zig_lib_directory.path.?, arch_name,
476 }));
477
478 try args.append("-I");
479 try args.append(try lib_path(comp, arena, lib_libc ++ "include" ++ s ++ "any-linux-any"));
480}
481
482fn add_include_dirs_arch(
483 arena: Allocator,
484 args: *std.ArrayList([]const u8),
485 target: std.Target,
486 opt_nptl: ?[]const u8,
487 dir: []const u8,
488) error{OutOfMemory}!void {
489 const arch = target.cpu.arch;
490 const is_x86 = arch.isX86();
491 const is_aarch64 = arch.isAARCH64();
492 const is_ppc = arch.isPowerPC();
493 const is_sparc = arch.isSPARC();
494 const is_64 = target.ptrBitWidth() == 64;
495
496 const s = path.sep_str;
497
498 if (is_x86) {
499 if (arch == .x86_64) {
500 if (opt_nptl) |nptl| {
501 try args.append("-I");
502 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", nptl }));
503 } else {
504 if (target.abi == .gnux32) {
505 try args.append("-I");
506 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64", "x32" }));
507 }
508 try args.append("-I");
509 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86_64" }));
510 }
511 } else if (arch == .x86) {
512 if (opt_nptl) |nptl| {
513 try args.append("-I");
514 try args.append(try path.join(arena, &[_][]const u8{ dir, "i386", nptl }));
515 } else {
516 try args.append("-I");
517 try args.append(try path.join(arena, &[_][]const u8{ dir, "i386" }));
518 }
519 }
520 if (opt_nptl) |nptl| {
521 try args.append("-I");
522 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86", nptl }));
523 } else {
524 try args.append("-I");
525 try args.append(try path.join(arena, &[_][]const u8{ dir, "x86" }));
526 }
527 } else if (arch.isArm()) {
528 if (opt_nptl) |nptl| {
529 try args.append("-I");
530 try args.append(try path.join(arena, &[_][]const u8{ dir, "arm", nptl }));
531 } else {
532 try args.append("-I");
533 try args.append(try path.join(arena, &[_][]const u8{ dir, "arm" }));
534 }
535 } else if (arch.isMIPS()) {
536 if (opt_nptl) |nptl| {
537 try args.append("-I");
538 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips", nptl }));
539 } else {
540 if (is_64) {
541 try args.append("-I");
542 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips64" }));
543 } else {
544 try args.append("-I");
545 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" ++ s ++ "mips32" }));
546 }
547 try args.append("-I");
548 try args.append(try path.join(arena, &[_][]const u8{ dir, "mips" }));
549 }
550 } else if (is_sparc) {
551 if (opt_nptl) |nptl| {
552 try args.append("-I");
553 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc", nptl }));
554 } else {
555 if (is_64) {
556 try args.append("-I");
557 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc64" }));
558 } else {
559 try args.append("-I");
560 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" ++ s ++ "sparc32" }));
561 }
562 try args.append("-I");
563 try args.append(try path.join(arena, &[_][]const u8{ dir, "sparc" }));
564 }
565 } else if (is_aarch64) {
566 if (opt_nptl) |nptl| {
567 try args.append("-I");
568 try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64", nptl }));
569 } else {
570 try args.append("-I");
571 try args.append(try path.join(arena, &[_][]const u8{ dir, "aarch64" }));
572 }
573 } else if (is_ppc) {
574 if (opt_nptl) |nptl| {
575 try args.append("-I");
576 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc", nptl }));
577 } else {
578 if (is_64) {
579 try args.append("-I");
580 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc64" }));
581 } else {
582 try args.append("-I");
583 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" ++ s ++ "powerpc32" }));
584 }
585 try args.append("-I");
586 try args.append(try path.join(arena, &[_][]const u8{ dir, "powerpc" }));
587 }
588 } else if (arch.isRISCV()) {
589 if (opt_nptl) |nptl| {
590 try args.append("-I");
591 try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv", nptl }));
592 } else {
593 try args.append("-I");
594 try args.append(try path.join(arena, &[_][]const u8{ dir, "riscv" }));
595 }
596 } else if (arch == .s390x) {
597 if (opt_nptl) |nptl| {
598 try args.append("-I");
599 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390", nptl }));
600 } else {
601 try args.append("-I");
602 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" ++ s ++ "s390-64" }));
603 try args.append("-I");
604 try args.append(try path.join(arena, &[_][]const u8{ dir, "s390" }));
605 }
606 } else if (arch.isLoongArch()) {
607 try args.append("-I");
608 try args.append(try path.join(arena, &[_][]const u8{ dir, "loongarch" }));
609 } else if (arch == .m68k) {
610 if (opt_nptl) |nptl| {
611 try args.append("-I");
612 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k", nptl }));
613 } else {
614 // coldfire ABI support requires: https://github.com/ziglang/zig/issues/20690
615 try args.append("-I");
616 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" ++ s ++ "m680x0" }));
617 try args.append("-I");
618 try args.append(try path.join(arena, &[_][]const u8{ dir, "m68k" }));
619 }
620 } else if (arch == .arc) {
621 try args.append("-I");
622 try args.append(try path.join(arena, &[_][]const u8{ dir, "arc" }));
623 } else if (arch == .csky) {
624 try args.append("-I");
625 try args.append(try path.join(arena, &[_][]const u8{ dir, "csky" }));
626 }
627}
628
629fn path_from_lib(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
630 return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
631}
632
633const lib_libc = "libc" ++ path.sep_str;
634const lib_libc_glibc = lib_libc ++ "glibc" ++ path.sep_str;
635
636fn lib_path(comp: *Compilation, arena: Allocator, sub_path: []const u8) ![]const u8 {
637 return path.join(arena, &[_][]const u8{ comp.zig_lib_directory.path.?, sub_path });
638}
639
640pub const BuiltSharedObjects = struct {
641 lock: Cache.Lock,
642 dir_path: Path,
643
644 pub fn deinit(self: *BuiltSharedObjects, gpa: Allocator) void {
645 self.lock.release();
646 gpa.free(self.dir_path.sub_path);
647 self.* = undefined;
648 }
649};
650
651const all_map_basename = "all.map";
652
653fn wordDirective(target: std.Target) []const u8 {
654 // Based on its description in the GNU `as` manual, you might assume that `.word` is sized
655 // according to the target word size. But no; that would just make too much sense.
656 return if (target.ptrBitWidth() == 64) ".quad" else ".long";
657}
658
659/// TODO replace anyerror with explicit error set, recording user-friendly errors with
660/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
661pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anyerror!void {
662 const tracy = trace(@src());
663 defer tracy.end();
664
665 if (!build_options.have_llvm) {
666 return error.ZigCompilerNotBuiltWithLLVMExtensions;
667 }
668
669 const gpa = comp.gpa;
670
671 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
672 defer arena_allocator.deinit();
673 const arena = arena_allocator.allocator();
674
675 const target = comp.getTarget();
676 const target_version = target.os.versionRange().gnuLibCVersion().?;
677
678 // Use the global cache directory.
679 var cache: Cache = .{
680 .gpa = gpa,
681 .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
682 };
683 cache.addPrefix(.{ .path = null, .handle = fs.cwd() });
684 cache.addPrefix(comp.zig_lib_directory);
685 cache.addPrefix(comp.global_cache_directory);
686 defer cache.manifest_dir.close();
687
688 var man = cache.obtain();
689 defer man.deinit();
690 man.hash.addBytes(build_options.version);
691 man.hash.add(target.cpu.arch);
692 man.hash.add(target.abi);
693 man.hash.add(target_version);
694
695 const full_abilists_path = try comp.zig_lib_directory.join(arena, &.{abilists_path});
696 const abilists_index = try man.addFile(full_abilists_path, abilists_max_size);
697
698 if (try man.hit()) {
699 const digest = man.final();
700
701 return queueSharedObjects(comp, .{
702 .lock = man.toOwnedLock(),
703 .dir_path = .{
704 .root_dir = comp.global_cache_directory,
705 .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
706 },
707 });
708 }
709
710 const digest = man.final();
711 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
712
713 var o_directory: Compilation.Directory = .{
714 .handle = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{}),
715 .path = try comp.global_cache_directory.join(arena, &.{o_sub_path}),
716 };
717 defer o_directory.handle.close();
718
719 const abilists_contents = man.files.keys()[abilists_index].contents.?;
720 const metadata = try loadMetaData(gpa, abilists_contents);
721 defer metadata.destroy(gpa);
722
723 const target_targ_index = for (metadata.all_targets, 0..) |targ, i| {
724 if (targ.arch == target.cpu.arch and
725 targ.os == target.os.tag and
726 targ.abi == target.abi)
727 {
728 break i;
729 }
730 } else {
731 unreachable; // std.zig.target.available_libcs prevents us from getting here
732 };
733
734 const target_ver_index = for (metadata.all_versions, 0..) |ver, i| {
735 switch (ver.order(target_version)) {
736 .eq => break i,
737 .lt => continue,
738 .gt => {
739 // TODO Expose via compile error mechanism instead of log.
740 log.warn("invalid target glibc version: {}", .{target_version});
741 return error.InvalidTargetGLibCVersion;
742 },
743 }
744 } else blk: {
745 const latest_index = metadata.all_versions.len - 1;
746 log.warn("zig cannot build new glibc version {}; providing instead {}", .{
747 target_version, metadata.all_versions[latest_index],
748 });
749 break :blk latest_index;
750 };
751
752 {
753 var map_contents = std.ArrayList(u8).init(arena);
754 for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
755 if (ver.patch == 0) {
756 try map_contents.writer().print("GLIBC_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
757 } else {
758 try map_contents.writer().print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
759 }
760 }
761 try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
762 map_contents.deinit(); // The most recent allocation of an arena can be freed :)
763 }
764
765 var stubs_asm = std.ArrayList(u8).init(gpa);
766 defer stubs_asm.deinit();
767
768 for (libs, 0..) |lib, lib_i| {
769 if (lib.removed_in) |rem_in| {
770 if (target_version.order(rem_in) != .lt) continue;
771 }
772
773 stubs_asm.shrinkRetainingCapacity(0);
774 try stubs_asm.appendSlice(".text\n");
775
776 var sym_i: usize = 0;
777 var sym_name_buf = std.ArrayList(u8).init(arena);
778 var opt_symbol_name: ?[]const u8 = null;
779 var versions_buffer: [32]u8 = undefined;
780 var versions_len: usize = undefined;
781
782 // There can be situations where there are multiple inclusions for the same symbol with
783 // partially overlapping versions, due to different target lists. For example:
784 //
785 // lgammal:
786 // library: libm.so
787 // versions: 2.4 2.23
788 // targets: ... powerpc64-linux-gnu s390x-linux-gnu
789 // lgammal:
790 // library: libm.so
791 // versions: 2.2 2.23
792 // targets: sparc64-linux-gnu s390x-linux-gnu
793 //
794 // If we don't handle this, we end up writing the default `lgammal` symbol for version 2.33
795 // twice, which causes a "duplicate symbol" assembler error.
796 var versions_written = std.AutoArrayHashMap(Version, void).init(arena);
797
798 var inc_fbs = std.io.fixedBufferStream(metadata.inclusions);
799 var inc_reader = inc_fbs.reader();
800
801 const fn_inclusions_len = try inc_reader.readInt(u16, .little);
802
803 while (sym_i < fn_inclusions_len) : (sym_i += 1) {
804 const sym_name = opt_symbol_name orelse n: {
805 sym_name_buf.clearRetainingCapacity();
806 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
807
808 opt_symbol_name = sym_name_buf.items;
809 versions_buffer = undefined;
810 versions_len = 0;
811
812 break :n sym_name_buf.items;
813 };
814 const targets = try std.leb.readUleb128(u64, inc_reader);
815 var lib_index = try inc_reader.readByte();
816
817 const is_terminal = (lib_index & (1 << 7)) != 0;
818 if (is_terminal) {
819 lib_index &= ~@as(u8, 1 << 7);
820 opt_symbol_name = null;
821 }
822
823 // Test whether the inclusion applies to our current library and target.
824 const ok_lib_and_target =
825 (lib_index == lib_i) and
826 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
827
828 while (true) {
829 const byte = try inc_reader.readByte();
830 const last = (byte & 0b1000_0000) != 0;
831 const ver_i = @as(u7, @truncate(byte));
832 if (ok_lib_and_target and ver_i <= target_ver_index) {
833 versions_buffer[versions_len] = ver_i;
834 versions_len += 1;
835 }
836 if (last) break;
837 }
838
839 if (!is_terminal) continue;
840
841 // Pick the default symbol version:
842 // - If there are no versions, don't emit it
843 // - Take the greatest one <= than the target one
844 // - If none of them is <= than the
845 // specified one don't pick any default version
846 if (versions_len == 0) continue;
847 var chosen_def_ver_index: u8 = 255;
848 {
849 var ver_buf_i: u8 = 0;
850 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
851 const ver_index = versions_buffer[ver_buf_i];
852 if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
853 chosen_def_ver_index = ver_index;
854 }
855 }
856 }
857
858 versions_written.clearRetainingCapacity();
859 try versions_written.ensureTotalCapacity(versions_len);
860
861 {
862 var ver_buf_i: u8 = 0;
863 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
864 // Example:
865 // .balign 4
866 // .globl _Exit_2_2_5
867 // .type _Exit_2_2_5, %function
868 // .symver _Exit_2_2_5, _Exit@@GLIBC_2.2.5, remove
869 // _Exit_2_2_5: .long 0
870 const ver_index = versions_buffer[ver_buf_i];
871 const ver = metadata.all_versions[ver_index];
872
873 if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
874
875 // Default symbol version definition vs normal symbol version definition
876 const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
877 const at_sign_str: []const u8 = if (want_default) "@@" else "@";
878 if (ver.patch == 0) {
879 const sym_plus_ver = try std.fmt.allocPrint(
880 arena,
881 "{s}_{d}_{d}",
882 .{ sym_name, ver.major, ver.minor },
883 );
884 try stubs_asm.writer().print(
885 \\.balign {d}
886 \\.globl {s}
887 \\.type {s}, %function
888 \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
889 \\{s}: {s} 0
890 \\
891 , .{
892 target.ptrBitWidth() / 8,
893 sym_plus_ver,
894 sym_plus_ver,
895 sym_plus_ver,
896 sym_name,
897 at_sign_str,
898 ver.major,
899 ver.minor,
900 sym_plus_ver,
901 wordDirective(target),
902 });
903 } else {
904 const sym_plus_ver = try std.fmt.allocPrint(
905 arena,
906 "{s}_{d}_{d}_{d}",
907 .{ sym_name, ver.major, ver.minor, ver.patch },
908 );
909 try stubs_asm.writer().print(
910 \\.balign {d}
911 \\.globl {s}
912 \\.type {s}, %function
913 \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
914 \\{s}: {s} 0
915 \\
916 , .{
917 target.ptrBitWidth() / 8,
918 sym_plus_ver,
919 sym_plus_ver,
920 sym_plus_ver,
921 sym_name,
922 at_sign_str,
923 ver.major,
924 ver.minor,
925 ver.patch,
926 sym_plus_ver,
927 wordDirective(target),
928 });
929 }
930 }
931 }
932 }
933
934 try stubs_asm.appendSlice(".rodata\n");
935
936 // For some targets, the real `libc.so.6` will contain a weak reference to `_IO_stdin_used`,
937 // making the linker put the symbol in the dynamic symbol table. We likewise need to emit a
938 // reference to it here for that effect, or it will not show up, which in turn will cause
939 // the real glibc to think that the program was built against an ancient `FILE` structure
940 // (pre-glibc 2.1).
941 //
942 // Note that glibc only compiles in the legacy compatibility code for some targets; it
943 // depends on what is defined in the `shlib-versions` file for the particular architecture
944 // and ABI. Those files are preprocessed by 2 separate tools during the glibc build to get
945 // the final `abi-versions.h`, so it would be quite brittle to try to condition our emission
946 // of the `_IO_stdin_used` reference in the exact same way. The only downside of emitting
947 // the reference unconditionally is that it ends up being unused for newer targets; it
948 // otherwise has no negative effect.
949 //
950 // glibc uses a weak reference because it has to work with programs compiled against pre-2.1
951 // versions where the symbol didn't exist. We only care about modern glibc versions, so use
952 // a strong reference.
953 if (std.mem.eql(u8, lib.name, "c")) {
954 try stubs_asm.writer().print(
955 \\.balign {d}
956 \\.globl _IO_stdin_used
957 \\{s} _IO_stdin_used
958 \\
959 , .{
960 target.ptrBitWidth() / 8,
961 wordDirective(target),
962 });
963 }
964
965 try stubs_asm.appendSlice(".data\n");
966
967 const obj_inclusions_len = try inc_reader.readInt(u16, .little);
968
969 sym_i = 0;
970 opt_symbol_name = null;
971 versions_buffer = undefined;
972 versions_len = undefined;
973 while (sym_i < obj_inclusions_len) : (sym_i += 1) {
974 const sym_name = opt_symbol_name orelse n: {
975 sym_name_buf.clearRetainingCapacity();
976 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
977
978 opt_symbol_name = sym_name_buf.items;
979 versions_buffer = undefined;
980 versions_len = 0;
981
982 break :n sym_name_buf.items;
983 };
984 const targets = try std.leb.readUleb128(u64, inc_reader);
985 const size = try std.leb.readUleb128(u16, inc_reader);
986 var lib_index = try inc_reader.readByte();
987
988 const is_terminal = (lib_index & (1 << 7)) != 0;
989 if (is_terminal) {
990 lib_index &= ~@as(u8, 1 << 7);
991 opt_symbol_name = null;
992 }
993
994 // Test whether the inclusion applies to our current library and target.
995 const ok_lib_and_target =
996 (lib_index == lib_i) and
997 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
998
999 while (true) {
1000 const byte = try inc_reader.readByte();
1001 const last = (byte & 0b1000_0000) != 0;
1002 const ver_i = @as(u7, @truncate(byte));
1003 if (ok_lib_and_target and ver_i <= target_ver_index) {
1004 versions_buffer[versions_len] = ver_i;
1005 versions_len += 1;
1006 }
1007 if (last) break;
1008 }
1009
1010 if (!is_terminal) continue;
1011
1012 // Pick the default symbol version:
1013 // - If there are no versions, don't emit it
1014 // - Take the greatest one <= than the target one
1015 // - If none of them is <= than the
1016 // specified one don't pick any default version
1017 if (versions_len == 0) continue;
1018 var chosen_def_ver_index: u8 = 255;
1019 {
1020 var ver_buf_i: u8 = 0;
1021 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
1022 const ver_index = versions_buffer[ver_buf_i];
1023 if (chosen_def_ver_index == 255 or ver_index > chosen_def_ver_index) {
1024 chosen_def_ver_index = ver_index;
1025 }
1026 }
1027 }
1028
1029 versions_written.clearRetainingCapacity();
1030 try versions_written.ensureTotalCapacity(versions_len);
1031
1032 {
1033 var ver_buf_i: u8 = 0;
1034 while (ver_buf_i < versions_len) : (ver_buf_i += 1) {
1035 // Example:
1036 // .balign 4
1037 // .globl environ_2_2_5
1038 // .type environ_2_2_5, %object
1039 // .size environ_2_2_5, 4
1040 // .symver environ_2_2_5, environ@@GLIBC_2.2.5, remove
1041 // environ_2_2_5: .fill 4, 1, 0
1042 const ver_index = versions_buffer[ver_buf_i];
1043 const ver = metadata.all_versions[ver_index];
1044
1045 if (versions_written.getOrPutAssumeCapacity(ver).found_existing) continue;
1046
1047 // Default symbol version definition vs normal symbol version definition
1048 const want_default = chosen_def_ver_index != 255 and ver_index == chosen_def_ver_index;
1049 const at_sign_str: []const u8 = if (want_default) "@@" else "@";
1050 if (ver.patch == 0) {
1051 const sym_plus_ver = try std.fmt.allocPrint(
1052 arena,
1053 "{s}_{d}_{d}",
1054 .{ sym_name, ver.major, ver.minor },
1055 );
1056 try stubs_asm.writer().print(
1057 \\.balign {d}
1058 \\.globl {s}
1059 \\.type {s}, %object
1060 \\.size {s}, {d}
1061 \\.symver {s}, {s}{s}GLIBC_{d}.{d}, remove
1062 \\{s}: .fill {d}, 1, 0
1063 \\
1064 , .{
1065 target.ptrBitWidth() / 8,
1066 sym_plus_ver,
1067 sym_plus_ver,
1068 sym_plus_ver,
1069 size,
1070 sym_plus_ver,
1071 sym_name,
1072 at_sign_str,
1073 ver.major,
1074 ver.minor,
1075 sym_plus_ver,
1076 size,
1077 });
1078 } else {
1079 const sym_plus_ver = try std.fmt.allocPrint(
1080 arena,
1081 "{s}_{d}_{d}_{d}",
1082 .{ sym_name, ver.major, ver.minor, ver.patch },
1083 );
1084 try stubs_asm.writer().print(
1085 \\.balign {d}
1086 \\.globl {s}
1087 \\.type {s}, %object
1088 \\.size {s}, {d}
1089 \\.symver {s}, {s}{s}GLIBC_{d}.{d}.{d}, remove
1090 \\{s}: .fill {d}, 1, 0
1091 \\
1092 , .{
1093 target.ptrBitWidth() / 8,
1094 sym_plus_ver,
1095 sym_plus_ver,
1096 sym_plus_ver,
1097 size,
1098 sym_plus_ver,
1099 sym_name,
1100 at_sign_str,
1101 ver.major,
1102 ver.minor,
1103 ver.patch,
1104 sym_plus_ver,
1105 size,
1106 });
1107 }
1108 }
1109 }
1110 }
1111
1112 var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
1113 const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
1114 try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
1115 try buildSharedLib(comp, arena, comp.global_cache_directory, o_directory, asm_file_basename, lib, prog_node);
1116 }
1117
1118 man.writeManifest() catch |err| {
1119 log.warn("failed to write cache manifest for glibc stubs: {s}", .{@errorName(err)});
1120 };
1121
1122 return queueSharedObjects(comp, .{
1123 .lock = man.toOwnedLock(),
1124 .dir_path = .{
1125 .root_dir = comp.global_cache_directory,
1126 .sub_path = try gpa.dupe(u8, "o" ++ fs.path.sep_str ++ digest),
1127 },
1128 });
1129}
1130
1131pub fn sharedObjectsCount(target: *const std.Target) u8 {
1132 const target_version = target.os.versionRange().gnuLibCVersion() orelse return 0;
1133 var count: u8 = 0;
1134 for (libs) |lib| {
1135 if (lib.removed_in) |rem_in| {
1136 if (target_version.order(rem_in) != .lt) continue;
1137 }
1138 count += 1;
1139 }
1140 return count;
1141}
1142
1143fn queueSharedObjects(comp: *Compilation, so_files: BuiltSharedObjects) void {
1144 const target_version = comp.getTarget().os.versionRange().gnuLibCVersion().?;
1145
1146 assert(comp.glibc_so_files == null);
1147 comp.glibc_so_files = so_files;
1148
1149 var task_buffer: [libs.len]link.Task = undefined;
1150 var task_buffer_i: usize = 0;
1151
1152 {
1153 comp.mutex.lock(); // protect comp.arena
1154 defer comp.mutex.unlock();
1155
1156 for (libs) |lib| {
1157 if (lib.removed_in) |rem_in| {
1158 if (target_version.order(rem_in) != .lt) continue;
1159 }
1160 const so_path: Path = .{
1161 .root_dir = so_files.dir_path.root_dir,
1162 .sub_path = std.fmt.allocPrint(comp.arena, "{s}{c}lib{s}.so.{d}", .{
1163 so_files.dir_path.sub_path, fs.path.sep, lib.name, lib.sover,
1164 }) catch return comp.setAllocFailure(),
1165 };
1166 task_buffer[task_buffer_i] = .{ .load_dso = so_path };
1167 task_buffer_i += 1;
1168 }
1169 }
1170
1171 comp.queueLinkTasks(task_buffer[0..task_buffer_i]);
1172}
1173
1174fn buildSharedLib(
1175 comp: *Compilation,
1176 arena: Allocator,
1177 zig_cache_directory: Compilation.Directory,
1178 bin_directory: Compilation.Directory,
1179 asm_file_basename: []const u8,
1180 lib: Lib,
1181 prog_node: std.Progress.Node,
1182) !void {
1183 const tracy = trace(@src());
1184 defer tracy.end();
1185
1186 const basename = try std.fmt.allocPrint(arena, "lib{s}.so.{d}", .{ lib.name, lib.sover });
1187 const emit_bin = Compilation.EmitLoc{
1188 .directory = bin_directory,
1189 .basename = basename,
1190 };
1191 const version: Version = .{ .major = lib.sover, .minor = 0, .patch = 0 };
1192 const ld_basename = path.basename(comp.getTarget().standardDynamicLinkerPath().get().?);
1193 const soname = if (mem.eql(u8, lib.name, "ld")) ld_basename else basename;
1194 const map_file_path = try path.join(arena, &.{ bin_directory.path.?, all_map_basename });
1195
1196 const optimize_mode = comp.compilerRtOptMode();
1197 const strip = comp.compilerRtStrip();
1198 const config = try Compilation.Config.resolve(.{
1199 .output_mode = .Lib,
1200 .link_mode = .dynamic,
1201 .resolved_target = comp.root_mod.resolved_target,
1202 .is_test = false,
1203 .have_zcu = false,
1204 .emit_bin = true,
1205 .root_optimize_mode = optimize_mode,
1206 .root_strip = strip,
1207 .link_libc = false,
1208 });
1209
1210 const root_mod = try Module.create(arena, .{
1211 .global_cache_directory = comp.global_cache_directory,
1212 .paths = .{
1213 .root = .{ .root_dir = comp.zig_lib_directory },
1214 .root_src_path = "",
1215 },
1216 .fully_qualified_name = "root",
1217 .inherited = .{
1218 .resolved_target = comp.root_mod.resolved_target,
1219 .strip = strip,
1220 .stack_check = false,
1221 .stack_protector = 0,
1222 .sanitize_c = .off,
1223 .sanitize_thread = false,
1224 .red_zone = comp.root_mod.red_zone,
1225 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
1226 .valgrind = false,
1227 .optimize_mode = optimize_mode,
1228 .structured_cfg = comp.root_mod.structured_cfg,
1229 },
1230 .global = config,
1231 .cc_argv = &.{},
1232 .parent = null,
1233 .builtin_mod = null,
1234 .builtin_modules = null, // there is only one module in this compilation
1235 });
1236
1237 const c_source_files = [1]Compilation.CSourceFile{
1238 .{
1239 .src_path = try path.join(arena, &.{ bin_directory.path.?, asm_file_basename }),
1240 .owner = root_mod,
1241 },
1242 };
1243
1244 const sub_compilation = try Compilation.create(comp.gpa, arena, .{
1245 .local_cache_directory = zig_cache_directory,
1246 .global_cache_directory = comp.global_cache_directory,
1247 .zig_lib_directory = comp.zig_lib_directory,
1248 .thread_pool = comp.thread_pool,
1249 .self_exe_path = comp.self_exe_path,
1250 .cache_mode = .incremental,
1251 .config = config,
1252 .root_mod = root_mod,
1253 .root_name = lib.name,
1254 .libc_installation = comp.libc_installation,
1255 .emit_bin = emit_bin,
1256 .emit_h = null,
1257 .verbose_cc = comp.verbose_cc,
1258 .verbose_link = comp.verbose_link,
1259 .verbose_air = comp.verbose_air,
1260 .verbose_llvm_ir = comp.verbose_llvm_ir,
1261 .verbose_llvm_bc = comp.verbose_llvm_bc,
1262 .verbose_cimport = comp.verbose_cimport,
1263 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
1264 .clang_passthrough_mode = comp.clang_passthrough_mode,
1265 .version = version,
1266 .version_script = map_file_path,
1267 .soname = soname,
1268 .c_source_files = &c_source_files,
1269 .skip_linker_dependencies = true,
1270 });
1271 defer sub_compilation.destroy();
1272
1273 try comp.updateSubCompilation(sub_compilation, .@"glibc shared object", prog_node);
1274}
1275
1276pub fn needsCrt0(output_mode: std.builtin.OutputMode) ?CrtFile {
1277 return switch (output_mode) {
1278 .Obj, .Lib => null,
1279 .Exe => .scrt1_o,
1280 };
1281}
src/libs/libcxx.zig created+578
...@@ -0,0 +1,578 @@
1const std = @import("std");
2const path = std.fs.path;
3const assert = std.debug.assert;
4
5const target_util = @import("../target.zig");
6const Compilation = @import("../Compilation.zig");
7const build_options = @import("build_options");
8const trace = @import("../tracy.zig").trace;
9const Module = @import("../Package/Module.zig");
10
11const libcxxabi_files = [_][]const u8{
12 "src/abort_message.cpp",
13 "src/cxa_aux_runtime.cpp",
14 "src/cxa_default_handlers.cpp",
15 "src/cxa_demangle.cpp",
16 "src/cxa_exception.cpp",
17 "src/cxa_exception_storage.cpp",
18 "src/cxa_guard.cpp",
19 "src/cxa_handlers.cpp",
20 "src/cxa_noexception.cpp",
21 "src/cxa_personality.cpp",
22 "src/cxa_thread_atexit.cpp",
23 "src/cxa_vector.cpp",
24 "src/cxa_virtual.cpp",
25 "src/fallback_malloc.cpp",
26 "src/private_typeinfo.cpp",
27 "src/stdlib_exception.cpp",
28 "src/stdlib_new_delete.cpp",
29 "src/stdlib_stdexcept.cpp",
30 "src/stdlib_typeinfo.cpp",
31};
32
33const libcxx_base_files = [_][]const u8{
34 "src/algorithm.cpp",
35 "src/any.cpp",
36 "src/bind.cpp",
37 "src/call_once.cpp",
38 "src/charconv.cpp",
39 "src/chrono.cpp",
40 "src/error_category.cpp",
41 "src/exception.cpp",
42 "src/expected.cpp",
43 "src/filesystem/directory_entry.cpp",
44 "src/filesystem/directory_iterator.cpp",
45 "src/filesystem/filesystem_clock.cpp",
46 "src/filesystem/filesystem_error.cpp",
47 // omit int128_builtins.cpp because it provides __muloti4 which is already provided
48 // by compiler_rt and crashes on Windows x86_64: https://github.com/ziglang/zig/issues/10719
49 //"src/filesystem/int128_builtins.cpp",
50 "src/filesystem/operations.cpp",
51 "src/filesystem/path.cpp",
52 "src/fstream.cpp",
53 "src/functional.cpp",
54 "src/hash.cpp",
55 "src/ios.cpp",
56 "src/ios.instantiations.cpp",
57 "src/iostream.cpp",
58 "src/locale.cpp",
59 "src/memory.cpp",
60 "src/memory_resource.cpp",
61 "src/new.cpp",
62 "src/new_handler.cpp",
63 "src/new_helpers.cpp",
64 "src/optional.cpp",
65 "src/ostream.cpp",
66 "src/print.cpp",
67 //"src/pstl/libdispatch.cpp",
68 "src/random.cpp",
69 "src/random_shuffle.cpp",
70 "src/regex.cpp",
71 "src/ryu/d2fixed.cpp",
72 "src/ryu/d2s.cpp",
73 "src/ryu/f2s.cpp",
74 "src/stdexcept.cpp",
75 "src/string.cpp",
76 "src/strstream.cpp",
77 "src/support/ibm/mbsnrtowcs.cpp",
78 "src/support/ibm/wcsnrtombs.cpp",
79 "src/support/ibm/xlocale_zos.cpp",
80 "src/support/win32/locale_win32.cpp",
81 "src/support/win32/support.cpp",
82 "src/system_error.cpp",
83 "src/typeinfo.cpp",
84 "src/valarray.cpp",
85 "src/variant.cpp",
86 "src/vector.cpp",
87 "src/verbose_abort.cpp",
88};
89
90const libcxx_thread_files = [_][]const u8{
91 "src/atomic.cpp",
92 "src/barrier.cpp",
93 "src/condition_variable.cpp",
94 "src/condition_variable_destructor.cpp",
95 "src/future.cpp",
96 "src/mutex.cpp",
97 "src/mutex_destructor.cpp",
98 "src/shared_mutex.cpp",
99 "src/support/win32/thread_win32.cpp",
100 "src/thread.cpp",
101};
102
103pub const BuildError = error{
104 OutOfMemory,
105 SubCompilationFailed,
106 ZigCompilerNotBuiltWithLLVMExtensions,
107};
108
109pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
110 if (!build_options.have_llvm) {
111 return error.ZigCompilerNotBuiltWithLLVMExtensions;
112 }
113
114 const tracy = trace(@src());
115 defer tracy.end();
116
117 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
118 defer arena_allocator.deinit();
119 const arena = arena_allocator.allocator();
120
121 const root_name = "c++";
122 const output_mode = .Lib;
123 const link_mode = .static;
124 const target = comp.root_mod.resolved_target.result;
125 const basename = try std.zig.binNameAlloc(arena, .{
126 .root_name = root_name,
127 .target = target,
128 .output_mode = output_mode,
129 .link_mode = link_mode,
130 });
131
132 const emit_bin = Compilation.EmitLoc{
133 .directory = null, // Put it in the cache directory.
134 .basename = basename,
135 };
136
137 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
138 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
139 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
140 const cxx_libc_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "libc" });
141
142 const optimize_mode = comp.compilerRtOptMode();
143 const strip = comp.compilerRtStrip();
144
145 const config = Compilation.Config.resolve(.{
146 .output_mode = output_mode,
147 .link_mode = link_mode,
148 .resolved_target = comp.root_mod.resolved_target,
149 .is_test = false,
150 .have_zcu = false,
151 .emit_bin = true,
152 .root_optimize_mode = optimize_mode,
153 .root_strip = strip,
154 .link_libc = true,
155 .lto = comp.config.lto,
156 .any_sanitize_thread = comp.config.any_sanitize_thread,
157 }) catch |err| {
158 comp.setMiscFailure(
159 .libcxx,
160 "unable to build libc++: resolving configuration failed: {s}",
161 .{@errorName(err)},
162 );
163 return error.SubCompilationFailed;
164 };
165
166 const root_mod = Module.create(arena, .{
167 .global_cache_directory = comp.global_cache_directory,
168 .paths = .{
169 .root = .{ .root_dir = comp.zig_lib_directory },
170 .root_src_path = "",
171 },
172 .fully_qualified_name = "root",
173 .inherited = .{
174 .resolved_target = comp.root_mod.resolved_target,
175 .strip = strip,
176 .stack_check = false,
177 .stack_protector = 0,
178 .sanitize_c = .off,
179 .sanitize_thread = comp.config.any_sanitize_thread,
180 .red_zone = comp.root_mod.red_zone,
181 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
182 .valgrind = false,
183 .optimize_mode = optimize_mode,
184 .structured_cfg = comp.root_mod.structured_cfg,
185 .pic = if (target_util.supports_fpic(target)) true else null,
186 .code_model = comp.root_mod.code_model,
187 },
188 .global = config,
189 .cc_argv = &.{},
190 .parent = null,
191 .builtin_mod = null,
192 .builtin_modules = null, // there is only one module in this compilation
193 }) catch |err| {
194 comp.setMiscFailure(
195 .libcxx,
196 "unable to build libc++: creating module failed: {s}",
197 .{@errorName(err)},
198 );
199 return error.SubCompilationFailed;
200 };
201
202 const libcxx_files = if (comp.config.any_non_single_threaded)
203 &(libcxx_base_files ++ libcxx_thread_files)
204 else
205 &libcxx_base_files;
206
207 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len);
208
209 for (libcxx_files) |cxx_src| {
210 // These don't compile on WASI due to e.g. `fchmod` usage.
211 if (std.mem.startsWith(u8, cxx_src, "src/filesystem/") and target.os.tag == .wasi)
212 continue;
213 if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows)
214 continue;
215 if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos)
216 continue;
217
218 var cflags = std.ArrayList([]const u8).init(arena);
219
220 try addCxxArgs(comp, arena, &cflags);
221
222 try cflags.append("-DNDEBUG");
223 try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils");
224 try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
225 try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
226 try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
227
228 try cflags.append("-fvisibility=hidden");
229 try cflags.append("-fvisibility-inlines-hidden");
230
231 if (target.os.tag == .zos) {
232 try cflags.append("-fno-aligned-allocation");
233 } else {
234 try cflags.append("-faligned-allocation");
235 }
236
237 try cflags.append("-nostdinc++");
238 try cflags.append("-std=c++23");
239 try cflags.append("-Wno-user-defined-literals");
240 try cflags.append("-Wno-covered-switch-default");
241 try cflags.append("-Wno-suggest-override");
242
243 // These depend on only the zig lib directory file path, which is
244 // purposefully either in the cache or not in the cache. The decision
245 // should not be overridden here.
246 var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
247
248 try cache_exempt_flags.append("-I");
249 try cache_exempt_flags.append(cxx_include_path);
250
251 try cache_exempt_flags.append("-I");
252 try cache_exempt_flags.append(cxxabi_include_path);
253
254 try cache_exempt_flags.append("-I");
255 try cache_exempt_flags.append(cxx_src_include_path);
256
257 try cache_exempt_flags.append("-I");
258 try cache_exempt_flags.append(cxx_libc_include_path);
259
260 c_source_files.appendAssumeCapacity(.{
261 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }),
262 .extra_flags = cflags.items,
263 .cache_exempt_flags = cache_exempt_flags.items,
264 .owner = root_mod,
265 });
266 }
267
268 const sub_compilation = Compilation.create(comp.gpa, arena, .{
269 .local_cache_directory = comp.global_cache_directory,
270 .global_cache_directory = comp.global_cache_directory,
271 .zig_lib_directory = comp.zig_lib_directory,
272 .self_exe_path = comp.self_exe_path,
273 .cache_mode = .whole,
274 .config = config,
275 .root_mod = root_mod,
276 .root_name = root_name,
277 .thread_pool = comp.thread_pool,
278 .libc_installation = comp.libc_installation,
279 .emit_bin = emit_bin,
280 .emit_h = null,
281 .c_source_files = c_source_files.items,
282 .verbose_cc = comp.verbose_cc,
283 .verbose_link = comp.verbose_link,
284 .verbose_air = comp.verbose_air,
285 .verbose_llvm_ir = comp.verbose_llvm_ir,
286 .verbose_llvm_bc = comp.verbose_llvm_bc,
287 .verbose_cimport = comp.verbose_cimport,
288 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
289 .clang_passthrough_mode = comp.clang_passthrough_mode,
290 .skip_linker_dependencies = true,
291 }) catch |err| {
292 comp.setMiscFailure(
293 .libcxx,
294 "unable to build libc++: create compilation failed: {s}",
295 .{@errorName(err)},
296 );
297 return error.SubCompilationFailed;
298 };
299 defer sub_compilation.destroy();
300
301 comp.updateSubCompilation(sub_compilation, .libcxx, prog_node) catch |err| switch (err) {
302 error.SubCompilationFailed => return error.SubCompilationFailed,
303 else => |e| {
304 comp.setMiscFailure(
305 .libcxx,
306 "unable to build libc++: compilation failed: {s}",
307 .{@errorName(e)},
308 );
309 return error.SubCompilationFailed;
310 },
311 };
312
313 assert(comp.libcxx_static_lib == null);
314 const crt_file = try sub_compilation.toCrtFile();
315 comp.libcxx_static_lib = crt_file;
316 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
317}
318
319pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
320 if (!build_options.have_llvm) {
321 return error.ZigCompilerNotBuiltWithLLVMExtensions;
322 }
323
324 const tracy = trace(@src());
325 defer tracy.end();
326
327 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
328 defer arena_allocator.deinit();
329 const arena = arena_allocator.allocator();
330
331 const root_name = "c++abi";
332 const output_mode = .Lib;
333 const link_mode = .static;
334 const target = comp.root_mod.resolved_target.result;
335 const basename = try std.zig.binNameAlloc(arena, .{
336 .root_name = root_name,
337 .target = target,
338 .output_mode = output_mode,
339 .link_mode = link_mode,
340 });
341
342 const emit_bin = Compilation.EmitLoc{
343 .directory = null, // Put it in the cache directory.
344 .basename = basename,
345 };
346
347 const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" });
348 const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" });
349 const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" });
350
351 const optimize_mode = comp.compilerRtOptMode();
352 const strip = comp.compilerRtStrip();
353 // See the `-fno-exceptions` logic for WASI.
354 // The old 32-bit x86 variant of SEH doesn't use tables.
355 const unwind_tables: std.builtin.UnwindTables =
356 if (target.os.tag == .wasi or (target.cpu.arch == .x86 and target.os.tag == .windows)) .none else .@"async";
357
358 const config = Compilation.Config.resolve(.{
359 .output_mode = output_mode,
360 .link_mode = link_mode,
361 .resolved_target = comp.root_mod.resolved_target,
362 .is_test = false,
363 .have_zcu = false,
364 .emit_bin = true,
365 .root_optimize_mode = optimize_mode,
366 .root_strip = strip,
367 .link_libc = true,
368 .any_unwind_tables = unwind_tables != .none,
369 .lto = comp.config.lto,
370 .any_sanitize_thread = comp.config.any_sanitize_thread,
371 }) catch |err| {
372 comp.setMiscFailure(
373 .libcxxabi,
374 "unable to build libc++abi: resolving configuration failed: {s}",
375 .{@errorName(err)},
376 );
377 return error.SubCompilationFailed;
378 };
379
380 const root_mod = Module.create(arena, .{
381 .global_cache_directory = comp.global_cache_directory,
382 .paths = .{
383 .root = .{ .root_dir = comp.zig_lib_directory },
384 .root_src_path = "",
385 },
386 .fully_qualified_name = "root",
387 .inherited = .{
388 .resolved_target = comp.root_mod.resolved_target,
389 .strip = strip,
390 .stack_check = false,
391 .stack_protector = 0,
392 .sanitize_c = .off,
393 .sanitize_thread = comp.config.any_sanitize_thread,
394 .red_zone = comp.root_mod.red_zone,
395 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
396 .valgrind = false,
397 .optimize_mode = optimize_mode,
398 .structured_cfg = comp.root_mod.structured_cfg,
399 .unwind_tables = unwind_tables,
400 .pic = comp.root_mod.pic,
401 .code_model = comp.root_mod.code_model,
402 },
403 .global = config,
404 .cc_argv = &.{},
405 .parent = null,
406 .builtin_mod = null,
407 .builtin_modules = null, // there is only one module in this compilation
408 }) catch |err| {
409 comp.setMiscFailure(
410 .libcxxabi,
411 "unable to build libc++abi: creating module failed: {s}",
412 .{@errorName(err)},
413 );
414 return error.SubCompilationFailed;
415 };
416
417 var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len);
418
419 for (libcxxabi_files) |cxxabi_src| {
420 if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
421 continue;
422
423 var cflags = std.ArrayList([]const u8).init(arena);
424
425 try addCxxArgs(comp, arena, &cflags);
426
427 try cflags.append("-DNDEBUG");
428 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
429 if (!comp.config.any_non_single_threaded) {
430 try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
431 }
432 if (target.abi.isGnu()) {
433 if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
434 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
435 }
436
437 try cflags.append("-fvisibility=hidden");
438 try cflags.append("-fvisibility-inlines-hidden");
439
440 if (target_util.supports_fpic(target)) {
441 try cflags.append("-fPIC");
442 }
443 try cflags.append("-nostdinc++");
444 try cflags.append("-fstrict-aliasing");
445 try cflags.append("-std=c++23");
446 try cflags.append("-Wno-user-defined-literals");
447 try cflags.append("-Wno-covered-switch-default");
448 try cflags.append("-Wno-suggest-override");
449
450 // These depend on only the zig lib directory file path, which is
451 // purposefully either in the cache or not in the cache. The decision
452 // should not be overridden here.
453 var cache_exempt_flags = std.ArrayList([]const u8).init(arena);
454
455 try cache_exempt_flags.append("-I");
456 try cache_exempt_flags.append(cxxabi_include_path);
457
458 try cache_exempt_flags.append("-I");
459 try cache_exempt_flags.append(cxx_include_path);
460
461 try cache_exempt_flags.append("-I");
462 try cache_exempt_flags.append(cxx_src_include_path);
463
464 c_source_files.appendAssumeCapacity(.{
465 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }),
466 .extra_flags = cflags.items,
467 .cache_exempt_flags = cache_exempt_flags.items,
468 .owner = root_mod,
469 });
470 }
471
472 const sub_compilation = Compilation.create(comp.gpa, arena, .{
473 .local_cache_directory = comp.global_cache_directory,
474 .global_cache_directory = comp.global_cache_directory,
475 .zig_lib_directory = comp.zig_lib_directory,
476 .self_exe_path = comp.self_exe_path,
477 .cache_mode = .whole,
478 .config = config,
479 .root_mod = root_mod,
480 .root_name = root_name,
481 .thread_pool = comp.thread_pool,
482 .libc_installation = comp.libc_installation,
483 .emit_bin = emit_bin,
484 .emit_h = null,
485 .c_source_files = c_source_files.items,
486 .verbose_cc = comp.verbose_cc,
487 .verbose_link = comp.verbose_link,
488 .verbose_air = comp.verbose_air,
489 .verbose_llvm_ir = comp.verbose_llvm_ir,
490 .verbose_llvm_bc = comp.verbose_llvm_bc,
491 .verbose_cimport = comp.verbose_cimport,
492 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
493 .clang_passthrough_mode = comp.clang_passthrough_mode,
494 .skip_linker_dependencies = true,
495 }) catch |err| {
496 comp.setMiscFailure(
497 .libcxxabi,
498 "unable to build libc++abi: create compilation failed: {s}",
499 .{@errorName(err)},
500 );
501 return error.SubCompilationFailed;
502 };
503 defer sub_compilation.destroy();
504
505 comp.updateSubCompilation(sub_compilation, .libcxxabi, prog_node) catch |err| switch (err) {
506 error.SubCompilationFailed => return error.SubCompilationFailed,
507 else => |e| {
508 comp.setMiscFailure(
509 .libcxxabi,
510 "unable to build libc++abi: compilation failed: {s}",
511 .{@errorName(e)},
512 );
513 return error.SubCompilationFailed;
514 },
515 };
516
517 assert(comp.libcxxabi_static_lib == null);
518 const crt_file = try sub_compilation.toCrtFile();
519 comp.libcxxabi_static_lib = crt_file;
520 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
521}
522
523pub fn addCxxArgs(
524 comp: *const Compilation,
525 arena: std.mem.Allocator,
526 cflags: *std.ArrayList([]const u8),
527) error{OutOfMemory}!void {
528 const target = comp.getTarget();
529 const optimize_mode = comp.compilerRtOptMode();
530
531 const abi_version: u2 = if (target.os.tag == .emscripten) 2 else 1;
532 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
533 abi_version,
534 }));
535 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
536 abi_version,
537 }));
538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
539 if (!comp.config.any_non_single_threaded) "NO_" else "",
540 }));
541 try cflags.append("-D_LIBCPP_HAS_MONOTONIC_CLOCK");
542 try cflags.append("-D_LIBCPP_HAS_TERMINAL");
543 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}MUSL_LIBC", .{
544 if (!target.abi.isMusl()) "NO_" else "",
545 }));
546 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
547 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
548 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
549 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}FILESYSTEM", .{
550 if (target.os.tag == .wasi) "NO_" else "",
551 }));
552 try cflags.append("-D_LIBCPP_HAS_RANDOM_DEVICE");
553 try cflags.append("-D_LIBCPP_HAS_LOCALIZATION");
554 try cflags.append("-D_LIBCPP_HAS_UNICODE");
555 try cflags.append("-D_LIBCPP_HAS_WIDE_CHARACTERS");
556 try cflags.append("-D_LIBCPP_HAS_NO_STD_MODULES");
557 if (target.os.tag == .linux) {
558 try cflags.append("-D_LIBCPP_HAS_TIME_ZONE_DATABASE");
559 }
560 // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
561 // for potentially enabling some fancy features here, which would
562 // require corresponding changes in libcxx.zig, as well as
563 // Compilation.addCCArgs. This option makes it use serial backend which
564 // is simple and works everywhere.
565 try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
566 try cflags.append(switch (optimize_mode) {
567 .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG",
568 .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE",
569 .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST",
570 });
571 if (target.isGnuLibC()) {
572 // glibc 2.16 introduced aligned_alloc
573 if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
574 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
575 }
576 }
577 try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
578}
src/libs/libtsan.zig created+499
...@@ -0,0 +1,499 @@
1const std = @import("std");
2const assert = std.debug.assert;
3
4const Compilation = @import("../Compilation.zig");
5const build_options = @import("build_options");
6const trace = @import("../tracy.zig").trace;
7const Module = @import("../Package/Module.zig");
8
9pub const BuildError = error{
10 OutOfMemory,
11 SubCompilationFailed,
12 ZigCompilerNotBuiltWithLLVMExtensions,
13 TSANUnsupportedCPUArchitecture,
14};
15
16pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
17 if (!build_options.have_llvm) {
18 return error.ZigCompilerNotBuiltWithLLVMExtensions;
19 }
20
21 const tracy = trace(@src());
22 defer tracy.end();
23
24 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
25 defer arena_allocator.deinit();
26 const arena = arena_allocator.allocator();
27
28 const target = comp.getTarget();
29 const root_name = switch (target.os.tag) {
30 // On Apple platforms, we use the same name as LLVM because the
31 // TSAN library implementation hard-codes a check for these names.
32 .driverkit, .macos => "clang_rt.tsan_osx_dynamic",
33 .ios => if (target.abi == .simulator) "clang_rt.tsan_iossim_dynamic" else "clang_rt.tsan_ios_dynamic",
34 .tvos => if (target.abi == .simulator) "clang_rt.tsan_tvossim_dynamic" else "clang_rt.tsan_tvos_dynamic",
35 .visionos => if (target.abi == .simulator) "clang_rt.tsan_xrossim_dynamic" else "clang_rt.tsan_xros_dynamic",
36 .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic",
37 else => "tsan",
38 };
39 const link_mode: std.builtin.LinkMode = if (target.os.tag.isDarwin()) .dynamic else .static;
40 const output_mode = .Lib;
41 const basename = try std.zig.binNameAlloc(arena, .{
42 .root_name = root_name,
43 .target = target,
44 .output_mode = output_mode,
45 .link_mode = link_mode,
46 });
47
48 const emit_bin = Compilation.EmitLoc{
49 .directory = null, // Put it in the cache directory.
50 .basename = basename,
51 };
52
53 const optimize_mode = comp.compilerRtOptMode();
54 const strip = comp.compilerRtStrip();
55 const unwind_tables: std.builtin.UnwindTables =
56 if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
57 const link_libcpp = target.os.tag.isDarwin();
58
59 const config = Compilation.Config.resolve(.{
60 .output_mode = output_mode,
61 .link_mode = link_mode,
62 .resolved_target = comp.root_mod.resolved_target,
63 .is_test = false,
64 .have_zcu = false,
65 .emit_bin = true,
66 .root_optimize_mode = optimize_mode,
67 .root_strip = strip,
68 .link_libc = true,
69 .link_libcpp = link_libcpp,
70 .any_unwind_tables = unwind_tables != .none,
71 // LLVM disables LTO for its libtsan.
72 .lto = .none,
73 }) catch |err| {
74 comp.setMiscFailure(
75 .libtsan,
76 "unable to build thread sanitizer runtime: resolving configuration failed: {s}",
77 .{@errorName(err)},
78 );
79 return error.SubCompilationFailed;
80 };
81
82 const common_flags = [_][]const u8{
83 "-DTSAN_CONTAINS_UBSAN=0",
84 };
85
86 const root_mod = Module.create(arena, .{
87 .global_cache_directory = comp.global_cache_directory,
88 .paths = .{
89 .root = .{ .root_dir = comp.zig_lib_directory },
90 .root_src_path = "",
91 },
92 .fully_qualified_name = "root",
93 .inherited = .{
94 .resolved_target = comp.root_mod.resolved_target,
95 .strip = strip,
96 .stack_check = false,
97 .stack_protector = 0,
98 .sanitize_c = .off,
99 .sanitize_thread = false,
100 .red_zone = comp.root_mod.red_zone,
101 .omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(),
102 .valgrind = false,
103 .unwind_tables = unwind_tables,
104 .optimize_mode = optimize_mode,
105 .structured_cfg = comp.root_mod.structured_cfg,
106 .pic = true,
107 .no_builtin = true,
108 .code_model = comp.root_mod.code_model,
109 },
110 .global = config,
111 .cc_argv = &common_flags,
112 .parent = null,
113 .builtin_mod = null,
114 .builtin_modules = null, // there is only one module in this compilation
115 }) catch |err| {
116 comp.setMiscFailure(
117 .libtsan,
118 "unable to build thread sanitizer runtime: creating module failed: {s}",
119 .{@errorName(err)},
120 );
121 return error.SubCompilationFailed;
122 };
123
124 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
125 try c_source_files.ensureUnusedCapacity(tsan_sources.len);
126
127 const tsan_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{"libtsan"});
128 for (tsan_sources) |tsan_src| {
129 var cflags = std.ArrayList([]const u8).init(arena);
130
131 try cflags.append("-I");
132 try cflags.append(tsan_include_path);
133
134 try addCcArgs(target, &cflags);
135
136 c_source_files.appendAssumeCapacity(.{
137 .src_path = try comp.zig_lib_directory.join(arena, &.{ "libtsan", tsan_src }),
138 .extra_flags = cflags.items,
139 .owner = root_mod,
140 });
141 }
142
143 const platform_tsan_sources = switch (target.os.tag) {
144 .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
145 .windows => &windows_tsan_sources,
146 else => &unix_tsan_sources,
147 };
148 try c_source_files.ensureUnusedCapacity(platform_tsan_sources.len);
149 for (platform_tsan_sources) |tsan_src| {
150 var cflags = std.ArrayList([]const u8).init(arena);
151
152 try cflags.append("-I");
153 try cflags.append(tsan_include_path);
154
155 try addCcArgs(target, &cflags);
156
157 c_source_files.appendAssumeCapacity(.{
158 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", tsan_src }),
159 .extra_flags = cflags.items,
160 .owner = root_mod,
161 });
162 }
163 {
164 const asm_source = switch (target.cpu.arch) {
165 .aarch64, .aarch64_be => "tsan_rtl_aarch64.S",
166 .loongarch64 => "tsan_rtl_loongarch64.S",
167 .mips64, .mips64el => "tsan_rtl_mips64.S",
168 .powerpc64, .powerpc64le => "tsan_rtl_ppc64.S",
169 .riscv64 => "tsan_rtl_riscv64.S",
170 .s390x => "tsan_rtl_s390x.S",
171 .x86_64 => "tsan_rtl_amd64.S",
172 else => return error.TSANUnsupportedCPUArchitecture,
173 };
174 var cflags = std.ArrayList([]const u8).init(arena);
175
176 try cflags.append("-I");
177 try cflags.append(tsan_include_path);
178
179 try cflags.append("-DNDEBUG");
180
181 c_source_files.appendAssumeCapacity(.{
182 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", asm_source }),
183 .extra_flags = cflags.items,
184 .owner = root_mod,
185 });
186 }
187
188 try c_source_files.ensureUnusedCapacity(sanitizer_common_sources.len);
189 const sanitizer_common_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
190 "libtsan", "sanitizer_common",
191 });
192 for (sanitizer_common_sources) |common_src| {
193 var cflags = std.ArrayList([]const u8).init(arena);
194
195 try cflags.append("-I");
196 try cflags.append(sanitizer_common_include_path);
197 try cflags.append("-I");
198 try cflags.append(tsan_include_path);
199
200 try addCcArgs(target, &cflags);
201
202 c_source_files.appendAssumeCapacity(.{
203 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
204 "libtsan", "sanitizer_common", common_src,
205 }),
206 .extra_flags = cflags.items,
207 .owner = root_mod,
208 });
209 }
210
211 const to_c_or_not_to_c_sources = if (comp.config.link_libc)
212 &sanitizer_libcdep_sources
213 else
214 &sanitizer_nolibc_sources;
215 try c_source_files.ensureUnusedCapacity(to_c_or_not_to_c_sources.len);
216 for (to_c_or_not_to_c_sources) |c_src| {
217 var cflags = std.ArrayList([]const u8).init(arena);
218
219 try cflags.append("-I");
220 try cflags.append(sanitizer_common_include_path);
221 try cflags.append("-I");
222 try cflags.append(tsan_include_path);
223
224 try addCcArgs(target, &cflags);
225
226 c_source_files.appendAssumeCapacity(.{
227 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
228 "libtsan", "sanitizer_common", c_src,
229 }),
230 .extra_flags = cflags.items,
231 .owner = root_mod,
232 });
233 }
234
235 try c_source_files.ensureUnusedCapacity(sanitizer_symbolizer_sources.len);
236 for (sanitizer_symbolizer_sources) |c_src| {
237 var cflags = std.ArrayList([]const u8).init(arena);
238
239 try cflags.append("-I");
240 try cflags.append(tsan_include_path);
241
242 try addCcArgs(target, &cflags);
243
244 c_source_files.appendAssumeCapacity(.{
245 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
246 "libtsan", "sanitizer_common", c_src,
247 }),
248 .extra_flags = cflags.items,
249 .owner = root_mod,
250 });
251 }
252
253 const interception_include_path = try comp.zig_lib_directory.join(
254 arena,
255 &[_][]const u8{"interception"},
256 );
257
258 try c_source_files.ensureUnusedCapacity(interception_sources.len);
259 for (interception_sources) |c_src| {
260 var cflags = std.ArrayList([]const u8).init(arena);
261
262 try cflags.append("-I");
263 try cflags.append(interception_include_path);
264
265 try cflags.append("-I");
266 try cflags.append(tsan_include_path);
267
268 try addCcArgs(target, &cflags);
269
270 c_source_files.appendAssumeCapacity(.{
271 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
272 "libtsan", "interception", c_src,
273 }),
274 .extra_flags = cflags.items,
275 .owner = root_mod,
276 });
277 }
278
279 const skip_linker_dependencies = !target.os.tag.isDarwin();
280 const linker_allow_shlib_undefined = target.os.tag.isDarwin();
281 const install_name = if (target.os.tag.isDarwin())
282 try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename})
283 else
284 null;
285 // Workaround for https://github.com/llvm/llvm-project/issues/97627
286 const headerpad_size: ?u32 = if (target.os.tag.isDarwin()) 32 else null;
287 const sub_compilation = Compilation.create(comp.gpa, arena, .{
288 .local_cache_directory = comp.global_cache_directory,
289 .global_cache_directory = comp.global_cache_directory,
290 .zig_lib_directory = comp.zig_lib_directory,
291 .thread_pool = comp.thread_pool,
292 .self_exe_path = comp.self_exe_path,
293 .cache_mode = .whole,
294 .config = config,
295 .root_mod = root_mod,
296 .root_name = root_name,
297 .libc_installation = comp.libc_installation,
298 .emit_bin = emit_bin,
299 .emit_h = null,
300 .c_source_files = c_source_files.items,
301 .verbose_cc = comp.verbose_cc,
302 .verbose_link = comp.verbose_link,
303 .verbose_air = comp.verbose_air,
304 .verbose_llvm_ir = comp.verbose_llvm_ir,
305 .verbose_llvm_bc = comp.verbose_llvm_bc,
306 .verbose_cimport = comp.verbose_cimport,
307 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
308 .clang_passthrough_mode = comp.clang_passthrough_mode,
309 .skip_linker_dependencies = skip_linker_dependencies,
310 .linker_allow_shlib_undefined = linker_allow_shlib_undefined,
311 .install_name = install_name,
312 .headerpad_size = headerpad_size,
313 }) catch |err| {
314 comp.setMiscFailure(
315 .libtsan,
316 "unable to build thread sanitizer runtime: create compilation failed: {s}",
317 .{@errorName(err)},
318 );
319 return error.SubCompilationFailed;
320 };
321 defer sub_compilation.destroy();
322
323 comp.updateSubCompilation(sub_compilation, .libtsan, prog_node) catch |err| switch (err) {
324 error.SubCompilationFailed => return error.SubCompilationFailed,
325 else => |e| {
326 comp.setMiscFailure(
327 .libtsan,
328 "unable to build thread sanitizer runtime: compilation failed: {s}",
329 .{@errorName(e)},
330 );
331 return error.SubCompilationFailed;
332 },
333 };
334
335 const crt_file = try sub_compilation.toCrtFile();
336 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
337 assert(comp.tsan_lib == null);
338 comp.tsan_lib = crt_file;
339}
340
341fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
342 try args.appendSlice(&[_][]const u8{
343 "-nostdinc++",
344 "-fvisibility=hidden",
345 "-fvisibility-inlines-hidden",
346 "-std=c++17",
347 "-fno-rtti",
348 "-fno-exceptions",
349 });
350
351 if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) {
352 try args.append("-fno-emulated-tls");
353 }
354
355 if (target.isMinGW()) {
356 try args.append("-fms-extensions");
357 }
358}
359
360const tsan_sources = [_][]const u8{
361 "tsan_debugging.cpp",
362 "tsan_external.cpp",
363 "tsan_fd.cpp",
364 "tsan_flags.cpp",
365 "tsan_ignoreset.cpp",
366 "tsan_interceptors_memintrinsics.cpp",
367 "tsan_interceptors_posix.cpp",
368 "tsan_interface.cpp",
369 "tsan_interface_ann.cpp",
370 "tsan_interface_atomic.cpp",
371 "tsan_interface_java.cpp",
372 "tsan_malloc_mac.cpp",
373 "tsan_md5.cpp",
374 "tsan_mman.cpp",
375 "tsan_mutexset.cpp",
376 "tsan_new_delete.cpp",
377 "tsan_platform_windows.cpp",
378 "tsan_preinit.cpp",
379 "tsan_report.cpp",
380 "tsan_rtl.cpp",
381 "tsan_rtl_access.cpp",
382 "tsan_rtl_mutex.cpp",
383 "tsan_rtl_proc.cpp",
384 "tsan_rtl_report.cpp",
385 "tsan_rtl_thread.cpp",
386 "tsan_stack_trace.cpp",
387 "tsan_suppressions.cpp",
388 "tsan_symbolize.cpp",
389 "tsan_sync.cpp",
390 "tsan_vector_clock.cpp",
391};
392
393const darwin_tsan_sources = [_][]const u8{
394 "tsan_interceptors_mac.cpp",
395 "tsan_interceptors_mach_vm.cpp",
396 "tsan_platform_mac.cpp",
397 "tsan_platform_posix.cpp",
398};
399
400const unix_tsan_sources = [_][]const u8{
401 "tsan_platform_linux.cpp",
402 "tsan_platform_posix.cpp",
403};
404
405const windows_tsan_sources = [_][]const u8{
406 "tsan_platform_windows.cpp",
407};
408
409const sanitizer_common_sources = [_][]const u8{
410 "sanitizer_allocator.cpp",
411 "sanitizer_chained_origin_depot.cpp",
412 "sanitizer_common.cpp",
413 "sanitizer_deadlock_detector1.cpp",
414 "sanitizer_deadlock_detector2.cpp",
415 "sanitizer_errno.cpp",
416 "sanitizer_file.cpp",
417 "sanitizer_flag_parser.cpp",
418 "sanitizer_flags.cpp",
419 "sanitizer_fuchsia.cpp",
420 "sanitizer_libc.cpp",
421 "sanitizer_libignore.cpp",
422 "sanitizer_linux.cpp",
423 "sanitizer_linux_s390.cpp",
424 "sanitizer_mac.cpp",
425 "sanitizer_mutex.cpp",
426 "sanitizer_netbsd.cpp",
427 "sanitizer_platform_limits_freebsd.cpp",
428 "sanitizer_platform_limits_linux.cpp",
429 "sanitizer_platform_limits_netbsd.cpp",
430 "sanitizer_platform_limits_posix.cpp",
431 "sanitizer_platform_limits_solaris.cpp",
432 "sanitizer_posix.cpp",
433 "sanitizer_printf.cpp",
434 "sanitizer_procmaps_bsd.cpp",
435 "sanitizer_procmaps_common.cpp",
436 "sanitizer_procmaps_fuchsia.cpp",
437 "sanitizer_procmaps_linux.cpp",
438 "sanitizer_procmaps_mac.cpp",
439 "sanitizer_procmaps_solaris.cpp",
440 "sanitizer_range.cpp",
441 "sanitizer_solaris.cpp",
442 "sanitizer_stoptheworld_fuchsia.cpp",
443 "sanitizer_stoptheworld_mac.cpp",
444 "sanitizer_stoptheworld_win.cpp",
445 "sanitizer_suppressions.cpp",
446 "sanitizer_termination.cpp",
447 "sanitizer_thread_arg_retval.cpp",
448 "sanitizer_thread_registry.cpp",
449 "sanitizer_tls_get_addr.cpp",
450 "sanitizer_type_traits.cpp",
451 "sanitizer_win.cpp",
452 "sanitizer_win_interception.cpp",
453};
454
455const sanitizer_nolibc_sources = [_][]const u8{
456 "sanitizer_common_nolibc.cpp",
457};
458
459const sanitizer_libcdep_sources = [_][]const u8{
460 "sanitizer_common_libcdep.cpp",
461 "sanitizer_allocator_checks.cpp",
462 "sanitizer_dl.cpp",
463 "sanitizer_linux_libcdep.cpp",
464 "sanitizer_mac_libcdep.cpp",
465 "sanitizer_posix_libcdep.cpp",
466 "sanitizer_stoptheworld_linux_libcdep.cpp",
467 "sanitizer_stoptheworld_netbsd_libcdep.cpp",
468};
469
470const sanitizer_symbolizer_sources = [_][]const u8{
471 "sanitizer_allocator_report.cpp",
472 "sanitizer_stack_store.cpp",
473 "sanitizer_stackdepot.cpp",
474 "sanitizer_stacktrace.cpp",
475 "sanitizer_stacktrace_libcdep.cpp",
476 "sanitizer_stacktrace_printer.cpp",
477 "sanitizer_stacktrace_sparc.cpp",
478 "sanitizer_symbolizer.cpp",
479 "sanitizer_symbolizer_libbacktrace.cpp",
480 "sanitizer_symbolizer_libcdep.cpp",
481 "sanitizer_symbolizer_mac.cpp",
482 "sanitizer_symbolizer_markup.cpp",
483 "sanitizer_symbolizer_markup_fuchsia.cpp",
484 "sanitizer_symbolizer_posix_libcdep.cpp",
485 "sanitizer_symbolizer_report.cpp",
486 "sanitizer_symbolizer_report_fuchsia.cpp",
487 "sanitizer_symbolizer_win.cpp",
488 "sanitizer_thread_history.cpp",
489 "sanitizer_unwind_linux_libcdep.cpp",
490 "sanitizer_unwind_fuchsia.cpp",
491 "sanitizer_unwind_win.cpp",
492};
493
494const interception_sources = [_][]const u8{
495 "interception_linux.cpp",
496 "interception_mac.cpp",
497 "interception_win.cpp",
498 "interception_type_test.cpp",
499};
src/libs/libunwind.zig created+220
...@@ -0,0 +1,220 @@
1const std = @import("std");
2const path = std.fs.path;
3const assert = std.debug.assert;
4
5const target_util = @import("../target.zig");
6const Compilation = @import("../Compilation.zig");
7const Module = @import("../Package/Module.zig");
8const build_options = @import("build_options");
9const trace = @import("../tracy.zig").trace;
10
11pub const BuildError = error{
12 OutOfMemory,
13 SubCompilationFailed,
14 ZigCompilerNotBuiltWithLLVMExtensions,
15};
16
17pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
18 if (!build_options.have_llvm) {
19 return error.ZigCompilerNotBuiltWithLLVMExtensions;
20 }
21
22 const tracy = trace(@src());
23 defer tracy.end();
24
25 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
26 defer arena_allocator.deinit();
27 const arena = arena_allocator.allocator();
28
29 const output_mode = .Lib;
30 const target = comp.root_mod.resolved_target.result;
31 const unwind_tables: std.builtin.UnwindTables =
32 if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
33 const config = Compilation.Config.resolve(.{
34 .output_mode = .Lib,
35 .resolved_target = comp.root_mod.resolved_target,
36 .is_test = false,
37 .have_zcu = false,
38 .emit_bin = true,
39 .root_optimize_mode = comp.compilerRtOptMode(),
40 .root_strip = comp.compilerRtStrip(),
41 .link_libc = true,
42 .any_unwind_tables = unwind_tables != .none,
43 .lto = comp.config.lto,
44 }) catch |err| {
45 comp.setMiscFailure(
46 .libunwind,
47 "unable to build libunwind: resolving configuration failed: {s}",
48 .{@errorName(err)},
49 );
50 return error.SubCompilationFailed;
51 };
52 const root_mod = Module.create(arena, .{
53 .global_cache_directory = comp.global_cache_directory,
54 .paths = .{
55 .root = .{ .root_dir = comp.zig_lib_directory },
56 .root_src_path = "",
57 },
58 .fully_qualified_name = "root",
59 .inherited = .{
60 .resolved_target = comp.root_mod.resolved_target,
61 .strip = comp.compilerRtStrip(),
62 .stack_check = false,
63 .stack_protector = 0,
64 .red_zone = comp.root_mod.red_zone,
65 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
66 .valgrind = false,
67 .sanitize_c = .off,
68 .sanitize_thread = false,
69 // necessary so that libunwind can unwind through its own stack frames
70 // The old 32-bit x86 variant of SEH doesn't use tables.
71 .unwind_tables = unwind_tables,
72 .pic = if (target_util.supports_fpic(target)) true else null,
73 .optimize_mode = comp.compilerRtOptMode(),
74 .code_model = comp.root_mod.code_model,
75 },
76 .global = config,
77 .cc_argv = &.{},
78 .parent = null,
79 .builtin_mod = null,
80 .builtin_modules = null, // there is only one module in this compilation
81 }) catch |err| {
82 comp.setMiscFailure(
83 .libunwind,
84 "unable to build libunwind: creating module failed: {s}",
85 .{@errorName(err)},
86 );
87 return error.SubCompilationFailed;
88 };
89
90 const root_name = "unwind";
91 const link_mode = .static;
92 const basename = try std.zig.binNameAlloc(arena, .{
93 .root_name = root_name,
94 .target = target,
95 .output_mode = output_mode,
96 .link_mode = link_mode,
97 });
98 const emit_bin = Compilation.EmitLoc{
99 .directory = null, // Put it in the cache directory.
100 .basename = basename,
101 };
102 var c_source_files: [unwind_src_list.len]Compilation.CSourceFile = undefined;
103 for (unwind_src_list, 0..) |unwind_src, i| {
104 var cflags = std.ArrayList([]const u8).init(arena);
105
106 switch (Compilation.classifyFileExt(unwind_src)) {
107 .c => {
108 try cflags.appendSlice(&.{
109 "-std=c99",
110 "-fexceptions",
111 });
112 },
113 .cpp => {
114 try cflags.append("-fno-exceptions");
115 try cflags.append("-fno-rtti");
116 },
117 .assembly_with_cpp => {},
118 else => unreachable, // See `unwind_src_list`.
119 }
120 try cflags.append("-I");
121 try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));
122 try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");
123 try cflags.append("-Wa,--noexecstack");
124 try cflags.append("-fvisibility=hidden");
125 try cflags.append("-fvisibility-inlines-hidden");
126 try cflags.append("-fvisibility-global-new-delete=force-hidden");
127
128 // This is intentionally always defined because the macro definition means, should it only
129 // build for the target specified by compiler defines. Since we pass -target the compiler
130 // defines will be correct.
131 try cflags.append("-D_LIBUNWIND_IS_NATIVE_ONLY");
132
133 if (comp.root_mod.optimize_mode == .Debug) {
134 try cflags.append("-D_DEBUG");
135 }
136 if (!comp.config.any_non_single_threaded) {
137 try cflags.append("-D_LIBUNWIND_HAS_NO_THREADS");
138 }
139 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
140 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
141 }
142 try cflags.append("-Wno-bitwise-conditional-parentheses");
143 try cflags.append("-Wno-visibility");
144 try cflags.append("-Wno-incompatible-pointer-types");
145
146 if (target.os.tag == .windows) {
147 try cflags.append("-Wno-dll-attribute-on-redeclaration");
148 }
149
150 c_source_files[i] = .{
151 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{unwind_src}),
152 .extra_flags = cflags.items,
153 .owner = root_mod,
154 };
155 }
156 const sub_compilation = Compilation.create(comp.gpa, arena, .{
157 .self_exe_path = comp.self_exe_path,
158 .local_cache_directory = comp.global_cache_directory,
159 .global_cache_directory = comp.global_cache_directory,
160 .zig_lib_directory = comp.zig_lib_directory,
161 .config = config,
162 .root_mod = root_mod,
163 .cache_mode = .whole,
164 .root_name = root_name,
165 .main_mod = null,
166 .thread_pool = comp.thread_pool,
167 .libc_installation = comp.libc_installation,
168 .emit_bin = emit_bin,
169 .function_sections = comp.function_sections,
170 .c_source_files = &c_source_files,
171 .verbose_cc = comp.verbose_cc,
172 .verbose_link = comp.verbose_link,
173 .verbose_air = comp.verbose_air,
174 .verbose_llvm_ir = comp.verbose_llvm_ir,
175 .verbose_llvm_bc = comp.verbose_llvm_bc,
176 .verbose_cimport = comp.verbose_cimport,
177 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
178 .clang_passthrough_mode = comp.clang_passthrough_mode,
179 .skip_linker_dependencies = true,
180 }) catch |err| {
181 comp.setMiscFailure(
182 .libunwind,
183 "unable to build libunwind: create compilation failed: {s}",
184 .{@errorName(err)},
185 );
186 return error.SubCompilationFailed;
187 };
188 defer sub_compilation.destroy();
189
190 comp.updateSubCompilation(sub_compilation, .libunwind, prog_node) catch |err| switch (err) {
191 error.SubCompilationFailed => return error.SubCompilationFailed,
192 else => |e| {
193 comp.setMiscFailure(
194 .libunwind,
195 "unable to build libunwind: compilation failed: {s}",
196 .{@errorName(e)},
197 );
198 return error.SubCompilationFailed;
199 },
200 };
201
202 const crt_file = try sub_compilation.toCrtFile();
203 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
204 assert(comp.libunwind_static_lib == null);
205 comp.libunwind_static_lib = crt_file;
206}
207
208const unwind_src_list = [_][]const u8{
209 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "libunwind.cpp",
210 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-EHABI.cpp",
211 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-seh.cpp",
212 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1.c",
213 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1-gcc-ext.c",
214 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-sjlj.c",
215 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-wasm.c",
216 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersRestore.S",
217 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersSave.S",
218 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind_AIXExtras.cpp",
219 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "gcc_personality_v0.c",
220};
src/libs/mingw.zig created+1038
...@@ -0,0 +1,1038 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const path = std.fs.path;
5const assert = std.debug.assert;
6const log = std.log.scoped(.mingw);
7
8const builtin = @import("builtin");
9const Compilation = @import("../Compilation.zig");
10const build_options = @import("build_options");
11const Cache = std.Build.Cache;
12const dev = @import("../dev.zig");
13
14pub const CrtFile = enum {
15 crt2_o,
16 dllcrt2_o,
17 libmingw32_lib,
18};
19
20/// TODO replace anyerror with explicit error set, recording user-friendly errors with
21/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
22pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
23 if (!build_options.have_llvm) {
24 return error.ZigCompilerNotBuiltWithLLVMExtensions;
25 }
26 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
27 defer arena_allocator.deinit();
28 const arena = arena_allocator.allocator();
29 const target = comp.getTarget();
30
31 // The old 32-bit x86 variant of SEH doesn't use tables.
32 const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .@"async" else .none;
33
34 switch (crt_file) {
35 .crt2_o => {
36 var args = std.ArrayList([]const u8).init(arena);
37 try addCrtCcArgs(comp, arena, &args);
38 if (comp.mingw_unicode_entry_point) {
39 try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" });
40 }
41 var files = [_]Compilation.CSourceFile{
42 .{
43 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
44 "libc", "mingw", "crt", "crtexe.c",
45 }),
46 .extra_flags = args.items,
47 .owner = undefined,
48 },
49 };
50 return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files, .{
51 .unwind_tables = unwind_tables,
52 });
53 },
54
55 .dllcrt2_o => {
56 var args = std.ArrayList([]const u8).init(arena);
57 try addCrtCcArgs(comp, arena, &args);
58 var files = [_]Compilation.CSourceFile{
59 .{
60 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
61 "libc", "mingw", "crt", "crtdll.c",
62 }),
63 .extra_flags = args.items,
64 .owner = undefined,
65 },
66 };
67 return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files, .{
68 .unwind_tables = unwind_tables,
69 });
70 },
71
72 .libmingw32_lib => {
73 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
74
75 {
76 var crt_args = std.ArrayList([]const u8).init(arena);
77 try addCrtCcArgs(comp, arena, &crt_args);
78
79 for (mingw32_generic_src) |dep| {
80 try c_source_files.append(.{
81 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
82 "libc", "mingw", dep,
83 }),
84 .extra_flags = crt_args.items,
85 .owner = undefined,
86 });
87 }
88 if (target.cpu.arch.isX86()) {
89 for (mingw32_x86_src) |dep| {
90 try c_source_files.append(.{
91 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
92 "libc", "mingw", dep,
93 }),
94 .extra_flags = crt_args.items,
95 .owner = undefined,
96 });
97 }
98 if (target.cpu.arch == .x86) {
99 for (mingw32_x86_32_src) |dep| {
100 try c_source_files.append(.{
101 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
102 "libc", "mingw", dep,
103 }),
104 .extra_flags = crt_args.items,
105 .owner = undefined,
106 });
107 }
108 }
109 } else if (target.cpu.arch == .thumb) {
110 for (mingw32_arm_src) |dep| {
111 try c_source_files.append(.{
112 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
113 "libc", "mingw", dep,
114 }),
115 .extra_flags = crt_args.items,
116 .owner = undefined,
117 });
118 }
119 for (mingw32_arm32_src) |dep| {
120 try c_source_files.append(.{
121 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
122 "libc", "mingw", dep,
123 }),
124 .extra_flags = crt_args.items,
125 .owner = undefined,
126 });
127 }
128 } else if (target.cpu.arch == .aarch64) {
129 for (mingw32_arm_src) |dep| {
130 try c_source_files.append(.{
131 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
132 "libc", "mingw", dep,
133 }),
134 .extra_flags = crt_args.items,
135 .owner = undefined,
136 });
137 }
138 for (mingw32_arm64_src) |dep| {
139 try c_source_files.append(.{
140 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
141 "libc", "mingw", dep,
142 }),
143 .extra_flags = crt_args.items,
144 .owner = undefined,
145 });
146 }
147 } else {
148 @panic("unsupported arch");
149 }
150 }
151
152 {
153 var winpthreads_args = std.ArrayList([]const u8).init(arena);
154 try addCcArgs(comp, arena, &winpthreads_args);
155 try winpthreads_args.appendSlice(&[_][]const u8{
156 "-DIN_WINPTHREAD",
157 "-DWIN32_LEAN_AND_MEAN",
158 });
159
160 switch (comp.compilerRtOptMode()) {
161 .Debug, .ReleaseSafe => try winpthreads_args.append("-DWINPTHREAD_DBG"),
162 .ReleaseFast, .ReleaseSmall => {},
163 }
164
165 for (mingw32_winpthreads_src) |dep| {
166 try c_source_files.append(.{
167 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
168 "libc", "mingw", dep,
169 }),
170 .extra_flags = winpthreads_args.items,
171 .owner = undefined,
172 });
173 }
174 }
175
176 return comp.build_crt_file("libmingw32", .Lib, .@"mingw-w64 libmingw32.lib", prog_node, c_source_files.items, .{
177 .unwind_tables = unwind_tables,
178 // https://github.com/llvm/llvm-project/issues/43698#issuecomment-2542660611
179 .allow_lto = false,
180 });
181 },
182 }
183}
184
185fn addCcArgs(
186 comp: *Compilation,
187 arena: Allocator,
188 args: *std.ArrayList([]const u8),
189) error{OutOfMemory}!void {
190 try args.appendSlice(&[_][]const u8{
191 "-std=gnu11",
192 "-D__USE_MINGW_ANSI_STDIO=0",
193
194 "-isystem",
195 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
196 });
197}
198
199fn addCrtCcArgs(
200 comp: *Compilation,
201 arena: Allocator,
202 args: *std.ArrayList([]const u8),
203) error{OutOfMemory}!void {
204 try addCcArgs(comp, arena, args);
205
206 if (comp.getTarget().cpu.arch == .thumb) {
207 try args.append("-mfpu=vfp");
208 }
209
210 try args.appendSlice(&[_][]const u8{
211 // According to Martin Storsjö,
212 // > the files under mingw-w64-crt are designed to always
213 // be built with __MSVCRT_VERSION__=0x700
214 "-D__MSVCRT_VERSION__=0x700",
215 "-D_CRTBLD",
216 "-D_SYSCRT=1",
217 "-D_WIN32_WINNT=0x0f00",
218 "-DCRTDLL=1",
219 "-DHAVE_CONFIG_H",
220
221 "-I",
222 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "include" }),
223 });
224}
225
226pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
227 dev.check(.build_import_lib);
228
229 const gpa = comp.gpa;
230
231 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
232 defer arena_allocator.deinit();
233 const arena = arena_allocator.allocator();
234
235 const def_file_path = findDef(arena, comp.getTarget(), comp.zig_lib_directory, lib_name) catch |err| switch (err) {
236 error.FileNotFound => {
237 log.debug("no {s}.def file available to make a DLL import {s}.lib", .{ lib_name, lib_name });
238 // In this case we will end up putting foo.lib onto the linker line and letting the linker
239 // use its library paths to look for libraries and report any problems.
240 return;
241 },
242 else => |e| return e,
243 };
244
245 const target = comp.getTarget();
246
247 // Use the global cache directory.
248 var cache: Cache = .{
249 .gpa = gpa,
250 .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
251 };
252 cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
253 cache.addPrefix(comp.zig_lib_directory);
254 cache.addPrefix(comp.global_cache_directory);
255 defer cache.manifest_dir.close();
256
257 cache.hash.addBytes(build_options.version);
258 cache.hash.addOptionalBytes(comp.zig_lib_directory.path);
259 cache.hash.add(target.cpu.arch);
260
261 var man = cache.obtain();
262 defer man.deinit();
263
264 _ = try man.addFile(def_file_path, null);
265
266 const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name});
267 errdefer gpa.free(final_lib_basename);
268
269 if (try man.hit()) {
270 const digest = man.final();
271 const sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
272 errdefer gpa.free(sub_path);
273
274 comp.mutex.lock();
275 defer comp.mutex.unlock();
276 try comp.crt_files.ensureUnusedCapacity(gpa, 1);
277 comp.crt_files.putAssumeCapacityNoClobber(final_lib_basename, .{
278 .full_object_path = .{
279 .root_dir = comp.global_cache_directory,
280 .sub_path = sub_path,
281 },
282 .lock = man.toOwnedLock(),
283 });
284 return;
285 }
286
287 const digest = man.final();
288 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
289 var o_dir = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{});
290 defer o_dir.close();
291
292 const final_def_basename = try std.fmt.allocPrint(arena, "{s}.def", .{lib_name});
293 const def_final_path = try comp.global_cache_directory.join(arena, &[_][]const u8{
294 "o", &digest, final_def_basename,
295 });
296
297 const target_defines = switch (target.cpu.arch) {
298 .thumb => "#define DEF_ARM32\n",
299 .aarch64 => "#define DEF_ARM64\n",
300 .x86 => "#define DEF_I386\n",
301 .x86_64 => "#define DEF_X64\n",
302 else => unreachable,
303 };
304
305 const aro = @import("aro");
306 var aro_comp = aro.Compilation.init(gpa, std.fs.cwd());
307 defer aro_comp.deinit();
308
309 const include_dir = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "def-include" });
310
311 if (comp.verbose_cc) print: {
312 std.debug.lockStdErr();
313 defer std.debug.unlockStdErr();
314 const stderr = std.io.getStdErr().writer();
315 nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print;
316 nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print;
317 nosuspend stderr.print("output path: {s}\n", .{def_final_path}) catch break :print;
318 }
319
320 try aro_comp.include_dirs.append(gpa, include_dir);
321
322 const builtin_macros = try aro_comp.generateBuiltinMacros(.include_system_defines);
323 const user_macros = try aro_comp.addSourceFromBuffer("<command line>", target_defines);
324 const def_file_source = try aro_comp.addSourceFromPath(def_file_path);
325
326 var pp = aro.Preprocessor.init(&aro_comp);
327 defer pp.deinit();
328 pp.linemarkers = .none;
329 pp.preserve_whitespace = true;
330
331 try pp.preprocessSources(&.{ def_file_source, builtin_macros, user_macros });
332
333 for (aro_comp.diagnostics.list.items) |diagnostic| {
334 if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") {
335 aro.Diagnostics.render(&aro_comp, std.io.tty.detectConfig(std.io.getStdErr()));
336 return error.AroPreprocessorFailed;
337 }
338 }
339
340 {
341 // new scope to ensure definition file is written before passing the path to WriteImportLibrary
342 const def_final_file = try o_dir.createFile(final_def_basename, .{ .truncate = true });
343 defer def_final_file.close();
344 try pp.prettyPrintTokens(def_final_file.writer(), .result_only);
345 }
346
347 const lib_final_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
348 errdefer gpa.free(lib_final_path);
349
350 if (!build_options.have_llvm) return error.ZigCompilerNotBuiltWithLLVMExtensions;
351 const llvm_bindings = @import("../codegen/llvm/bindings.zig");
352 const def_final_path_z = try arena.dupeZ(u8, def_final_path);
353 const lib_final_path_z = try comp.global_cache_directory.joinZ(arena, &.{lib_final_path});
354 if (llvm_bindings.WriteImportLibrary(
355 def_final_path_z.ptr,
356 @intFromEnum(target.toCoffMachine()),
357 lib_final_path_z.ptr,
358 true,
359 )) {
360 // TODO surface a proper error here
361 log.err("unable to turn {s}.def into {s}.lib", .{ lib_name, lib_name });
362 return error.WritingImportLibFailed;
363 }
364
365 man.writeManifest() catch |err| {
366 log.warn("failed to write cache manifest for DLL import {s}.lib: {s}", .{ lib_name, @errorName(err) });
367 };
368
369 comp.mutex.lock();
370 defer comp.mutex.unlock();
371 try comp.crt_files.putNoClobber(gpa, final_lib_basename, .{
372 .full_object_path = .{
373 .root_dir = comp.global_cache_directory,
374 .sub_path = lib_final_path,
375 },
376 .lock = man.toOwnedLock(),
377 });
378}
379
380pub fn libExists(
381 allocator: Allocator,
382 target: std.Target,
383 zig_lib_directory: Cache.Directory,
384 lib_name: []const u8,
385) !bool {
386 const s = findDef(allocator, target, zig_lib_directory, lib_name) catch |err| switch (err) {
387 error.FileNotFound => return false,
388 else => |e| return e,
389 };
390 defer allocator.free(s);
391 return true;
392}
393
394/// This function body is verbose but all it does is test 3 different paths and
395/// see if a .def file exists.
396fn findDef(
397 allocator: Allocator,
398 target: std.Target,
399 zig_lib_directory: Cache.Directory,
400 lib_name: []const u8,
401) ![]u8 {
402 const lib_path = switch (target.cpu.arch) {
403 .thumb => "libarm32",
404 .aarch64 => "libarm64",
405 .x86 => "lib32",
406 .x86_64 => "lib64",
407 else => unreachable,
408 };
409
410 var override_path = std.ArrayList(u8).init(allocator);
411 defer override_path.deinit();
412
413 const s = path.sep_str;
414
415 {
416 // Try the archtecture-specific path first.
417 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";
418 if (zig_lib_directory.path) |p| {
419 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });
420 } else {
421 try override_path.writer().print(fmt_path, .{ lib_path, lib_name });
422 }
423 if (std.fs.cwd().access(override_path.items, .{})) |_| {
424 return override_path.toOwnedSlice();
425 } else |err| switch (err) {
426 error.FileNotFound => {},
427 else => |e| return e,
428 }
429 }
430
431 {
432 // Try the generic version.
433 override_path.shrinkRetainingCapacity(0);
434 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def";
435 if (zig_lib_directory.path) |p| {
436 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
437 } else {
438 try override_path.writer().print(fmt_path, .{lib_name});
439 }
440 if (std.fs.cwd().access(override_path.items, .{})) |_| {
441 return override_path.toOwnedSlice();
442 } else |err| switch (err) {
443 error.FileNotFound => {},
444 else => |e| return e,
445 }
446 }
447
448 {
449 // Try the generic version and preprocess it.
450 override_path.shrinkRetainingCapacity(0);
451 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";
452 if (zig_lib_directory.path) |p| {
453 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
454 } else {
455 try override_path.writer().print(fmt_path, .{lib_name});
456 }
457 if (std.fs.cwd().access(override_path.items, .{})) |_| {
458 return override_path.toOwnedSlice();
459 } else |err| switch (err) {
460 error.FileNotFound => {},
461 else => |e| return e,
462 }
463 }
464
465 return error.FileNotFound;
466}
467
468const mingw32_generic_src = [_][]const u8{
469 // mingw32
470 "crt" ++ path.sep_str ++ "crtexewin.c",
471 "crt" ++ path.sep_str ++ "dll_argv.c",
472 "crt" ++ path.sep_str ++ "gccmain.c",
473 "crt" ++ path.sep_str ++ "natstart.c",
474 "crt" ++ path.sep_str ++ "pseudo-reloc-list.c",
475 "crt" ++ path.sep_str ++ "wildcard.c",
476 "crt" ++ path.sep_str ++ "charmax.c",
477 "crt" ++ path.sep_str ++ "ucrtexewin.c",
478 "crt" ++ path.sep_str ++ "dllargv.c",
479 "crt" ++ path.sep_str ++ "_newmode.c",
480 "crt" ++ path.sep_str ++ "tlssup.c",
481 "crt" ++ path.sep_str ++ "xncommod.c",
482 "crt" ++ path.sep_str ++ "cinitexe.c",
483 "crt" ++ path.sep_str ++ "merr.c",
484 "crt" ++ path.sep_str ++ "usermatherr.c",
485 "crt" ++ path.sep_str ++ "pesect.c",
486 "crt" ++ path.sep_str ++ "udllargc.c",
487 "crt" ++ path.sep_str ++ "xthdloc.c",
488 "crt" ++ path.sep_str ++ "CRT_fp10.c",
489 "crt" ++ path.sep_str ++ "mingw_helpers.c",
490 "crt" ++ path.sep_str ++ "pseudo-reloc.c",
491 "crt" ++ path.sep_str ++ "udll_argv.c",
492 "crt" ++ path.sep_str ++ "xtxtmode.c",
493 "crt" ++ path.sep_str ++ "crt_handler.c",
494 "crt" ++ path.sep_str ++ "tlsthrd.c",
495 "crt" ++ path.sep_str ++ "tlsmthread.c",
496 "crt" ++ path.sep_str ++ "tlsmcrt.c",
497 "crt" ++ path.sep_str ++ "cxa_atexit.c",
498 "crt" ++ path.sep_str ++ "cxa_thread_atexit.c",
499 "crt" ++ path.sep_str ++ "tls_atexit.c",
500 "intrincs" ++ path.sep_str ++ "RtlSecureZeroMemory.c",
501 // mingwex
502 "cfguard" ++ path.sep_str ++ "mingw_cfguard_support.c",
503 "complex" ++ path.sep_str ++ "_cabs.c",
504 "complex" ++ path.sep_str ++ "cabs.c",
505 "complex" ++ path.sep_str ++ "cabsf.c",
506 "complex" ++ path.sep_str ++ "cabsl.c",
507 "complex" ++ path.sep_str ++ "cacos.c",
508 "complex" ++ path.sep_str ++ "cacosf.c",
509 "complex" ++ path.sep_str ++ "cacosl.c",
510 "complex" ++ path.sep_str ++ "carg.c",
511 "complex" ++ path.sep_str ++ "cargf.c",
512 "complex" ++ path.sep_str ++ "cargl.c",
513 "complex" ++ path.sep_str ++ "casin.c",
514 "complex" ++ path.sep_str ++ "casinf.c",
515 "complex" ++ path.sep_str ++ "casinl.c",
516 "complex" ++ path.sep_str ++ "catan.c",
517 "complex" ++ path.sep_str ++ "catanf.c",
518 "complex" ++ path.sep_str ++ "catanl.c",
519 "complex" ++ path.sep_str ++ "ccos.c",
520 "complex" ++ path.sep_str ++ "ccosf.c",
521 "complex" ++ path.sep_str ++ "ccosl.c",
522 "complex" ++ path.sep_str ++ "cexp.c",
523 "complex" ++ path.sep_str ++ "cexpf.c",
524 "complex" ++ path.sep_str ++ "cexpl.c",
525 "complex" ++ path.sep_str ++ "cimag.c",
526 "complex" ++ path.sep_str ++ "cimagf.c",
527 "complex" ++ path.sep_str ++ "cimagl.c",
528 "complex" ++ path.sep_str ++ "clog.c",
529 "complex" ++ path.sep_str ++ "clog10.c",
530 "complex" ++ path.sep_str ++ "clog10f.c",
531 "complex" ++ path.sep_str ++ "clog10l.c",
532 "complex" ++ path.sep_str ++ "clogf.c",
533 "complex" ++ path.sep_str ++ "clogl.c",
534 "complex" ++ path.sep_str ++ "conj.c",
535 "complex" ++ path.sep_str ++ "conjf.c",
536 "complex" ++ path.sep_str ++ "conjl.c",
537 "complex" ++ path.sep_str ++ "cpow.c",
538 "complex" ++ path.sep_str ++ "cpowf.c",
539 "complex" ++ path.sep_str ++ "cpowl.c",
540 "complex" ++ path.sep_str ++ "cproj.c",
541 "complex" ++ path.sep_str ++ "cprojf.c",
542 "complex" ++ path.sep_str ++ "cprojl.c",
543 "complex" ++ path.sep_str ++ "creal.c",
544 "complex" ++ path.sep_str ++ "crealf.c",
545 "complex" ++ path.sep_str ++ "creall.c",
546 "complex" ++ path.sep_str ++ "csin.c",
547 "complex" ++ path.sep_str ++ "csinf.c",
548 "complex" ++ path.sep_str ++ "csinl.c",
549 "complex" ++ path.sep_str ++ "csqrt.c",
550 "complex" ++ path.sep_str ++ "csqrtf.c",
551 "complex" ++ path.sep_str ++ "csqrtl.c",
552 "complex" ++ path.sep_str ++ "ctan.c",
553 "complex" ++ path.sep_str ++ "ctanf.c",
554 "complex" ++ path.sep_str ++ "ctanl.c",
555 "gdtoa" ++ path.sep_str ++ "arithchk.c",
556 "gdtoa" ++ path.sep_str ++ "dmisc.c",
557 "gdtoa" ++ path.sep_str ++ "dtoa.c",
558 "gdtoa" ++ path.sep_str ++ "g__fmt.c",
559 "gdtoa" ++ path.sep_str ++ "g_dfmt.c",
560 "gdtoa" ++ path.sep_str ++ "g_ffmt.c",
561 "gdtoa" ++ path.sep_str ++ "g_xfmt.c",
562 "gdtoa" ++ path.sep_str ++ "gdtoa.c",
563 "gdtoa" ++ path.sep_str ++ "gethex.c",
564 "gdtoa" ++ path.sep_str ++ "gmisc.c",
565 "gdtoa" ++ path.sep_str ++ "hd_init.c",
566 "gdtoa" ++ path.sep_str ++ "hexnan.c",
567 "gdtoa" ++ path.sep_str ++ "misc.c",
568 "gdtoa" ++ path.sep_str ++ "qnan.c",
569 "gdtoa" ++ path.sep_str ++ "smisc.c",
570 "gdtoa" ++ path.sep_str ++ "strtodg.c",
571 "gdtoa" ++ path.sep_str ++ "strtodnrp.c",
572 "gdtoa" ++ path.sep_str ++ "strtof.c",
573 "gdtoa" ++ path.sep_str ++ "strtopx.c",
574 "gdtoa" ++ path.sep_str ++ "sum.c",
575 "gdtoa" ++ path.sep_str ++ "ulp.c",
576 "math" ++ path.sep_str ++ "coshl.c",
577 "math" ++ path.sep_str ++ "fabsl.c",
578 "math" ++ path.sep_str ++ "fp_consts.c",
579 "math" ++ path.sep_str ++ "fp_constsf.c",
580 "math" ++ path.sep_str ++ "fp_constsl.c",
581 "math" ++ path.sep_str ++ "fpclassify.c",
582 "math" ++ path.sep_str ++ "fpclassifyf.c",
583 "math" ++ path.sep_str ++ "fpclassifyl.c",
584 "math" ++ path.sep_str ++ "frexpf.c",
585 "math" ++ path.sep_str ++ "frexpl.c",
586 "math" ++ path.sep_str ++ "hypotf.c",
587 "math" ++ path.sep_str ++ "hypotl.c",
588 "math" ++ path.sep_str ++ "isnan.c",
589 "math" ++ path.sep_str ++ "isnanf.c",
590 "math" ++ path.sep_str ++ "isnanl.c",
591 "math" ++ path.sep_str ++ "ldexpf.c",
592 "math" ++ path.sep_str ++ "lgamma.c",
593 "math" ++ path.sep_str ++ "lgammaf.c",
594 "math" ++ path.sep_str ++ "lgammal.c",
595 "math" ++ path.sep_str ++ "modfl.c",
596 "math" ++ path.sep_str ++ "powi.c",
597 "math" ++ path.sep_str ++ "powif.c",
598 "math" ++ path.sep_str ++ "powil.c",
599 "math" ++ path.sep_str ++ "signbit.c",
600 "math" ++ path.sep_str ++ "signbitf.c",
601 "math" ++ path.sep_str ++ "signbitl.c",
602 "math" ++ path.sep_str ++ "signgam.c",
603 "math" ++ path.sep_str ++ "sinhl.c",
604 "math" ++ path.sep_str ++ "sqrtl.c",
605 "math" ++ path.sep_str ++ "tanhl.c",
606 "misc" ++ path.sep_str ++ "alarm.c",
607 "misc" ++ path.sep_str ++ "btowc.c",
608 "misc" ++ path.sep_str ++ "delay-f.c",
609 "misc" ++ path.sep_str ++ "delay-n.c",
610 "misc" ++ path.sep_str ++ "delayimp.c",
611 "misc" ++ path.sep_str ++ "dirent.c",
612 "misc" ++ path.sep_str ++ "dirname.c",
613 "misc" ++ path.sep_str ++ "dllentrypoint.c",
614 "misc" ++ path.sep_str ++ "dllmain.c",
615 "misc" ++ path.sep_str ++ "feclearexcept.c",
616 "misc" ++ path.sep_str ++ "fegetenv.c",
617 "misc" ++ path.sep_str ++ "fegetexceptflag.c",
618 "misc" ++ path.sep_str ++ "fegetround.c",
619 "misc" ++ path.sep_str ++ "feholdexcept.c",
620 "misc" ++ path.sep_str ++ "feraiseexcept.c",
621 "misc" ++ path.sep_str ++ "fesetenv.c",
622 "misc" ++ path.sep_str ++ "fesetexceptflag.c",
623 "misc" ++ path.sep_str ++ "fesetround.c",
624 "misc" ++ path.sep_str ++ "fetestexcept.c",
625 "misc" ++ path.sep_str ++ "feupdateenv.c",
626 "misc" ++ path.sep_str ++ "ftruncate.c",
627 "misc" ++ path.sep_str ++ "ftw.c",
628 "misc" ++ path.sep_str ++ "ftw64.c",
629 "misc" ++ path.sep_str ++ "fwide.c",
630 "misc" ++ path.sep_str ++ "getlogin.c",
631 "misc" ++ path.sep_str ++ "getopt.c",
632 "misc" ++ path.sep_str ++ "gettimeofday.c",
633 "misc" ++ path.sep_str ++ "mempcpy.c",
634 "misc" ++ path.sep_str ++ "mingw-access.c",
635 "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c",
636 "misc" ++ path.sep_str ++ "mingw_getsp.S",
637 "misc" ++ path.sep_str ++ "mingw_longjmp.S",
638 "misc" ++ path.sep_str ++ "mingw_matherr.c",
639 "misc" ++ path.sep_str ++ "mingw_mbwc_convert.c",
640 "misc" ++ path.sep_str ++ "mingw_usleep.c",
641 "misc" ++ path.sep_str ++ "mingw_wcstod.c",
642 "misc" ++ path.sep_str ++ "mingw_wcstof.c",
643 "misc" ++ path.sep_str ++ "mingw_wcstold.c",
644 "misc" ++ path.sep_str ++ "mkstemp.c",
645 "misc" ++ path.sep_str ++ "sleep.c",
646 "misc" ++ path.sep_str ++ "strnlen.c",
647 "misc" ++ path.sep_str ++ "strsafe.c",
648 "misc" ++ path.sep_str ++ "tdelete.c",
649 "misc" ++ path.sep_str ++ "tdestroy.c",
650 "misc" ++ path.sep_str ++ "tfind.c",
651 "misc" ++ path.sep_str ++ "tsearch.c",
652 "misc" ++ path.sep_str ++ "twalk.c",
653 "misc" ++ path.sep_str ++ "wcsnlen.c",
654 "misc" ++ path.sep_str ++ "wcstof.c",
655 "misc" ++ path.sep_str ++ "wcstoimax.c",
656 "misc" ++ path.sep_str ++ "wcstold.c",
657 "misc" ++ path.sep_str ++ "wcstoumax.c",
658 "misc" ++ path.sep_str ++ "wctob.c",
659 "misc" ++ path.sep_str ++ "wdirent.c",
660 "misc" ++ path.sep_str ++ "winbs_uint64.c",
661 "misc" ++ path.sep_str ++ "winbs_ulong.c",
662 "misc" ++ path.sep_str ++ "winbs_ushort.c",
663 "misc" ++ path.sep_str ++ "wmemchr.c",
664 "misc" ++ path.sep_str ++ "wmemcmp.c",
665 "misc" ++ path.sep_str ++ "wmemcpy.c",
666 "misc" ++ path.sep_str ++ "wmemmove.c",
667 "misc" ++ path.sep_str ++ "wmempcpy.c",
668 "misc" ++ path.sep_str ++ "wmemset.c",
669 "stdio" ++ path.sep_str ++ "_Exit.c",
670 "stdio" ++ path.sep_str ++ "_findfirst64i32.c",
671 "stdio" ++ path.sep_str ++ "_findnext64i32.c",
672 "stdio" ++ path.sep_str ++ "_fstat64i32.c",
673 "stdio" ++ path.sep_str ++ "_stat.c",
674 "stdio" ++ path.sep_str ++ "_stat64i32.c",
675 "stdio" ++ path.sep_str ++ "_wfindfirst64i32.c",
676 "stdio" ++ path.sep_str ++ "_wfindnext64i32.c",
677 "stdio" ++ path.sep_str ++ "_wstat.c",
678 "stdio" ++ path.sep_str ++ "_wstat64i32.c",
679 "stdio" ++ path.sep_str ++ "asprintf.c",
680 "stdio" ++ path.sep_str ++ "fopen64.c",
681 "stdio" ++ path.sep_str ++ "fseeko32.c",
682 "stdio" ++ path.sep_str ++ "fseeko64.c",
683 "stdio" ++ path.sep_str ++ "ftello.c",
684 "stdio" ++ path.sep_str ++ "ftello64.c",
685 "stdio" ++ path.sep_str ++ "ftruncate64.c",
686 "stdio" ++ path.sep_str ++ "lltoa.c",
687 "stdio" ++ path.sep_str ++ "lltow.c",
688 "stdio" ++ path.sep_str ++ "lseek64.c",
689 "stdio" ++ path.sep_str ++ "mingw_asprintf.c",
690 "stdio" ++ path.sep_str ++ "mingw_fprintf.c",
691 "stdio" ++ path.sep_str ++ "mingw_fwprintf.c",
692 "stdio" ++ path.sep_str ++ "mingw_fscanf.c",
693 "stdio" ++ path.sep_str ++ "mingw_fwscanf.c",
694 "stdio" ++ path.sep_str ++ "mingw_pformat.c",
695 "stdio" ++ path.sep_str ++ "mingw_sformat.c",
696 "stdio" ++ path.sep_str ++ "mingw_swformat.c",
697 "stdio" ++ path.sep_str ++ "mingw_wpformat.c",
698 "stdio" ++ path.sep_str ++ "mingw_printf.c",
699 "stdio" ++ path.sep_str ++ "mingw_wprintf.c",
700 "stdio" ++ path.sep_str ++ "mingw_scanf.c",
701 "stdio" ++ path.sep_str ++ "mingw_snprintf.c",
702 "stdio" ++ path.sep_str ++ "mingw_snwprintf.c",
703 "stdio" ++ path.sep_str ++ "mingw_sprintf.c",
704 "stdio" ++ path.sep_str ++ "mingw_swprintf.c",
705 "stdio" ++ path.sep_str ++ "mingw_sscanf.c",
706 "stdio" ++ path.sep_str ++ "mingw_swscanf.c",
707 "stdio" ++ path.sep_str ++ "mingw_vasprintf.c",
708 "stdio" ++ path.sep_str ++ "mingw_vfprintf.c",
709 "stdio" ++ path.sep_str ++ "mingw_vfwprintf.c",
710 "stdio" ++ path.sep_str ++ "mingw_vfscanf.c",
711 "stdio" ++ path.sep_str ++ "mingw_vprintf.c",
712 "stdio" ++ path.sep_str ++ "mingw_vsscanf.c",
713 "stdio" ++ path.sep_str ++ "mingw_vwprintf.c",
714 "stdio" ++ path.sep_str ++ "mingw_vsnprintf.c",
715 "stdio" ++ path.sep_str ++ "mingw_vsnwprintf.c",
716 "stdio" ++ path.sep_str ++ "mingw_vsprintf.c",
717 "stdio" ++ path.sep_str ++ "mingw_vswprintf.c",
718 "stdio" ++ path.sep_str ++ "mingw_wscanf.c",
719 "stdio" ++ path.sep_str ++ "mingw_vfwscanf.c",
720 "stdio" ++ path.sep_str ++ "mingw_vswscanf.c",
721 "stdio" ++ path.sep_str ++ "snprintf.c",
722 "stdio" ++ path.sep_str ++ "snwprintf.c",
723 "stdio" ++ path.sep_str ++ "strtok_r.c",
724 "stdio" ++ path.sep_str ++ "truncate.c",
725 "stdio" ++ path.sep_str ++ "ulltoa.c",
726 "stdio" ++ path.sep_str ++ "ulltow.c",
727 "stdio" ++ path.sep_str ++ "vasprintf.c",
728 "stdio" ++ path.sep_str ++ "vsnprintf.c",
729 "stdio" ++ path.sep_str ++ "vsnwprintf.c",
730 "stdio" ++ path.sep_str ++ "wtoll.c",
731 // mingwthrd
732 "libsrc" ++ path.sep_str ++ "mingwthrd_mt.c",
733 // ucrtbase
734 "math" ++ path.sep_str ++ "_huge.c",
735 "misc" ++ path.sep_str ++ "__initenv.c",
736 "misc" ++ path.sep_str ++ "__winitenv.c",
737 "misc" ++ path.sep_str ++ "__p___initenv.c",
738 "misc" ++ path.sep_str ++ "__p___winitenv.c",
739 "misc" ++ path.sep_str ++ "_onexit.c",
740 "misc" ++ path.sep_str ++ "ucrt-access.c",
741 "misc" ++ path.sep_str ++ "ucrt__getmainargs.c",
742 "misc" ++ path.sep_str ++ "ucrt__wgetmainargs.c",
743 "misc" ++ path.sep_str ++ "ucrt_amsg_exit.c",
744 "misc" ++ path.sep_str ++ "ucrt_at_quick_exit.c",
745 "misc" ++ path.sep_str ++ "ucrt_tzset.c",
746 "stdio" ++ path.sep_str ++ "ucrt__scprintf.c",
747 "stdio" ++ path.sep_str ++ "ucrt__snprintf.c",
748 "stdio" ++ path.sep_str ++ "ucrt__snscanf.c",
749 "stdio" ++ path.sep_str ++ "ucrt__snwprintf.c",
750 "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c",
751 "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c",
752 "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c",
753 "stdio" ++ path.sep_str ++ "ucrt_fprintf.c",
754 "stdio" ++ path.sep_str ++ "ucrt_fscanf.c",
755 "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c",
756 "stdio" ++ path.sep_str ++ "ucrt_ms_fprintf.c",
757 "stdio" ++ path.sep_str ++ "ucrt_ms_fwprintf.c",
758 "stdio" ++ path.sep_str ++ "ucrt_printf.c",
759 "stdio" ++ path.sep_str ++ "ucrt_scanf.c",
760 "stdio" ++ path.sep_str ++ "ucrt_snprintf.c",
761 "stdio" ++ path.sep_str ++ "ucrt_sprintf.c",
762 "stdio" ++ path.sep_str ++ "ucrt_sscanf.c",
763 "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c",
764 "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c",
765 "stdio" ++ path.sep_str ++ "ucrt_vprintf.c",
766 "stdio" ++ path.sep_str ++ "ucrt_vscanf.c",
767 "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c",
768 "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c",
769 "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c",
770 "string" ++ path.sep_str ++ "ucrt__wcstok.c",
771 // uuid
772 "libsrc" ++ path.sep_str ++ "ativscp-uuid.c",
773 "libsrc" ++ path.sep_str ++ "atsmedia-uuid.c",
774 "libsrc" ++ path.sep_str ++ "bth-uuid.c",
775 "libsrc" ++ path.sep_str ++ "cguid-uuid.c",
776 "libsrc" ++ path.sep_str ++ "comcat-uuid.c",
777 "libsrc" ++ path.sep_str ++ "ctxtcall-uuid.c",
778 "libsrc" ++ path.sep_str ++ "devguid.c",
779 "libsrc" ++ path.sep_str ++ "docobj-uuid.c",
780 "libsrc" ++ path.sep_str ++ "dxva-uuid.c",
781 "libsrc" ++ path.sep_str ++ "exdisp-uuid.c",
782 "libsrc" ++ path.sep_str ++ "extras-uuid.c",
783 "libsrc" ++ path.sep_str ++ "fwp-uuid.c",
784 "libsrc" ++ path.sep_str ++ "guid_nul.c",
785 "libsrc" ++ path.sep_str ++ "hlguids-uuid.c",
786 "libsrc" ++ path.sep_str ++ "hlink-uuid.c",
787 "libsrc" ++ path.sep_str ++ "mlang-uuid.c",
788 "libsrc" ++ path.sep_str ++ "msctf-uuid.c",
789 "libsrc" ++ path.sep_str ++ "mshtmhst-uuid.c",
790 "libsrc" ++ path.sep_str ++ "mshtml-uuid.c",
791 "libsrc" ++ path.sep_str ++ "msxml-uuid.c",
792 "libsrc" ++ path.sep_str ++ "netcfg-uuid.c",
793 "libsrc" ++ path.sep_str ++ "netcon-uuid.c",
794 "libsrc" ++ path.sep_str ++ "ntddkbd-uuid.c",
795 "libsrc" ++ path.sep_str ++ "ntddmou-uuid.c",
796 "libsrc" ++ path.sep_str ++ "ntddpar-uuid.c",
797 "libsrc" ++ path.sep_str ++ "ntddscsi-uuid.c",
798 "libsrc" ++ path.sep_str ++ "ntddser-uuid.c",
799 "libsrc" ++ path.sep_str ++ "ntddstor-uuid.c",
800 "libsrc" ++ path.sep_str ++ "ntddvdeo-uuid.c",
801 "libsrc" ++ path.sep_str ++ "oaidl-uuid.c",
802 "libsrc" ++ path.sep_str ++ "objidl-uuid.c",
803 "libsrc" ++ path.sep_str ++ "objsafe-uuid.c",
804 "libsrc" ++ path.sep_str ++ "ocidl-uuid.c",
805 "libsrc" ++ path.sep_str ++ "oleacc-uuid.c",
806 "libsrc" ++ path.sep_str ++ "olectlid-uuid.c",
807 "libsrc" ++ path.sep_str ++ "oleidl-uuid.c",
808 "libsrc" ++ path.sep_str ++ "power-uuid.c",
809 "libsrc" ++ path.sep_str ++ "powrprof-uuid.c",
810 "libsrc" ++ path.sep_str ++ "uianimation-uuid.c",
811 "libsrc" ++ path.sep_str ++ "usbcamdi-uuid.c",
812 "libsrc" ++ path.sep_str ++ "usbiodef-uuid.c",
813 "libsrc" ++ path.sep_str ++ "uuid.c",
814 "libsrc" ++ path.sep_str ++ "vds-uuid.c",
815 "libsrc" ++ path.sep_str ++ "virtdisk-uuid.c",
816 "libsrc" ++ path.sep_str ++ "vss-uuid.c",
817 "libsrc" ++ path.sep_str ++ "wia-uuid.c",
818 "libsrc" ++ path.sep_str ++ "windowscodecs.c",
819 // ws2_32
820 "libsrc" ++ path.sep_str ++ "ws2_32.c",
821 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_addr_equal.c",
822 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isany.c",
823 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isloopback.c",
824 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setany.c",
825 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setloopback.c",
826 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_linklocal.c",
827 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_loopback.c",
828 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_global.c",
829 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_linklocal.c",
830 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_nodelocal.c",
831 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_orglocal.c",
832 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_sitelocal.c",
833 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_multicast.c",
834 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_sitelocal.c",
835 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_unspecified.c",
836 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4compat.c",
837 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4mapped.c",
838 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_loopback.c",
839 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_unspecified.c",
840 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorA.c",
841 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorW.c",
842 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiStrdup.c",
843 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiParseV4Address.c",
844 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiNewAddrInfo.c",
845 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiQueryDNS.c",
846 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLookupNode.c",
847 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiClone.c",
848 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyFreeAddrInfo.c",
849 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetAddrInfo.c",
850 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetNameInfo.c",
851 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLoad.c",
852 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetAddrInfo.c",
853 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetNameInfo.c",
854 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiFreeAddrInfo.c",
855 // dinput
856 "libsrc" ++ path.sep_str ++ "dinput_kbd.c",
857 "libsrc" ++ path.sep_str ++ "dinput_joy.c",
858 "libsrc" ++ path.sep_str ++ "dinput_joy2.c",
859 "libsrc" ++ path.sep_str ++ "dinput_mouse.c",
860 "libsrc" ++ path.sep_str ++ "dinput_mouse2.c",
861 // dloadhelper
862 "libsrc" ++ path.sep_str ++ "dloadhelper.c",
863 "misc" ++ path.sep_str ++ "delay-f.c",
864 // misc.
865 "libsrc" ++ path.sep_str ++ "bits.c",
866 "libsrc" ++ path.sep_str ++ "shell32.c",
867 "libsrc" ++ path.sep_str ++ "dmoguids.c",
868 "libsrc" ++ path.sep_str ++ "dxerr8.c",
869 "libsrc" ++ path.sep_str ++ "dxerr8w.c",
870 "libsrc" ++ path.sep_str ++ "dxerr9.c",
871 "libsrc" ++ path.sep_str ++ "dxerr9w.c",
872 "libsrc" ++ path.sep_str ++ "mfuuid.c",
873 "libsrc" ++ path.sep_str ++ "msxml2.c",
874 "libsrc" ++ path.sep_str ++ "msxml6.c",
875 "libsrc" ++ path.sep_str ++ "amstrmid.c",
876 "libsrc" ++ path.sep_str ++ "wbemuuid.c",
877 "libsrc" ++ path.sep_str ++ "wmcodecdspuuid.c",
878 "libsrc" ++ path.sep_str ++ "windowscodecs.c",
879 "libsrc" ++ path.sep_str ++ "dxguid.c",
880 "libsrc" ++ path.sep_str ++ "ksuser.c",
881 "libsrc" ++ path.sep_str ++ "largeint.c",
882 "libsrc" ++ path.sep_str ++ "locationapi.c",
883 "libsrc" ++ path.sep_str ++ "sapi.c",
884 "libsrc" ++ path.sep_str ++ "sensorsapi.c",
885 "libsrc" ++ path.sep_str ++ "portabledeviceguids.c",
886 "libsrc" ++ path.sep_str ++ "taskschd.c",
887 "libsrc" ++ path.sep_str ++ "scrnsave.c",
888 "libsrc" ++ path.sep_str ++ "strmiids.c",
889 "libsrc" ++ path.sep_str ++ "gdiplus.c",
890 "libsrc" ++ path.sep_str ++ "activeds-uuid.c",
891};
892
893const mingw32_x86_src = [_][]const u8{
894 // mingwex
895 "math" ++ path.sep_str ++ "cbrtl.c",
896 "math" ++ path.sep_str ++ "erfl.c",
897 "math" ++ path.sep_str ++ "fdiml.c",
898 "math" ++ path.sep_str ++ "fmal.c",
899 "math" ++ path.sep_str ++ "fmaxl.c",
900 "math" ++ path.sep_str ++ "fminl.c",
901 "math" ++ path.sep_str ++ "llrintl.c",
902 "math" ++ path.sep_str ++ "llroundl.c",
903 "math" ++ path.sep_str ++ "lrintl.c",
904 "math" ++ path.sep_str ++ "lroundl.c",
905 "math" ++ path.sep_str ++ "rintl.c",
906 "math" ++ path.sep_str ++ "roundl.c",
907 "math" ++ path.sep_str ++ "tgammal.c",
908 "math" ++ path.sep_str ++ "truncl.c",
909 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "_chgsignl.S",
910 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acoshl.c",
911 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosl.c",
912 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinhl.c",
913 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinl.c",
914 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
915 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
916 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
917 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceill.S",
918 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
919 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
920 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
921 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossin.c",
922 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
923 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S",
924 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c",
925 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expm1l.c",
926 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorl.S",
927 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodl.c",
928 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fucom.c",
929 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ilogbl.S",
930 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "internal_logl.S",
931 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexp.c",
932 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexpl.c",
933 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log10l.S",
934 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log1pl.S",
935 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log2l.S",
936 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logbl.c",
937 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logl.c",
938 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "nearbyintl.S",
939 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "powl.c",
940 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remainderl.S",
941 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remquol.S",
942 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbn.S",
943 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnf.S",
944 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnl.S",
945 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl.c",
946 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl_internal.S",
947 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanl.S",
948 // ucrtbase
949 "math" ++ path.sep_str ++ "fabsf.c",
950 "math" ++ path.sep_str ++ "nextafterl.c",
951 "math" ++ path.sep_str ++ "nexttoward.c",
952 "math" ++ path.sep_str ++ "nexttowardf.c",
953};
954
955const mingw32_x86_32_src = [_][]const u8{
956 // ucrtbase
957 "math" ++ path.sep_str ++ "coshf.c",
958 "math" ++ path.sep_str ++ "expf.c",
959 "math" ++ path.sep_str ++ "log10f.c",
960 "math" ++ path.sep_str ++ "logf.c",
961 "math" ++ path.sep_str ++ "modff.c",
962 "math" ++ path.sep_str ++ "powf.c",
963 "math" ++ path.sep_str ++ "sinhf.c",
964 "math" ++ path.sep_str ++ "sqrtf.c",
965 "math" ++ path.sep_str ++ "tanhf.c",
966 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosf.c",
967 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c",
968 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",
969 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",
970 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S",
971 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosf.c",
972 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorf.S",
973 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",
974 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinf.c",
975 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanf.c",
976};
977
978const mingw32_arm_src = [_][]const u8{
979 // mingwex
980 "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c",
981};
982
983const mingw32_arm32_src = [_][]const u8{
984 // mingwex
985 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S",
986 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c",
987 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c",
988 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S",
989 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincosf.S",
990};
991
992const mingw32_arm64_src = [_][]const u8{
993 // mingwex
994 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S",
995 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c",
996 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c",
997 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S",
998 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincosf.S",
999};
1000
1001const mingw32_winpthreads_src = [_][]const u8{
1002 // winpthreads
1003 "winpthreads" ++ path.sep_str ++ "barrier.c",
1004 "winpthreads" ++ path.sep_str ++ "clock.c",
1005 "winpthreads" ++ path.sep_str ++ "cond.c",
1006 "winpthreads" ++ path.sep_str ++ "misc.c",
1007 "winpthreads" ++ path.sep_str ++ "mutex.c",
1008 "winpthreads" ++ path.sep_str ++ "nanosleep.c",
1009 "winpthreads" ++ path.sep_str ++ "ref.c",
1010 "winpthreads" ++ path.sep_str ++ "rwlock.c",
1011 "winpthreads" ++ path.sep_str ++ "sched.c",
1012 "winpthreads" ++ path.sep_str ++ "sem.c",
1013 "winpthreads" ++ path.sep_str ++ "spinlock.c",
1014 "winpthreads" ++ path.sep_str ++ "thread.c",
1015};
1016
1017pub const always_link_libs = [_][]const u8{
1018 "api-ms-win-crt-conio-l1-1-0",
1019 "api-ms-win-crt-convert-l1-1-0",
1020 "api-ms-win-crt-environment-l1-1-0",
1021 "api-ms-win-crt-filesystem-l1-1-0",
1022 "api-ms-win-crt-heap-l1-1-0",
1023 "api-ms-win-crt-locale-l1-1-0",
1024 "api-ms-win-crt-math-l1-1-0",
1025 "api-ms-win-crt-multibyte-l1-1-0",
1026 "api-ms-win-crt-private-l1-1-0",
1027 "api-ms-win-crt-process-l1-1-0",
1028 "api-ms-win-crt-runtime-l1-1-0",
1029 "api-ms-win-crt-stdio-l1-1-0",
1030 "api-ms-win-crt-string-l1-1-0",
1031 "api-ms-win-crt-time-l1-1-0",
1032 "api-ms-win-crt-utility-l1-1-0",
1033 "advapi32",
1034 "kernel32",
1035 "ntdll",
1036 "shell32",
1037 "user32",
1038};
src/libs/musl.zig created+2313
...@@ -0,0 +1,2313 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const path = std.fs.path;
5const assert = std.debug.assert;
6const Module = @import("../Package/Module.zig");
7
8const Compilation = @import("../Compilation.zig");
9const build_options = @import("build_options");
10
11pub const CrtFile = enum {
12 crt1_o,
13 rcrt1_o,
14 scrt1_o,
15 libc_a,
16 libc_so,
17};
18
19/// TODO replace anyerror with explicit error set, recording user-friendly errors with
20/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
21pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
22 if (!build_options.have_llvm) {
23 return error.ZigCompilerNotBuiltWithLLVMExtensions;
24 }
25 const gpa = comp.gpa;
26 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
27 defer arena_allocator.deinit();
28 const arena = arena_allocator.allocator();
29
30 switch (in_crt_file) {
31 .crt1_o => {
32 var args = std.ArrayList([]const u8).init(arena);
33 try addCcArgs(comp, arena, &args, false);
34 try args.append("-DCRT");
35 var files = [_]Compilation.CSourceFile{
36 .{
37 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
38 "libc", "musl", "crt", "crt1.c",
39 }),
40 .extra_flags = args.items,
41 .owner = undefined,
42 },
43 };
44 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
45 .function_sections = true,
46 .data_sections = true,
47 .omit_frame_pointer = true,
48 .no_builtin = true,
49 });
50 },
51 .rcrt1_o => {
52 var args = std.ArrayList([]const u8).init(arena);
53 try addCcArgs(comp, arena, &args, false);
54 try args.append("-DCRT");
55 var files = [_]Compilation.CSourceFile{
56 .{
57 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
58 "libc", "musl", "crt", "rcrt1.c",
59 }),
60 .extra_flags = args.items,
61 .owner = undefined,
62 },
63 };
64 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
65 .function_sections = true,
66 .data_sections = true,
67 .omit_frame_pointer = true,
68 .pic = true,
69 .no_builtin = true,
70 });
71 },
72 .scrt1_o => {
73 var args = std.ArrayList([]const u8).init(arena);
74 try addCcArgs(comp, arena, &args, false);
75 try args.append("-DCRT");
76 var files = [_]Compilation.CSourceFile{
77 .{
78 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
79 "libc", "musl", "crt", "Scrt1.c",
80 }),
81 .extra_flags = args.items,
82 .owner = undefined,
83 },
84 };
85 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
86 .function_sections = true,
87 .data_sections = true,
88 .omit_frame_pointer = true,
89 .pic = true,
90 .no_builtin = true,
91 });
92 },
93 .libc_a => {
94 // When there is a src/<arch>/foo.* then it should substitute for src/foo.*
95 // Even a .s file can substitute for a .c file.
96 const target = comp.getTarget();
97 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
98 var source_table = std.StringArrayHashMap(Ext).init(comp.gpa);
99 defer source_table.deinit();
100
101 try source_table.ensureTotalCapacity(compat_time32_files.len + src_files.len);
102
103 for (src_files) |src_file| {
104 try addSrcFile(arena, &source_table, src_file);
105 }
106
107 for (time32_compat_arch_list) |time32_compat_arch| {
108 if (mem.eql(u8, arch_name, time32_compat_arch)) {
109 for (compat_time32_files) |compat_time32_file| {
110 try addSrcFile(arena, &source_table, compat_time32_file);
111 }
112 }
113 }
114
115 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);
116 defer c_source_files.deinit();
117
118 var override_path = std.ArrayList(u8).init(comp.gpa);
119 defer override_path.deinit();
120
121 const s = path.sep_str;
122
123 var it = source_table.iterator();
124 while (it.next()) |entry| {
125 const src_file = entry.key_ptr.*;
126 const ext = entry.value_ptr.*;
127
128 const dirname = path.dirname(src_file).?;
129 const basename = path.basename(src_file);
130 const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
131 const dirbasename = path.basename(dirname);
132
133 var is_arch_specific = false;
134 // Architecture-specific implementations are under a <arch>/ folder.
135 if (isArchName(dirbasename)) {
136 if (!mem.eql(u8, dirbasename, arch_name))
137 continue; // Not the architecture we're compiling for.
138 is_arch_specific = true;
139 }
140 if (!is_arch_specific) {
141 // Look for an arch specific override.
142 override_path.shrinkRetainingCapacity(0);
143 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
144 dirname, arch_name, noextbasename,
145 });
146 if (source_table.contains(override_path.items))
147 continue;
148
149 override_path.shrinkRetainingCapacity(0);
150 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
151 dirname, arch_name, noextbasename,
152 });
153 if (source_table.contains(override_path.items))
154 continue;
155
156 override_path.shrinkRetainingCapacity(0);
157 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
158 dirname, arch_name, noextbasename,
159 });
160 if (source_table.contains(override_path.items))
161 continue;
162 }
163
164 var args = std.ArrayList([]const u8).init(arena);
165 try addCcArgs(comp, arena, &args, ext == .o3);
166 const c_source_file = try c_source_files.addOne();
167 c_source_file.* = .{
168 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", src_file }),
169 .extra_flags = args.items,
170 .owner = undefined,
171 };
172 }
173 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
174 .function_sections = true,
175 .data_sections = true,
176 .omit_frame_pointer = true,
177 .no_builtin = true,
178 });
179 },
180 .libc_so => {
181 const optimize_mode = comp.compilerRtOptMode();
182 const strip = comp.compilerRtStrip();
183 const output_mode: std.builtin.OutputMode = .Lib;
184 const config = try Compilation.Config.resolve(.{
185 .output_mode = output_mode,
186 .link_mode = .dynamic,
187 .resolved_target = comp.root_mod.resolved_target,
188 .is_test = false,
189 .have_zcu = false,
190 .emit_bin = true,
191 .root_optimize_mode = optimize_mode,
192 .root_strip = strip,
193 .link_libc = false,
194 });
195
196 const target = comp.root_mod.resolved_target.result;
197 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
198 const time32 = for (time32_compat_arch_list) |time32_compat_arch| {
199 if (mem.eql(u8, arch_name, time32_compat_arch)) break true;
200 } else false;
201 const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{arch_name});
202 const family_define = switch (target.cpu.arch) {
203 .arm, .armeb, .thumb, .thumbeb => "-DFAMILY_arm",
204 .aarch64, .aarch64_be => "-DFAMILY_aarch64",
205 .hexagon => "-DFAMILY_hexagon",
206 .loongarch64 => "-DFAMILY_loongarch",
207 .m68k => "-DFAMILY_m68k",
208 .mips, .mipsel, .mips64, .mips64el => "-DFAMILY_mips",
209 .powerpc, .powerpc64, .powerpc64le => "-DFAMILY_powerpc",
210 .riscv32, .riscv64 => "-DFAMILY_riscv",
211 .s390x => "-DFAMILY_s390x",
212 .x86, .x86_64 => "-DFAMILY_x86",
213 else => unreachable,
214 };
215 const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64)
216 &.{ "-DPTR64", arch_define, family_define }
217 else if (time32)
218 &.{ "-DTIME32", arch_define, family_define }
219 else
220 &.{ arch_define, family_define };
221
222 const root_mod = try Module.create(arena, .{
223 .global_cache_directory = comp.global_cache_directory,
224 .paths = .{
225 .root = .{ .root_dir = comp.zig_lib_directory },
226 .root_src_path = "",
227 },
228 .fully_qualified_name = "root",
229 .inherited = .{
230 .resolved_target = comp.root_mod.resolved_target,
231 .strip = strip,
232 .stack_check = false,
233 .stack_protector = 0,
234 .sanitize_c = .off,
235 .sanitize_thread = false,
236 .red_zone = comp.root_mod.red_zone,
237 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
238 .valgrind = false,
239 .optimize_mode = optimize_mode,
240 .structured_cfg = comp.root_mod.structured_cfg,
241 },
242 .global = config,
243 .cc_argv = cc_argv,
244 .parent = null,
245 .builtin_mod = null,
246 .builtin_modules = null, // there is only one module in this compilation
247 });
248
249 const sub_compilation = try Compilation.create(comp.gpa, arena, .{
250 .local_cache_directory = comp.global_cache_directory,
251 .global_cache_directory = comp.global_cache_directory,
252 .zig_lib_directory = comp.zig_lib_directory,
253 .self_exe_path = comp.self_exe_path,
254 .cache_mode = .whole,
255 .config = config,
256 .root_mod = root_mod,
257 .thread_pool = comp.thread_pool,
258 .root_name = "c",
259 .libc_installation = comp.libc_installation,
260 .emit_bin = .{ .directory = null, .basename = "libc.so" },
261 .emit_h = null,
262 .verbose_cc = comp.verbose_cc,
263 .verbose_link = comp.verbose_link,
264 .verbose_air = comp.verbose_air,
265 .verbose_llvm_ir = comp.verbose_llvm_ir,
266 .verbose_cimport = comp.verbose_cimport,
267 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
268 .clang_passthrough_mode = comp.clang_passthrough_mode,
269 .c_source_files = &[_]Compilation.CSourceFile{
270 .{
271 .src_path = try comp.zig_lib_directory.join(arena, &.{ "libc", "musl", "libc.S" }),
272 .owner = root_mod,
273 },
274 },
275 .skip_linker_dependencies = true,
276 .soname = "libc.so",
277 });
278 defer sub_compilation.destroy();
279
280 try comp.updateSubCompilation(sub_compilation, .@"musl libc.so", prog_node);
281
282 const basename = try comp.gpa.dupe(u8, "libc.so");
283 errdefer comp.gpa.free(basename);
284
285 const crt_file = try sub_compilation.toCrtFile();
286 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
287 {
288 comp.mutex.lock();
289 defer comp.mutex.unlock();
290 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
291 comp.crt_files.putAssumeCapacityNoClobber(basename, crt_file);
292 }
293 },
294 }
295}
296
297pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
298 return switch (output_mode) {
299 .Obj, .Lib => null,
300 .Exe => switch (link_mode) {
301 .dynamic => if (pie) .scrt1_o else .crt1_o,
302 .static => if (pie) .rcrt1_o else .crt1_o,
303 },
304 };
305}
306
307const time32_compat_arch_list = [_][]const u8{
308 "arm",
309 "i386",
310 "m68k",
311 "microblaze",
312 "mips",
313 "mipsn32",
314 "or1k",
315 "powerpc",
316 "sh",
317};
318
319fn isArchName(name: []const u8) bool {
320 const musl_arch_names = [_][]const u8{
321 "aarch64",
322 "arm",
323 "generic",
324 "hexagon",
325 "i386",
326 "loongarch64",
327 "m68k",
328 "microblaze",
329 "mips",
330 "mips64",
331 "mipsn32",
332 "or1k",
333 "powerpc",
334 "powerpc64",
335 "riscv32",
336 "riscv64",
337 "s390x",
338 "sh",
339 "x32",
340 "x86_64",
341 };
342 for (musl_arch_names) |musl_arch_name| {
343 if (mem.eql(u8, musl_arch_name, name)) {
344 return true;
345 }
346 }
347 return false;
348}
349
350const Ext = enum {
351 assembly,
352 o3,
353};
354
355fn addSrcFile(arena: Allocator, source_table: *std.StringArrayHashMap(Ext), file_path: []const u8) !void {
356 const ext: Ext = ext: {
357 if (mem.endsWith(u8, file_path, ".c")) {
358 if (mem.startsWith(u8, file_path, "musl/src/malloc/") or
359 mem.startsWith(u8, file_path, "musl/src/string/") or
360 mem.startsWith(u8, file_path, "musl/src/internal/"))
361 {
362 break :ext .o3;
363 } else {
364 break :ext .assembly;
365 }
366 } else if (mem.endsWith(u8, file_path, ".s") or mem.endsWith(u8, file_path, ".S")) {
367 break :ext .assembly;
368 } else {
369 unreachable;
370 }
371 };
372 // TODO do this at comptime on the comptime data rather than at runtime
373 // probably best to wait until self-hosted is done and our comptime execution
374 // is faster and uses less memory.
375 const key = if (path.sep != '/') blk: {
376 const mutable_file_path = try arena.dupe(u8, file_path);
377 for (mutable_file_path) |*c| {
378 if (c.* == '/') {
379 c.* = path.sep;
380 }
381 }
382 break :blk mutable_file_path;
383 } else file_path;
384 source_table.putAssumeCapacityNoClobber(key, ext);
385}
386
387fn addCcArgs(
388 comp: *Compilation,
389 arena: Allocator,
390 args: *std.ArrayList([]const u8),
391 want_O3: bool,
392) error{OutOfMemory}!void {
393 const target = comp.getTarget();
394 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
395 const os_name = @tagName(target.os.tag);
396 const triple = try std.fmt.allocPrint(arena, "{s}-{s}-{s}", .{
397 std.zig.target.muslArchNameHeaders(target.cpu.arch),
398 os_name,
399 std.zig.target.muslAbiNameHeaders(target.abi),
400 });
401 const o_arg = if (want_O3) "-O3" else "-Os";
402
403 try args.appendSlice(&[_][]const u8{
404 "-std=c99",
405 "-ffreestanding",
406 "-fexcess-precision=standard",
407 "-frounding-math",
408 "-ffp-contract=off",
409 "-fno-strict-aliasing",
410 "-Wa,--noexecstack",
411 "-D_XOPEN_SOURCE=700",
412
413 "-I",
414 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", arch_name }),
415
416 "-I",
417 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", "generic" }),
418
419 "-I",
420 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "include" }),
421
422 "-I",
423 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "internal" }),
424
425 "-I",
426 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "include" }),
427
428 "-I",
429 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
430
431 "-I",
432 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
433
434 o_arg,
435
436 "-Qunused-arguments",
437 "-w", // disable all warnings
438 });
439
440 if (target.cpu.arch.isThumb()) {
441 try args.append("-mimplicit-it=always");
442 }
443}
444
445fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
446 const target = comp.getTarget();
447 return comp.zig_lib_directory.join(arena, &[_][]const u8{
448 "libc", "musl", "crt", std.zig.target.muslArchName(target.cpu.arch, target.abi), basename,
449 });
450}
451
452const src_files = [_][]const u8{
453 "musl/src/aio/aio.c",
454 "musl/src/aio/aio_suspend.c",
455 "musl/src/aio/lio_listio.c",
456 "musl/src/complex/cabs.c",
457 "musl/src/complex/cabsf.c",
458 "musl/src/complex/cabsl.c",
459 "musl/src/complex/cacos.c",
460 "musl/src/complex/cacosf.c",
461 "musl/src/complex/cacosh.c",
462 "musl/src/complex/cacoshf.c",
463 "musl/src/complex/cacoshl.c",
464 "musl/src/complex/cacosl.c",
465 "musl/src/complex/carg.c",
466 "musl/src/complex/cargf.c",
467 "musl/src/complex/cargl.c",
468 "musl/src/complex/casin.c",
469 "musl/src/complex/casinf.c",
470 "musl/src/complex/casinh.c",
471 "musl/src/complex/casinhf.c",
472 "musl/src/complex/casinhl.c",
473 "musl/src/complex/casinl.c",
474 "musl/src/complex/catan.c",
475 "musl/src/complex/catanf.c",
476 "musl/src/complex/catanh.c",
477 "musl/src/complex/catanhf.c",
478 "musl/src/complex/catanhl.c",
479 "musl/src/complex/catanl.c",
480 "musl/src/complex/ccos.c",
481 "musl/src/complex/ccosf.c",
482 "musl/src/complex/ccosh.c",
483 "musl/src/complex/ccoshf.c",
484 "musl/src/complex/ccoshl.c",
485 "musl/src/complex/ccosl.c",
486 "musl/src/complex/__cexp.c",
487 "musl/src/complex/cexp.c",
488 "musl/src/complex/__cexpf.c",
489 "musl/src/complex/cexpf.c",
490 "musl/src/complex/cexpl.c",
491 "musl/src/complex/cimag.c",
492 "musl/src/complex/cimagf.c",
493 "musl/src/complex/cimagl.c",
494 "musl/src/complex/clog.c",
495 "musl/src/complex/clogf.c",
496 "musl/src/complex/clogl.c",
497 "musl/src/complex/conj.c",
498 "musl/src/complex/conjf.c",
499 "musl/src/complex/conjl.c",
500 "musl/src/complex/cpow.c",
501 "musl/src/complex/cpowf.c",
502 "musl/src/complex/cpowl.c",
503 "musl/src/complex/cproj.c",
504 "musl/src/complex/cprojf.c",
505 "musl/src/complex/cprojl.c",
506 "musl/src/complex/creal.c",
507 "musl/src/complex/crealf.c",
508 "musl/src/complex/creall.c",
509 "musl/src/complex/csin.c",
510 "musl/src/complex/csinf.c",
511 "musl/src/complex/csinh.c",
512 "musl/src/complex/csinhf.c",
513 "musl/src/complex/csinhl.c",
514 "musl/src/complex/csinl.c",
515 "musl/src/complex/csqrt.c",
516 "musl/src/complex/csqrtf.c",
517 "musl/src/complex/csqrtl.c",
518 "musl/src/complex/ctan.c",
519 "musl/src/complex/ctanf.c",
520 "musl/src/complex/ctanh.c",
521 "musl/src/complex/ctanhf.c",
522 "musl/src/complex/ctanhl.c",
523 "musl/src/complex/ctanl.c",
524 "musl/src/conf/confstr.c",
525 "musl/src/conf/fpathconf.c",
526 "musl/src/conf/legacy.c",
527 "musl/src/conf/pathconf.c",
528 "musl/src/conf/sysconf.c",
529 "musl/src/crypt/crypt_blowfish.c",
530 "musl/src/crypt/crypt.c",
531 "musl/src/crypt/crypt_des.c",
532 "musl/src/crypt/crypt_md5.c",
533 "musl/src/crypt/crypt_r.c",
534 "musl/src/crypt/crypt_sha256.c",
535 "musl/src/crypt/crypt_sha512.c",
536 "musl/src/crypt/encrypt.c",
537 "musl/src/ctype/__ctype_b_loc.c",
538 "musl/src/ctype/__ctype_get_mb_cur_max.c",
539 "musl/src/ctype/__ctype_tolower_loc.c",
540 "musl/src/ctype/__ctype_toupper_loc.c",
541 "musl/src/ctype/isalnum.c",
542 "musl/src/ctype/isalpha.c",
543 "musl/src/ctype/isascii.c",
544 "musl/src/ctype/isblank.c",
545 "musl/src/ctype/iscntrl.c",
546 "musl/src/ctype/isdigit.c",
547 "musl/src/ctype/isgraph.c",
548 "musl/src/ctype/islower.c",
549 "musl/src/ctype/isprint.c",
550 "musl/src/ctype/ispunct.c",
551 "musl/src/ctype/isspace.c",
552 "musl/src/ctype/isupper.c",
553 "musl/src/ctype/iswalnum.c",
554 "musl/src/ctype/iswalpha.c",
555 "musl/src/ctype/iswblank.c",
556 "musl/src/ctype/iswcntrl.c",
557 "musl/src/ctype/iswctype.c",
558 "musl/src/ctype/iswdigit.c",
559 "musl/src/ctype/iswgraph.c",
560 "musl/src/ctype/iswlower.c",
561 "musl/src/ctype/iswprint.c",
562 "musl/src/ctype/iswpunct.c",
563 "musl/src/ctype/iswspace.c",
564 "musl/src/ctype/iswupper.c",
565 "musl/src/ctype/iswxdigit.c",
566 "musl/src/ctype/isxdigit.c",
567 "musl/src/ctype/toascii.c",
568 "musl/src/ctype/tolower.c",
569 "musl/src/ctype/toupper.c",
570 "musl/src/ctype/towctrans.c",
571 "musl/src/ctype/wcswidth.c",
572 "musl/src/ctype/wctrans.c",
573 "musl/src/ctype/wcwidth.c",
574 "musl/src/dirent/alphasort.c",
575 "musl/src/dirent/closedir.c",
576 "musl/src/dirent/dirfd.c",
577 "musl/src/dirent/fdopendir.c",
578 "musl/src/dirent/opendir.c",
579 "musl/src/dirent/readdir.c",
580 "musl/src/dirent/readdir_r.c",
581 "musl/src/dirent/rewinddir.c",
582 "musl/src/dirent/scandir.c",
583 "musl/src/dirent/seekdir.c",
584 "musl/src/dirent/telldir.c",
585 "musl/src/dirent/versionsort.c",
586 "musl/src/env/clearenv.c",
587 "musl/src/env/__environ.c",
588 "musl/src/env/getenv.c",
589 "musl/src/env/__init_tls.c",
590 "musl/src/env/__libc_start_main.c",
591 "musl/src/env/putenv.c",
592 "musl/src/env/__reset_tls.c",
593 "musl/src/env/secure_getenv.c",
594 "musl/src/env/setenv.c",
595 "musl/src/env/__stack_chk_fail.c",
596 "musl/src/env/unsetenv.c",
597 "musl/src/errno/__errno_location.c",
598 "musl/src/errno/strerror.c",
599 "musl/src/exit/abort.c",
600 "musl/src/exit/abort_lock.c",
601 "musl/src/exit/arm/__aeabi_atexit.c",
602 "musl/src/exit/assert.c",
603 "musl/src/exit/atexit.c",
604 "musl/src/exit/at_quick_exit.c",
605 "musl/src/exit/exit.c",
606 "musl/src/exit/_Exit.c",
607 "musl/src/exit/quick_exit.c",
608 "musl/src/fcntl/creat.c",
609 "musl/src/fcntl/fcntl.c",
610 "musl/src/fcntl/openat.c",
611 "musl/src/fcntl/open.c",
612 "musl/src/fcntl/posix_fadvise.c",
613 "musl/src/fcntl/posix_fallocate.c",
614 "musl/src/fenv/aarch64/fenv.s",
615 "musl/src/fenv/arm/fenv.c",
616 "musl/src/fenv/arm/fenv-hf.S",
617 "musl/src/fenv/fegetexceptflag.c",
618 "musl/src/fenv/feholdexcept.c",
619 "musl/src/fenv/fenv.c",
620 "musl/src/fenv/fesetexceptflag.c",
621 "musl/src/fenv/fesetround.c",
622 "musl/src/fenv/feupdateenv.c",
623 "musl/src/fenv/__flt_rounds.c",
624 "musl/src/fenv/hexagon/fenv.S",
625 "musl/src/fenv/i386/fenv.s",
626 "musl/src/fenv/loongarch64/fenv.S",
627 "musl/src/fenv/m68k/fenv.c",
628 "musl/src/fenv/mips64/fenv.S",
629 "musl/src/fenv/mips64/fenv-sf.c",
630 "musl/src/fenv/mips/fenv.S",
631 "musl/src/fenv/mips/fenv-sf.c",
632 "musl/src/fenv/mipsn32/fenv.S",
633 "musl/src/fenv/mipsn32/fenv-sf.c",
634 "musl/src/fenv/powerpc64/fenv.c",
635 "musl/src/fenv/powerpc/fenv.S",
636 "musl/src/fenv/powerpc/fenv-sf.c",
637 "musl/src/fenv/riscv32/fenv.S",
638 "musl/src/fenv/riscv32/fenv-sf.c",
639 "musl/src/fenv/riscv64/fenv.S",
640 "musl/src/fenv/riscv64/fenv-sf.c",
641 "musl/src/fenv/s390x/fenv.c",
642 "musl/src/fenv/x32/fenv.s",
643 "musl/src/fenv/x86_64/fenv.s",
644 "musl/src/internal/defsysinfo.c",
645 "musl/src/internal/emulate_wait4.c",
646 "musl/src/internal/floatscan.c",
647 "musl/src/internal/i386/defsysinfo.s",
648 "musl/src/internal/intscan.c",
649 "musl/src/internal/libc.c",
650 "musl/src/internal/procfdname.c",
651 "musl/src/internal/shgetc.c",
652 "musl/src/internal/syscall_ret.c",
653 "musl/src/internal/vdso.c",
654 "musl/src/internal/version.c",
655 "musl/src/ipc/ftok.c",
656 "musl/src/ipc/msgctl.c",
657 "musl/src/ipc/msgget.c",
658 "musl/src/ipc/msgrcv.c",
659 "musl/src/ipc/msgsnd.c",
660 "musl/src/ipc/semctl.c",
661 "musl/src/ipc/semget.c",
662 "musl/src/ipc/semop.c",
663 "musl/src/ipc/semtimedop.c",
664 "musl/src/ipc/shmat.c",
665 "musl/src/ipc/shmctl.c",
666 "musl/src/ipc/shmdt.c",
667 "musl/src/ipc/shmget.c",
668 "musl/src/ldso/aarch64/dlsym.s",
669 "musl/src/ldso/aarch64/tlsdesc.s",
670 "musl/src/ldso/arm/dlsym.s",
671 "musl/src/ldso/arm/dlsym_time64.S",
672 "musl/src/ldso/arm/find_exidx.c",
673 "musl/src/ldso/arm/tlsdesc.S",
674 "musl/src/ldso/dladdr.c",
675 "musl/src/ldso/dlclose.c",
676 "musl/src/ldso/dlerror.c",
677 "musl/src/ldso/dlinfo.c",
678 "musl/src/ldso/dl_iterate_phdr.c",
679 "musl/src/ldso/dlopen.c",
680 "musl/src/ldso/__dlsym.c",
681 "musl/src/ldso/dlsym.c",
682 "musl/src/ldso/i386/dlsym.s",
683 "musl/src/ldso/i386/dlsym_time64.S",
684 "musl/src/ldso/i386/tlsdesc.s",
685 "musl/src/ldso/loongarch64/dlsym.s",
686 "musl/src/ldso/m68k/dlsym.s",
687 "musl/src/ldso/m68k/dlsym_time64.S",
688 "musl/src/ldso/mips64/dlsym.s",
689 "musl/src/ldso/mips/dlsym.s",
690 "musl/src/ldso/mips/dlsym_time64.S",
691 "musl/src/ldso/mipsn32/dlsym.s",
692 "musl/src/ldso/mipsn32/dlsym_time64.S",
693 "musl/src/ldso/powerpc64/dlsym.s",
694 "musl/src/ldso/powerpc/dlsym.s",
695 "musl/src/ldso/powerpc/dlsym_time64.S",
696 "musl/src/ldso/riscv32/dlsym.s",
697 "musl/src/ldso/riscv64/dlsym.s",
698 "musl/src/ldso/riscv64/tlsdesc.s",
699 "musl/src/ldso/s390x/dlsym.s",
700 "musl/src/ldso/tlsdesc.c",
701 "musl/src/ldso/x32/dlsym.s",
702 "musl/src/ldso/x86_64/dlsym.s",
703 "musl/src/ldso/x86_64/tlsdesc.s",
704 "musl/src/legacy/cuserid.c",
705 "musl/src/legacy/daemon.c",
706 "musl/src/legacy/err.c",
707 "musl/src/legacy/euidaccess.c",
708 "musl/src/legacy/ftw.c",
709 "musl/src/legacy/futimes.c",
710 "musl/src/legacy/getdtablesize.c",
711 "musl/src/legacy/getloadavg.c",
712 "musl/src/legacy/getpagesize.c",
713 "musl/src/legacy/getpass.c",
714 "musl/src/legacy/getusershell.c",
715 "musl/src/legacy/isastream.c",
716 "musl/src/legacy/lutimes.c",
717 "musl/src/legacy/ulimit.c",
718 "musl/src/legacy/utmpx.c",
719 "musl/src/legacy/valloc.c",
720 "musl/src/linux/adjtime.c",
721 "musl/src/linux/adjtimex.c",
722 "musl/src/linux/arch_prctl.c",
723 "musl/src/linux/brk.c",
724 "musl/src/linux/cache.c",
725 "musl/src/linux/cap.c",
726 "musl/src/linux/chroot.c",
727 "musl/src/linux/clock_adjtime.c",
728 "musl/src/linux/clone.c",
729 "musl/src/linux/copy_file_range.c",
730 "musl/src/linux/epoll.c",
731 "musl/src/linux/eventfd.c",
732 "musl/src/linux/fallocate.c",
733 "musl/src/linux/fanotify.c",
734 "musl/src/linux/flock.c",
735 "musl/src/linux/getdents.c",
736 "musl/src/linux/getrandom.c",
737 "musl/src/linux/gettid.c",
738 "musl/src/linux/inotify.c",
739 "musl/src/linux/ioperm.c",
740 "musl/src/linux/iopl.c",
741 "musl/src/linux/klogctl.c",
742 "musl/src/linux/membarrier.c",
743 "musl/src/linux/memfd_create.c",
744 "musl/src/linux/mlock2.c",
745 "musl/src/linux/module.c",
746 "musl/src/linux/mount.c",
747 "musl/src/linux/name_to_handle_at.c",
748 "musl/src/linux/open_by_handle_at.c",
749 "musl/src/linux/personality.c",
750 "musl/src/linux/pivot_root.c",
751 "musl/src/linux/prctl.c",
752 "musl/src/linux/preadv2.c",
753 "musl/src/linux/prlimit.c",
754 "musl/src/linux/process_vm.c",
755 "musl/src/linux/ptrace.c",
756 "musl/src/linux/pwritev2.c",
757 "musl/src/linux/quotactl.c",
758 "musl/src/linux/readahead.c",
759 "musl/src/linux/reboot.c",
760 "musl/src/linux/remap_file_pages.c",
761 "musl/src/linux/sbrk.c",
762 "musl/src/linux/sendfile.c",
763 "musl/src/linux/setfsgid.c",
764 "musl/src/linux/setfsuid.c",
765 "musl/src/linux/setgroups.c",
766 "musl/src/linux/sethostname.c",
767 "musl/src/linux/setns.c",
768 "musl/src/linux/settimeofday.c",
769 "musl/src/linux/signalfd.c",
770 "musl/src/linux/splice.c",
771 "musl/src/linux/statx.c",
772 "musl/src/linux/stime.c",
773 "musl/src/linux/swap.c",
774 "musl/src/linux/sync_file_range.c",
775 "musl/src/linux/syncfs.c",
776 "musl/src/linux/sysinfo.c",
777 "musl/src/linux/tee.c",
778 "musl/src/linux/timerfd.c",
779 "musl/src/linux/unshare.c",
780 "musl/src/linux/utimes.c",
781 "musl/src/linux/vhangup.c",
782 "musl/src/linux/vmsplice.c",
783 "musl/src/linux/wait3.c",
784 "musl/src/linux/wait4.c",
785 "musl/src/linux/x32/sysinfo.c",
786 "musl/src/linux/xattr.c",
787 "musl/src/locale/bind_textdomain_codeset.c",
788 "musl/src/locale/catclose.c",
789 "musl/src/locale/catgets.c",
790 "musl/src/locale/catopen.c",
791 "musl/src/locale/c_locale.c",
792 "musl/src/locale/dcngettext.c",
793 "musl/src/locale/duplocale.c",
794 "musl/src/locale/freelocale.c",
795 "musl/src/locale/iconv.c",
796 "musl/src/locale/iconv_close.c",
797 "musl/src/locale/langinfo.c",
798 "musl/src/locale/__lctrans.c",
799 "musl/src/locale/localeconv.c",
800 "musl/src/locale/locale_map.c",
801 "musl/src/locale/__mo_lookup.c",
802 "musl/src/locale/newlocale.c",
803 "musl/src/locale/pleval.c",
804 "musl/src/locale/setlocale.c",
805 "musl/src/locale/strcoll.c",
806 "musl/src/locale/strfmon.c",
807 "musl/src/locale/strtod_l.c",
808 "musl/src/locale/strxfrm.c",
809 "musl/src/locale/textdomain.c",
810 "musl/src/locale/uselocale.c",
811 "musl/src/locale/wcscoll.c",
812 "musl/src/locale/wcsxfrm.c",
813 "musl/src/malloc/calloc.c",
814 "musl/src/malloc/free.c",
815 "musl/src/malloc/libc_calloc.c",
816 "musl/src/malloc/lite_malloc.c",
817 "musl/src/malloc/mallocng/aligned_alloc.c",
818 "musl/src/malloc/mallocng/donate.c",
819 "musl/src/malloc/mallocng/free.c",
820 "musl/src/malloc/mallocng/malloc.c",
821 "musl/src/malloc/mallocng/malloc_usable_size.c",
822 "musl/src/malloc/mallocng/realloc.c",
823 "musl/src/malloc/memalign.c",
824 "musl/src/malloc/oldmalloc/aligned_alloc.c",
825 "musl/src/malloc/oldmalloc/malloc.c",
826 "musl/src/malloc/oldmalloc/malloc_usable_size.c",
827 "musl/src/malloc/posix_memalign.c",
828 "musl/src/malloc/reallocarray.c",
829 "musl/src/malloc/realloc.c",
830 "musl/src/malloc/replaced.c",
831 "musl/src/math/aarch64/ceil.c",
832 "musl/src/math/aarch64/ceilf.c",
833 "musl/src/math/aarch64/fabs.c",
834 "musl/src/math/aarch64/fabsf.c",
835 "musl/src/math/aarch64/floor.c",
836 "musl/src/math/aarch64/floorf.c",
837 "musl/src/math/aarch64/fma.c",
838 "musl/src/math/aarch64/fmaf.c",
839 "musl/src/math/aarch64/fmax.c",
840 "musl/src/math/aarch64/fmaxf.c",
841 "musl/src/math/aarch64/fmin.c",
842 "musl/src/math/aarch64/fminf.c",
843 "musl/src/math/aarch64/llrint.c",
844 "musl/src/math/aarch64/llrintf.c",
845 "musl/src/math/aarch64/llround.c",
846 "musl/src/math/aarch64/llroundf.c",
847 "musl/src/math/aarch64/lrint.c",
848 "musl/src/math/aarch64/lrintf.c",
849 "musl/src/math/aarch64/lround.c",
850 "musl/src/math/aarch64/lroundf.c",
851 "musl/src/math/aarch64/nearbyint.c",
852 "musl/src/math/aarch64/nearbyintf.c",
853 "musl/src/math/aarch64/rint.c",
854 "musl/src/math/aarch64/rintf.c",
855 "musl/src/math/aarch64/round.c",
856 "musl/src/math/aarch64/roundf.c",
857 "musl/src/math/aarch64/sqrt.c",
858 "musl/src/math/aarch64/sqrtf.c",
859 "musl/src/math/aarch64/trunc.c",
860 "musl/src/math/aarch64/truncf.c",
861 "musl/src/math/acos.c",
862 "musl/src/math/acosf.c",
863 "musl/src/math/acosh.c",
864 "musl/src/math/acoshf.c",
865 "musl/src/math/acoshl.c",
866 "musl/src/math/acosl.c",
867 "musl/src/math/arm/fabs.c",
868 "musl/src/math/arm/fabsf.c",
869 "musl/src/math/arm/fma.c",
870 "musl/src/math/arm/fmaf.c",
871 "musl/src/math/arm/sqrt.c",
872 "musl/src/math/arm/sqrtf.c",
873 "musl/src/math/asin.c",
874 "musl/src/math/asinf.c",
875 "musl/src/math/asinh.c",
876 "musl/src/math/asinhf.c",
877 "musl/src/math/asinhl.c",
878 "musl/src/math/asinl.c",
879 "musl/src/math/atan2.c",
880 "musl/src/math/atan2f.c",
881 "musl/src/math/atan2l.c",
882 "musl/src/math/atan.c",
883 "musl/src/math/atanf.c",
884 "musl/src/math/atanh.c",
885 "musl/src/math/atanhf.c",
886 "musl/src/math/atanhl.c",
887 "musl/src/math/atanl.c",
888 "musl/src/math/cbrt.c",
889 "musl/src/math/cbrtf.c",
890 "musl/src/math/cbrtl.c",
891 "musl/src/math/ceil.c",
892 "musl/src/math/ceilf.c",
893 "musl/src/math/ceill.c",
894 "musl/src/math/copysign.c",
895 "musl/src/math/copysignf.c",
896 "musl/src/math/copysignl.c",
897 "musl/src/math/__cos.c",
898 "musl/src/math/cos.c",
899 "musl/src/math/__cosdf.c",
900 "musl/src/math/cosf.c",
901 "musl/src/math/cosh.c",
902 "musl/src/math/coshf.c",
903 "musl/src/math/coshl.c",
904 "musl/src/math/__cosl.c",
905 "musl/src/math/cosl.c",
906 "musl/src/math/erf.c",
907 "musl/src/math/erff.c",
908 "musl/src/math/erfl.c",
909 "musl/src/math/exp10.c",
910 "musl/src/math/exp10f.c",
911 "musl/src/math/exp10l.c",
912 "musl/src/math/exp2.c",
913 "musl/src/math/exp2f.c",
914 "musl/src/math/exp2f_data.c",
915 "musl/src/math/exp2l.c",
916 "musl/src/math/exp.c",
917 "musl/src/math/exp_data.c",
918 "musl/src/math/expf.c",
919 "musl/src/math/expl.c",
920 "musl/src/math/expm1.c",
921 "musl/src/math/expm1f.c",
922 "musl/src/math/expm1l.c",
923 "musl/src/math/__expo2.c",
924 "musl/src/math/__expo2f.c",
925 "musl/src/math/fabs.c",
926 "musl/src/math/fabsf.c",
927 "musl/src/math/fabsl.c",
928 "musl/src/math/fdim.c",
929 "musl/src/math/fdimf.c",
930 "musl/src/math/fdiml.c",
931 "musl/src/math/finite.c",
932 "musl/src/math/finitef.c",
933 "musl/src/math/floor.c",
934 "musl/src/math/floorf.c",
935 "musl/src/math/floorl.c",
936 "musl/src/math/fma.c",
937 "musl/src/math/fmaf.c",
938 "musl/src/math/fmal.c",
939 "musl/src/math/fmax.c",
940 "musl/src/math/fmaxf.c",
941 "musl/src/math/fmaxl.c",
942 "musl/src/math/fmin.c",
943 "musl/src/math/fminf.c",
944 "musl/src/math/fminl.c",
945 "musl/src/math/fmod.c",
946 "musl/src/math/fmodf.c",
947 "musl/src/math/fmodl.c",
948 "musl/src/math/__fpclassify.c",
949 "musl/src/math/__fpclassifyf.c",
950 "musl/src/math/__fpclassifyl.c",
951 "musl/src/math/frexp.c",
952 "musl/src/math/frexpf.c",
953 "musl/src/math/frexpl.c",
954 "musl/src/math/hypot.c",
955 "musl/src/math/hypotf.c",
956 "musl/src/math/hypotl.c",
957 "musl/src/math/i386/acosf.s",
958 "musl/src/math/i386/acosl.s",
959 "musl/src/math/i386/acos.s",
960 "musl/src/math/i386/asinf.s",
961 "musl/src/math/i386/asinl.s",
962 "musl/src/math/i386/asin.s",
963 "musl/src/math/i386/atan2f.s",
964 "musl/src/math/i386/atan2l.s",
965 "musl/src/math/i386/atan2.s",
966 "musl/src/math/i386/atanf.s",
967 "musl/src/math/i386/atanl.s",
968 "musl/src/math/i386/atan.s",
969 "musl/src/math/i386/ceilf.s",
970 "musl/src/math/i386/ceill.s",
971 "musl/src/math/i386/ceil.s",
972 "musl/src/math/i386/exp2l.s",
973 "musl/src/math/i386/exp_ld.s",
974 "musl/src/math/i386/expl.s",
975 "musl/src/math/i386/expm1l.s",
976 "musl/src/math/i386/fabs.c",
977 "musl/src/math/i386/fabsf.c",
978 "musl/src/math/i386/fabsl.c",
979 "musl/src/math/i386/floorf.s",
980 "musl/src/math/i386/floorl.s",
981 "musl/src/math/i386/floor.s",
982 "musl/src/math/i386/fmod.c",
983 "musl/src/math/i386/fmodf.c",
984 "musl/src/math/i386/fmodl.c",
985 "musl/src/math/i386/hypotf.s",
986 "musl/src/math/i386/hypot.s",
987 "musl/src/math/i386/__invtrigl.s",
988 "musl/src/math/i386/ldexpf.s",
989 "musl/src/math/i386/ldexpl.s",
990 "musl/src/math/i386/ldexp.s",
991 "musl/src/math/i386/llrint.c",
992 "musl/src/math/i386/llrintf.c",
993 "musl/src/math/i386/llrintl.c",
994 "musl/src/math/i386/log10f.s",
995 "musl/src/math/i386/log10l.s",
996 "musl/src/math/i386/log10.s",
997 "musl/src/math/i386/log1pf.s",
998 "musl/src/math/i386/log1pl.s",
999 "musl/src/math/i386/log1p.s",
1000 "musl/src/math/i386/log2f.s",
1001 "musl/src/math/i386/log2l.s",
1002 "musl/src/math/i386/log2.s",
1003 "musl/src/math/i386/logf.s",
1004 "musl/src/math/i386/logl.s",
1005 "musl/src/math/i386/log.s",
1006 "musl/src/math/i386/lrint.c",
1007 "musl/src/math/i386/lrintf.c",
1008 "musl/src/math/i386/lrintl.c",
1009 "musl/src/math/i386/remainder.c",
1010 "musl/src/math/i386/remainderf.c",
1011 "musl/src/math/i386/remainderl.c",
1012 "musl/src/math/i386/remquof.s",
1013 "musl/src/math/i386/remquol.s",
1014 "musl/src/math/i386/remquo.s",
1015 "musl/src/math/i386/rint.c",
1016 "musl/src/math/i386/rintf.c",
1017 "musl/src/math/i386/rintl.c",
1018 "musl/src/math/i386/scalblnf.s",
1019 "musl/src/math/i386/scalblnl.s",
1020 "musl/src/math/i386/scalbln.s",
1021 "musl/src/math/i386/scalbnf.s",
1022 "musl/src/math/i386/scalbnl.s",
1023 "musl/src/math/i386/scalbn.s",
1024 "musl/src/math/i386/sqrt.c",
1025 "musl/src/math/i386/sqrtf.c",
1026 "musl/src/math/i386/sqrtl.c",
1027 "musl/src/math/i386/truncf.s",
1028 "musl/src/math/i386/truncl.s",
1029 "musl/src/math/i386/trunc.s",
1030 "musl/src/math/ilogb.c",
1031 "musl/src/math/ilogbf.c",
1032 "musl/src/math/ilogbl.c",
1033 "musl/src/math/__invtrigl.c",
1034 "musl/src/math/j0.c",
1035 "musl/src/math/j0f.c",
1036 "musl/src/math/j1.c",
1037 "musl/src/math/j1f.c",
1038 "musl/src/math/jn.c",
1039 "musl/src/math/jnf.c",
1040 "musl/src/math/ldexp.c",
1041 "musl/src/math/ldexpf.c",
1042 "musl/src/math/ldexpl.c",
1043 "musl/src/math/lgamma.c",
1044 "musl/src/math/lgammaf.c",
1045 "musl/src/math/lgammaf_r.c",
1046 "musl/src/math/lgammal.c",
1047 "musl/src/math/lgamma_r.c",
1048 "musl/src/math/llrint.c",
1049 "musl/src/math/llrintf.c",
1050 "musl/src/math/llrintl.c",
1051 "musl/src/math/llround.c",
1052 "musl/src/math/llroundf.c",
1053 "musl/src/math/llroundl.c",
1054 "musl/src/math/log10.c",
1055 "musl/src/math/log10f.c",
1056 "musl/src/math/log10l.c",
1057 "musl/src/math/log1p.c",
1058 "musl/src/math/log1pf.c",
1059 "musl/src/math/log1pl.c",
1060 "musl/src/math/log2.c",
1061 "musl/src/math/log2_data.c",
1062 "musl/src/math/log2f.c",
1063 "musl/src/math/log2f_data.c",
1064 "musl/src/math/log2l.c",
1065 "musl/src/math/logb.c",
1066 "musl/src/math/logbf.c",
1067 "musl/src/math/logbl.c",
1068 "musl/src/math/log.c",
1069 "musl/src/math/log_data.c",
1070 "musl/src/math/logf.c",
1071 "musl/src/math/logf_data.c",
1072 "musl/src/math/logl.c",
1073 "musl/src/math/lrint.c",
1074 "musl/src/math/lrintf.c",
1075 "musl/src/math/lrintl.c",
1076 "musl/src/math/lround.c",
1077 "musl/src/math/lroundf.c",
1078 "musl/src/math/lroundl.c",
1079 "musl/src/math/m68k/sqrtl.c",
1080 "musl/src/math/__math_divzero.c",
1081 "musl/src/math/__math_divzerof.c",
1082 "musl/src/math/__math_invalid.c",
1083 "musl/src/math/__math_invalidf.c",
1084 "musl/src/math/__math_invalidl.c",
1085 "musl/src/math/__math_oflow.c",
1086 "musl/src/math/__math_oflowf.c",
1087 "musl/src/math/__math_uflow.c",
1088 "musl/src/math/__math_uflowf.c",
1089 "musl/src/math/__math_xflow.c",
1090 "musl/src/math/__math_xflowf.c",
1091 "musl/src/math/mips/fabs.c",
1092 "musl/src/math/mips/fabsf.c",
1093 "musl/src/math/mips/sqrt.c",
1094 "musl/src/math/mips/sqrtf.c",
1095 "musl/src/math/modf.c",
1096 "musl/src/math/modff.c",
1097 "musl/src/math/modfl.c",
1098 "musl/src/math/nan.c",
1099 "musl/src/math/nanf.c",
1100 "musl/src/math/nanl.c",
1101 "musl/src/math/nearbyint.c",
1102 "musl/src/math/nearbyintf.c",
1103 "musl/src/math/nearbyintl.c",
1104 "musl/src/math/nextafter.c",
1105 "musl/src/math/nextafterf.c",
1106 "musl/src/math/nextafterl.c",
1107 "musl/src/math/nexttoward.c",
1108 "musl/src/math/nexttowardf.c",
1109 "musl/src/math/nexttowardl.c",
1110 "musl/src/math/__polevll.c",
1111 "musl/src/math/pow.c",
1112 "musl/src/math/pow_data.c",
1113 "musl/src/math/powerpc64/ceil.c",
1114 "musl/src/math/powerpc64/ceilf.c",
1115 "musl/src/math/powerpc64/fabs.c",
1116 "musl/src/math/powerpc64/fabsf.c",
1117 "musl/src/math/powerpc64/floor.c",
1118 "musl/src/math/powerpc64/floorf.c",
1119 "musl/src/math/powerpc64/fma.c",
1120 "musl/src/math/powerpc64/fmaf.c",
1121 "musl/src/math/powerpc64/fmax.c",
1122 "musl/src/math/powerpc64/fmaxf.c",
1123 "musl/src/math/powerpc64/fmin.c",
1124 "musl/src/math/powerpc64/fminf.c",
1125 "musl/src/math/powerpc64/lrint.c",
1126 "musl/src/math/powerpc64/lrintf.c",
1127 "musl/src/math/powerpc64/lround.c",
1128 "musl/src/math/powerpc64/lroundf.c",
1129 "musl/src/math/powerpc64/round.c",
1130 "musl/src/math/powerpc64/roundf.c",
1131 "musl/src/math/powerpc64/sqrt.c",
1132 "musl/src/math/powerpc64/sqrtf.c",
1133 "musl/src/math/powerpc64/trunc.c",
1134 "musl/src/math/powerpc64/truncf.c",
1135 "musl/src/math/powerpc/fabs.c",
1136 "musl/src/math/powerpc/fabsf.c",
1137 "musl/src/math/powerpc/fma.c",
1138 "musl/src/math/powerpc/fmaf.c",
1139 "musl/src/math/powerpc/sqrt.c",
1140 "musl/src/math/powerpc/sqrtf.c",
1141 "musl/src/math/powf.c",
1142 "musl/src/math/powf_data.c",
1143 "musl/src/math/powl.c",
1144 "musl/src/math/remainder.c",
1145 "musl/src/math/remainderf.c",
1146 "musl/src/math/remainderl.c",
1147 "musl/src/math/__rem_pio2.c",
1148 "musl/src/math/__rem_pio2f.c",
1149 "musl/src/math/__rem_pio2_large.c",
1150 "musl/src/math/__rem_pio2l.c",
1151 "musl/src/math/remquo.c",
1152 "musl/src/math/remquof.c",
1153 "musl/src/math/remquol.c",
1154 "musl/src/math/rint.c",
1155 "musl/src/math/rintf.c",
1156 "musl/src/math/rintl.c",
1157 "musl/src/math/riscv32/copysign.c",
1158 "musl/src/math/riscv32/copysignf.c",
1159 "musl/src/math/riscv32/fabs.c",
1160 "musl/src/math/riscv32/fabsf.c",
1161 "musl/src/math/riscv32/fma.c",
1162 "musl/src/math/riscv32/fmaf.c",
1163 "musl/src/math/riscv32/fmax.c",
1164 "musl/src/math/riscv32/fmaxf.c",
1165 "musl/src/math/riscv32/fmin.c",
1166 "musl/src/math/riscv32/fminf.c",
1167 "musl/src/math/riscv32/sqrt.c",
1168 "musl/src/math/riscv32/sqrtf.c",
1169 "musl/src/math/riscv64/copysign.c",
1170 "musl/src/math/riscv64/copysignf.c",
1171 "musl/src/math/riscv64/fabs.c",
1172 "musl/src/math/riscv64/fabsf.c",
1173 "musl/src/math/riscv64/fma.c",
1174 "musl/src/math/riscv64/fmaf.c",
1175 "musl/src/math/riscv64/fmax.c",
1176 "musl/src/math/riscv64/fmaxf.c",
1177 "musl/src/math/riscv64/fmin.c",
1178 "musl/src/math/riscv64/fminf.c",
1179 "musl/src/math/riscv64/sqrt.c",
1180 "musl/src/math/riscv64/sqrtf.c",
1181 "musl/src/math/round.c",
1182 "musl/src/math/roundf.c",
1183 "musl/src/math/roundl.c",
1184 "musl/src/math/s390x/ceil.c",
1185 "musl/src/math/s390x/ceilf.c",
1186 "musl/src/math/s390x/ceill.c",
1187 "musl/src/math/s390x/fabs.c",
1188 "musl/src/math/s390x/fabsf.c",
1189 "musl/src/math/s390x/fabsl.c",
1190 "musl/src/math/s390x/floor.c",
1191 "musl/src/math/s390x/floorf.c",
1192 "musl/src/math/s390x/floorl.c",
1193 "musl/src/math/s390x/fma.c",
1194 "musl/src/math/s390x/fmaf.c",
1195 "musl/src/math/s390x/nearbyint.c",
1196 "musl/src/math/s390x/nearbyintf.c",
1197 "musl/src/math/s390x/nearbyintl.c",
1198 "musl/src/math/s390x/rint.c",
1199 "musl/src/math/s390x/rintf.c",
1200 "musl/src/math/s390x/rintl.c",
1201 "musl/src/math/s390x/round.c",
1202 "musl/src/math/s390x/roundf.c",
1203 "musl/src/math/s390x/roundl.c",
1204 "musl/src/math/s390x/sqrt.c",
1205 "musl/src/math/s390x/sqrtf.c",
1206 "musl/src/math/s390x/sqrtl.c",
1207 "musl/src/math/s390x/trunc.c",
1208 "musl/src/math/s390x/truncf.c",
1209 "musl/src/math/s390x/truncl.c",
1210 "musl/src/math/scalb.c",
1211 "musl/src/math/scalbf.c",
1212 "musl/src/math/scalbln.c",
1213 "musl/src/math/scalblnf.c",
1214 "musl/src/math/scalblnl.c",
1215 "musl/src/math/scalbn.c",
1216 "musl/src/math/scalbnf.c",
1217 "musl/src/math/scalbnl.c",
1218 "musl/src/math/__signbit.c",
1219 "musl/src/math/__signbitf.c",
1220 "musl/src/math/__signbitl.c",
1221 "musl/src/math/signgam.c",
1222 "musl/src/math/significand.c",
1223 "musl/src/math/significandf.c",
1224 "musl/src/math/__sin.c",
1225 "musl/src/math/sin.c",
1226 "musl/src/math/sincos.c",
1227 "musl/src/math/sincosf.c",
1228 "musl/src/math/sincosl.c",
1229 "musl/src/math/__sindf.c",
1230 "musl/src/math/sinf.c",
1231 "musl/src/math/sinh.c",
1232 "musl/src/math/sinhf.c",
1233 "musl/src/math/sinhl.c",
1234 "musl/src/math/__sinl.c",
1235 "musl/src/math/sinl.c",
1236 "musl/src/math/sqrt.c",
1237 "musl/src/math/sqrt_data.c",
1238 "musl/src/math/sqrtf.c",
1239 "musl/src/math/sqrtl.c",
1240 "musl/src/math/__tan.c",
1241 "musl/src/math/tan.c",
1242 "musl/src/math/__tandf.c",
1243 "musl/src/math/tanf.c",
1244 "musl/src/math/tanh.c",
1245 "musl/src/math/tanhf.c",
1246 "musl/src/math/tanhl.c",
1247 "musl/src/math/__tanl.c",
1248 "musl/src/math/tanl.c",
1249 "musl/src/math/tgamma.c",
1250 "musl/src/math/tgammaf.c",
1251 "musl/src/math/tgammal.c",
1252 "musl/src/math/trunc.c",
1253 "musl/src/math/truncf.c",
1254 "musl/src/math/truncl.c",
1255 "musl/src/math/x32/acosl.s",
1256 "musl/src/math/x32/asinl.s",
1257 "musl/src/math/x32/atan2l.s",
1258 "musl/src/math/x32/atanl.s",
1259 "musl/src/math/x32/ceill.s",
1260 "musl/src/math/x32/exp2l.s",
1261 "musl/src/math/x32/expl.s",
1262 "musl/src/math/x32/expm1l.s",
1263 "musl/src/math/x32/fabsf.s",
1264 "musl/src/math/x32/fabsl.s",
1265 "musl/src/math/x32/fabs.s",
1266 "musl/src/math/x32/floorl.s",
1267 "musl/src/math/x32/fma.c",
1268 "musl/src/math/x32/fmaf.c",
1269 "musl/src/math/x32/fmodl.s",
1270 "musl/src/math/x32/__invtrigl.s",
1271 "musl/src/math/x32/llrintf.s",
1272 "musl/src/math/x32/llrintl.s",
1273 "musl/src/math/x32/llrint.s",
1274 "musl/src/math/x32/log10l.s",
1275 "musl/src/math/x32/log1pl.s",
1276 "musl/src/math/x32/log2l.s",
1277 "musl/src/math/x32/logl.s",
1278 "musl/src/math/x32/lrintf.s",
1279 "musl/src/math/x32/lrintl.s",
1280 "musl/src/math/x32/lrint.s",
1281 "musl/src/math/x32/remainderl.s",
1282 "musl/src/math/x32/rintl.s",
1283 "musl/src/math/x32/sqrtf.s",
1284 "musl/src/math/x32/sqrtl.s",
1285 "musl/src/math/x32/sqrt.s",
1286 "musl/src/math/x32/truncl.s",
1287 "musl/src/math/x86_64/acosl.s",
1288 "musl/src/math/x86_64/asinl.s",
1289 "musl/src/math/x86_64/atan2l.s",
1290 "musl/src/math/x86_64/atanl.s",
1291 "musl/src/math/x86_64/ceill.s",
1292 "musl/src/math/x86_64/exp2l.s",
1293 "musl/src/math/x86_64/expl.s",
1294 "musl/src/math/x86_64/expm1l.s",
1295 "musl/src/math/x86_64/fabs.c",
1296 "musl/src/math/x86_64/fabsf.c",
1297 "musl/src/math/x86_64/fabsl.c",
1298 "musl/src/math/x86_64/floorl.s",
1299 "musl/src/math/x86_64/fma.c",
1300 "musl/src/math/x86_64/fmaf.c",
1301 "musl/src/math/x86_64/fmodl.c",
1302 "musl/src/math/x86_64/__invtrigl.s",
1303 "musl/src/math/x86_64/llrint.c",
1304 "musl/src/math/x86_64/llrintf.c",
1305 "musl/src/math/x86_64/llrintl.c",
1306 "musl/src/math/x86_64/log10l.s",
1307 "musl/src/math/x86_64/log1pl.s",
1308 "musl/src/math/x86_64/log2l.s",
1309 "musl/src/math/x86_64/logl.s",
1310 "musl/src/math/x86_64/lrint.c",
1311 "musl/src/math/x86_64/lrintf.c",
1312 "musl/src/math/x86_64/lrintl.c",
1313 "musl/src/math/x86_64/remainderl.c",
1314 "musl/src/math/x86_64/remquol.c",
1315 "musl/src/math/x86_64/rintl.c",
1316 "musl/src/math/x86_64/sqrt.c",
1317 "musl/src/math/x86_64/sqrtf.c",
1318 "musl/src/math/x86_64/sqrtl.c",
1319 "musl/src/math/x86_64/truncl.s",
1320 "musl/src/misc/a64l.c",
1321 "musl/src/misc/basename.c",
1322 "musl/src/misc/dirname.c",
1323 "musl/src/misc/ffs.c",
1324 "musl/src/misc/ffsl.c",
1325 "musl/src/misc/ffsll.c",
1326 "musl/src/misc/fmtmsg.c",
1327 "musl/src/misc/forkpty.c",
1328 "musl/src/misc/getauxval.c",
1329 "musl/src/misc/get_current_dir_name.c",
1330 "musl/src/misc/getdomainname.c",
1331 "musl/src/misc/getentropy.c",
1332 "musl/src/misc/gethostid.c",
1333 "musl/src/misc/getopt.c",
1334 "musl/src/misc/getopt_long.c",
1335 "musl/src/misc/getpriority.c",
1336 "musl/src/misc/getresgid.c",
1337 "musl/src/misc/getresuid.c",
1338 "musl/src/misc/getrlimit.c",
1339 "musl/src/misc/getrusage.c",
1340 "musl/src/misc/getsubopt.c",
1341 "musl/src/misc/initgroups.c",
1342 "musl/src/misc/ioctl.c",
1343 "musl/src/misc/issetugid.c",
1344 "musl/src/misc/lockf.c",
1345 "musl/src/misc/login_tty.c",
1346 "musl/src/misc/mntent.c",
1347 "musl/src/misc/nftw.c",
1348 "musl/src/misc/openpty.c",
1349 "musl/src/misc/ptsname.c",
1350 "musl/src/misc/pty.c",
1351 "musl/src/misc/realpath.c",
1352 "musl/src/misc/setdomainname.c",
1353 "musl/src/misc/setpriority.c",
1354 "musl/src/misc/setrlimit.c",
1355 "musl/src/misc/syscall.c",
1356 "musl/src/misc/syslog.c",
1357 "musl/src/misc/uname.c",
1358 "musl/src/misc/wordexp.c",
1359 "musl/src/mman/madvise.c",
1360 "musl/src/mman/mincore.c",
1361 "musl/src/mman/mlockall.c",
1362 "musl/src/mman/mlock.c",
1363 "musl/src/mman/mmap.c",
1364 "musl/src/mman/mprotect.c",
1365 "musl/src/mman/mremap.c",
1366 "musl/src/mman/msync.c",
1367 "musl/src/mman/munlockall.c",
1368 "musl/src/mman/munlock.c",
1369 "musl/src/mman/munmap.c",
1370 "musl/src/mman/posix_madvise.c",
1371 "musl/src/mman/shm_open.c",
1372 "musl/src/mq/mq_close.c",
1373 "musl/src/mq/mq_getattr.c",
1374 "musl/src/mq/mq_notify.c",
1375 "musl/src/mq/mq_open.c",
1376 "musl/src/mq/mq_receive.c",
1377 "musl/src/mq/mq_send.c",
1378 "musl/src/mq/mq_setattr.c",
1379 "musl/src/mq/mq_timedreceive.c",
1380 "musl/src/mq/mq_timedsend.c",
1381 "musl/src/mq/mq_unlink.c",
1382 "musl/src/multibyte/btowc.c",
1383 "musl/src/multibyte/c16rtomb.c",
1384 "musl/src/multibyte/c32rtomb.c",
1385 "musl/src/multibyte/internal.c",
1386 "musl/src/multibyte/mblen.c",
1387 "musl/src/multibyte/mbrlen.c",
1388 "musl/src/multibyte/mbrtoc16.c",
1389 "musl/src/multibyte/mbrtoc32.c",
1390 "musl/src/multibyte/mbrtowc.c",
1391 "musl/src/multibyte/mbsinit.c",
1392 "musl/src/multibyte/mbsnrtowcs.c",
1393 "musl/src/multibyte/mbsrtowcs.c",
1394 "musl/src/multibyte/mbstowcs.c",
1395 "musl/src/multibyte/mbtowc.c",
1396 "musl/src/multibyte/wcrtomb.c",
1397 "musl/src/multibyte/wcsnrtombs.c",
1398 "musl/src/multibyte/wcsrtombs.c",
1399 "musl/src/multibyte/wcstombs.c",
1400 "musl/src/multibyte/wctob.c",
1401 "musl/src/multibyte/wctomb.c",
1402 "musl/src/network/accept4.c",
1403 "musl/src/network/accept.c",
1404 "musl/src/network/bind.c",
1405 "musl/src/network/connect.c",
1406 "musl/src/network/dn_comp.c",
1407 "musl/src/network/dn_expand.c",
1408 "musl/src/network/dn_skipname.c",
1409 "musl/src/network/dns_parse.c",
1410 "musl/src/network/ent.c",
1411 "musl/src/network/ether.c",
1412 "musl/src/network/freeaddrinfo.c",
1413 "musl/src/network/gai_strerror.c",
1414 "musl/src/network/getaddrinfo.c",
1415 "musl/src/network/gethostbyaddr.c",
1416 "musl/src/network/gethostbyaddr_r.c",
1417 "musl/src/network/gethostbyname2.c",
1418 "musl/src/network/gethostbyname2_r.c",
1419 "musl/src/network/gethostbyname.c",
1420 "musl/src/network/gethostbyname_r.c",
1421 "musl/src/network/getifaddrs.c",
1422 "musl/src/network/getnameinfo.c",
1423 "musl/src/network/getpeername.c",
1424 "musl/src/network/getservbyname.c",
1425 "musl/src/network/getservbyname_r.c",
1426 "musl/src/network/getservbyport.c",
1427 "musl/src/network/getservbyport_r.c",
1428 "musl/src/network/getsockname.c",
1429 "musl/src/network/getsockopt.c",
1430 "musl/src/network/h_errno.c",
1431 "musl/src/network/herror.c",
1432 "musl/src/network/hstrerror.c",
1433 "musl/src/network/htonl.c",
1434 "musl/src/network/htons.c",
1435 "musl/src/network/if_freenameindex.c",
1436 "musl/src/network/if_indextoname.c",
1437 "musl/src/network/if_nameindex.c",
1438 "musl/src/network/if_nametoindex.c",
1439 "musl/src/network/in6addr_any.c",
1440 "musl/src/network/in6addr_loopback.c",
1441 "musl/src/network/inet_addr.c",
1442 "musl/src/network/inet_aton.c",
1443 "musl/src/network/inet_legacy.c",
1444 "musl/src/network/inet_ntoa.c",
1445 "musl/src/network/inet_ntop.c",
1446 "musl/src/network/inet_pton.c",
1447 "musl/src/network/listen.c",
1448 "musl/src/network/lookup_ipliteral.c",
1449 "musl/src/network/lookup_name.c",
1450 "musl/src/network/lookup_serv.c",
1451 "musl/src/network/netlink.c",
1452 "musl/src/network/netname.c",
1453 "musl/src/network/ns_parse.c",
1454 "musl/src/network/ntohl.c",
1455 "musl/src/network/ntohs.c",
1456 "musl/src/network/proto.c",
1457 "musl/src/network/recv.c",
1458 "musl/src/network/recvfrom.c",
1459 "musl/src/network/recvmmsg.c",
1460 "musl/src/network/recvmsg.c",
1461 "musl/src/network/res_init.c",
1462 "musl/src/network/res_mkquery.c",
1463 "musl/src/network/res_msend.c",
1464 "musl/src/network/resolvconf.c",
1465 "musl/src/network/res_query.c",
1466 "musl/src/network/res_querydomain.c",
1467 "musl/src/network/res_send.c",
1468 "musl/src/network/res_state.c",
1469 "musl/src/network/send.c",
1470 "musl/src/network/sendmmsg.c",
1471 "musl/src/network/sendmsg.c",
1472 "musl/src/network/sendto.c",
1473 "musl/src/network/serv.c",
1474 "musl/src/network/setsockopt.c",
1475 "musl/src/network/shutdown.c",
1476 "musl/src/network/sockatmark.c",
1477 "musl/src/network/socket.c",
1478 "musl/src/network/socketpair.c",
1479 "musl/src/passwd/fgetgrent.c",
1480 "musl/src/passwd/fgetpwent.c",
1481 "musl/src/passwd/fgetspent.c",
1482 "musl/src/passwd/getgr_a.c",
1483 "musl/src/passwd/getgrent_a.c",
1484 "musl/src/passwd/getgrent.c",
1485 "musl/src/passwd/getgrouplist.c",
1486 "musl/src/passwd/getgr_r.c",
1487 "musl/src/passwd/getpw_a.c",
1488 "musl/src/passwd/getpwent_a.c",
1489 "musl/src/passwd/getpwent.c",
1490 "musl/src/passwd/getpw_r.c",
1491 "musl/src/passwd/getspent.c",
1492 "musl/src/passwd/getspnam.c",
1493 "musl/src/passwd/getspnam_r.c",
1494 "musl/src/passwd/lckpwdf.c",
1495 "musl/src/passwd/nscd_query.c",
1496 "musl/src/passwd/putgrent.c",
1497 "musl/src/passwd/putpwent.c",
1498 "musl/src/passwd/putspent.c",
1499 "musl/src/prng/drand48.c",
1500 "musl/src/prng/lcong48.c",
1501 "musl/src/prng/lrand48.c",
1502 "musl/src/prng/mrand48.c",
1503 "musl/src/prng/__rand48_step.c",
1504 "musl/src/prng/rand.c",
1505 "musl/src/prng/random.c",
1506 "musl/src/prng/rand_r.c",
1507 "musl/src/prng/__seed48.c",
1508 "musl/src/prng/seed48.c",
1509 "musl/src/prng/srand48.c",
1510 "musl/src/process/aarch64/vfork.s",
1511 "musl/src/process/arm/vfork.s",
1512 "musl/src/process/execl.c",
1513 "musl/src/process/execle.c",
1514 "musl/src/process/execlp.c",
1515 "musl/src/process/execv.c",
1516 "musl/src/process/execve.c",
1517 "musl/src/process/execvp.c",
1518 "musl/src/process/fexecve.c",
1519 "musl/src/process/fork.c",
1520 "musl/src/process/_Fork.c",
1521 "musl/src/process/i386/vfork.s",
1522 "musl/src/process/posix_spawnattr_destroy.c",
1523 "musl/src/process/posix_spawnattr_getflags.c",
1524 "musl/src/process/posix_spawnattr_getpgroup.c",
1525 "musl/src/process/posix_spawnattr_getsigdefault.c",
1526 "musl/src/process/posix_spawnattr_getsigmask.c",
1527 "musl/src/process/posix_spawnattr_init.c",
1528 "musl/src/process/posix_spawnattr_sched.c",
1529 "musl/src/process/posix_spawnattr_setflags.c",
1530 "musl/src/process/posix_spawnattr_setpgroup.c",
1531 "musl/src/process/posix_spawnattr_setsigdefault.c",
1532 "musl/src/process/posix_spawnattr_setsigmask.c",
1533 "musl/src/process/posix_spawn.c",
1534 "musl/src/process/posix_spawn_file_actions_addchdir.c",
1535 "musl/src/process/posix_spawn_file_actions_addclose.c",
1536 "musl/src/process/posix_spawn_file_actions_adddup2.c",
1537 "musl/src/process/posix_spawn_file_actions_addfchdir.c",
1538 "musl/src/process/posix_spawn_file_actions_addopen.c",
1539 "musl/src/process/posix_spawn_file_actions_destroy.c",
1540 "musl/src/process/posix_spawn_file_actions_init.c",
1541 "musl/src/process/posix_spawnp.c",
1542 "musl/src/process/riscv64/vfork.s",
1543 "musl/src/process/s390x/vfork.s",
1544 "musl/src/process/system.c",
1545 "musl/src/process/vfork.c",
1546 "musl/src/process/wait.c",
1547 "musl/src/process/waitid.c",
1548 "musl/src/process/waitpid.c",
1549 "musl/src/process/x32/vfork.s",
1550 "musl/src/process/x86_64/vfork.s",
1551 "musl/src/regex/fnmatch.c",
1552 "musl/src/regex/glob.c",
1553 "musl/src/regex/regcomp.c",
1554 "musl/src/regex/regerror.c",
1555 "musl/src/regex/regexec.c",
1556 "musl/src/regex/tre-mem.c",
1557 "musl/src/sched/affinity.c",
1558 "musl/src/sched/sched_cpucount.c",
1559 "musl/src/sched/sched_getcpu.c",
1560 "musl/src/sched/sched_getparam.c",
1561 "musl/src/sched/sched_get_priority_max.c",
1562 "musl/src/sched/sched_getscheduler.c",
1563 "musl/src/sched/sched_rr_get_interval.c",
1564 "musl/src/sched/sched_setparam.c",
1565 "musl/src/sched/sched_setscheduler.c",
1566 "musl/src/sched/sched_yield.c",
1567 "musl/src/search/hsearch.c",
1568 "musl/src/search/insque.c",
1569 "musl/src/search/lsearch.c",
1570 "musl/src/search/tdelete.c",
1571 "musl/src/search/tdestroy.c",
1572 "musl/src/search/tfind.c",
1573 "musl/src/search/tsearch.c",
1574 "musl/src/search/twalk.c",
1575 "musl/src/select/poll.c",
1576 "musl/src/select/ppoll.c",
1577 "musl/src/select/pselect.c",
1578 "musl/src/select/select.c",
1579 "musl/src/setjmp/aarch64/longjmp.s",
1580 "musl/src/setjmp/aarch64/setjmp.s",
1581 "musl/src/setjmp/arm/longjmp.S",
1582 "musl/src/setjmp/arm/setjmp.S",
1583 "musl/src/setjmp/hexagon/longjmp.s",
1584 "musl/src/setjmp/hexagon/setjmp.s",
1585 "musl/src/setjmp/i386/longjmp.s",
1586 "musl/src/setjmp/i386/setjmp.s",
1587 "musl/src/setjmp/longjmp.c",
1588 "musl/src/setjmp/loongarch64/longjmp.S",
1589 "musl/src/setjmp/loongarch64/setjmp.S",
1590 "musl/src/setjmp/m68k/longjmp.s",
1591 "musl/src/setjmp/m68k/setjmp.s",
1592 "musl/src/setjmp/mips64/longjmp.S",
1593 "musl/src/setjmp/mips64/setjmp.S",
1594 "musl/src/setjmp/mips/longjmp.S",
1595 "musl/src/setjmp/mipsn32/longjmp.S",
1596 "musl/src/setjmp/mipsn32/setjmp.S",
1597 "musl/src/setjmp/mips/setjmp.S",
1598 "musl/src/setjmp/powerpc64/longjmp.s",
1599 "musl/src/setjmp/powerpc64/setjmp.s",
1600 "musl/src/setjmp/powerpc/longjmp.S",
1601 "musl/src/setjmp/powerpc/setjmp.S",
1602 "musl/src/setjmp/riscv32/longjmp.S",
1603 "musl/src/setjmp/riscv32/setjmp.S",
1604 "musl/src/setjmp/riscv64/longjmp.S",
1605 "musl/src/setjmp/riscv64/setjmp.S",
1606 "musl/src/setjmp/s390x/longjmp.s",
1607 "musl/src/setjmp/s390x/setjmp.s",
1608 "musl/src/setjmp/setjmp.c",
1609 "musl/src/setjmp/x32/longjmp.s",
1610 "musl/src/setjmp/x32/setjmp.s",
1611 "musl/src/setjmp/x86_64/longjmp.s",
1612 "musl/src/setjmp/x86_64/setjmp.s",
1613 "musl/src/signal/aarch64/restore.s",
1614 "musl/src/signal/aarch64/sigsetjmp.s",
1615 "musl/src/signal/arm/restore.s",
1616 "musl/src/signal/arm/sigsetjmp.s",
1617 "musl/src/signal/block.c",
1618 "musl/src/signal/getitimer.c",
1619 "musl/src/signal/hexagon/restore.s",
1620 "musl/src/signal/hexagon/sigsetjmp.s",
1621 "musl/src/signal/i386/restore.s",
1622 "musl/src/signal/i386/sigsetjmp.s",
1623 "musl/src/signal/kill.c",
1624 "musl/src/signal/killpg.c",
1625 "musl/src/signal/loongarch64/restore.s",
1626 "musl/src/signal/loongarch64/sigsetjmp.s",
1627 "musl/src/signal/m68k/sigsetjmp.s",
1628 "musl/src/signal/mips64/sigsetjmp.s",
1629 "musl/src/signal/mipsn32/sigsetjmp.s",
1630 "musl/src/signal/mips/sigsetjmp.s",
1631 "musl/src/signal/powerpc64/restore.s",
1632 "musl/src/signal/powerpc64/sigsetjmp.s",
1633 "musl/src/signal/powerpc/restore.s",
1634 "musl/src/signal/powerpc/sigsetjmp.s",
1635 "musl/src/signal/psiginfo.c",
1636 "musl/src/signal/psignal.c",
1637 "musl/src/signal/raise.c",
1638 "musl/src/signal/restore.c",
1639 "musl/src/signal/riscv32/restore.s",
1640 "musl/src/signal/riscv32/sigsetjmp.s",
1641 "musl/src/signal/riscv64/restore.s",
1642 "musl/src/signal/riscv64/sigsetjmp.s",
1643 "musl/src/signal/s390x/restore.s",
1644 "musl/src/signal/s390x/sigsetjmp.s",
1645 "musl/src/signal/setitimer.c",
1646 "musl/src/signal/sigaction.c",
1647 "musl/src/signal/sigaddset.c",
1648 "musl/src/signal/sigaltstack.c",
1649 "musl/src/signal/sigandset.c",
1650 "musl/src/signal/sigdelset.c",
1651 "musl/src/signal/sigemptyset.c",
1652 "musl/src/signal/sigfillset.c",
1653 "musl/src/signal/sighold.c",
1654 "musl/src/signal/sigignore.c",
1655 "musl/src/signal/siginterrupt.c",
1656 "musl/src/signal/sigisemptyset.c",
1657 "musl/src/signal/sigismember.c",
1658 "musl/src/signal/siglongjmp.c",
1659 "musl/src/signal/signal.c",
1660 "musl/src/signal/sigorset.c",
1661 "musl/src/signal/sigpause.c",
1662 "musl/src/signal/sigpending.c",
1663 "musl/src/signal/sigprocmask.c",
1664 "musl/src/signal/sigqueue.c",
1665 "musl/src/signal/sigrelse.c",
1666 "musl/src/signal/sigrtmax.c",
1667 "musl/src/signal/sigrtmin.c",
1668 "musl/src/signal/sigset.c",
1669 "musl/src/signal/sigsetjmp.c",
1670 "musl/src/signal/sigsetjmp_tail.c",
1671 "musl/src/signal/sigsuspend.c",
1672 "musl/src/signal/sigtimedwait.c",
1673 "musl/src/signal/sigwait.c",
1674 "musl/src/signal/sigwaitinfo.c",
1675 "musl/src/signal/x32/getitimer.c",
1676 "musl/src/signal/x32/restore.s",
1677 "musl/src/signal/x32/setitimer.c",
1678 "musl/src/signal/x32/sigsetjmp.s",
1679 "musl/src/signal/x86_64/restore.s",
1680 "musl/src/signal/x86_64/sigsetjmp.s",
1681 "musl/src/stat/chmod.c",
1682 "musl/src/stat/fchmodat.c",
1683 "musl/src/stat/fchmod.c",
1684 "musl/src/stat/fstatat.c",
1685 "musl/src/stat/fstat.c",
1686 "musl/src/stat/futimens.c",
1687 "musl/src/stat/futimesat.c",
1688 "musl/src/stat/lchmod.c",
1689 "musl/src/stat/lstat.c",
1690 "musl/src/stat/mkdirat.c",
1691 "musl/src/stat/mkdir.c",
1692 "musl/src/stat/mkfifoat.c",
1693 "musl/src/stat/mkfifo.c",
1694 "musl/src/stat/mknodat.c",
1695 "musl/src/stat/mknod.c",
1696 "musl/src/stat/stat.c",
1697 "musl/src/stat/statvfs.c",
1698 "musl/src/stat/umask.c",
1699 "musl/src/stat/utimensat.c",
1700 "musl/src/stat/__xstat.c",
1701 "musl/src/stdio/asprintf.c",
1702 "musl/src/stdio/clearerr.c",
1703 "musl/src/stdio/dprintf.c",
1704 "musl/src/stdio/ext2.c",
1705 "musl/src/stdio/ext.c",
1706 "musl/src/stdio/fclose.c",
1707 "musl/src/stdio/__fclose_ca.c",
1708 "musl/src/stdio/__fdopen.c",
1709 "musl/src/stdio/feof.c",
1710 "musl/src/stdio/ferror.c",
1711 "musl/src/stdio/fflush.c",
1712 "musl/src/stdio/fgetc.c",
1713 "musl/src/stdio/fgetln.c",
1714 "musl/src/stdio/fgetpos.c",
1715 "musl/src/stdio/fgets.c",
1716 "musl/src/stdio/fgetwc.c",
1717 "musl/src/stdio/fgetws.c",
1718 "musl/src/stdio/fileno.c",
1719 "musl/src/stdio/flockfile.c",
1720 "musl/src/stdio/fmemopen.c",
1721 "musl/src/stdio/__fmodeflags.c",
1722 "musl/src/stdio/fopen.c",
1723 "musl/src/stdio/fopencookie.c",
1724 "musl/src/stdio/__fopen_rb_ca.c",
1725 "musl/src/stdio/fprintf.c",
1726 "musl/src/stdio/fputc.c",
1727 "musl/src/stdio/fputs.c",
1728 "musl/src/stdio/fputwc.c",
1729 "musl/src/stdio/fputws.c",
1730 "musl/src/stdio/fread.c",
1731 "musl/src/stdio/freopen.c",
1732 "musl/src/stdio/fscanf.c",
1733 "musl/src/stdio/fseek.c",
1734 "musl/src/stdio/fsetpos.c",
1735 "musl/src/stdio/ftell.c",
1736 "musl/src/stdio/ftrylockfile.c",
1737 "musl/src/stdio/funlockfile.c",
1738 "musl/src/stdio/fwide.c",
1739 "musl/src/stdio/fwprintf.c",
1740 "musl/src/stdio/fwrite.c",
1741 "musl/src/stdio/fwscanf.c",
1742 "musl/src/stdio/getc.c",
1743 "musl/src/stdio/getchar.c",
1744 "musl/src/stdio/getchar_unlocked.c",
1745 "musl/src/stdio/getc_unlocked.c",
1746 "musl/src/stdio/getdelim.c",
1747 "musl/src/stdio/getline.c",
1748 "musl/src/stdio/gets.c",
1749 "musl/src/stdio/getw.c",
1750 "musl/src/stdio/getwc.c",
1751 "musl/src/stdio/getwchar.c",
1752 "musl/src/stdio/__lockfile.c",
1753 "musl/src/stdio/ofl_add.c",
1754 "musl/src/stdio/ofl.c",
1755 "musl/src/stdio/open_memstream.c",
1756 "musl/src/stdio/open_wmemstream.c",
1757 "musl/src/stdio/__overflow.c",
1758 "musl/src/stdio/pclose.c",
1759 "musl/src/stdio/perror.c",
1760 "musl/src/stdio/popen.c",
1761 "musl/src/stdio/printf.c",
1762 "musl/src/stdio/putc.c",
1763 "musl/src/stdio/putchar.c",
1764 "musl/src/stdio/putchar_unlocked.c",
1765 "musl/src/stdio/putc_unlocked.c",
1766 "musl/src/stdio/puts.c",
1767 "musl/src/stdio/putw.c",
1768 "musl/src/stdio/putwc.c",
1769 "musl/src/stdio/putwchar.c",
1770 "musl/src/stdio/remove.c",
1771 "musl/src/stdio/rename.c",
1772 "musl/src/stdio/rewind.c",
1773 "musl/src/stdio/scanf.c",
1774 "musl/src/stdio/setbuf.c",
1775 "musl/src/stdio/setbuffer.c",
1776 "musl/src/stdio/setlinebuf.c",
1777 "musl/src/stdio/setvbuf.c",
1778 "musl/src/stdio/snprintf.c",
1779 "musl/src/stdio/sprintf.c",
1780 "musl/src/stdio/sscanf.c",
1781 "musl/src/stdio/stderr.c",
1782 "musl/src/stdio/stdin.c",
1783 "musl/src/stdio/__stdio_close.c",
1784 "musl/src/stdio/__stdio_exit.c",
1785 "musl/src/stdio/__stdio_read.c",
1786 "musl/src/stdio/__stdio_seek.c",
1787 "musl/src/stdio/__stdio_write.c",
1788 "musl/src/stdio/stdout.c",
1789 "musl/src/stdio/__stdout_write.c",
1790 "musl/src/stdio/swprintf.c",
1791 "musl/src/stdio/swscanf.c",
1792 "musl/src/stdio/tempnam.c",
1793 "musl/src/stdio/tmpfile.c",
1794 "musl/src/stdio/tmpnam.c",
1795 "musl/src/stdio/__toread.c",
1796 "musl/src/stdio/__towrite.c",
1797 "musl/src/stdio/__uflow.c",
1798 "musl/src/stdio/ungetc.c",
1799 "musl/src/stdio/ungetwc.c",
1800 "musl/src/stdio/vasprintf.c",
1801 "musl/src/stdio/vdprintf.c",
1802 "musl/src/stdio/vfprintf.c",
1803 "musl/src/stdio/vfscanf.c",
1804 "musl/src/stdio/vfwprintf.c",
1805 "musl/src/stdio/vfwscanf.c",
1806 "musl/src/stdio/vprintf.c",
1807 "musl/src/stdio/vscanf.c",
1808 "musl/src/stdio/vsnprintf.c",
1809 "musl/src/stdio/vsprintf.c",
1810 "musl/src/stdio/vsscanf.c",
1811 "musl/src/stdio/vswprintf.c",
1812 "musl/src/stdio/vswscanf.c",
1813 "musl/src/stdio/vwprintf.c",
1814 "musl/src/stdio/vwscanf.c",
1815 "musl/src/stdio/wprintf.c",
1816 "musl/src/stdio/wscanf.c",
1817 "musl/src/stdlib/abs.c",
1818 "musl/src/stdlib/atof.c",
1819 "musl/src/stdlib/atoi.c",
1820 "musl/src/stdlib/atol.c",
1821 "musl/src/stdlib/atoll.c",
1822 "musl/src/stdlib/bsearch.c",
1823 "musl/src/stdlib/div.c",
1824 "musl/src/stdlib/ecvt.c",
1825 "musl/src/stdlib/fcvt.c",
1826 "musl/src/stdlib/gcvt.c",
1827 "musl/src/stdlib/imaxabs.c",
1828 "musl/src/stdlib/imaxdiv.c",
1829 "musl/src/stdlib/labs.c",
1830 "musl/src/stdlib/ldiv.c",
1831 "musl/src/stdlib/llabs.c",
1832 "musl/src/stdlib/lldiv.c",
1833 "musl/src/stdlib/qsort.c",
1834 "musl/src/stdlib/qsort_nr.c",
1835 "musl/src/stdlib/strtod.c",
1836 "musl/src/stdlib/strtol.c",
1837 "musl/src/stdlib/wcstod.c",
1838 "musl/src/stdlib/wcstol.c",
1839 "musl/src/string/aarch64/memset.S",
1840 "musl/src/string/arm/__aeabi_memset.s",
1841 "musl/src/string/bcmp.c",
1842 "musl/src/string/bcopy.c",
1843 "musl/src/string/explicit_bzero.c",
1844 "musl/src/string/i386/memset.s",
1845 "musl/src/string/index.c",
1846 "musl/src/string/memccpy.c",
1847 "musl/src/string/memchr.c",
1848 "musl/src/string/memcmp.c",
1849 "musl/src/string/memmem.c",
1850 "musl/src/string/mempcpy.c",
1851 "musl/src/string/memrchr.c",
1852 "musl/src/string/memset.c",
1853 "musl/src/string/rindex.c",
1854 "musl/src/string/stpcpy.c",
1855 "musl/src/string/stpncpy.c",
1856 "musl/src/string/strcasecmp.c",
1857 "musl/src/string/strcasestr.c",
1858 "musl/src/string/strcat.c",
1859 "musl/src/string/strchr.c",
1860 "musl/src/string/strchrnul.c",
1861 "musl/src/string/strcpy.c",
1862 "musl/src/string/strcspn.c",
1863 "musl/src/string/strdup.c",
1864 "musl/src/string/strerror_r.c",
1865 "musl/src/string/strlcat.c",
1866 "musl/src/string/strlcpy.c",
1867 "musl/src/string/strncasecmp.c",
1868 "musl/src/string/strncat.c",
1869 "musl/src/string/strncpy.c",
1870 "musl/src/string/strndup.c",
1871 "musl/src/string/strnlen.c",
1872 "musl/src/string/strpbrk.c",
1873 "musl/src/string/strrchr.c",
1874 "musl/src/string/strsep.c",
1875 "musl/src/string/strsignal.c",
1876 "musl/src/string/strspn.c",
1877 "musl/src/string/strstr.c",
1878 "musl/src/string/strtok.c",
1879 "musl/src/string/strtok_r.c",
1880 "musl/src/string/strverscmp.c",
1881 "musl/src/string/swab.c",
1882 "musl/src/string/wcpcpy.c",
1883 "musl/src/string/wcpncpy.c",
1884 "musl/src/string/wcscasecmp.c",
1885 "musl/src/string/wcscasecmp_l.c",
1886 "musl/src/string/wcscat.c",
1887 "musl/src/string/wcschr.c",
1888 "musl/src/string/wcscmp.c",
1889 "musl/src/string/wcscpy.c",
1890 "musl/src/string/wcscspn.c",
1891 "musl/src/string/wcsdup.c",
1892 "musl/src/string/wcslen.c",
1893 "musl/src/string/wcsncasecmp.c",
1894 "musl/src/string/wcsncasecmp_l.c",
1895 "musl/src/string/wcsncat.c",
1896 "musl/src/string/wcsncmp.c",
1897 "musl/src/string/wcsncpy.c",
1898 "musl/src/string/wcsnlen.c",
1899 "musl/src/string/wcspbrk.c",
1900 "musl/src/string/wcsrchr.c",
1901 "musl/src/string/wcsspn.c",
1902 "musl/src/string/wcsstr.c",
1903 "musl/src/string/wcstok.c",
1904 "musl/src/string/wcswcs.c",
1905 "musl/src/string/wmemchr.c",
1906 "musl/src/string/wmemcmp.c",
1907 "musl/src/string/wmemcpy.c",
1908 "musl/src/string/wmemmove.c",
1909 "musl/src/string/wmemset.c",
1910 "musl/src/string/x86_64/memset.s",
1911 "musl/src/temp/mkdtemp.c",
1912 "musl/src/temp/mkostemp.c",
1913 "musl/src/temp/mkostemps.c",
1914 "musl/src/temp/mkstemp.c",
1915 "musl/src/temp/mkstemps.c",
1916 "musl/src/temp/mktemp.c",
1917 "musl/src/temp/__randname.c",
1918 "musl/src/termios/cfgetospeed.c",
1919 "musl/src/termios/cfmakeraw.c",
1920 "musl/src/termios/cfsetospeed.c",
1921 "musl/src/termios/tcdrain.c",
1922 "musl/src/termios/tcflow.c",
1923 "musl/src/termios/tcflush.c",
1924 "musl/src/termios/tcgetattr.c",
1925 "musl/src/termios/tcgetsid.c",
1926 "musl/src/termios/tcgetwinsize.c",
1927 "musl/src/termios/tcsendbreak.c",
1928 "musl/src/termios/tcsetattr.c",
1929 "musl/src/termios/tcsetwinsize.c",
1930 "musl/src/thread/aarch64/clone.s",
1931 "musl/src/thread/aarch64/__set_thread_area.s",
1932 "musl/src/thread/aarch64/syscall_cp.s",
1933 "musl/src/thread/aarch64/__unmapself.s",
1934 "musl/src/thread/arm/__aeabi_read_tp.s",
1935 "musl/src/thread/arm/atomics.s",
1936 "musl/src/thread/arm/clone.s",
1937 "musl/src/thread/arm/__set_thread_area.c",
1938 "musl/src/thread/arm/syscall_cp.s",
1939 "musl/src/thread/arm/__unmapself.s",
1940 "musl/src/thread/call_once.c",
1941 "musl/src/thread/clone.c",
1942 "musl/src/thread/cnd_broadcast.c",
1943 "musl/src/thread/cnd_destroy.c",
1944 "musl/src/thread/cnd_init.c",
1945 "musl/src/thread/cnd_signal.c",
1946 "musl/src/thread/cnd_timedwait.c",
1947 "musl/src/thread/cnd_wait.c",
1948 "musl/src/thread/default_attr.c",
1949 "musl/src/thread/hexagon/clone.s",
1950 "musl/src/thread/hexagon/__set_thread_area.s",
1951 "musl/src/thread/hexagon/syscall_cp.s",
1952 "musl/src/thread/hexagon/__unmapself.s",
1953 "musl/src/thread/i386/clone.s",
1954 "musl/src/thread/i386/__set_thread_area.s",
1955 "musl/src/thread/i386/syscall_cp.s",
1956 "musl/src/thread/i386/tls.s",
1957 "musl/src/thread/i386/__unmapself.s",
1958 "musl/src/thread/__lock.c",
1959 "musl/src/thread/lock_ptc.c",
1960 "musl/src/thread/loongarch64/clone.s",
1961 "musl/src/thread/loongarch64/__set_thread_area.s",
1962 "musl/src/thread/loongarch64/syscall_cp.s",
1963 "musl/src/thread/loongarch64/__unmapself.s",
1964 "musl/src/thread/m68k/clone.s",
1965 "musl/src/thread/m68k/__m68k_read_tp.s",
1966 "musl/src/thread/m68k/syscall_cp.s",
1967 "musl/src/thread/mips64/clone.s",
1968 "musl/src/thread/mips64/syscall_cp.s",
1969 "musl/src/thread/mips64/__unmapself.s",
1970 "musl/src/thread/mips/clone.s",
1971 "musl/src/thread/mipsn32/clone.s",
1972 "musl/src/thread/mipsn32/syscall_cp.s",
1973 "musl/src/thread/mipsn32/__unmapself.s",
1974 "musl/src/thread/mips/syscall_cp.s",
1975 "musl/src/thread/mips/__unmapself.s",
1976 "musl/src/thread/mtx_destroy.c",
1977 "musl/src/thread/mtx_init.c",
1978 "musl/src/thread/mtx_lock.c",
1979 "musl/src/thread/mtx_timedlock.c",
1980 "musl/src/thread/mtx_trylock.c",
1981 "musl/src/thread/mtx_unlock.c",
1982 "musl/src/thread/powerpc64/clone.s",
1983 "musl/src/thread/powerpc64/__set_thread_area.s",
1984 "musl/src/thread/powerpc64/syscall_cp.s",
1985 "musl/src/thread/powerpc64/__unmapself.s",
1986 "musl/src/thread/powerpc/clone.s",
1987 "musl/src/thread/powerpc/__set_thread_area.s",
1988 "musl/src/thread/powerpc/syscall_cp.s",
1989 "musl/src/thread/powerpc/__unmapself.s",
1990 "musl/src/thread/pthread_atfork.c",
1991 "musl/src/thread/pthread_attr_destroy.c",
1992 "musl/src/thread/pthread_attr_get.c",
1993 "musl/src/thread/pthread_attr_init.c",
1994 "musl/src/thread/pthread_attr_setdetachstate.c",
1995 "musl/src/thread/pthread_attr_setguardsize.c",
1996 "musl/src/thread/pthread_attr_setinheritsched.c",
1997 "musl/src/thread/pthread_attr_setschedparam.c",
1998 "musl/src/thread/pthread_attr_setschedpolicy.c",
1999 "musl/src/thread/pthread_attr_setscope.c",
2000 "musl/src/thread/pthread_attr_setstack.c",
2001 "musl/src/thread/pthread_attr_setstacksize.c",
2002 "musl/src/thread/pthread_barrierattr_destroy.c",
2003 "musl/src/thread/pthread_barrierattr_init.c",
2004 "musl/src/thread/pthread_barrierattr_setpshared.c",
2005 "musl/src/thread/pthread_barrier_destroy.c",
2006 "musl/src/thread/pthread_barrier_init.c",
2007 "musl/src/thread/pthread_barrier_wait.c",
2008 "musl/src/thread/pthread_cancel.c",
2009 "musl/src/thread/pthread_cleanup_push.c",
2010 "musl/src/thread/pthread_condattr_destroy.c",
2011 "musl/src/thread/pthread_condattr_init.c",
2012 "musl/src/thread/pthread_condattr_setclock.c",
2013 "musl/src/thread/pthread_condattr_setpshared.c",
2014 "musl/src/thread/pthread_cond_broadcast.c",
2015 "musl/src/thread/pthread_cond_destroy.c",
2016 "musl/src/thread/pthread_cond_init.c",
2017 "musl/src/thread/pthread_cond_signal.c",
2018 "musl/src/thread/pthread_cond_timedwait.c",
2019 "musl/src/thread/pthread_cond_wait.c",
2020 "musl/src/thread/pthread_create.c",
2021 "musl/src/thread/pthread_detach.c",
2022 "musl/src/thread/pthread_equal.c",
2023 "musl/src/thread/pthread_getattr_np.c",
2024 "musl/src/thread/pthread_getconcurrency.c",
2025 "musl/src/thread/pthread_getcpuclockid.c",
2026 "musl/src/thread/pthread_getname_np.c",
2027 "musl/src/thread/pthread_getschedparam.c",
2028 "musl/src/thread/pthread_getspecific.c",
2029 "musl/src/thread/pthread_join.c",
2030 "musl/src/thread/pthread_key_create.c",
2031 "musl/src/thread/pthread_kill.c",
2032 "musl/src/thread/pthread_mutexattr_destroy.c",
2033 "musl/src/thread/pthread_mutexattr_init.c",
2034 "musl/src/thread/pthread_mutexattr_setprotocol.c",
2035 "musl/src/thread/pthread_mutexattr_setpshared.c",
2036 "musl/src/thread/pthread_mutexattr_setrobust.c",
2037 "musl/src/thread/pthread_mutexattr_settype.c",
2038 "musl/src/thread/pthread_mutex_consistent.c",
2039 "musl/src/thread/pthread_mutex_destroy.c",
2040 "musl/src/thread/pthread_mutex_getprioceiling.c",
2041 "musl/src/thread/pthread_mutex_init.c",
2042 "musl/src/thread/pthread_mutex_lock.c",
2043 "musl/src/thread/pthread_mutex_setprioceiling.c",
2044 "musl/src/thread/pthread_mutex_timedlock.c",
2045 "musl/src/thread/pthread_mutex_trylock.c",
2046 "musl/src/thread/pthread_mutex_unlock.c",
2047 "musl/src/thread/pthread_once.c",
2048 "musl/src/thread/pthread_rwlockattr_destroy.c",
2049 "musl/src/thread/pthread_rwlockattr_init.c",
2050 "musl/src/thread/pthread_rwlockattr_setpshared.c",
2051 "musl/src/thread/pthread_rwlock_destroy.c",
2052 "musl/src/thread/pthread_rwlock_init.c",
2053 "musl/src/thread/pthread_rwlock_rdlock.c",
2054 "musl/src/thread/pthread_rwlock_timedrdlock.c",
2055 "musl/src/thread/pthread_rwlock_timedwrlock.c",
2056 "musl/src/thread/pthread_rwlock_tryrdlock.c",
2057 "musl/src/thread/pthread_rwlock_trywrlock.c",
2058 "musl/src/thread/pthread_rwlock_unlock.c",
2059 "musl/src/thread/pthread_rwlock_wrlock.c",
2060 "musl/src/thread/pthread_self.c",
2061 "musl/src/thread/pthread_setattr_default_np.c",
2062 "musl/src/thread/pthread_setcancelstate.c",
2063 "musl/src/thread/pthread_setcanceltype.c",
2064 "musl/src/thread/pthread_setconcurrency.c",
2065 "musl/src/thread/pthread_setname_np.c",
2066 "musl/src/thread/pthread_setschedparam.c",
2067 "musl/src/thread/pthread_setschedprio.c",
2068 "musl/src/thread/pthread_setspecific.c",
2069 "musl/src/thread/pthread_sigmask.c",
2070 "musl/src/thread/pthread_spin_destroy.c",
2071 "musl/src/thread/pthread_spin_init.c",
2072 "musl/src/thread/pthread_spin_lock.c",
2073 "musl/src/thread/pthread_spin_trylock.c",
2074 "musl/src/thread/pthread_spin_unlock.c",
2075 "musl/src/thread/pthread_testcancel.c",
2076 "musl/src/thread/riscv32/clone.s",
2077 "musl/src/thread/riscv32/__set_thread_area.s",
2078 "musl/src/thread/riscv32/syscall_cp.s",
2079 "musl/src/thread/riscv32/__unmapself.s",
2080 "musl/src/thread/riscv64/clone.s",
2081 "musl/src/thread/riscv64/__set_thread_area.s",
2082 "musl/src/thread/riscv64/syscall_cp.s",
2083 "musl/src/thread/riscv64/__unmapself.s",
2084 "musl/src/thread/s390x/clone.s",
2085 "musl/src/thread/s390x/__set_thread_area.s",
2086 "musl/src/thread/s390x/syscall_cp.s",
2087 "musl/src/thread/s390x/__tls_get_offset.s",
2088 "musl/src/thread/s390x/__unmapself.s",
2089 "musl/src/thread/sem_destroy.c",
2090 "musl/src/thread/sem_getvalue.c",
2091 "musl/src/thread/sem_init.c",
2092 "musl/src/thread/sem_open.c",
2093 "musl/src/thread/sem_post.c",
2094 "musl/src/thread/sem_timedwait.c",
2095 "musl/src/thread/sem_trywait.c",
2096 "musl/src/thread/sem_unlink.c",
2097 "musl/src/thread/sem_wait.c",
2098 "musl/src/thread/__set_thread_area.c",
2099 "musl/src/thread/synccall.c",
2100 "musl/src/thread/__syscall_cp.c",
2101 "musl/src/thread/syscall_cp.c",
2102 "musl/src/thread/thrd_create.c",
2103 "musl/src/thread/thrd_exit.c",
2104 "musl/src/thread/thrd_join.c",
2105 "musl/src/thread/thrd_sleep.c",
2106 "musl/src/thread/thrd_yield.c",
2107 "musl/src/thread/__timedwait.c",
2108 "musl/src/thread/tls.c",
2109 "musl/src/thread/__tls_get_addr.c",
2110 "musl/src/thread/tss_create.c",
2111 "musl/src/thread/tss_delete.c",
2112 "musl/src/thread/tss_set.c",
2113 "musl/src/thread/__unmapself.c",
2114 "musl/src/thread/vmlock.c",
2115 "musl/src/thread/__wait.c",
2116 "musl/src/thread/x32/clone.s",
2117 "musl/src/thread/x32/__set_thread_area.s",
2118 "musl/src/thread/x32/syscall_cp.s",
2119 "musl/src/thread/x32/__unmapself.s",
2120 "musl/src/thread/x86_64/clone.s",
2121 "musl/src/thread/x86_64/__set_thread_area.s",
2122 "musl/src/thread/x86_64/syscall_cp.s",
2123 "musl/src/thread/x86_64/__unmapself.s",
2124 "musl/src/time/asctime.c",
2125 "musl/src/time/asctime_r.c",
2126 "musl/src/time/clock.c",
2127 "musl/src/time/clock_getcpuclockid.c",
2128 "musl/src/time/clock_getres.c",
2129 "musl/src/time/clock_gettime.c",
2130 "musl/src/time/clock_nanosleep.c",
2131 "musl/src/time/clock_settime.c",
2132 "musl/src/time/ctime.c",
2133 "musl/src/time/ctime_r.c",
2134 "musl/src/time/difftime.c",
2135 "musl/src/time/ftime.c",
2136 "musl/src/time/getdate.c",
2137 "musl/src/time/gettimeofday.c",
2138 "musl/src/time/gmtime.c",
2139 "musl/src/time/gmtime_r.c",
2140 "musl/src/time/localtime.c",
2141 "musl/src/time/localtime_r.c",
2142 "musl/src/time/__map_file.c",
2143 "musl/src/time/mktime.c",
2144 "musl/src/time/__month_to_secs.c",
2145 "musl/src/time/nanosleep.c",
2146 "musl/src/time/__secs_to_tm.c",
2147 "musl/src/time/strftime.c",
2148 "musl/src/time/strptime.c",
2149 "musl/src/time/time.c",
2150 "musl/src/time/timegm.c",
2151 "musl/src/time/timer_create.c",
2152 "musl/src/time/timer_delete.c",
2153 "musl/src/time/timer_getoverrun.c",
2154 "musl/src/time/timer_gettime.c",
2155 "musl/src/time/timer_settime.c",
2156 "musl/src/time/times.c",
2157 "musl/src/time/timespec_get.c",
2158 "musl/src/time/__tm_to_secs.c",
2159 "musl/src/time/__tz.c",
2160 "musl/src/time/utime.c",
2161 "musl/src/time/wcsftime.c",
2162 "musl/src/time/__year_to_secs.c",
2163 "musl/src/unistd/access.c",
2164 "musl/src/unistd/acct.c",
2165 "musl/src/unistd/alarm.c",
2166 "musl/src/unistd/chdir.c",
2167 "musl/src/unistd/chown.c",
2168 "musl/src/unistd/close.c",
2169 "musl/src/unistd/ctermid.c",
2170 "musl/src/unistd/dup2.c",
2171 "musl/src/unistd/dup3.c",
2172 "musl/src/unistd/dup.c",
2173 "musl/src/unistd/_exit.c",
2174 "musl/src/unistd/faccessat.c",
2175 "musl/src/unistd/fchdir.c",
2176 "musl/src/unistd/fchownat.c",
2177 "musl/src/unistd/fchown.c",
2178 "musl/src/unistd/fdatasync.c",
2179 "musl/src/unistd/fsync.c",
2180 "musl/src/unistd/ftruncate.c",
2181 "musl/src/unistd/getcwd.c",
2182 "musl/src/unistd/getegid.c",
2183 "musl/src/unistd/geteuid.c",
2184 "musl/src/unistd/getgid.c",
2185 "musl/src/unistd/getgroups.c",
2186 "musl/src/unistd/gethostname.c",
2187 "musl/src/unistd/getlogin.c",
2188 "musl/src/unistd/getlogin_r.c",
2189 "musl/src/unistd/getpgid.c",
2190 "musl/src/unistd/getpgrp.c",
2191 "musl/src/unistd/getpid.c",
2192 "musl/src/unistd/getppid.c",
2193 "musl/src/unistd/getsid.c",
2194 "musl/src/unistd/getuid.c",
2195 "musl/src/unistd/isatty.c",
2196 "musl/src/unistd/lchown.c",
2197 "musl/src/unistd/linkat.c",
2198 "musl/src/unistd/link.c",
2199 "musl/src/unistd/lseek.c",
2200 "musl/src/unistd/mips64/pipe.s",
2201 "musl/src/unistd/mipsn32/lseek.c",
2202 "musl/src/unistd/mipsn32/pipe.s",
2203 "musl/src/unistd/mips/pipe.s",
2204 "musl/src/unistd/nice.c",
2205 "musl/src/unistd/pause.c",
2206 "musl/src/unistd/pipe2.c",
2207 "musl/src/unistd/pipe.c",
2208 "musl/src/unistd/posix_close.c",
2209 "musl/src/unistd/pread.c",
2210 "musl/src/unistd/preadv.c",
2211 "musl/src/unistd/pwrite.c",
2212 "musl/src/unistd/pwritev.c",
2213 "musl/src/unistd/read.c",
2214 "musl/src/unistd/readlinkat.c",
2215 "musl/src/unistd/readlink.c",
2216 "musl/src/unistd/readv.c",
2217 "musl/src/unistd/renameat.c",
2218 "musl/src/unistd/rmdir.c",
2219 "musl/src/unistd/setegid.c",
2220 "musl/src/unistd/seteuid.c",
2221 "musl/src/unistd/setgid.c",
2222 "musl/src/unistd/setpgid.c",
2223 "musl/src/unistd/setpgrp.c",
2224 "musl/src/unistd/setregid.c",
2225 "musl/src/unistd/setresgid.c",
2226 "musl/src/unistd/setresuid.c",
2227 "musl/src/unistd/setreuid.c",
2228 "musl/src/unistd/setsid.c",
2229 "musl/src/unistd/setuid.c",
2230 "musl/src/unistd/setxid.c",
2231 "musl/src/unistd/sleep.c",
2232 "musl/src/unistd/symlinkat.c",
2233 "musl/src/unistd/symlink.c",
2234 "musl/src/unistd/sync.c",
2235 "musl/src/unistd/tcgetpgrp.c",
2236 "musl/src/unistd/tcsetpgrp.c",
2237 "musl/src/unistd/truncate.c",
2238 "musl/src/unistd/ttyname.c",
2239 "musl/src/unistd/ttyname_r.c",
2240 "musl/src/unistd/ualarm.c",
2241 "musl/src/unistd/unlinkat.c",
2242 "musl/src/unistd/unlink.c",
2243 "musl/src/unistd/usleep.c",
2244 "musl/src/unistd/write.c",
2245 "musl/src/unistd/writev.c",
2246 "musl/src/unistd/x32/lseek.c",
2247};
2248
2249const compat_time32_files = [_][]const u8{
2250 "musl/compat/time32/adjtime32.c",
2251 "musl/compat/time32/adjtimex_time32.c",
2252 "musl/compat/time32/aio_suspend_time32.c",
2253 "musl/compat/time32/clock_adjtime32.c",
2254 "musl/compat/time32/clock_getres_time32.c",
2255 "musl/compat/time32/clock_gettime32.c",
2256 "musl/compat/time32/clock_nanosleep_time32.c",
2257 "musl/compat/time32/clock_settime32.c",
2258 "musl/compat/time32/cnd_timedwait_time32.c",
2259 "musl/compat/time32/ctime32.c",
2260 "musl/compat/time32/ctime32_r.c",
2261 "musl/compat/time32/difftime32.c",
2262 "musl/compat/time32/fstatat_time32.c",
2263 "musl/compat/time32/fstat_time32.c",
2264 "musl/compat/time32/ftime32.c",
2265 "musl/compat/time32/futimens_time32.c",
2266 "musl/compat/time32/futimesat_time32.c",
2267 "musl/compat/time32/futimes_time32.c",
2268 "musl/compat/time32/getitimer_time32.c",
2269 "musl/compat/time32/getrusage_time32.c",
2270 "musl/compat/time32/gettimeofday_time32.c",
2271 "musl/compat/time32/gmtime32.c",
2272 "musl/compat/time32/gmtime32_r.c",
2273 "musl/compat/time32/localtime32.c",
2274 "musl/compat/time32/localtime32_r.c",
2275 "musl/compat/time32/lstat_time32.c",
2276 "musl/compat/time32/lutimes_time32.c",
2277 "musl/compat/time32/mktime32.c",
2278 "musl/compat/time32/mq_timedreceive_time32.c",
2279 "musl/compat/time32/mq_timedsend_time32.c",
2280 "musl/compat/time32/mtx_timedlock_time32.c",
2281 "musl/compat/time32/nanosleep_time32.c",
2282 "musl/compat/time32/ppoll_time32.c",
2283 "musl/compat/time32/pselect_time32.c",
2284 "musl/compat/time32/pthread_cond_timedwait_time32.c",
2285 "musl/compat/time32/pthread_mutex_timedlock_time32.c",
2286 "musl/compat/time32/pthread_rwlock_timedrdlock_time32.c",
2287 "musl/compat/time32/pthread_rwlock_timedwrlock_time32.c",
2288 "musl/compat/time32/pthread_timedjoin_np_time32.c",
2289 "musl/compat/time32/recvmmsg_time32.c",
2290 "musl/compat/time32/sched_rr_get_interval_time32.c",
2291 "musl/compat/time32/select_time32.c",
2292 "musl/compat/time32/semtimedop_time32.c",
2293 "musl/compat/time32/sem_timedwait_time32.c",
2294 "musl/compat/time32/setitimer_time32.c",
2295 "musl/compat/time32/settimeofday_time32.c",
2296 "musl/compat/time32/sigtimedwait_time32.c",
2297 "musl/compat/time32/stat_time32.c",
2298 "musl/compat/time32/stime32.c",
2299 "musl/compat/time32/thrd_sleep_time32.c",
2300 "musl/compat/time32/time32.c",
2301 "musl/compat/time32/time32gm.c",
2302 "musl/compat/time32/timerfd_gettime32.c",
2303 "musl/compat/time32/timerfd_settime32.c",
2304 "musl/compat/time32/timer_gettime32.c",
2305 "musl/compat/time32/timer_settime32.c",
2306 "musl/compat/time32/timespec_get_time32.c",
2307 "musl/compat/time32/utimensat_time32.c",
2308 "musl/compat/time32/utimes_time32.c",
2309 "musl/compat/time32/utime_time32.c",
2310 "musl/compat/time32/wait3_time32.c",
2311 "musl/compat/time32/wait4_time32.c",
2312 "musl/compat/time32/__xstat.c",
2313};
src/libs/wasi_libc.zig created+1256
...@@ -0,0 +1,1256 @@
1const std = @import("std");
2const mem = std.mem;
3const path = std.fs.path;
4
5const Allocator = std.mem.Allocator;
6const Compilation = @import("../Compilation.zig");
7const build_options = @import("build_options");
8
9pub const CrtFile = enum {
10 crt1_reactor_o,
11 crt1_command_o,
12 libc_a,
13 libdl_a,
14 libwasi_emulated_process_clocks_a,
15 libwasi_emulated_getpid_a,
16 libwasi_emulated_mman_a,
17 libwasi_emulated_signal_a,
18};
19
20pub fn getEmulatedLibCrtFile(lib_name: []const u8) ?CrtFile {
21 if (mem.eql(u8, lib_name, "dl")) {
22 return .libdl_a;
23 }
24 if (mem.eql(u8, lib_name, "wasi-emulated-process-clocks")) {
25 return .libwasi_emulated_process_clocks_a;
26 }
27 if (mem.eql(u8, lib_name, "wasi-emulated-getpid")) {
28 return .libwasi_emulated_getpid_a;
29 }
30 if (mem.eql(u8, lib_name, "wasi-emulated-mman")) {
31 return .libwasi_emulated_mman_a;
32 }
33 if (mem.eql(u8, lib_name, "wasi-emulated-signal")) {
34 return .libwasi_emulated_signal_a;
35 }
36 return null;
37}
38
39pub fn emulatedLibCRFileLibName(crt_file: CrtFile) []const u8 {
40 return switch (crt_file) {
41 .libdl_a => "libdl.a",
42 .libwasi_emulated_process_clocks_a => "libwasi-emulated-process-clocks.a",
43 .libwasi_emulated_getpid_a => "libwasi-emulated-getpid.a",
44 .libwasi_emulated_mman_a => "libwasi-emulated-mman.a",
45 .libwasi_emulated_signal_a => "libwasi-emulated-signal.a",
46 else => unreachable,
47 };
48}
49
50pub fn execModelCrtFile(wasi_exec_model: std.builtin.WasiExecModel) CrtFile {
51 return switch (wasi_exec_model) {
52 .reactor => CrtFile.crt1_reactor_o,
53 .command => CrtFile.crt1_command_o,
54 };
55}
56
57pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []const u8 {
58 return switch (execModelCrtFile(wasi_exec_model)) {
59 .crt1_reactor_o => "crt1-reactor.o",
60 .crt1_command_o => "crt1-command.o",
61 else => unreachable,
62 };
63}
64
65/// TODO replace anyerror with explicit error set, recording user-friendly errors with
66/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
67pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
68 if (!build_options.have_llvm) {
69 return error.ZigCompilerNotBuiltWithLLVMExtensions;
70 }
71
72 const gpa = comp.gpa;
73 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
74 defer arena_allocator.deinit();
75 const arena = arena_allocator.allocator();
76
77 switch (crt_file) {
78 .crt1_reactor_o => {
79 var args = std.ArrayList([]const u8).init(arena);
80 try addCCArgs(comp, arena, &args, .{});
81 try addLibcBottomHalfIncludes(comp, arena, &args);
82 var files = [_]Compilation.CSourceFile{
83 .{
84 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
85 "libc", try sanitize(arena, crt1_reactor_src_file),
86 }),
87 .extra_flags = args.items,
88 .owner = undefined,
89 },
90 };
91 return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &files, .{});
92 },
93 .crt1_command_o => {
94 var args = std.ArrayList([]const u8).init(arena);
95 try addCCArgs(comp, arena, &args, .{});
96 try addLibcBottomHalfIncludes(comp, arena, &args);
97 var files = [_]Compilation.CSourceFile{
98 .{
99 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
100 "libc", try sanitize(arena, crt1_command_src_file),
101 }),
102 .extra_flags = args.items,
103 .owner = undefined,
104 },
105 };
106 return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &files, .{});
107 },
108 .libc_a => {
109 var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
110
111 {
112 // Compile emmalloc.
113 var args = std.ArrayList([]const u8).init(arena);
114 try addCCArgs(comp, arena, &args, .{ .want_O3 = true, .no_strict_aliasing = true });
115 for (emmalloc_src_files) |file_path| {
116 try libc_sources.append(.{
117 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
118 "libc", try sanitize(arena, file_path),
119 }),
120 .extra_flags = args.items,
121 .owner = undefined,
122 });
123 }
124 }
125
126 {
127 // Compile libc-bottom-half.
128 var args = std.ArrayList([]const u8).init(arena);
129 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
130 try addLibcBottomHalfIncludes(comp, arena, &args);
131
132 for (libc_bottom_half_src_files) |file_path| {
133 try libc_sources.append(.{
134 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
135 "libc", try sanitize(arena, file_path),
136 }),
137 .extra_flags = args.items,
138 .owner = undefined,
139 });
140 }
141 }
142
143 {
144 // Compile libc-top-half.
145 var args = std.ArrayList([]const u8).init(arena);
146 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
147 try addLibcTopHalfIncludes(comp, arena, &args);
148
149 for (libc_top_half_src_files) |file_path| {
150 try libc_sources.append(.{
151 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
152 "libc", try sanitize(arena, file_path),
153 }),
154 .extra_flags = args.items,
155 .owner = undefined,
156 });
157 }
158 }
159
160 try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items, .{});
161 },
162
163 .libdl_a => {
164 var args = std.ArrayList([]const u8).init(arena);
165 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
166 try addLibcBottomHalfIncludes(comp, arena, &args);
167
168 var emu_dl_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
169 for (emulated_dl_src_files) |file_path| {
170 try emu_dl_sources.append(.{
171 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
172 "libc", try sanitize(arena, file_path),
173 }),
174 .extra_flags = args.items,
175 .owner = undefined,
176 });
177 }
178 try comp.build_crt_file("dl", .Lib, .@"wasi libdl.a", prog_node, emu_dl_sources.items, .{});
179 },
180
181 .libwasi_emulated_process_clocks_a => {
182 var args = std.ArrayList([]const u8).init(arena);
183 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
184 try addLibcBottomHalfIncludes(comp, arena, &args);
185
186 var emu_clocks_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
187 for (emulated_process_clocks_src_files) |file_path| {
188 try emu_clocks_sources.append(.{
189 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
190 "libc", try sanitize(arena, file_path),
191 }),
192 .extra_flags = args.items,
193 .owner = undefined,
194 });
195 }
196 try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items, .{});
197 },
198 .libwasi_emulated_getpid_a => {
199 var args = std.ArrayList([]const u8).init(arena);
200 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
201 try addLibcBottomHalfIncludes(comp, arena, &args);
202
203 var emu_getpid_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
204 for (emulated_getpid_src_files) |file_path| {
205 try emu_getpid_sources.append(.{
206 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
207 "libc", try sanitize(arena, file_path),
208 }),
209 .extra_flags = args.items,
210 .owner = undefined,
211 });
212 }
213 try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items, .{});
214 },
215 .libwasi_emulated_mman_a => {
216 var args = std.ArrayList([]const u8).init(arena);
217 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
218 try addLibcBottomHalfIncludes(comp, arena, &args);
219
220 var emu_mman_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
221 for (emulated_mman_src_files) |file_path| {
222 try emu_mman_sources.append(.{
223 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
224 "libc", try sanitize(arena, file_path),
225 }),
226 .extra_flags = args.items,
227 .owner = undefined,
228 });
229 }
230 try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items, .{});
231 },
232 .libwasi_emulated_signal_a => {
233 var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
234
235 {
236 var args = std.ArrayList([]const u8).init(arena);
237 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
238
239 for (emulated_signal_bottom_half_src_files) |file_path| {
240 try emu_signal_sources.append(.{
241 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
242 "libc", try sanitize(arena, file_path),
243 }),
244 .extra_flags = args.items,
245 .owner = undefined,
246 });
247 }
248 }
249
250 {
251 var args = std.ArrayList([]const u8).init(arena);
252 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
253 try addLibcTopHalfIncludes(comp, arena, &args);
254 try args.append("-D_WASI_EMULATED_SIGNAL");
255
256 for (emulated_signal_top_half_src_files) |file_path| {
257 try emu_signal_sources.append(.{
258 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
259 "libc", try sanitize(arena, file_path),
260 }),
261 .extra_flags = args.items,
262 .owner = undefined,
263 });
264 }
265 }
266
267 try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items, .{});
268 },
269 }
270}
271
272fn sanitize(arena: Allocator, file_path: []const u8) ![]const u8 {
273 // TODO do this at comptime on the comptime data rather than at runtime
274 // probably best to wait until self-hosted is done and our comptime execution
275 // is faster and uses less memory.
276 const out_path = if (path.sep != '/') blk: {
277 const mutable_file_path = try arena.dupe(u8, file_path);
278 for (mutable_file_path) |*c| {
279 if (c.* == '/') {
280 c.* = path.sep;
281 }
282 }
283 break :blk mutable_file_path;
284 } else file_path;
285 return out_path;
286}
287
288const CCOptions = struct {
289 want_O3: bool = false,
290 no_strict_aliasing: bool = false,
291};
292
293fn addCCArgs(
294 comp: *Compilation,
295 arena: Allocator,
296 args: *std.ArrayList([]const u8),
297 options: CCOptions,
298) error{OutOfMemory}!void {
299 const target = comp.getTarget();
300 const arch_name = std.zig.target.muslArchNameHeaders(target.cpu.arch);
301 const os_name = @tagName(target.os.tag);
302 const triple = try std.fmt.allocPrint(arena, "{s}-{s}-musl", .{ arch_name, os_name });
303 const o_arg = if (options.want_O3) "-O3" else "-Os";
304
305 try args.appendSlice(&[_][]const u8{
306 "-std=gnu17",
307 "-fno-trapping-math",
308 "-w", // ignore all warnings
309
310 o_arg,
311
312 "-mthread-model",
313 "single",
314
315 "-isysroot",
316 "/",
317
318 "-iwithsysroot",
319 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
320
321 "-iwithsysroot",
322 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
323
324 "-DBULK_MEMORY_THRESHOLD=32",
325 });
326
327 if (options.no_strict_aliasing) {
328 try args.appendSlice(&[_][]const u8{"-fno-strict-aliasing"});
329 }
330}
331
332fn addLibcBottomHalfIncludes(
333 comp: *Compilation,
334 arena: Allocator,
335 args: *std.ArrayList([]const u8),
336) error{OutOfMemory}!void {
337 try args.appendSlice(&[_][]const u8{
338 "-I",
339 try comp.zig_lib_directory.join(arena, &[_][]const u8{
340 "libc",
341 "wasi",
342 "libc-bottom-half",
343 "headers",
344 "private",
345 }),
346
347 "-I",
348 try comp.zig_lib_directory.join(arena, &[_][]const u8{
349 "libc",
350 "wasi",
351 "libc-bottom-half",
352 "cloudlibc",
353 "src",
354 "include",
355 }),
356
357 "-I",
358 try comp.zig_lib_directory.join(arena, &[_][]const u8{
359 "libc",
360 "wasi",
361 "libc-bottom-half",
362 "cloudlibc",
363 "src",
364 }),
365
366 "-I",
367 try comp.zig_lib_directory.join(arena, &[_][]const u8{
368 "libc",
369 "wasi",
370 "libc-top-half",
371 "musl",
372 "src",
373 "include",
374 }),
375
376 "-I",
377 try comp.zig_lib_directory.join(arena, &[_][]const u8{
378 "libc",
379 "musl",
380 "src",
381 "include",
382 }),
383
384 "-I",
385 try comp.zig_lib_directory.join(arena, &[_][]const u8{
386 "libc",
387 "wasi",
388 "libc-top-half",
389 "musl",
390 "src",
391 "internal",
392 }),
393
394 "-I",
395 try comp.zig_lib_directory.join(arena, &[_][]const u8{
396 "libc",
397 "musl",
398 "src",
399 "internal",
400 }),
401 });
402}
403
404fn addLibcTopHalfIncludes(
405 comp: *Compilation,
406 arena: Allocator,
407 args: *std.ArrayList([]const u8),
408) error{OutOfMemory}!void {
409 try args.appendSlice(&[_][]const u8{
410 "-I",
411 try comp.zig_lib_directory.join(arena, &[_][]const u8{
412 "libc",
413 "wasi",
414 "libc-top-half",
415 "musl",
416 "src",
417 "include",
418 }),
419
420 "-I",
421 try comp.zig_lib_directory.join(arena, &[_][]const u8{
422 "libc",
423 "musl",
424 "src",
425 "include",
426 }),
427
428 "-I",
429 try comp.zig_lib_directory.join(arena, &[_][]const u8{
430 "libc",
431 "wasi",
432 "libc-top-half",
433 "musl",
434 "src",
435 "internal",
436 }),
437
438 "-I",
439 try comp.zig_lib_directory.join(arena, &[_][]const u8{
440 "libc",
441 "musl",
442 "src",
443 "internal",
444 }),
445
446 "-I",
447 try comp.zig_lib_directory.join(arena, &[_][]const u8{
448 "libc",
449 "wasi",
450 "libc-top-half",
451 "musl",
452 "arch",
453 "wasm32",
454 }),
455
456 "-I",
457 try comp.zig_lib_directory.join(arena, &[_][]const u8{
458 "libc",
459 "musl",
460 "arch",
461 "generic",
462 }),
463
464 "-I",
465 try comp.zig_lib_directory.join(arena, &[_][]const u8{
466 "libc",
467 "wasi",
468 "libc-top-half",
469 "headers",
470 "private",
471 }),
472 });
473}
474
475const emmalloc_src_files = [_][]const u8{
476 "wasi/emmalloc/emmalloc.c",
477};
478
479const libc_bottom_half_src_files = [_][]const u8{
480 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/closedir.c",
481 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/dirfd.c",
482 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdclosedir.c",
483 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c",
484 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/opendirat.c",
485 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c",
486 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/rewinddir.c",
487 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/scandirat.c",
488 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/seekdir.c",
489 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/telldir.c",
490 "wasi/libc-bottom-half/cloudlibc/src/libc/errno/errno.c",
491 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c",
492 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c",
493 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fadvise.c",
494 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fallocate.c",
495 "wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c",
496 "wasi/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c",
497 "wasi/libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c",
498 "wasi/libc-bottom-half/cloudlibc/src/libc/stdlib/_Exit.c",
499 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c",
500 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c",
501 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/select.c",
502 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/getsockopt.c",
503 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c",
504 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c",
505 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c",
506 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstat.c",
507 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c",
508 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/futimens.c",
509 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c",
510 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c",
511 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/time/gettimeofday.c",
512 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c",
513 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c",
514 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/readv.c",
515 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/writev.c",
516 "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_MONOTONIC.c",
517 "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_REALTIME.c",
518 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_getres.c",
519 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_gettime.c",
520 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c",
521 "wasi/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c",
522 "wasi/libc-bottom-half/cloudlibc/src/libc/time/time.c",
523 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c",
524 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fdatasync.c",
525 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fsync.c",
526 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/ftruncate.c",
527 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c",
528 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c",
529 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pread.c",
530 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c",
531 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/read.c",
532 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c",
533 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/sleep.c",
534 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c",
535 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c",
536 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/usleep.c",
537 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/write.c",
538 "wasi/libc-bottom-half/sources/__errno_location.c",
539 "wasi/libc-bottom-half/sources/__main_void.c",
540 "wasi/libc-bottom-half/sources/__wasilibc_dt.c",
541 "wasi/libc-bottom-half/sources/__wasilibc_environ.c",
542 "wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c",
543 "wasi/libc-bottom-half/sources/__wasilibc_initialize_environ.c",
544 "wasi/libc-bottom-half/sources/__wasilibc_real.c",
545 "wasi/libc-bottom-half/sources/__wasilibc_rmdirat.c",
546 "wasi/libc-bottom-half/sources/__wasilibc_tell.c",
547 "wasi/libc-bottom-half/sources/__wasilibc_unlinkat.c",
548 "wasi/libc-bottom-half/sources/abort.c",
549 "wasi/libc-bottom-half/sources/accept-wasip1.c",
550 "wasi/libc-bottom-half/sources/at_fdcwd.c",
551 "wasi/libc-bottom-half/sources/complex-builtins.c",
552 "wasi/libc-bottom-half/sources/environ.c",
553 "wasi/libc-bottom-half/sources/errno.c",
554 "wasi/libc-bottom-half/sources/getcwd.c",
555 "wasi/libc-bottom-half/sources/getentropy.c",
556 "wasi/libc-bottom-half/sources/isatty.c",
557 "wasi/libc-bottom-half/sources/math/fmin-fmax.c",
558 "wasi/libc-bottom-half/sources/math/math-builtins.c",
559 "wasi/libc-bottom-half/sources/posix.c",
560 "wasi/libc-bottom-half/sources/preopens.c",
561 "wasi/libc-bottom-half/sources/reallocarray.c",
562 "wasi/libc-bottom-half/sources/sbrk.c",
563 "wasi/libc-bottom-half/sources/truncate.c",
564 "wasi/libc-bottom-half/sources/chdir.c",
565};
566
567const libc_top_half_src_files = [_][]const u8{
568 "musl/src/complex/cabs.c",
569 "musl/src/complex/cabsf.c",
570 "musl/src/complex/cabsl.c",
571 "musl/src/complex/cacos.c",
572 "musl/src/complex/cacosf.c",
573 "musl/src/complex/cacosh.c",
574 "musl/src/complex/cacoshf.c",
575 "musl/src/complex/cacoshl.c",
576 "musl/src/complex/cacosl.c",
577 "musl/src/complex/carg.c",
578 "musl/src/complex/cargf.c",
579 "musl/src/complex/cargl.c",
580 "musl/src/complex/casin.c",
581 "musl/src/complex/casinf.c",
582 "musl/src/complex/casinh.c",
583 "musl/src/complex/casinhf.c",
584 "musl/src/complex/casinhl.c",
585 "musl/src/complex/casinl.c",
586 "musl/src/complex/catan.c",
587 "musl/src/complex/catanf.c",
588 "musl/src/complex/catanh.c",
589 "musl/src/complex/catanhf.c",
590 "musl/src/complex/catanhl.c",
591 "musl/src/complex/catanl.c",
592 "musl/src/complex/ccos.c",
593 "musl/src/complex/ccosf.c",
594 "musl/src/complex/ccosh.c",
595 "musl/src/complex/ccoshf.c",
596 "musl/src/complex/ccoshl.c",
597 "musl/src/complex/ccosl.c",
598 "musl/src/complex/__cexp.c",
599 "musl/src/complex/cexp.c",
600 "musl/src/complex/__cexpf.c",
601 "musl/src/complex/cexpf.c",
602 "musl/src/complex/cexpl.c",
603 "musl/src/complex/clog.c",
604 "musl/src/complex/clogf.c",
605 "musl/src/complex/clogl.c",
606 "musl/src/complex/conj.c",
607 "musl/src/complex/conjf.c",
608 "musl/src/complex/conjl.c",
609 "musl/src/complex/cpow.c",
610 "musl/src/complex/cpowf.c",
611 "musl/src/complex/cpowl.c",
612 "musl/src/complex/cproj.c",
613 "musl/src/complex/cprojf.c",
614 "musl/src/complex/cprojl.c",
615 "musl/src/complex/csin.c",
616 "musl/src/complex/csinf.c",
617 "musl/src/complex/csinh.c",
618 "musl/src/complex/csinhf.c",
619 "musl/src/complex/csinhl.c",
620 "musl/src/complex/csinl.c",
621 "musl/src/complex/csqrt.c",
622 "musl/src/complex/csqrtf.c",
623 "musl/src/complex/csqrtl.c",
624 "musl/src/complex/ctan.c",
625 "musl/src/complex/ctanf.c",
626 "musl/src/complex/ctanh.c",
627 "musl/src/complex/ctanhf.c",
628 "musl/src/complex/ctanhl.c",
629 "musl/src/complex/ctanl.c",
630 "musl/src/conf/legacy.c",
631 "musl/src/conf/pathconf.c",
632 "musl/src/crypt/crypt_blowfish.c",
633 "musl/src/crypt/crypt.c",
634 "musl/src/crypt/crypt_des.c",
635 "musl/src/crypt/crypt_md5.c",
636 "musl/src/crypt/crypt_r.c",
637 "musl/src/crypt/crypt_sha256.c",
638 "musl/src/crypt/crypt_sha512.c",
639 "musl/src/crypt/encrypt.c",
640 "musl/src/ctype/__ctype_b_loc.c",
641 "musl/src/ctype/__ctype_get_mb_cur_max.c",
642 "musl/src/ctype/__ctype_tolower_loc.c",
643 "musl/src/ctype/__ctype_toupper_loc.c",
644 "musl/src/ctype/isalnum.c",
645 "musl/src/ctype/isalpha.c",
646 "musl/src/ctype/isascii.c",
647 "musl/src/ctype/isblank.c",
648 "musl/src/ctype/iscntrl.c",
649 "musl/src/ctype/isdigit.c",
650 "musl/src/ctype/isgraph.c",
651 "musl/src/ctype/islower.c",
652 "musl/src/ctype/isprint.c",
653 "musl/src/ctype/ispunct.c",
654 "musl/src/ctype/isspace.c",
655 "musl/src/ctype/isupper.c",
656 "musl/src/ctype/iswalnum.c",
657 "musl/src/ctype/iswalpha.c",
658 "musl/src/ctype/iswblank.c",
659 "musl/src/ctype/iswcntrl.c",
660 "musl/src/ctype/iswctype.c",
661 "musl/src/ctype/iswdigit.c",
662 "musl/src/ctype/iswgraph.c",
663 "musl/src/ctype/iswlower.c",
664 "musl/src/ctype/iswprint.c",
665 "musl/src/ctype/iswpunct.c",
666 "musl/src/ctype/iswspace.c",
667 "musl/src/ctype/iswupper.c",
668 "musl/src/ctype/iswxdigit.c",
669 "musl/src/ctype/isxdigit.c",
670 "musl/src/ctype/toascii.c",
671 "musl/src/ctype/tolower.c",
672 "musl/src/ctype/toupper.c",
673 "musl/src/ctype/towctrans.c",
674 "musl/src/ctype/wcswidth.c",
675 "musl/src/ctype/wctrans.c",
676 "musl/src/ctype/wcwidth.c",
677 "musl/src/env/setenv.c",
678 "musl/src/exit/assert.c",
679 "musl/src/exit/quick_exit.c",
680 "musl/src/fenv/fegetexceptflag.c",
681 "musl/src/fenv/feholdexcept.c",
682 "musl/src/fenv/fenv.c",
683 "musl/src/fenv/fesetexceptflag.c",
684 "musl/src/fenv/fesetround.c",
685 "musl/src/fenv/feupdateenv.c",
686 "musl/src/legacy/getpagesize.c",
687 "musl/src/locale/c_locale.c",
688 "musl/src/locale/duplocale.c",
689 "musl/src/locale/freelocale.c",
690 "musl/src/locale/iconv.c",
691 "musl/src/locale/iconv_close.c",
692 "musl/src/locale/langinfo.c",
693 "musl/src/locale/__lctrans.c",
694 "musl/src/locale/localeconv.c",
695 "musl/src/locale/__mo_lookup.c",
696 "musl/src/locale/pleval.c",
697 "musl/src/locale/setlocale.c",
698 "musl/src/locale/strcoll.c",
699 "musl/src/locale/strfmon.c",
700 "musl/src/locale/strtod_l.c",
701 "musl/src/locale/strxfrm.c",
702 "musl/src/locale/wcscoll.c",
703 "musl/src/locale/wcsxfrm.c",
704 "musl/src/math/acos.c",
705 "musl/src/math/acosf.c",
706 "musl/src/math/acosh.c",
707 "musl/src/math/acoshf.c",
708 "musl/src/math/acoshl.c",
709 "musl/src/math/acosl.c",
710 "musl/src/math/asin.c",
711 "musl/src/math/asinf.c",
712 "musl/src/math/asinh.c",
713 "musl/src/math/asinhf.c",
714 "musl/src/math/asinhl.c",
715 "musl/src/math/asinl.c",
716 "musl/src/math/atan2.c",
717 "musl/src/math/atan2f.c",
718 "musl/src/math/atan2l.c",
719 "musl/src/math/atan.c",
720 "musl/src/math/atanf.c",
721 "musl/src/math/atanh.c",
722 "musl/src/math/atanhf.c",
723 "musl/src/math/atanhl.c",
724 "musl/src/math/atanl.c",
725 "musl/src/math/cbrt.c",
726 "musl/src/math/cbrtf.c",
727 "musl/src/math/cbrtl.c",
728 "musl/src/math/ceill.c",
729 "musl/src/math/copysignl.c",
730 "musl/src/math/__cos.c",
731 "musl/src/math/cos.c",
732 "musl/src/math/__cosdf.c",
733 "musl/src/math/cosf.c",
734 "musl/src/math/coshl.c",
735 "musl/src/math/__cosl.c",
736 "musl/src/math/cosl.c",
737 "musl/src/math/erf.c",
738 "musl/src/math/erff.c",
739 "musl/src/math/erfl.c",
740 "musl/src/math/exp10.c",
741 "musl/src/math/exp10f.c",
742 "musl/src/math/exp10l.c",
743 "musl/src/math/exp2.c",
744 "musl/src/math/exp2f.c",
745 "musl/src/math/exp2f_data.c",
746 "musl/src/math/exp2l.c",
747 "musl/src/math/exp.c",
748 "musl/src/math/exp_data.c",
749 "musl/src/math/expf.c",
750 "musl/src/math/expl.c",
751 "musl/src/math/expm1.c",
752 "musl/src/math/expm1f.c",
753 "musl/src/math/expm1l.c",
754 "musl/src/math/fabsl.c",
755 "musl/src/math/fdim.c",
756 "musl/src/math/fdimf.c",
757 "musl/src/math/fdiml.c",
758 "musl/src/math/finite.c",
759 "musl/src/math/finitef.c",
760 "musl/src/math/floorl.c",
761 "musl/src/math/fma.c",
762 "musl/src/math/fmaf.c",
763 "musl/src/math/fmaxl.c",
764 "musl/src/math/fminl.c",
765 "musl/src/math/fmod.c",
766 "musl/src/math/fmodf.c",
767 "musl/src/math/fmodl.c",
768 "musl/src/math/frexp.c",
769 "musl/src/math/frexpf.c",
770 "musl/src/math/frexpl.c",
771 "musl/src/math/hypot.c",
772 "musl/src/math/hypotf.c",
773 "musl/src/math/hypotl.c",
774 "musl/src/math/ilogb.c",
775 "musl/src/math/ilogbf.c",
776 "musl/src/math/ilogbl.c",
777 "musl/src/math/__invtrigl.c",
778 "musl/src/math/j0.c",
779 "musl/src/math/j0f.c",
780 "musl/src/math/j1.c",
781 "musl/src/math/j1f.c",
782 "musl/src/math/jn.c",
783 "musl/src/math/jnf.c",
784 "musl/src/math/ldexp.c",
785 "musl/src/math/ldexpf.c",
786 "musl/src/math/ldexpl.c",
787 "musl/src/math/lgamma.c",
788 "musl/src/math/lgammaf.c",
789 "musl/src/math/lgammaf_r.c",
790 "musl/src/math/lgammal.c",
791 "musl/src/math/lgamma_r.c",
792 "musl/src/math/llrint.c",
793 "musl/src/math/llrintf.c",
794 "musl/src/math/llrintl.c",
795 "musl/src/math/llround.c",
796 "musl/src/math/llroundf.c",
797 "musl/src/math/llroundl.c",
798 "musl/src/math/log10.c",
799 "musl/src/math/log10f.c",
800 "musl/src/math/log10l.c",
801 "musl/src/math/log1p.c",
802 "musl/src/math/log1pf.c",
803 "musl/src/math/log1pl.c",
804 "musl/src/math/log2.c",
805 "musl/src/math/log2_data.c",
806 "musl/src/math/log2f.c",
807 "musl/src/math/log2f_data.c",
808 "musl/src/math/log2l.c",
809 "musl/src/math/logb.c",
810 "musl/src/math/logbf.c",
811 "musl/src/math/logbl.c",
812 "musl/src/math/log.c",
813 "musl/src/math/log_data.c",
814 "musl/src/math/logf.c",
815 "musl/src/math/logf_data.c",
816 "musl/src/math/logl.c",
817 "musl/src/math/lrint.c",
818 "musl/src/math/lrintf.c",
819 "musl/src/math/lrintl.c",
820 "musl/src/math/lround.c",
821 "musl/src/math/lroundf.c",
822 "musl/src/math/lroundl.c",
823 "musl/src/math/__math_divzero.c",
824 "musl/src/math/__math_divzerof.c",
825 "musl/src/math/__math_invalid.c",
826 "musl/src/math/__math_invalidf.c",
827 "musl/src/math/__math_invalidl.c",
828 "musl/src/math/__math_oflow.c",
829 "musl/src/math/__math_oflowf.c",
830 "musl/src/math/__math_uflow.c",
831 "musl/src/math/__math_uflowf.c",
832 "musl/src/math/__math_xflow.c",
833 "musl/src/math/__math_xflowf.c",
834 "musl/src/math/modf.c",
835 "musl/src/math/modff.c",
836 "musl/src/math/modfl.c",
837 "musl/src/math/nan.c",
838 "musl/src/math/nanf.c",
839 "musl/src/math/nanl.c",
840 "musl/src/math/nearbyintl.c",
841 "musl/src/math/nextafter.c",
842 "musl/src/math/nextafterf.c",
843 "musl/src/math/nextafterl.c",
844 "musl/src/math/nexttoward.c",
845 "musl/src/math/nexttowardf.c",
846 "musl/src/math/nexttowardl.c",
847 "musl/src/math/__polevll.c",
848 "musl/src/math/pow.c",
849 "musl/src/math/pow_data.c",
850 "musl/src/math/powf.c",
851 "musl/src/math/powf_data.c",
852 "musl/src/math/remainder.c",
853 "musl/src/math/remainderf.c",
854 "musl/src/math/remainderl.c",
855 "musl/src/math/__rem_pio2_large.c",
856 "musl/src/math/remquo.c",
857 "musl/src/math/remquof.c",
858 "musl/src/math/remquol.c",
859 "musl/src/math/rintl.c",
860 "musl/src/math/round.c",
861 "musl/src/math/roundf.c",
862 "musl/src/math/roundl.c",
863 "musl/src/math/scalb.c",
864 "musl/src/math/scalbf.c",
865 "musl/src/math/scalbln.c",
866 "musl/src/math/scalblnf.c",
867 "musl/src/math/scalblnl.c",
868 "musl/src/math/scalbn.c",
869 "musl/src/math/scalbnf.c",
870 "musl/src/math/scalbnl.c",
871 "musl/src/math/signgam.c",
872 "musl/src/math/significand.c",
873 "musl/src/math/significandf.c",
874 "musl/src/math/__sin.c",
875 "musl/src/math/sin.c",
876 "musl/src/math/sincos.c",
877 "musl/src/math/sincosf.c",
878 "musl/src/math/sincosl.c",
879 "musl/src/math/__sindf.c",
880 "musl/src/math/sinf.c",
881 "musl/src/math/sinhl.c",
882 "musl/src/math/__sinl.c",
883 "musl/src/math/sinl.c",
884 "musl/src/math/sqrt_data.c",
885 "musl/src/math/sqrtl.c",
886 "musl/src/math/__tan.c",
887 "musl/src/math/tan.c",
888 "musl/src/math/__tandf.c",
889 "musl/src/math/tanf.c",
890 "musl/src/math/tanh.c",
891 "musl/src/math/tanhf.c",
892 "musl/src/math/tanhl.c",
893 "musl/src/math/__tanl.c",
894 "musl/src/math/tanl.c",
895 "musl/src/math/tgamma.c",
896 "musl/src/math/tgammaf.c",
897 "musl/src/math/tgammal.c",
898 "musl/src/math/truncl.c",
899 "musl/src/misc/a64l.c",
900 "musl/src/misc/basename.c",
901 "musl/src/misc/dirname.c",
902 "musl/src/misc/ffs.c",
903 "musl/src/misc/ffsl.c",
904 "musl/src/misc/ffsll.c",
905 "musl/src/misc/getdomainname.c",
906 "musl/src/misc/gethostid.c",
907 "musl/src/misc/getopt.c",
908 "musl/src/misc/getopt_long.c",
909 "musl/src/misc/getsubopt.c",
910 "musl/src/misc/realpath.c",
911 "musl/src/multibyte/btowc.c",
912 "musl/src/multibyte/c16rtomb.c",
913 "musl/src/multibyte/c32rtomb.c",
914 "musl/src/multibyte/internal.c",
915 "musl/src/multibyte/mblen.c",
916 "musl/src/multibyte/mbrlen.c",
917 "musl/src/multibyte/mbrtoc16.c",
918 "musl/src/multibyte/mbrtoc32.c",
919 "musl/src/multibyte/mbrtowc.c",
920 "musl/src/multibyte/mbsinit.c",
921 "musl/src/multibyte/mbsnrtowcs.c",
922 "musl/src/multibyte/mbsrtowcs.c",
923 "musl/src/multibyte/mbstowcs.c",
924 "musl/src/multibyte/mbtowc.c",
925 "musl/src/multibyte/wcrtomb.c",
926 "musl/src/multibyte/wcsnrtombs.c",
927 "musl/src/multibyte/wcsrtombs.c",
928 "musl/src/multibyte/wcstombs.c",
929 "musl/src/multibyte/wctob.c",
930 "musl/src/multibyte/wctomb.c",
931 "musl/src/network/htonl.c",
932 "musl/src/network/htons.c",
933 "musl/src/network/in6addr_any.c",
934 "musl/src/network/in6addr_loopback.c",
935 "musl/src/network/inet_aton.c",
936 "musl/src/network/inet_ntop.c",
937 "musl/src/network/inet_pton.c",
938 "musl/src/network/ntohl.c",
939 "musl/src/network/ntohs.c",
940 "musl/src/prng/drand48.c",
941 "musl/src/prng/lcong48.c",
942 "musl/src/prng/lrand48.c",
943 "musl/src/prng/mrand48.c",
944 "musl/src/prng/__rand48_step.c",
945 "musl/src/prng/rand.c",
946 "musl/src/prng/rand_r.c",
947 "musl/src/prng/__seed48.c",
948 "musl/src/prng/seed48.c",
949 "musl/src/prng/srand48.c",
950 "musl/src/regex/fnmatch.c",
951 "musl/src/regex/regerror.c",
952 "musl/src/search/hsearch.c",
953 "musl/src/search/insque.c",
954 "musl/src/search/lsearch.c",
955 "musl/src/search/tdelete.c",
956 "musl/src/search/tdestroy.c",
957 "musl/src/search/tfind.c",
958 "musl/src/search/tsearch.c",
959 "musl/src/search/twalk.c",
960 "musl/src/stdio/asprintf.c",
961 "musl/src/stdio/clearerr.c",
962 "musl/src/stdio/dprintf.c",
963 "musl/src/stdio/ext2.c",
964 "musl/src/stdio/ext.c",
965 "musl/src/stdio/fclose.c",
966 "musl/src/stdio/__fclose_ca.c",
967 "musl/src/stdio/feof.c",
968 "musl/src/stdio/ferror.c",
969 "musl/src/stdio/fflush.c",
970 "musl/src/stdio/fgetln.c",
971 "musl/src/stdio/fgets.c",
972 "musl/src/stdio/fgetwc.c",
973 "musl/src/stdio/fgetws.c",
974 "musl/src/stdio/fileno.c",
975 "musl/src/stdio/__fmodeflags.c",
976 "musl/src/stdio/fopencookie.c",
977 "musl/src/stdio/fprintf.c",
978 "musl/src/stdio/fputs.c",
979 "musl/src/stdio/fputwc.c",
980 "musl/src/stdio/fputws.c",
981 "musl/src/stdio/fread.c",
982 "musl/src/stdio/fscanf.c",
983 "musl/src/stdio/fwide.c",
984 "musl/src/stdio/fwprintf.c",
985 "musl/src/stdio/fwrite.c",
986 "musl/src/stdio/fwscanf.c",
987 "musl/src/stdio/getchar_unlocked.c",
988 "musl/src/stdio/getc_unlocked.c",
989 "musl/src/stdio/getdelim.c",
990 "musl/src/stdio/getline.c",
991 "musl/src/stdio/getw.c",
992 "musl/src/stdio/getwc.c",
993 "musl/src/stdio/getwchar.c",
994 "musl/src/stdio/ofl_add.c",
995 "musl/src/stdio/__overflow.c",
996 "musl/src/stdio/perror.c",
997 "musl/src/stdio/putchar_unlocked.c",
998 "musl/src/stdio/putc_unlocked.c",
999 "musl/src/stdio/puts.c",
1000 "musl/src/stdio/putw.c",
1001 "musl/src/stdio/putwc.c",
1002 "musl/src/stdio/putwchar.c",
1003 "musl/src/stdio/rewind.c",
1004 "musl/src/stdio/scanf.c",
1005 "musl/src/stdio/setbuf.c",
1006 "musl/src/stdio/setbuffer.c",
1007 "musl/src/stdio/setlinebuf.c",
1008 "musl/src/stdio/setvbuf.c",
1009 "musl/src/stdio/snprintf.c",
1010 "musl/src/stdio/sprintf.c",
1011 "musl/src/stdio/sscanf.c",
1012 "musl/src/stdio/__stdio_exit.c",
1013 "musl/src/stdio/swprintf.c",
1014 "musl/src/stdio/swscanf.c",
1015 "musl/src/stdio/__toread.c",
1016 "musl/src/stdio/__towrite.c",
1017 "musl/src/stdio/__uflow.c",
1018 "musl/src/stdio/ungetwc.c",
1019 "musl/src/stdio/vasprintf.c",
1020 "musl/src/stdio/vprintf.c",
1021 "musl/src/stdio/vscanf.c",
1022 "musl/src/stdio/vsprintf.c",
1023 "musl/src/stdio/vwprintf.c",
1024 "musl/src/stdio/vwscanf.c",
1025 "musl/src/stdio/wprintf.c",
1026 "musl/src/stdio/wscanf.c",
1027 "musl/src/stdlib/abs.c",
1028 "musl/src/stdlib/atof.c",
1029 "musl/src/stdlib/atoi.c",
1030 "musl/src/stdlib/atol.c",
1031 "musl/src/stdlib/atoll.c",
1032 "musl/src/stdlib/bsearch.c",
1033 "musl/src/stdlib/div.c",
1034 "musl/src/stdlib/ecvt.c",
1035 "musl/src/stdlib/fcvt.c",
1036 "musl/src/stdlib/gcvt.c",
1037 "musl/src/stdlib/imaxabs.c",
1038 "musl/src/stdlib/imaxdiv.c",
1039 "musl/src/stdlib/labs.c",
1040 "musl/src/stdlib/ldiv.c",
1041 "musl/src/stdlib/llabs.c",
1042 "musl/src/stdlib/lldiv.c",
1043 "musl/src/stdlib/qsort.c",
1044 "musl/src/stdlib/qsort_nr.c",
1045 "musl/src/string/bcmp.c",
1046 "musl/src/string/bcopy.c",
1047 "musl/src/string/explicit_bzero.c",
1048 "musl/src/string/index.c",
1049 "musl/src/string/memccpy.c",
1050 "musl/src/string/memchr.c",
1051 "musl/src/string/memcmp.c",
1052 "musl/src/string/memmem.c",
1053 "musl/src/string/mempcpy.c",
1054 "musl/src/string/memrchr.c",
1055 "musl/src/string/rindex.c",
1056 "musl/src/string/stpcpy.c",
1057 "musl/src/string/stpncpy.c",
1058 "musl/src/string/strcasecmp.c",
1059 "musl/src/string/strcasestr.c",
1060 "musl/src/string/strcat.c",
1061 "musl/src/string/strchr.c",
1062 "musl/src/string/strchrnul.c",
1063 "musl/src/string/strcpy.c",
1064 "musl/src/string/strcspn.c",
1065 "musl/src/string/strdup.c",
1066 "musl/src/string/strerror_r.c",
1067 "musl/src/string/strlcat.c",
1068 "musl/src/string/strlcpy.c",
1069 "musl/src/string/strncasecmp.c",
1070 "musl/src/string/strncat.c",
1071 "musl/src/string/strncpy.c",
1072 "musl/src/string/strndup.c",
1073 "musl/src/string/strnlen.c",
1074 "musl/src/string/strpbrk.c",
1075 "musl/src/string/strrchr.c",
1076 "musl/src/string/strsep.c",
1077 "musl/src/string/strspn.c",
1078 "musl/src/string/strstr.c",
1079 "musl/src/string/strtok.c",
1080 "musl/src/string/strtok_r.c",
1081 "musl/src/string/strverscmp.c",
1082 "musl/src/string/swab.c",
1083 "musl/src/string/wcpcpy.c",
1084 "musl/src/string/wcpncpy.c",
1085 "musl/src/string/wcscasecmp.c",
1086 "musl/src/string/wcscasecmp_l.c",
1087 "musl/src/string/wcscat.c",
1088 "musl/src/string/wcschr.c",
1089 "musl/src/string/wcscmp.c",
1090 "musl/src/string/wcscpy.c",
1091 "musl/src/string/wcscspn.c",
1092 "musl/src/string/wcsdup.c",
1093 "musl/src/string/wcslen.c",
1094 "musl/src/string/wcsncasecmp.c",
1095 "musl/src/string/wcsncasecmp_l.c",
1096 "musl/src/string/wcsncat.c",
1097 "musl/src/string/wcsncmp.c",
1098 "musl/src/string/wcsncpy.c",
1099 "musl/src/string/wcsnlen.c",
1100 "musl/src/string/wcspbrk.c",
1101 "musl/src/string/wcsrchr.c",
1102 "musl/src/string/wcsspn.c",
1103 "musl/src/string/wcsstr.c",
1104 "musl/src/string/wcstok.c",
1105 "musl/src/string/wcswcs.c",
1106 "musl/src/string/wmemchr.c",
1107 "musl/src/string/wmemcmp.c",
1108 "musl/src/string/wmemcpy.c",
1109 "musl/src/string/wmemmove.c",
1110 "musl/src/string/wmemset.c",
1111 "musl/src/thread/thrd_sleep.c",
1112 "musl/src/time/asctime.c",
1113 "musl/src/time/asctime_r.c",
1114 "musl/src/time/ctime.c",
1115 "musl/src/time/ctime_r.c",
1116 "musl/src/time/difftime.c",
1117 "musl/src/time/ftime.c",
1118 "musl/src/time/__month_to_secs.c",
1119 "musl/src/time/strptime.c",
1120 "musl/src/time/timespec_get.c",
1121 "musl/src/time/__year_to_secs.c",
1122 "musl/src/unistd/posix_close.c",
1123
1124 "wasi/libc-top-half/musl/src/conf/confstr.c",
1125 "wasi/libc-top-half/musl/src/conf/fpathconf.c",
1126 "wasi/libc-top-half/musl/src/conf/sysconf.c",
1127 "wasi/libc-top-half/musl/src/dirent/alphasort.c",
1128 "wasi/libc-top-half/musl/src/dirent/versionsort.c",
1129 "wasi/libc-top-half/musl/src/env/clearenv.c",
1130 "wasi/libc-top-half/musl/src/env/getenv.c",
1131 "wasi/libc-top-half/musl/src/env/putenv.c",
1132 "wasi/libc-top-half/musl/src/env/__stack_chk_fail.c",
1133 "wasi/libc-top-half/musl/src/env/unsetenv.c",
1134 "wasi/libc-top-half/musl/src/errno/strerror.c",
1135 "wasi/libc-top-half/musl/src/exit/atexit.c",
1136 "wasi/libc-top-half/musl/src/exit/at_quick_exit.c",
1137 "wasi/libc-top-half/musl/src/exit/exit.c",
1138 "wasi/libc-top-half/musl/src/fcntl/creat.c",
1139 "wasi/libc-top-half/musl/src/internal/defsysinfo.c",
1140 "wasi/libc-top-half/musl/src/internal/floatscan.c",
1141 "wasi/libc-top-half/musl/src/internal/intscan.c",
1142 "wasi/libc-top-half/musl/src/internal/libc.c",
1143 "wasi/libc-top-half/musl/src/internal/shgetc.c",
1144 "wasi/libc-top-half/musl/src/locale/catclose.c",
1145 "wasi/libc-top-half/musl/src/locale/catgets.c",
1146 "wasi/libc-top-half/musl/src/locale/catopen.c",
1147 "wasi/libc-top-half/musl/src/locale/locale_map.c",
1148 "wasi/libc-top-half/musl/src/locale/newlocale.c",
1149 "wasi/libc-top-half/musl/src/locale/uselocale.c",
1150 "wasi/libc-top-half/musl/src/math/cosh.c",
1151 "wasi/libc-top-half/musl/src/math/coshf.c",
1152 "wasi/libc-top-half/musl/src/math/__expo2.c",
1153 "wasi/libc-top-half/musl/src/math/__expo2f.c",
1154 "wasi/libc-top-half/musl/src/math/fmal.c",
1155 "wasi/libc-top-half/musl/src/math/powl.c",
1156 "wasi/libc-top-half/musl/src/math/__rem_pio2.c",
1157 "wasi/libc-top-half/musl/src/math/__rem_pio2f.c",
1158 "wasi/libc-top-half/musl/src/math/__rem_pio2l.c",
1159 "wasi/libc-top-half/musl/src/math/sinh.c",
1160 "wasi/libc-top-half/musl/src/math/sinhf.c",
1161 "wasi/libc-top-half/musl/src/misc/fmtmsg.c",
1162 "wasi/libc-top-half/musl/src/misc/nftw.c",
1163 "wasi/libc-top-half/musl/src/misc/uname.c",
1164 "wasi/libc-top-half/musl/src/prng/random.c",
1165 "wasi/libc-top-half/musl/src/regex/regcomp.c",
1166 "wasi/libc-top-half/musl/src/regex/regexec.c",
1167 "wasi/libc-top-half/musl/src/regex/glob.c",
1168 "wasi/libc-top-half/musl/src/regex/tre-mem.c",
1169 "wasi/libc-top-half/musl/src/stat/futimesat.c",
1170 "wasi/libc-top-half/musl/src/stdio/__fdopen.c",
1171 "wasi/libc-top-half/musl/src/stdio/fgetc.c",
1172 "wasi/libc-top-half/musl/src/stdio/fgetpos.c",
1173 "wasi/libc-top-half/musl/src/stdio/fmemopen.c",
1174 "wasi/libc-top-half/musl/src/stdio/fopen.c",
1175 "wasi/libc-top-half/musl/src/stdio/__fopen_rb_ca.c",
1176 "wasi/libc-top-half/musl/src/stdio/fputc.c",
1177 "wasi/libc-top-half/musl/src/stdio/freopen.c",
1178 "wasi/libc-top-half/musl/src/stdio/fseek.c",
1179 "wasi/libc-top-half/musl/src/stdio/fsetpos.c",
1180 "wasi/libc-top-half/musl/src/stdio/ftell.c",
1181 "wasi/libc-top-half/musl/src/stdio/getc.c",
1182 "wasi/libc-top-half/musl/src/stdio/getchar.c",
1183 "wasi/libc-top-half/musl/src/stdio/ofl.c",
1184 "wasi/libc-top-half/musl/src/stdio/open_memstream.c",
1185 "wasi/libc-top-half/musl/src/stdio/open_wmemstream.c",
1186 "wasi/libc-top-half/musl/src/stdio/printf.c",
1187 "wasi/libc-top-half/musl/src/stdio/putc.c",
1188 "wasi/libc-top-half/musl/src/stdio/putchar.c",
1189 "wasi/libc-top-half/musl/src/stdio/stderr.c",
1190 "wasi/libc-top-half/musl/src/stdio/stdin.c",
1191 "wasi/libc-top-half/musl/src/stdio/__stdio_close.c",
1192 "wasi/libc-top-half/musl/src/stdio/__stdio_read.c",
1193 "wasi/libc-top-half/musl/src/stdio/__stdio_seek.c",
1194 "wasi/libc-top-half/musl/src/stdio/__stdio_write.c",
1195 "wasi/libc-top-half/musl/src/stdio/stdout.c",
1196 "wasi/libc-top-half/musl/src/stdio/__stdout_write.c",
1197 "wasi/libc-top-half/musl/src/stdio/ungetc.c",
1198 "wasi/libc-top-half/musl/src/stdio/vdprintf.c",
1199 "wasi/libc-top-half/musl/src/stdio/vfprintf.c",
1200 "wasi/libc-top-half/musl/src/stdio/vfscanf.c",
1201 "wasi/libc-top-half/musl/src/stdio/vfwprintf.c",
1202 "wasi/libc-top-half/musl/src/stdio/vfwscanf.c",
1203 "wasi/libc-top-half/musl/src/stdio/vsnprintf.c",
1204 "wasi/libc-top-half/musl/src/stdio/vsscanf.c",
1205 "wasi/libc-top-half/musl/src/stdio/vswprintf.c",
1206 "wasi/libc-top-half/musl/src/stdio/vswscanf.c",
1207 "wasi/libc-top-half/musl/src/stdlib/strtod.c",
1208 "wasi/libc-top-half/musl/src/stdlib/strtol.c",
1209 "wasi/libc-top-half/musl/src/stdlib/wcstod.c",
1210 "wasi/libc-top-half/musl/src/stdlib/wcstol.c",
1211 "wasi/libc-top-half/musl/src/string/memset.c",
1212 "wasi/libc-top-half/musl/src/time/getdate.c",
1213 "wasi/libc-top-half/musl/src/time/gmtime.c",
1214 "wasi/libc-top-half/musl/src/time/gmtime_r.c",
1215 "wasi/libc-top-half/musl/src/time/localtime.c",
1216 "wasi/libc-top-half/musl/src/time/localtime_r.c",
1217 "wasi/libc-top-half/musl/src/time/mktime.c",
1218 "wasi/libc-top-half/musl/src/time/__secs_to_tm.c",
1219 "wasi/libc-top-half/musl/src/time/strftime.c",
1220 "wasi/libc-top-half/musl/src/time/timegm.c",
1221 "wasi/libc-top-half/musl/src/time/__tm_to_secs.c",
1222 "wasi/libc-top-half/musl/src/time/__tz.c",
1223 "wasi/libc-top-half/musl/src/time/wcsftime.c",
1224
1225 "wasi/libc-top-half/sources/arc4random.c",
1226};
1227
1228const crt1_command_src_file = "wasi/libc-bottom-half/crt/crt1-command.c";
1229const crt1_reactor_src_file = "wasi/libc-bottom-half/crt/crt1-reactor.c";
1230
1231const emulated_dl_src_files = &[_][]const u8{
1232 "wasi/libc-top-half/musl/src/misc/dl.c",
1233};
1234
1235const emulated_process_clocks_src_files = &[_][]const u8{
1236 "wasi/libc-bottom-half/clocks/clock.c",
1237 "wasi/libc-bottom-half/clocks/getrusage.c",
1238 "wasi/libc-bottom-half/clocks/times.c",
1239};
1240
1241const emulated_getpid_src_files = &[_][]const u8{
1242 "wasi/libc-bottom-half/getpid/getpid.c",
1243};
1244
1245const emulated_mman_src_files = &[_][]const u8{
1246 "wasi/libc-bottom-half/mman/mman.c",
1247};
1248
1249const emulated_signal_bottom_half_src_files = &[_][]const u8{
1250 "wasi/libc-bottom-half/signal/signal.c",
1251};
1252
1253const emulated_signal_top_half_src_files = &[_][]const u8{
1254 "musl/src/signal/psignal.c",
1255 "musl/src/string/strsignal.c",
1256};
src/libtsan.zig deleted-499
...@@ -1,499 +0,0 @@
1const std = @import("std");
2const assert = std.debug.assert;
3
4const Compilation = @import("Compilation.zig");
5const build_options = @import("build_options");
6const trace = @import("tracy.zig").trace;
7const Module = @import("Package/Module.zig");
8
9pub const BuildError = error{
10 OutOfMemory,
11 SubCompilationFailed,
12 ZigCompilerNotBuiltWithLLVMExtensions,
13 TSANUnsupportedCPUArchitecture,
14};
15
16pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
17 if (!build_options.have_llvm) {
18 return error.ZigCompilerNotBuiltWithLLVMExtensions;
19 }
20
21 const tracy = trace(@src());
22 defer tracy.end();
23
24 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
25 defer arena_allocator.deinit();
26 const arena = arena_allocator.allocator();
27
28 const target = comp.getTarget();
29 const root_name = switch (target.os.tag) {
30 // On Apple platforms, we use the same name as LLVM because the
31 // TSAN library implementation hard-codes a check for these names.
32 .driverkit, .macos => "clang_rt.tsan_osx_dynamic",
33 .ios => if (target.abi == .simulator) "clang_rt.tsan_iossim_dynamic" else "clang_rt.tsan_ios_dynamic",
34 .tvos => if (target.abi == .simulator) "clang_rt.tsan_tvossim_dynamic" else "clang_rt.tsan_tvos_dynamic",
35 .visionos => if (target.abi == .simulator) "clang_rt.tsan_xrossim_dynamic" else "clang_rt.tsan_xros_dynamic",
36 .watchos => if (target.abi == .simulator) "clang_rt.tsan_watchossim_dynamic" else "clang_rt.tsan_watchos_dynamic",
37 else => "tsan",
38 };
39 const link_mode: std.builtin.LinkMode = if (target.os.tag.isDarwin()) .dynamic else .static;
40 const output_mode = .Lib;
41 const basename = try std.zig.binNameAlloc(arena, .{
42 .root_name = root_name,
43 .target = target,
44 .output_mode = output_mode,
45 .link_mode = link_mode,
46 });
47
48 const emit_bin = Compilation.EmitLoc{
49 .directory = null, // Put it in the cache directory.
50 .basename = basename,
51 };
52
53 const optimize_mode = comp.compilerRtOptMode();
54 const strip = comp.compilerRtStrip();
55 const unwind_tables: std.builtin.UnwindTables =
56 if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
57 const link_libcpp = target.os.tag.isDarwin();
58
59 const config = Compilation.Config.resolve(.{
60 .output_mode = output_mode,
61 .link_mode = link_mode,
62 .resolved_target = comp.root_mod.resolved_target,
63 .is_test = false,
64 .have_zcu = false,
65 .emit_bin = true,
66 .root_optimize_mode = optimize_mode,
67 .root_strip = strip,
68 .link_libc = true,
69 .link_libcpp = link_libcpp,
70 .any_unwind_tables = unwind_tables != .none,
71 // LLVM disables LTO for its libtsan.
72 .lto = .none,
73 }) catch |err| {
74 comp.setMiscFailure(
75 .libtsan,
76 "unable to build thread sanitizer runtime: resolving configuration failed: {s}",
77 .{@errorName(err)},
78 );
79 return error.SubCompilationFailed;
80 };
81
82 const common_flags = [_][]const u8{
83 "-DTSAN_CONTAINS_UBSAN=0",
84 };
85
86 const root_mod = Module.create(arena, .{
87 .global_cache_directory = comp.global_cache_directory,
88 .paths = .{
89 .root = .{ .root_dir = comp.zig_lib_directory },
90 .root_src_path = "",
91 },
92 .fully_qualified_name = "root",
93 .inherited = .{
94 .resolved_target = comp.root_mod.resolved_target,
95 .strip = strip,
96 .stack_check = false,
97 .stack_protector = 0,
98 .sanitize_c = .off,
99 .sanitize_thread = false,
100 .red_zone = comp.root_mod.red_zone,
101 .omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(),
102 .valgrind = false,
103 .unwind_tables = unwind_tables,
104 .optimize_mode = optimize_mode,
105 .structured_cfg = comp.root_mod.structured_cfg,
106 .pic = true,
107 .no_builtin = true,
108 .code_model = comp.root_mod.code_model,
109 },
110 .global = config,
111 .cc_argv = &common_flags,
112 .parent = null,
113 .builtin_mod = null,
114 .builtin_modules = null, // there is only one module in this compilation
115 }) catch |err| {
116 comp.setMiscFailure(
117 .libtsan,
118 "unable to build thread sanitizer runtime: creating module failed: {s}",
119 .{@errorName(err)},
120 );
121 return error.SubCompilationFailed;
122 };
123
124 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
125 try c_source_files.ensureUnusedCapacity(tsan_sources.len);
126
127 const tsan_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{"libtsan"});
128 for (tsan_sources) |tsan_src| {
129 var cflags = std.ArrayList([]const u8).init(arena);
130
131 try cflags.append("-I");
132 try cflags.append(tsan_include_path);
133
134 try addCcArgs(target, &cflags);
135
136 c_source_files.appendAssumeCapacity(.{
137 .src_path = try comp.zig_lib_directory.join(arena, &.{ "libtsan", tsan_src }),
138 .extra_flags = cflags.items,
139 .owner = root_mod,
140 });
141 }
142
143 const platform_tsan_sources = switch (target.os.tag) {
144 .ios, .macos, .watchos, .tvos, .visionos => &darwin_tsan_sources,
145 .windows => &windows_tsan_sources,
146 else => &unix_tsan_sources,
147 };
148 try c_source_files.ensureUnusedCapacity(platform_tsan_sources.len);
149 for (platform_tsan_sources) |tsan_src| {
150 var cflags = std.ArrayList([]const u8).init(arena);
151
152 try cflags.append("-I");
153 try cflags.append(tsan_include_path);
154
155 try addCcArgs(target, &cflags);
156
157 c_source_files.appendAssumeCapacity(.{
158 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", tsan_src }),
159 .extra_flags = cflags.items,
160 .owner = root_mod,
161 });
162 }
163 {
164 const asm_source = switch (target.cpu.arch) {
165 .aarch64, .aarch64_be => "tsan_rtl_aarch64.S",
166 .loongarch64 => "tsan_rtl_loongarch64.S",
167 .mips64, .mips64el => "tsan_rtl_mips64.S",
168 .powerpc64, .powerpc64le => "tsan_rtl_ppc64.S",
169 .riscv64 => "tsan_rtl_riscv64.S",
170 .s390x => "tsan_rtl_s390x.S",
171 .x86_64 => "tsan_rtl_amd64.S",
172 else => return error.TSANUnsupportedCPUArchitecture,
173 };
174 var cflags = std.ArrayList([]const u8).init(arena);
175
176 try cflags.append("-I");
177 try cflags.append(tsan_include_path);
178
179 try cflags.append("-DNDEBUG");
180
181 c_source_files.appendAssumeCapacity(.{
182 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libtsan", asm_source }),
183 .extra_flags = cflags.items,
184 .owner = root_mod,
185 });
186 }
187
188 try c_source_files.ensureUnusedCapacity(sanitizer_common_sources.len);
189 const sanitizer_common_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
190 "libtsan", "sanitizer_common",
191 });
192 for (sanitizer_common_sources) |common_src| {
193 var cflags = std.ArrayList([]const u8).init(arena);
194
195 try cflags.append("-I");
196 try cflags.append(sanitizer_common_include_path);
197 try cflags.append("-I");
198 try cflags.append(tsan_include_path);
199
200 try addCcArgs(target, &cflags);
201
202 c_source_files.appendAssumeCapacity(.{
203 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
204 "libtsan", "sanitizer_common", common_src,
205 }),
206 .extra_flags = cflags.items,
207 .owner = root_mod,
208 });
209 }
210
211 const to_c_or_not_to_c_sources = if (comp.config.link_libc)
212 &sanitizer_libcdep_sources
213 else
214 &sanitizer_nolibc_sources;
215 try c_source_files.ensureUnusedCapacity(to_c_or_not_to_c_sources.len);
216 for (to_c_or_not_to_c_sources) |c_src| {
217 var cflags = std.ArrayList([]const u8).init(arena);
218
219 try cflags.append("-I");
220 try cflags.append(sanitizer_common_include_path);
221 try cflags.append("-I");
222 try cflags.append(tsan_include_path);
223
224 try addCcArgs(target, &cflags);
225
226 c_source_files.appendAssumeCapacity(.{
227 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
228 "libtsan", "sanitizer_common", c_src,
229 }),
230 .extra_flags = cflags.items,
231 .owner = root_mod,
232 });
233 }
234
235 try c_source_files.ensureUnusedCapacity(sanitizer_symbolizer_sources.len);
236 for (sanitizer_symbolizer_sources) |c_src| {
237 var cflags = std.ArrayList([]const u8).init(arena);
238
239 try cflags.append("-I");
240 try cflags.append(tsan_include_path);
241
242 try addCcArgs(target, &cflags);
243
244 c_source_files.appendAssumeCapacity(.{
245 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
246 "libtsan", "sanitizer_common", c_src,
247 }),
248 .extra_flags = cflags.items,
249 .owner = root_mod,
250 });
251 }
252
253 const interception_include_path = try comp.zig_lib_directory.join(
254 arena,
255 &[_][]const u8{"interception"},
256 );
257
258 try c_source_files.ensureUnusedCapacity(interception_sources.len);
259 for (interception_sources) |c_src| {
260 var cflags = std.ArrayList([]const u8).init(arena);
261
262 try cflags.append("-I");
263 try cflags.append(interception_include_path);
264
265 try cflags.append("-I");
266 try cflags.append(tsan_include_path);
267
268 try addCcArgs(target, &cflags);
269
270 c_source_files.appendAssumeCapacity(.{
271 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
272 "libtsan", "interception", c_src,
273 }),
274 .extra_flags = cflags.items,
275 .owner = root_mod,
276 });
277 }
278
279 const skip_linker_dependencies = !target.os.tag.isDarwin();
280 const linker_allow_shlib_undefined = target.os.tag.isDarwin();
281 const install_name = if (target.os.tag.isDarwin())
282 try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename})
283 else
284 null;
285 // Workaround for https://github.com/llvm/llvm-project/issues/97627
286 const headerpad_size: ?u32 = if (target.os.tag.isDarwin()) 32 else null;
287 const sub_compilation = Compilation.create(comp.gpa, arena, .{
288 .local_cache_directory = comp.global_cache_directory,
289 .global_cache_directory = comp.global_cache_directory,
290 .zig_lib_directory = comp.zig_lib_directory,
291 .thread_pool = comp.thread_pool,
292 .self_exe_path = comp.self_exe_path,
293 .cache_mode = .whole,
294 .config = config,
295 .root_mod = root_mod,
296 .root_name = root_name,
297 .libc_installation = comp.libc_installation,
298 .emit_bin = emit_bin,
299 .emit_h = null,
300 .c_source_files = c_source_files.items,
301 .verbose_cc = comp.verbose_cc,
302 .verbose_link = comp.verbose_link,
303 .verbose_air = comp.verbose_air,
304 .verbose_llvm_ir = comp.verbose_llvm_ir,
305 .verbose_llvm_bc = comp.verbose_llvm_bc,
306 .verbose_cimport = comp.verbose_cimport,
307 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
308 .clang_passthrough_mode = comp.clang_passthrough_mode,
309 .skip_linker_dependencies = skip_linker_dependencies,
310 .linker_allow_shlib_undefined = linker_allow_shlib_undefined,
311 .install_name = install_name,
312 .headerpad_size = headerpad_size,
313 }) catch |err| {
314 comp.setMiscFailure(
315 .libtsan,
316 "unable to build thread sanitizer runtime: create compilation failed: {s}",
317 .{@errorName(err)},
318 );
319 return error.SubCompilationFailed;
320 };
321 defer sub_compilation.destroy();
322
323 comp.updateSubCompilation(sub_compilation, .libtsan, prog_node) catch |err| switch (err) {
324 error.SubCompilationFailed => return error.SubCompilationFailed,
325 else => |e| {
326 comp.setMiscFailure(
327 .libtsan,
328 "unable to build thread sanitizer runtime: compilation failed: {s}",
329 .{@errorName(e)},
330 );
331 return error.SubCompilationFailed;
332 },
333 };
334
335 const crt_file = try sub_compilation.toCrtFile();
336 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
337 assert(comp.tsan_lib == null);
338 comp.tsan_lib = crt_file;
339}
340
341fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
342 try args.appendSlice(&[_][]const u8{
343 "-nostdinc++",
344 "-fvisibility=hidden",
345 "-fvisibility-inlines-hidden",
346 "-std=c++17",
347 "-fno-rtti",
348 "-fno-exceptions",
349 });
350
351 if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) {
352 try args.append("-fno-emulated-tls");
353 }
354
355 if (target.isMinGW()) {
356 try args.append("-fms-extensions");
357 }
358}
359
360const tsan_sources = [_][]const u8{
361 "tsan_debugging.cpp",
362 "tsan_external.cpp",
363 "tsan_fd.cpp",
364 "tsan_flags.cpp",
365 "tsan_ignoreset.cpp",
366 "tsan_interceptors_memintrinsics.cpp",
367 "tsan_interceptors_posix.cpp",
368 "tsan_interface.cpp",
369 "tsan_interface_ann.cpp",
370 "tsan_interface_atomic.cpp",
371 "tsan_interface_java.cpp",
372 "tsan_malloc_mac.cpp",
373 "tsan_md5.cpp",
374 "tsan_mman.cpp",
375 "tsan_mutexset.cpp",
376 "tsan_new_delete.cpp",
377 "tsan_platform_windows.cpp",
378 "tsan_preinit.cpp",
379 "tsan_report.cpp",
380 "tsan_rtl.cpp",
381 "tsan_rtl_access.cpp",
382 "tsan_rtl_mutex.cpp",
383 "tsan_rtl_proc.cpp",
384 "tsan_rtl_report.cpp",
385 "tsan_rtl_thread.cpp",
386 "tsan_stack_trace.cpp",
387 "tsan_suppressions.cpp",
388 "tsan_symbolize.cpp",
389 "tsan_sync.cpp",
390 "tsan_vector_clock.cpp",
391};
392
393const darwin_tsan_sources = [_][]const u8{
394 "tsan_interceptors_mac.cpp",
395 "tsan_interceptors_mach_vm.cpp",
396 "tsan_platform_mac.cpp",
397 "tsan_platform_posix.cpp",
398};
399
400const unix_tsan_sources = [_][]const u8{
401 "tsan_platform_linux.cpp",
402 "tsan_platform_posix.cpp",
403};
404
405const windows_tsan_sources = [_][]const u8{
406 "tsan_platform_windows.cpp",
407};
408
409const sanitizer_common_sources = [_][]const u8{
410 "sanitizer_allocator.cpp",
411 "sanitizer_chained_origin_depot.cpp",
412 "sanitizer_common.cpp",
413 "sanitizer_deadlock_detector1.cpp",
414 "sanitizer_deadlock_detector2.cpp",
415 "sanitizer_errno.cpp",
416 "sanitizer_file.cpp",
417 "sanitizer_flag_parser.cpp",
418 "sanitizer_flags.cpp",
419 "sanitizer_fuchsia.cpp",
420 "sanitizer_libc.cpp",
421 "sanitizer_libignore.cpp",
422 "sanitizer_linux.cpp",
423 "sanitizer_linux_s390.cpp",
424 "sanitizer_mac.cpp",
425 "sanitizer_mutex.cpp",
426 "sanitizer_netbsd.cpp",
427 "sanitizer_platform_limits_freebsd.cpp",
428 "sanitizer_platform_limits_linux.cpp",
429 "sanitizer_platform_limits_netbsd.cpp",
430 "sanitizer_platform_limits_posix.cpp",
431 "sanitizer_platform_limits_solaris.cpp",
432 "sanitizer_posix.cpp",
433 "sanitizer_printf.cpp",
434 "sanitizer_procmaps_bsd.cpp",
435 "sanitizer_procmaps_common.cpp",
436 "sanitizer_procmaps_fuchsia.cpp",
437 "sanitizer_procmaps_linux.cpp",
438 "sanitizer_procmaps_mac.cpp",
439 "sanitizer_procmaps_solaris.cpp",
440 "sanitizer_range.cpp",
441 "sanitizer_solaris.cpp",
442 "sanitizer_stoptheworld_fuchsia.cpp",
443 "sanitizer_stoptheworld_mac.cpp",
444 "sanitizer_stoptheworld_win.cpp",
445 "sanitizer_suppressions.cpp",
446 "sanitizer_termination.cpp",
447 "sanitizer_thread_arg_retval.cpp",
448 "sanitizer_thread_registry.cpp",
449 "sanitizer_tls_get_addr.cpp",
450 "sanitizer_type_traits.cpp",
451 "sanitizer_win.cpp",
452 "sanitizer_win_interception.cpp",
453};
454
455const sanitizer_nolibc_sources = [_][]const u8{
456 "sanitizer_common_nolibc.cpp",
457};
458
459const sanitizer_libcdep_sources = [_][]const u8{
460 "sanitizer_common_libcdep.cpp",
461 "sanitizer_allocator_checks.cpp",
462 "sanitizer_dl.cpp",
463 "sanitizer_linux_libcdep.cpp",
464 "sanitizer_mac_libcdep.cpp",
465 "sanitizer_posix_libcdep.cpp",
466 "sanitizer_stoptheworld_linux_libcdep.cpp",
467 "sanitizer_stoptheworld_netbsd_libcdep.cpp",
468};
469
470const sanitizer_symbolizer_sources = [_][]const u8{
471 "sanitizer_allocator_report.cpp",
472 "sanitizer_stack_store.cpp",
473 "sanitizer_stackdepot.cpp",
474 "sanitizer_stacktrace.cpp",
475 "sanitizer_stacktrace_libcdep.cpp",
476 "sanitizer_stacktrace_printer.cpp",
477 "sanitizer_stacktrace_sparc.cpp",
478 "sanitizer_symbolizer.cpp",
479 "sanitizer_symbolizer_libbacktrace.cpp",
480 "sanitizer_symbolizer_libcdep.cpp",
481 "sanitizer_symbolizer_mac.cpp",
482 "sanitizer_symbolizer_markup.cpp",
483 "sanitizer_symbolizer_markup_fuchsia.cpp",
484 "sanitizer_symbolizer_posix_libcdep.cpp",
485 "sanitizer_symbolizer_report.cpp",
486 "sanitizer_symbolizer_report_fuchsia.cpp",
487 "sanitizer_symbolizer_win.cpp",
488 "sanitizer_thread_history.cpp",
489 "sanitizer_unwind_linux_libcdep.cpp",
490 "sanitizer_unwind_fuchsia.cpp",
491 "sanitizer_unwind_win.cpp",
492};
493
494const interception_sources = [_][]const u8{
495 "interception_linux.cpp",
496 "interception_mac.cpp",
497 "interception_win.cpp",
498 "interception_type_test.cpp",
499};
src/libunwind.zig deleted-220
...@@ -1,220 +0,0 @@
1const std = @import("std");
2const path = std.fs.path;
3const assert = std.debug.assert;
4
5const target_util = @import("target.zig");
6const Compilation = @import("Compilation.zig");
7const Module = @import("Package/Module.zig");
8const build_options = @import("build_options");
9const trace = @import("tracy.zig").trace;
10
11pub const BuildError = error{
12 OutOfMemory,
13 SubCompilationFailed,
14 ZigCompilerNotBuiltWithLLVMExtensions,
15};
16
17pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildError!void {
18 if (!build_options.have_llvm) {
19 return error.ZigCompilerNotBuiltWithLLVMExtensions;
20 }
21
22 const tracy = trace(@src());
23 defer tracy.end();
24
25 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
26 defer arena_allocator.deinit();
27 const arena = arena_allocator.allocator();
28
29 const output_mode = .Lib;
30 const target = comp.root_mod.resolved_target.result;
31 const unwind_tables: std.builtin.UnwindTables =
32 if (target.cpu.arch == .x86 and target.os.tag == .windows) .none else .@"async";
33 const config = Compilation.Config.resolve(.{
34 .output_mode = .Lib,
35 .resolved_target = comp.root_mod.resolved_target,
36 .is_test = false,
37 .have_zcu = false,
38 .emit_bin = true,
39 .root_optimize_mode = comp.compilerRtOptMode(),
40 .root_strip = comp.compilerRtStrip(),
41 .link_libc = true,
42 .any_unwind_tables = unwind_tables != .none,
43 .lto = comp.config.lto,
44 }) catch |err| {
45 comp.setMiscFailure(
46 .libunwind,
47 "unable to build libunwind: resolving configuration failed: {s}",
48 .{@errorName(err)},
49 );
50 return error.SubCompilationFailed;
51 };
52 const root_mod = Module.create(arena, .{
53 .global_cache_directory = comp.global_cache_directory,
54 .paths = .{
55 .root = .{ .root_dir = comp.zig_lib_directory },
56 .root_src_path = "",
57 },
58 .fully_qualified_name = "root",
59 .inherited = .{
60 .resolved_target = comp.root_mod.resolved_target,
61 .strip = comp.compilerRtStrip(),
62 .stack_check = false,
63 .stack_protector = 0,
64 .red_zone = comp.root_mod.red_zone,
65 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
66 .valgrind = false,
67 .sanitize_c = .off,
68 .sanitize_thread = false,
69 // necessary so that libunwind can unwind through its own stack frames
70 // The old 32-bit x86 variant of SEH doesn't use tables.
71 .unwind_tables = unwind_tables,
72 .pic = if (target_util.supports_fpic(target)) true else null,
73 .optimize_mode = comp.compilerRtOptMode(),
74 .code_model = comp.root_mod.code_model,
75 },
76 .global = config,
77 .cc_argv = &.{},
78 .parent = null,
79 .builtin_mod = null,
80 .builtin_modules = null, // there is only one module in this compilation
81 }) catch |err| {
82 comp.setMiscFailure(
83 .libunwind,
84 "unable to build libunwind: creating module failed: {s}",
85 .{@errorName(err)},
86 );
87 return error.SubCompilationFailed;
88 };
89
90 const root_name = "unwind";
91 const link_mode = .static;
92 const basename = try std.zig.binNameAlloc(arena, .{
93 .root_name = root_name,
94 .target = target,
95 .output_mode = output_mode,
96 .link_mode = link_mode,
97 });
98 const emit_bin = Compilation.EmitLoc{
99 .directory = null, // Put it in the cache directory.
100 .basename = basename,
101 };
102 var c_source_files: [unwind_src_list.len]Compilation.CSourceFile = undefined;
103 for (unwind_src_list, 0..) |unwind_src, i| {
104 var cflags = std.ArrayList([]const u8).init(arena);
105
106 switch (Compilation.classifyFileExt(unwind_src)) {
107 .c => {
108 try cflags.appendSlice(&.{
109 "-std=c99",
110 "-fexceptions",
111 });
112 },
113 .cpp => {
114 try cflags.append("-fno-exceptions");
115 try cflags.append("-fno-rtti");
116 },
117 .assembly_with_cpp => {},
118 else => unreachable, // See `unwind_src_list`.
119 }
120 try cflags.append("-I");
121 try cflags.append(try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libunwind", "include" }));
122 try cflags.append("-D_LIBUNWIND_HIDE_SYMBOLS");
123 try cflags.append("-Wa,--noexecstack");
124 try cflags.append("-fvisibility=hidden");
125 try cflags.append("-fvisibility-inlines-hidden");
126 try cflags.append("-fvisibility-global-new-delete=force-hidden");
127
128 // This is intentionally always defined because the macro definition means, should it only
129 // build for the target specified by compiler defines. Since we pass -target the compiler
130 // defines will be correct.
131 try cflags.append("-D_LIBUNWIND_IS_NATIVE_ONLY");
132
133 if (comp.root_mod.optimize_mode == .Debug) {
134 try cflags.append("-D_DEBUG");
135 }
136 if (!comp.config.any_non_single_threaded) {
137 try cflags.append("-D_LIBUNWIND_HAS_NO_THREADS");
138 }
139 if (target.cpu.arch.isArm() and target.abi.float() == .hard) {
140 try cflags.append("-DCOMPILER_RT_ARMHF_TARGET");
141 }
142 try cflags.append("-Wno-bitwise-conditional-parentheses");
143 try cflags.append("-Wno-visibility");
144 try cflags.append("-Wno-incompatible-pointer-types");
145
146 if (target.os.tag == .windows) {
147 try cflags.append("-Wno-dll-attribute-on-redeclaration");
148 }
149
150 c_source_files[i] = .{
151 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{unwind_src}),
152 .extra_flags = cflags.items,
153 .owner = root_mod,
154 };
155 }
156 const sub_compilation = Compilation.create(comp.gpa, arena, .{
157 .self_exe_path = comp.self_exe_path,
158 .local_cache_directory = comp.global_cache_directory,
159 .global_cache_directory = comp.global_cache_directory,
160 .zig_lib_directory = comp.zig_lib_directory,
161 .config = config,
162 .root_mod = root_mod,
163 .cache_mode = .whole,
164 .root_name = root_name,
165 .main_mod = null,
166 .thread_pool = comp.thread_pool,
167 .libc_installation = comp.libc_installation,
168 .emit_bin = emit_bin,
169 .function_sections = comp.function_sections,
170 .c_source_files = &c_source_files,
171 .verbose_cc = comp.verbose_cc,
172 .verbose_link = comp.verbose_link,
173 .verbose_air = comp.verbose_air,
174 .verbose_llvm_ir = comp.verbose_llvm_ir,
175 .verbose_llvm_bc = comp.verbose_llvm_bc,
176 .verbose_cimport = comp.verbose_cimport,
177 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
178 .clang_passthrough_mode = comp.clang_passthrough_mode,
179 .skip_linker_dependencies = true,
180 }) catch |err| {
181 comp.setMiscFailure(
182 .libunwind,
183 "unable to build libunwind: create compilation failed: {s}",
184 .{@errorName(err)},
185 );
186 return error.SubCompilationFailed;
187 };
188 defer sub_compilation.destroy();
189
190 comp.updateSubCompilation(sub_compilation, .libunwind, prog_node) catch |err| switch (err) {
191 error.SubCompilationFailed => return error.SubCompilationFailed,
192 else => |e| {
193 comp.setMiscFailure(
194 .libunwind,
195 "unable to build libunwind: compilation failed: {s}",
196 .{@errorName(e)},
197 );
198 return error.SubCompilationFailed;
199 },
200 };
201
202 const crt_file = try sub_compilation.toCrtFile();
203 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
204 assert(comp.libunwind_static_lib == null);
205 comp.libunwind_static_lib = crt_file;
206}
207
208const unwind_src_list = [_][]const u8{
209 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "libunwind.cpp",
210 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-EHABI.cpp",
211 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-seh.cpp",
212 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1.c",
213 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindLevel1-gcc-ext.c",
214 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-sjlj.c",
215 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind-wasm.c",
216 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersRestore.S",
217 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "UnwindRegistersSave.S",
218 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "Unwind_AIXExtras.cpp",
219 "libunwind" ++ path.sep_str ++ "src" ++ path.sep_str ++ "gcc_personality_v0.c",
220};
src/link.zig+1-1
...@@ -6,7 +6,7 @@ const fs = std.fs;...@@ -6,7 +6,7 @@ const fs = std.fs;
6const mem = std.mem;6const mem = std.mem;
7const log = std.log.scoped(.link);7const log = std.log.scoped(.link);
8const trace = @import("tracy.zig").trace;8const trace = @import("tracy.zig").trace;
9const wasi_libc = @import("wasi_libc.zig");9const wasi_libc = @import("libs/wasi_libc.zig");
1010
11const Air = @import("Air.zig");11const Air = @import("Air.zig");
12const Allocator = std.mem.Allocator;12const Allocator = std.mem.Allocator;
src/link/Elf.zig+2-2
...@@ -5279,9 +5279,9 @@ const codegen = @import("../codegen.zig");...@@ -5279,9 +5279,9 @@ const codegen = @import("../codegen.zig");
5279const dev = @import("../dev.zig");5279const dev = @import("../dev.zig");
5280const eh_frame = @import("Elf/eh_frame.zig");5280const eh_frame = @import("Elf/eh_frame.zig");
5281const gc = @import("Elf/gc.zig");5281const gc = @import("Elf/gc.zig");
5282const glibc = @import("../glibc.zig");5282const glibc = @import("../libs/glibc.zig");
5283const link = @import("../link.zig");5283const link = @import("../link.zig");
5284const musl = @import("../musl.zig");5284const musl = @import("../libs/musl.zig");
5285const relocatable = @import("Elf/relocatable.zig");5285const relocatable = @import("Elf/relocatable.zig");
5286const relocation = @import("Elf/relocation.zig");5286const relocation = @import("Elf/relocation.zig");
5287const target_util = @import("../target.zig");5287const target_util = @import("../target.zig");
src/link/Wasm.zig+1-1
...@@ -44,7 +44,7 @@ const dev = @import("../dev.zig");...@@ -44,7 +44,7 @@ const dev = @import("../dev.zig");
44const link = @import("../link.zig");44const link = @import("../link.zig");
45const lldMain = @import("../main.zig").lldMain;45const lldMain = @import("../main.zig").lldMain;
46const trace = @import("../tracy.zig").trace;46const trace = @import("../tracy.zig").trace;
47const wasi_libc = @import("../wasi_libc.zig");47const wasi_libc = @import("../libs/wasi_libc.zig");
48const Value = @import("../Value.zig");48const Value = @import("../Value.zig");
4949
50base: link.File,50base: link.File,
src/main.zig+2-2
...@@ -28,11 +28,11 @@ const link = @import("link.zig");...@@ -28,11 +28,11 @@ const link = @import("link.zig");
28const Package = @import("Package.zig");28const Package = @import("Package.zig");
29const build_options = @import("build_options");29const build_options = @import("build_options");
30const introspect = @import("introspect.zig");30const introspect = @import("introspect.zig");
31const wasi_libc = @import("wasi_libc.zig");31const wasi_libc = @import("libs/wasi_libc.zig");
32const target_util = @import("target.zig");32const target_util = @import("target.zig");
33const crash_report = @import("crash_report.zig");33const crash_report = @import("crash_report.zig");
34const Zcu = @import("Zcu.zig");34const Zcu = @import("Zcu.zig");
35const mingw = @import("mingw.zig");35const mingw = @import("libs/mingw.zig");
36const dev = @import("dev.zig");36const dev = @import("dev.zig");
3737
38test {38test {
src/mingw.zig deleted-1038
...@@ -1,1038 +0,0 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const path = std.fs.path;
5const assert = std.debug.assert;
6const log = std.log.scoped(.mingw);
7
8const builtin = @import("builtin");
9const Compilation = @import("Compilation.zig");
10const build_options = @import("build_options");
11const Cache = std.Build.Cache;
12const dev = @import("dev.zig");
13
14pub const CrtFile = enum {
15 crt2_o,
16 dllcrt2_o,
17 libmingw32_lib,
18};
19
20/// TODO replace anyerror with explicit error set, recording user-friendly errors with
21/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
22pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
23 if (!build_options.have_llvm) {
24 return error.ZigCompilerNotBuiltWithLLVMExtensions;
25 }
26 var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa);
27 defer arena_allocator.deinit();
28 const arena = arena_allocator.allocator();
29 const target = comp.getTarget();
30
31 // The old 32-bit x86 variant of SEH doesn't use tables.
32 const unwind_tables: std.builtin.UnwindTables = if (target.cpu.arch != .x86) .@"async" else .none;
33
34 switch (crt_file) {
35 .crt2_o => {
36 var args = std.ArrayList([]const u8).init(arena);
37 try addCrtCcArgs(comp, arena, &args);
38 if (comp.mingw_unicode_entry_point) {
39 try args.appendSlice(&.{ "-DUNICODE", "-D_UNICODE" });
40 }
41 var files = [_]Compilation.CSourceFile{
42 .{
43 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
44 "libc", "mingw", "crt", "crtexe.c",
45 }),
46 .extra_flags = args.items,
47 .owner = undefined,
48 },
49 };
50 return comp.build_crt_file("crt2", .Obj, .@"mingw-w64 crt2.o", prog_node, &files, .{
51 .unwind_tables = unwind_tables,
52 });
53 },
54
55 .dllcrt2_o => {
56 var args = std.ArrayList([]const u8).init(arena);
57 try addCrtCcArgs(comp, arena, &args);
58 var files = [_]Compilation.CSourceFile{
59 .{
60 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
61 "libc", "mingw", "crt", "crtdll.c",
62 }),
63 .extra_flags = args.items,
64 .owner = undefined,
65 },
66 };
67 return comp.build_crt_file("dllcrt2", .Obj, .@"mingw-w64 dllcrt2.o", prog_node, &files, .{
68 .unwind_tables = unwind_tables,
69 });
70 },
71
72 .libmingw32_lib => {
73 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena);
74
75 {
76 var crt_args = std.ArrayList([]const u8).init(arena);
77 try addCrtCcArgs(comp, arena, &crt_args);
78
79 for (mingw32_generic_src) |dep| {
80 try c_source_files.append(.{
81 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
82 "libc", "mingw", dep,
83 }),
84 .extra_flags = crt_args.items,
85 .owner = undefined,
86 });
87 }
88 if (target.cpu.arch.isX86()) {
89 for (mingw32_x86_src) |dep| {
90 try c_source_files.append(.{
91 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
92 "libc", "mingw", dep,
93 }),
94 .extra_flags = crt_args.items,
95 .owner = undefined,
96 });
97 }
98 if (target.cpu.arch == .x86) {
99 for (mingw32_x86_32_src) |dep| {
100 try c_source_files.append(.{
101 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
102 "libc", "mingw", dep,
103 }),
104 .extra_flags = crt_args.items,
105 .owner = undefined,
106 });
107 }
108 }
109 } else if (target.cpu.arch == .thumb) {
110 for (mingw32_arm_src) |dep| {
111 try c_source_files.append(.{
112 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
113 "libc", "mingw", dep,
114 }),
115 .extra_flags = crt_args.items,
116 .owner = undefined,
117 });
118 }
119 for (mingw32_arm32_src) |dep| {
120 try c_source_files.append(.{
121 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
122 "libc", "mingw", dep,
123 }),
124 .extra_flags = crt_args.items,
125 .owner = undefined,
126 });
127 }
128 } else if (target.cpu.arch == .aarch64) {
129 for (mingw32_arm_src) |dep| {
130 try c_source_files.append(.{
131 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
132 "libc", "mingw", dep,
133 }),
134 .extra_flags = crt_args.items,
135 .owner = undefined,
136 });
137 }
138 for (mingw32_arm64_src) |dep| {
139 try c_source_files.append(.{
140 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
141 "libc", "mingw", dep,
142 }),
143 .extra_flags = crt_args.items,
144 .owner = undefined,
145 });
146 }
147 } else {
148 @panic("unsupported arch");
149 }
150 }
151
152 {
153 var winpthreads_args = std.ArrayList([]const u8).init(arena);
154 try addCcArgs(comp, arena, &winpthreads_args);
155 try winpthreads_args.appendSlice(&[_][]const u8{
156 "-DIN_WINPTHREAD",
157 "-DWIN32_LEAN_AND_MEAN",
158 });
159
160 switch (comp.compilerRtOptMode()) {
161 .Debug, .ReleaseSafe => try winpthreads_args.append("-DWINPTHREAD_DBG"),
162 .ReleaseFast, .ReleaseSmall => {},
163 }
164
165 for (mingw32_winpthreads_src) |dep| {
166 try c_source_files.append(.{
167 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
168 "libc", "mingw", dep,
169 }),
170 .extra_flags = winpthreads_args.items,
171 .owner = undefined,
172 });
173 }
174 }
175
176 return comp.build_crt_file("libmingw32", .Lib, .@"mingw-w64 libmingw32.lib", prog_node, c_source_files.items, .{
177 .unwind_tables = unwind_tables,
178 // https://github.com/llvm/llvm-project/issues/43698#issuecomment-2542660611
179 .allow_lto = false,
180 });
181 },
182 }
183}
184
185fn addCcArgs(
186 comp: *Compilation,
187 arena: Allocator,
188 args: *std.ArrayList([]const u8),
189) error{OutOfMemory}!void {
190 try args.appendSlice(&[_][]const u8{
191 "-std=gnu11",
192 "-D__USE_MINGW_ANSI_STDIO=0",
193
194 "-isystem",
195 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }),
196 });
197}
198
199fn addCrtCcArgs(
200 comp: *Compilation,
201 arena: Allocator,
202 args: *std.ArrayList([]const u8),
203) error{OutOfMemory}!void {
204 try addCcArgs(comp, arena, args);
205
206 if (comp.getTarget().cpu.arch == .thumb) {
207 try args.append("-mfpu=vfp");
208 }
209
210 try args.appendSlice(&[_][]const u8{
211 // According to Martin Storsjö,
212 // > the files under mingw-w64-crt are designed to always
213 // be built with __MSVCRT_VERSION__=0x700
214 "-D__MSVCRT_VERSION__=0x700",
215 "-D_CRTBLD",
216 "-D_SYSCRT=1",
217 "-D_WIN32_WINNT=0x0f00",
218 "-DCRTDLL=1",
219 "-DHAVE_CONFIG_H",
220
221 "-I",
222 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "include" }),
223 });
224}
225
226pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
227 dev.check(.build_import_lib);
228
229 const gpa = comp.gpa;
230
231 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
232 defer arena_allocator.deinit();
233 const arena = arena_allocator.allocator();
234
235 const def_file_path = findDef(arena, comp.getTarget(), comp.zig_lib_directory, lib_name) catch |err| switch (err) {
236 error.FileNotFound => {
237 log.debug("no {s}.def file available to make a DLL import {s}.lib", .{ lib_name, lib_name });
238 // In this case we will end up putting foo.lib onto the linker line and letting the linker
239 // use its library paths to look for libraries and report any problems.
240 return;
241 },
242 else => |e| return e,
243 };
244
245 const target = comp.getTarget();
246
247 // Use the global cache directory.
248 var cache: Cache = .{
249 .gpa = gpa,
250 .manifest_dir = try comp.global_cache_directory.handle.makeOpenPath("h", .{}),
251 };
252 cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() });
253 cache.addPrefix(comp.zig_lib_directory);
254 cache.addPrefix(comp.global_cache_directory);
255 defer cache.manifest_dir.close();
256
257 cache.hash.addBytes(build_options.version);
258 cache.hash.addOptionalBytes(comp.zig_lib_directory.path);
259 cache.hash.add(target.cpu.arch);
260
261 var man = cache.obtain();
262 defer man.deinit();
263
264 _ = try man.addFile(def_file_path, null);
265
266 const final_lib_basename = try std.fmt.allocPrint(gpa, "{s}.lib", .{lib_name});
267 errdefer gpa.free(final_lib_basename);
268
269 if (try man.hit()) {
270 const digest = man.final();
271 const sub_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
272 errdefer gpa.free(sub_path);
273
274 comp.mutex.lock();
275 defer comp.mutex.unlock();
276 try comp.crt_files.ensureUnusedCapacity(gpa, 1);
277 comp.crt_files.putAssumeCapacityNoClobber(final_lib_basename, .{
278 .full_object_path = .{
279 .root_dir = comp.global_cache_directory,
280 .sub_path = sub_path,
281 },
282 .lock = man.toOwnedLock(),
283 });
284 return;
285 }
286
287 const digest = man.final();
288 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
289 var o_dir = try comp.global_cache_directory.handle.makeOpenPath(o_sub_path, .{});
290 defer o_dir.close();
291
292 const final_def_basename = try std.fmt.allocPrint(arena, "{s}.def", .{lib_name});
293 const def_final_path = try comp.global_cache_directory.join(arena, &[_][]const u8{
294 "o", &digest, final_def_basename,
295 });
296
297 const target_defines = switch (target.cpu.arch) {
298 .thumb => "#define DEF_ARM32\n",
299 .aarch64 => "#define DEF_ARM64\n",
300 .x86 => "#define DEF_I386\n",
301 .x86_64 => "#define DEF_X64\n",
302 else => unreachable,
303 };
304
305 const aro = @import("aro");
306 var aro_comp = aro.Compilation.init(gpa, std.fs.cwd());
307 defer aro_comp.deinit();
308
309 const include_dir = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "mingw", "def-include" });
310
311 if (comp.verbose_cc) print: {
312 std.debug.lockStdErr();
313 defer std.debug.unlockStdErr();
314 const stderr = std.io.getStdErr().writer();
315 nosuspend stderr.print("def file: {s}\n", .{def_file_path}) catch break :print;
316 nosuspend stderr.print("include dir: {s}\n", .{include_dir}) catch break :print;
317 nosuspend stderr.print("output path: {s}\n", .{def_final_path}) catch break :print;
318 }
319
320 try aro_comp.include_dirs.append(gpa, include_dir);
321
322 const builtin_macros = try aro_comp.generateBuiltinMacros(.include_system_defines);
323 const user_macros = try aro_comp.addSourceFromBuffer("<command line>", target_defines);
324 const def_file_source = try aro_comp.addSourceFromPath(def_file_path);
325
326 var pp = aro.Preprocessor.init(&aro_comp);
327 defer pp.deinit();
328 pp.linemarkers = .none;
329 pp.preserve_whitespace = true;
330
331 try pp.preprocessSources(&.{ def_file_source, builtin_macros, user_macros });
332
333 for (aro_comp.diagnostics.list.items) |diagnostic| {
334 if (diagnostic.kind == .@"fatal error" or diagnostic.kind == .@"error") {
335 aro.Diagnostics.render(&aro_comp, std.io.tty.detectConfig(std.io.getStdErr()));
336 return error.AroPreprocessorFailed;
337 }
338 }
339
340 {
341 // new scope to ensure definition file is written before passing the path to WriteImportLibrary
342 const def_final_file = try o_dir.createFile(final_def_basename, .{ .truncate = true });
343 defer def_final_file.close();
344 try pp.prettyPrintTokens(def_final_file.writer(), .result_only);
345 }
346
347 const lib_final_path = try std.fs.path.join(gpa, &.{ "o", &digest, final_lib_basename });
348 errdefer gpa.free(lib_final_path);
349
350 if (!build_options.have_llvm) return error.ZigCompilerNotBuiltWithLLVMExtensions;
351 const llvm_bindings = @import("codegen/llvm/bindings.zig");
352 const def_final_path_z = try arena.dupeZ(u8, def_final_path);
353 const lib_final_path_z = try comp.global_cache_directory.joinZ(arena, &.{lib_final_path});
354 if (llvm_bindings.WriteImportLibrary(
355 def_final_path_z.ptr,
356 @intFromEnum(target.toCoffMachine()),
357 lib_final_path_z.ptr,
358 true,
359 )) {
360 // TODO surface a proper error here
361 log.err("unable to turn {s}.def into {s}.lib", .{ lib_name, lib_name });
362 return error.WritingImportLibFailed;
363 }
364
365 man.writeManifest() catch |err| {
366 log.warn("failed to write cache manifest for DLL import {s}.lib: {s}", .{ lib_name, @errorName(err) });
367 };
368
369 comp.mutex.lock();
370 defer comp.mutex.unlock();
371 try comp.crt_files.putNoClobber(gpa, final_lib_basename, .{
372 .full_object_path = .{
373 .root_dir = comp.global_cache_directory,
374 .sub_path = lib_final_path,
375 },
376 .lock = man.toOwnedLock(),
377 });
378}
379
380pub fn libExists(
381 allocator: Allocator,
382 target: std.Target,
383 zig_lib_directory: Cache.Directory,
384 lib_name: []const u8,
385) !bool {
386 const s = findDef(allocator, target, zig_lib_directory, lib_name) catch |err| switch (err) {
387 error.FileNotFound => return false,
388 else => |e| return e,
389 };
390 defer allocator.free(s);
391 return true;
392}
393
394/// This function body is verbose but all it does is test 3 different paths and
395/// see if a .def file exists.
396fn findDef(
397 allocator: Allocator,
398 target: std.Target,
399 zig_lib_directory: Cache.Directory,
400 lib_name: []const u8,
401) ![]u8 {
402 const lib_path = switch (target.cpu.arch) {
403 .thumb => "libarm32",
404 .aarch64 => "libarm64",
405 .x86 => "lib32",
406 .x86_64 => "lib64",
407 else => unreachable,
408 };
409
410 var override_path = std.ArrayList(u8).init(allocator);
411 defer override_path.deinit();
412
413 const s = path.sep_str;
414
415 {
416 // Try the archtecture-specific path first.
417 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def";
418 if (zig_lib_directory.path) |p| {
419 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name });
420 } else {
421 try override_path.writer().print(fmt_path, .{ lib_path, lib_name });
422 }
423 if (std.fs.cwd().access(override_path.items, .{})) |_| {
424 return override_path.toOwnedSlice();
425 } else |err| switch (err) {
426 error.FileNotFound => {},
427 else => |e| return e,
428 }
429 }
430
431 {
432 // Try the generic version.
433 override_path.shrinkRetainingCapacity(0);
434 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def";
435 if (zig_lib_directory.path) |p| {
436 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
437 } else {
438 try override_path.writer().print(fmt_path, .{lib_name});
439 }
440 if (std.fs.cwd().access(override_path.items, .{})) |_| {
441 return override_path.toOwnedSlice();
442 } else |err| switch (err) {
443 error.FileNotFound => {},
444 else => |e| return e,
445 }
446 }
447
448 {
449 // Try the generic version and preprocess it.
450 override_path.shrinkRetainingCapacity(0);
451 const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in";
452 if (zig_lib_directory.path) |p| {
453 try override_path.writer().print("{s}" ++ s ++ fmt_path, .{ p, lib_name });
454 } else {
455 try override_path.writer().print(fmt_path, .{lib_name});
456 }
457 if (std.fs.cwd().access(override_path.items, .{})) |_| {
458 return override_path.toOwnedSlice();
459 } else |err| switch (err) {
460 error.FileNotFound => {},
461 else => |e| return e,
462 }
463 }
464
465 return error.FileNotFound;
466}
467
468const mingw32_generic_src = [_][]const u8{
469 // mingw32
470 "crt" ++ path.sep_str ++ "crtexewin.c",
471 "crt" ++ path.sep_str ++ "dll_argv.c",
472 "crt" ++ path.sep_str ++ "gccmain.c",
473 "crt" ++ path.sep_str ++ "natstart.c",
474 "crt" ++ path.sep_str ++ "pseudo-reloc-list.c",
475 "crt" ++ path.sep_str ++ "wildcard.c",
476 "crt" ++ path.sep_str ++ "charmax.c",
477 "crt" ++ path.sep_str ++ "ucrtexewin.c",
478 "crt" ++ path.sep_str ++ "dllargv.c",
479 "crt" ++ path.sep_str ++ "_newmode.c",
480 "crt" ++ path.sep_str ++ "tlssup.c",
481 "crt" ++ path.sep_str ++ "xncommod.c",
482 "crt" ++ path.sep_str ++ "cinitexe.c",
483 "crt" ++ path.sep_str ++ "merr.c",
484 "crt" ++ path.sep_str ++ "usermatherr.c",
485 "crt" ++ path.sep_str ++ "pesect.c",
486 "crt" ++ path.sep_str ++ "udllargc.c",
487 "crt" ++ path.sep_str ++ "xthdloc.c",
488 "crt" ++ path.sep_str ++ "CRT_fp10.c",
489 "crt" ++ path.sep_str ++ "mingw_helpers.c",
490 "crt" ++ path.sep_str ++ "pseudo-reloc.c",
491 "crt" ++ path.sep_str ++ "udll_argv.c",
492 "crt" ++ path.sep_str ++ "xtxtmode.c",
493 "crt" ++ path.sep_str ++ "crt_handler.c",
494 "crt" ++ path.sep_str ++ "tlsthrd.c",
495 "crt" ++ path.sep_str ++ "tlsmthread.c",
496 "crt" ++ path.sep_str ++ "tlsmcrt.c",
497 "crt" ++ path.sep_str ++ "cxa_atexit.c",
498 "crt" ++ path.sep_str ++ "cxa_thread_atexit.c",
499 "crt" ++ path.sep_str ++ "tls_atexit.c",
500 "intrincs" ++ path.sep_str ++ "RtlSecureZeroMemory.c",
501 // mingwex
502 "cfguard" ++ path.sep_str ++ "mingw_cfguard_support.c",
503 "complex" ++ path.sep_str ++ "_cabs.c",
504 "complex" ++ path.sep_str ++ "cabs.c",
505 "complex" ++ path.sep_str ++ "cabsf.c",
506 "complex" ++ path.sep_str ++ "cabsl.c",
507 "complex" ++ path.sep_str ++ "cacos.c",
508 "complex" ++ path.sep_str ++ "cacosf.c",
509 "complex" ++ path.sep_str ++ "cacosl.c",
510 "complex" ++ path.sep_str ++ "carg.c",
511 "complex" ++ path.sep_str ++ "cargf.c",
512 "complex" ++ path.sep_str ++ "cargl.c",
513 "complex" ++ path.sep_str ++ "casin.c",
514 "complex" ++ path.sep_str ++ "casinf.c",
515 "complex" ++ path.sep_str ++ "casinl.c",
516 "complex" ++ path.sep_str ++ "catan.c",
517 "complex" ++ path.sep_str ++ "catanf.c",
518 "complex" ++ path.sep_str ++ "catanl.c",
519 "complex" ++ path.sep_str ++ "ccos.c",
520 "complex" ++ path.sep_str ++ "ccosf.c",
521 "complex" ++ path.sep_str ++ "ccosl.c",
522 "complex" ++ path.sep_str ++ "cexp.c",
523 "complex" ++ path.sep_str ++ "cexpf.c",
524 "complex" ++ path.sep_str ++ "cexpl.c",
525 "complex" ++ path.sep_str ++ "cimag.c",
526 "complex" ++ path.sep_str ++ "cimagf.c",
527 "complex" ++ path.sep_str ++ "cimagl.c",
528 "complex" ++ path.sep_str ++ "clog.c",
529 "complex" ++ path.sep_str ++ "clog10.c",
530 "complex" ++ path.sep_str ++ "clog10f.c",
531 "complex" ++ path.sep_str ++ "clog10l.c",
532 "complex" ++ path.sep_str ++ "clogf.c",
533 "complex" ++ path.sep_str ++ "clogl.c",
534 "complex" ++ path.sep_str ++ "conj.c",
535 "complex" ++ path.sep_str ++ "conjf.c",
536 "complex" ++ path.sep_str ++ "conjl.c",
537 "complex" ++ path.sep_str ++ "cpow.c",
538 "complex" ++ path.sep_str ++ "cpowf.c",
539 "complex" ++ path.sep_str ++ "cpowl.c",
540 "complex" ++ path.sep_str ++ "cproj.c",
541 "complex" ++ path.sep_str ++ "cprojf.c",
542 "complex" ++ path.sep_str ++ "cprojl.c",
543 "complex" ++ path.sep_str ++ "creal.c",
544 "complex" ++ path.sep_str ++ "crealf.c",
545 "complex" ++ path.sep_str ++ "creall.c",
546 "complex" ++ path.sep_str ++ "csin.c",
547 "complex" ++ path.sep_str ++ "csinf.c",
548 "complex" ++ path.sep_str ++ "csinl.c",
549 "complex" ++ path.sep_str ++ "csqrt.c",
550 "complex" ++ path.sep_str ++ "csqrtf.c",
551 "complex" ++ path.sep_str ++ "csqrtl.c",
552 "complex" ++ path.sep_str ++ "ctan.c",
553 "complex" ++ path.sep_str ++ "ctanf.c",
554 "complex" ++ path.sep_str ++ "ctanl.c",
555 "gdtoa" ++ path.sep_str ++ "arithchk.c",
556 "gdtoa" ++ path.sep_str ++ "dmisc.c",
557 "gdtoa" ++ path.sep_str ++ "dtoa.c",
558 "gdtoa" ++ path.sep_str ++ "g__fmt.c",
559 "gdtoa" ++ path.sep_str ++ "g_dfmt.c",
560 "gdtoa" ++ path.sep_str ++ "g_ffmt.c",
561 "gdtoa" ++ path.sep_str ++ "g_xfmt.c",
562 "gdtoa" ++ path.sep_str ++ "gdtoa.c",
563 "gdtoa" ++ path.sep_str ++ "gethex.c",
564 "gdtoa" ++ path.sep_str ++ "gmisc.c",
565 "gdtoa" ++ path.sep_str ++ "hd_init.c",
566 "gdtoa" ++ path.sep_str ++ "hexnan.c",
567 "gdtoa" ++ path.sep_str ++ "misc.c",
568 "gdtoa" ++ path.sep_str ++ "qnan.c",
569 "gdtoa" ++ path.sep_str ++ "smisc.c",
570 "gdtoa" ++ path.sep_str ++ "strtodg.c",
571 "gdtoa" ++ path.sep_str ++ "strtodnrp.c",
572 "gdtoa" ++ path.sep_str ++ "strtof.c",
573 "gdtoa" ++ path.sep_str ++ "strtopx.c",
574 "gdtoa" ++ path.sep_str ++ "sum.c",
575 "gdtoa" ++ path.sep_str ++ "ulp.c",
576 "math" ++ path.sep_str ++ "coshl.c",
577 "math" ++ path.sep_str ++ "fabsl.c",
578 "math" ++ path.sep_str ++ "fp_consts.c",
579 "math" ++ path.sep_str ++ "fp_constsf.c",
580 "math" ++ path.sep_str ++ "fp_constsl.c",
581 "math" ++ path.sep_str ++ "fpclassify.c",
582 "math" ++ path.sep_str ++ "fpclassifyf.c",
583 "math" ++ path.sep_str ++ "fpclassifyl.c",
584 "math" ++ path.sep_str ++ "frexpf.c",
585 "math" ++ path.sep_str ++ "frexpl.c",
586 "math" ++ path.sep_str ++ "hypotf.c",
587 "math" ++ path.sep_str ++ "hypotl.c",
588 "math" ++ path.sep_str ++ "isnan.c",
589 "math" ++ path.sep_str ++ "isnanf.c",
590 "math" ++ path.sep_str ++ "isnanl.c",
591 "math" ++ path.sep_str ++ "ldexpf.c",
592 "math" ++ path.sep_str ++ "lgamma.c",
593 "math" ++ path.sep_str ++ "lgammaf.c",
594 "math" ++ path.sep_str ++ "lgammal.c",
595 "math" ++ path.sep_str ++ "modfl.c",
596 "math" ++ path.sep_str ++ "powi.c",
597 "math" ++ path.sep_str ++ "powif.c",
598 "math" ++ path.sep_str ++ "powil.c",
599 "math" ++ path.sep_str ++ "signbit.c",
600 "math" ++ path.sep_str ++ "signbitf.c",
601 "math" ++ path.sep_str ++ "signbitl.c",
602 "math" ++ path.sep_str ++ "signgam.c",
603 "math" ++ path.sep_str ++ "sinhl.c",
604 "math" ++ path.sep_str ++ "sqrtl.c",
605 "math" ++ path.sep_str ++ "tanhl.c",
606 "misc" ++ path.sep_str ++ "alarm.c",
607 "misc" ++ path.sep_str ++ "btowc.c",
608 "misc" ++ path.sep_str ++ "delay-f.c",
609 "misc" ++ path.sep_str ++ "delay-n.c",
610 "misc" ++ path.sep_str ++ "delayimp.c",
611 "misc" ++ path.sep_str ++ "dirent.c",
612 "misc" ++ path.sep_str ++ "dirname.c",
613 "misc" ++ path.sep_str ++ "dllentrypoint.c",
614 "misc" ++ path.sep_str ++ "dllmain.c",
615 "misc" ++ path.sep_str ++ "feclearexcept.c",
616 "misc" ++ path.sep_str ++ "fegetenv.c",
617 "misc" ++ path.sep_str ++ "fegetexceptflag.c",
618 "misc" ++ path.sep_str ++ "fegetround.c",
619 "misc" ++ path.sep_str ++ "feholdexcept.c",
620 "misc" ++ path.sep_str ++ "feraiseexcept.c",
621 "misc" ++ path.sep_str ++ "fesetenv.c",
622 "misc" ++ path.sep_str ++ "fesetexceptflag.c",
623 "misc" ++ path.sep_str ++ "fesetround.c",
624 "misc" ++ path.sep_str ++ "fetestexcept.c",
625 "misc" ++ path.sep_str ++ "feupdateenv.c",
626 "misc" ++ path.sep_str ++ "ftruncate.c",
627 "misc" ++ path.sep_str ++ "ftw.c",
628 "misc" ++ path.sep_str ++ "ftw64.c",
629 "misc" ++ path.sep_str ++ "fwide.c",
630 "misc" ++ path.sep_str ++ "getlogin.c",
631 "misc" ++ path.sep_str ++ "getopt.c",
632 "misc" ++ path.sep_str ++ "gettimeofday.c",
633 "misc" ++ path.sep_str ++ "mempcpy.c",
634 "misc" ++ path.sep_str ++ "mingw-access.c",
635 "misc" ++ path.sep_str ++ "mingw-aligned-malloc.c",
636 "misc" ++ path.sep_str ++ "mingw_getsp.S",
637 "misc" ++ path.sep_str ++ "mingw_longjmp.S",
638 "misc" ++ path.sep_str ++ "mingw_matherr.c",
639 "misc" ++ path.sep_str ++ "mingw_mbwc_convert.c",
640 "misc" ++ path.sep_str ++ "mingw_usleep.c",
641 "misc" ++ path.sep_str ++ "mingw_wcstod.c",
642 "misc" ++ path.sep_str ++ "mingw_wcstof.c",
643 "misc" ++ path.sep_str ++ "mingw_wcstold.c",
644 "misc" ++ path.sep_str ++ "mkstemp.c",
645 "misc" ++ path.sep_str ++ "sleep.c",
646 "misc" ++ path.sep_str ++ "strnlen.c",
647 "misc" ++ path.sep_str ++ "strsafe.c",
648 "misc" ++ path.sep_str ++ "tdelete.c",
649 "misc" ++ path.sep_str ++ "tdestroy.c",
650 "misc" ++ path.sep_str ++ "tfind.c",
651 "misc" ++ path.sep_str ++ "tsearch.c",
652 "misc" ++ path.sep_str ++ "twalk.c",
653 "misc" ++ path.sep_str ++ "wcsnlen.c",
654 "misc" ++ path.sep_str ++ "wcstof.c",
655 "misc" ++ path.sep_str ++ "wcstoimax.c",
656 "misc" ++ path.sep_str ++ "wcstold.c",
657 "misc" ++ path.sep_str ++ "wcstoumax.c",
658 "misc" ++ path.sep_str ++ "wctob.c",
659 "misc" ++ path.sep_str ++ "wdirent.c",
660 "misc" ++ path.sep_str ++ "winbs_uint64.c",
661 "misc" ++ path.sep_str ++ "winbs_ulong.c",
662 "misc" ++ path.sep_str ++ "winbs_ushort.c",
663 "misc" ++ path.sep_str ++ "wmemchr.c",
664 "misc" ++ path.sep_str ++ "wmemcmp.c",
665 "misc" ++ path.sep_str ++ "wmemcpy.c",
666 "misc" ++ path.sep_str ++ "wmemmove.c",
667 "misc" ++ path.sep_str ++ "wmempcpy.c",
668 "misc" ++ path.sep_str ++ "wmemset.c",
669 "stdio" ++ path.sep_str ++ "_Exit.c",
670 "stdio" ++ path.sep_str ++ "_findfirst64i32.c",
671 "stdio" ++ path.sep_str ++ "_findnext64i32.c",
672 "stdio" ++ path.sep_str ++ "_fstat64i32.c",
673 "stdio" ++ path.sep_str ++ "_stat.c",
674 "stdio" ++ path.sep_str ++ "_stat64i32.c",
675 "stdio" ++ path.sep_str ++ "_wfindfirst64i32.c",
676 "stdio" ++ path.sep_str ++ "_wfindnext64i32.c",
677 "stdio" ++ path.sep_str ++ "_wstat.c",
678 "stdio" ++ path.sep_str ++ "_wstat64i32.c",
679 "stdio" ++ path.sep_str ++ "asprintf.c",
680 "stdio" ++ path.sep_str ++ "fopen64.c",
681 "stdio" ++ path.sep_str ++ "fseeko32.c",
682 "stdio" ++ path.sep_str ++ "fseeko64.c",
683 "stdio" ++ path.sep_str ++ "ftello.c",
684 "stdio" ++ path.sep_str ++ "ftello64.c",
685 "stdio" ++ path.sep_str ++ "ftruncate64.c",
686 "stdio" ++ path.sep_str ++ "lltoa.c",
687 "stdio" ++ path.sep_str ++ "lltow.c",
688 "stdio" ++ path.sep_str ++ "lseek64.c",
689 "stdio" ++ path.sep_str ++ "mingw_asprintf.c",
690 "stdio" ++ path.sep_str ++ "mingw_fprintf.c",
691 "stdio" ++ path.sep_str ++ "mingw_fwprintf.c",
692 "stdio" ++ path.sep_str ++ "mingw_fscanf.c",
693 "stdio" ++ path.sep_str ++ "mingw_fwscanf.c",
694 "stdio" ++ path.sep_str ++ "mingw_pformat.c",
695 "stdio" ++ path.sep_str ++ "mingw_sformat.c",
696 "stdio" ++ path.sep_str ++ "mingw_swformat.c",
697 "stdio" ++ path.sep_str ++ "mingw_wpformat.c",
698 "stdio" ++ path.sep_str ++ "mingw_printf.c",
699 "stdio" ++ path.sep_str ++ "mingw_wprintf.c",
700 "stdio" ++ path.sep_str ++ "mingw_scanf.c",
701 "stdio" ++ path.sep_str ++ "mingw_snprintf.c",
702 "stdio" ++ path.sep_str ++ "mingw_snwprintf.c",
703 "stdio" ++ path.sep_str ++ "mingw_sprintf.c",
704 "stdio" ++ path.sep_str ++ "mingw_swprintf.c",
705 "stdio" ++ path.sep_str ++ "mingw_sscanf.c",
706 "stdio" ++ path.sep_str ++ "mingw_swscanf.c",
707 "stdio" ++ path.sep_str ++ "mingw_vasprintf.c",
708 "stdio" ++ path.sep_str ++ "mingw_vfprintf.c",
709 "stdio" ++ path.sep_str ++ "mingw_vfwprintf.c",
710 "stdio" ++ path.sep_str ++ "mingw_vfscanf.c",
711 "stdio" ++ path.sep_str ++ "mingw_vprintf.c",
712 "stdio" ++ path.sep_str ++ "mingw_vsscanf.c",
713 "stdio" ++ path.sep_str ++ "mingw_vwprintf.c",
714 "stdio" ++ path.sep_str ++ "mingw_vsnprintf.c",
715 "stdio" ++ path.sep_str ++ "mingw_vsnwprintf.c",
716 "stdio" ++ path.sep_str ++ "mingw_vsprintf.c",
717 "stdio" ++ path.sep_str ++ "mingw_vswprintf.c",
718 "stdio" ++ path.sep_str ++ "mingw_wscanf.c",
719 "stdio" ++ path.sep_str ++ "mingw_vfwscanf.c",
720 "stdio" ++ path.sep_str ++ "mingw_vswscanf.c",
721 "stdio" ++ path.sep_str ++ "snprintf.c",
722 "stdio" ++ path.sep_str ++ "snwprintf.c",
723 "stdio" ++ path.sep_str ++ "strtok_r.c",
724 "stdio" ++ path.sep_str ++ "truncate.c",
725 "stdio" ++ path.sep_str ++ "ulltoa.c",
726 "stdio" ++ path.sep_str ++ "ulltow.c",
727 "stdio" ++ path.sep_str ++ "vasprintf.c",
728 "stdio" ++ path.sep_str ++ "vsnprintf.c",
729 "stdio" ++ path.sep_str ++ "vsnwprintf.c",
730 "stdio" ++ path.sep_str ++ "wtoll.c",
731 // mingwthrd
732 "libsrc" ++ path.sep_str ++ "mingwthrd_mt.c",
733 // ucrtbase
734 "math" ++ path.sep_str ++ "_huge.c",
735 "misc" ++ path.sep_str ++ "__initenv.c",
736 "misc" ++ path.sep_str ++ "__winitenv.c",
737 "misc" ++ path.sep_str ++ "__p___initenv.c",
738 "misc" ++ path.sep_str ++ "__p___winitenv.c",
739 "misc" ++ path.sep_str ++ "_onexit.c",
740 "misc" ++ path.sep_str ++ "ucrt-access.c",
741 "misc" ++ path.sep_str ++ "ucrt__getmainargs.c",
742 "misc" ++ path.sep_str ++ "ucrt__wgetmainargs.c",
743 "misc" ++ path.sep_str ++ "ucrt_amsg_exit.c",
744 "misc" ++ path.sep_str ++ "ucrt_at_quick_exit.c",
745 "misc" ++ path.sep_str ++ "ucrt_tzset.c",
746 "stdio" ++ path.sep_str ++ "ucrt__scprintf.c",
747 "stdio" ++ path.sep_str ++ "ucrt__snprintf.c",
748 "stdio" ++ path.sep_str ++ "ucrt__snscanf.c",
749 "stdio" ++ path.sep_str ++ "ucrt__snwprintf.c",
750 "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c",
751 "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c",
752 "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c",
753 "stdio" ++ path.sep_str ++ "ucrt_fprintf.c",
754 "stdio" ++ path.sep_str ++ "ucrt_fscanf.c",
755 "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c",
756 "stdio" ++ path.sep_str ++ "ucrt_ms_fprintf.c",
757 "stdio" ++ path.sep_str ++ "ucrt_ms_fwprintf.c",
758 "stdio" ++ path.sep_str ++ "ucrt_printf.c",
759 "stdio" ++ path.sep_str ++ "ucrt_scanf.c",
760 "stdio" ++ path.sep_str ++ "ucrt_snprintf.c",
761 "stdio" ++ path.sep_str ++ "ucrt_sprintf.c",
762 "stdio" ++ path.sep_str ++ "ucrt_sscanf.c",
763 "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c",
764 "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c",
765 "stdio" ++ path.sep_str ++ "ucrt_vprintf.c",
766 "stdio" ++ path.sep_str ++ "ucrt_vscanf.c",
767 "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c",
768 "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c",
769 "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c",
770 "string" ++ path.sep_str ++ "ucrt__wcstok.c",
771 // uuid
772 "libsrc" ++ path.sep_str ++ "ativscp-uuid.c",
773 "libsrc" ++ path.sep_str ++ "atsmedia-uuid.c",
774 "libsrc" ++ path.sep_str ++ "bth-uuid.c",
775 "libsrc" ++ path.sep_str ++ "cguid-uuid.c",
776 "libsrc" ++ path.sep_str ++ "comcat-uuid.c",
777 "libsrc" ++ path.sep_str ++ "ctxtcall-uuid.c",
778 "libsrc" ++ path.sep_str ++ "devguid.c",
779 "libsrc" ++ path.sep_str ++ "docobj-uuid.c",
780 "libsrc" ++ path.sep_str ++ "dxva-uuid.c",
781 "libsrc" ++ path.sep_str ++ "exdisp-uuid.c",
782 "libsrc" ++ path.sep_str ++ "extras-uuid.c",
783 "libsrc" ++ path.sep_str ++ "fwp-uuid.c",
784 "libsrc" ++ path.sep_str ++ "guid_nul.c",
785 "libsrc" ++ path.sep_str ++ "hlguids-uuid.c",
786 "libsrc" ++ path.sep_str ++ "hlink-uuid.c",
787 "libsrc" ++ path.sep_str ++ "mlang-uuid.c",
788 "libsrc" ++ path.sep_str ++ "msctf-uuid.c",
789 "libsrc" ++ path.sep_str ++ "mshtmhst-uuid.c",
790 "libsrc" ++ path.sep_str ++ "mshtml-uuid.c",
791 "libsrc" ++ path.sep_str ++ "msxml-uuid.c",
792 "libsrc" ++ path.sep_str ++ "netcfg-uuid.c",
793 "libsrc" ++ path.sep_str ++ "netcon-uuid.c",
794 "libsrc" ++ path.sep_str ++ "ntddkbd-uuid.c",
795 "libsrc" ++ path.sep_str ++ "ntddmou-uuid.c",
796 "libsrc" ++ path.sep_str ++ "ntddpar-uuid.c",
797 "libsrc" ++ path.sep_str ++ "ntddscsi-uuid.c",
798 "libsrc" ++ path.sep_str ++ "ntddser-uuid.c",
799 "libsrc" ++ path.sep_str ++ "ntddstor-uuid.c",
800 "libsrc" ++ path.sep_str ++ "ntddvdeo-uuid.c",
801 "libsrc" ++ path.sep_str ++ "oaidl-uuid.c",
802 "libsrc" ++ path.sep_str ++ "objidl-uuid.c",
803 "libsrc" ++ path.sep_str ++ "objsafe-uuid.c",
804 "libsrc" ++ path.sep_str ++ "ocidl-uuid.c",
805 "libsrc" ++ path.sep_str ++ "oleacc-uuid.c",
806 "libsrc" ++ path.sep_str ++ "olectlid-uuid.c",
807 "libsrc" ++ path.sep_str ++ "oleidl-uuid.c",
808 "libsrc" ++ path.sep_str ++ "power-uuid.c",
809 "libsrc" ++ path.sep_str ++ "powrprof-uuid.c",
810 "libsrc" ++ path.sep_str ++ "uianimation-uuid.c",
811 "libsrc" ++ path.sep_str ++ "usbcamdi-uuid.c",
812 "libsrc" ++ path.sep_str ++ "usbiodef-uuid.c",
813 "libsrc" ++ path.sep_str ++ "uuid.c",
814 "libsrc" ++ path.sep_str ++ "vds-uuid.c",
815 "libsrc" ++ path.sep_str ++ "virtdisk-uuid.c",
816 "libsrc" ++ path.sep_str ++ "vss-uuid.c",
817 "libsrc" ++ path.sep_str ++ "wia-uuid.c",
818 "libsrc" ++ path.sep_str ++ "windowscodecs.c",
819 // ws2_32
820 "libsrc" ++ path.sep_str ++ "ws2_32.c",
821 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_addr_equal.c",
822 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isany.c",
823 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_isloopback.c",
824 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setany.c",
825 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6addr_setloopback.c",
826 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_linklocal.c",
827 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_loopback.c",
828 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_global.c",
829 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_linklocal.c",
830 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_nodelocal.c",
831 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_orglocal.c",
832 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_mc_sitelocal.c",
833 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_multicast.c",
834 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_sitelocal.c",
835 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_unspecified.c",
836 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4compat.c",
837 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_is_addr_v4mapped.c",
838 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_loopback.c",
839 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "in6_set_addr_unspecified.c",
840 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorA.c",
841 "libsrc" ++ path.sep_str ++ "ws2tcpip" ++ path.sep_str ++ "gai_strerrorW.c",
842 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiStrdup.c",
843 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiParseV4Address.c",
844 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiNewAddrInfo.c",
845 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiQueryDNS.c",
846 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLookupNode.c",
847 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiClone.c",
848 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyFreeAddrInfo.c",
849 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetAddrInfo.c",
850 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLegacyGetNameInfo.c",
851 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiLoad.c",
852 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetAddrInfo.c",
853 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiGetNameInfo.c",
854 "libsrc" ++ path.sep_str ++ "wspiapi" ++ path.sep_str ++ "WspiapiFreeAddrInfo.c",
855 // dinput
856 "libsrc" ++ path.sep_str ++ "dinput_kbd.c",
857 "libsrc" ++ path.sep_str ++ "dinput_joy.c",
858 "libsrc" ++ path.sep_str ++ "dinput_joy2.c",
859 "libsrc" ++ path.sep_str ++ "dinput_mouse.c",
860 "libsrc" ++ path.sep_str ++ "dinput_mouse2.c",
861 // dloadhelper
862 "libsrc" ++ path.sep_str ++ "dloadhelper.c",
863 "misc" ++ path.sep_str ++ "delay-f.c",
864 // misc.
865 "libsrc" ++ path.sep_str ++ "bits.c",
866 "libsrc" ++ path.sep_str ++ "shell32.c",
867 "libsrc" ++ path.sep_str ++ "dmoguids.c",
868 "libsrc" ++ path.sep_str ++ "dxerr8.c",
869 "libsrc" ++ path.sep_str ++ "dxerr8w.c",
870 "libsrc" ++ path.sep_str ++ "dxerr9.c",
871 "libsrc" ++ path.sep_str ++ "dxerr9w.c",
872 "libsrc" ++ path.sep_str ++ "mfuuid.c",
873 "libsrc" ++ path.sep_str ++ "msxml2.c",
874 "libsrc" ++ path.sep_str ++ "msxml6.c",
875 "libsrc" ++ path.sep_str ++ "amstrmid.c",
876 "libsrc" ++ path.sep_str ++ "wbemuuid.c",
877 "libsrc" ++ path.sep_str ++ "wmcodecdspuuid.c",
878 "libsrc" ++ path.sep_str ++ "windowscodecs.c",
879 "libsrc" ++ path.sep_str ++ "dxguid.c",
880 "libsrc" ++ path.sep_str ++ "ksuser.c",
881 "libsrc" ++ path.sep_str ++ "largeint.c",
882 "libsrc" ++ path.sep_str ++ "locationapi.c",
883 "libsrc" ++ path.sep_str ++ "sapi.c",
884 "libsrc" ++ path.sep_str ++ "sensorsapi.c",
885 "libsrc" ++ path.sep_str ++ "portabledeviceguids.c",
886 "libsrc" ++ path.sep_str ++ "taskschd.c",
887 "libsrc" ++ path.sep_str ++ "scrnsave.c",
888 "libsrc" ++ path.sep_str ++ "strmiids.c",
889 "libsrc" ++ path.sep_str ++ "gdiplus.c",
890 "libsrc" ++ path.sep_str ++ "activeds-uuid.c",
891};
892
893const mingw32_x86_src = [_][]const u8{
894 // mingwex
895 "math" ++ path.sep_str ++ "cbrtl.c",
896 "math" ++ path.sep_str ++ "erfl.c",
897 "math" ++ path.sep_str ++ "fdiml.c",
898 "math" ++ path.sep_str ++ "fmal.c",
899 "math" ++ path.sep_str ++ "fmaxl.c",
900 "math" ++ path.sep_str ++ "fminl.c",
901 "math" ++ path.sep_str ++ "llrintl.c",
902 "math" ++ path.sep_str ++ "llroundl.c",
903 "math" ++ path.sep_str ++ "lrintl.c",
904 "math" ++ path.sep_str ++ "lroundl.c",
905 "math" ++ path.sep_str ++ "rintl.c",
906 "math" ++ path.sep_str ++ "roundl.c",
907 "math" ++ path.sep_str ++ "tgammal.c",
908 "math" ++ path.sep_str ++ "truncl.c",
909 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "_chgsignl.S",
910 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acoshl.c",
911 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosl.c",
912 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinhl.c",
913 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinl.c",
914 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
915 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
916 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
917 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceill.S",
918 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
919 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
920 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
921 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossin.c",
922 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cossinl.c",
923 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "exp2l.S",
924 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expl.c",
925 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "expm1l.c",
926 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorl.S",
927 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodl.c",
928 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fucom.c",
929 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ilogbl.S",
930 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "internal_logl.S",
931 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexp.c",
932 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ldexpl.c",
933 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log10l.S",
934 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log1pl.S",
935 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "log2l.S",
936 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logbl.c",
937 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "logl.c",
938 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "nearbyintl.S",
939 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "powl.c",
940 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remainderl.S",
941 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "remquol.S",
942 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbn.S",
943 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnf.S",
944 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "scalbnl.S",
945 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl.c",
946 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl_internal.S",
947 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanl.S",
948 // ucrtbase
949 "math" ++ path.sep_str ++ "fabsf.c",
950 "math" ++ path.sep_str ++ "nextafterl.c",
951 "math" ++ path.sep_str ++ "nexttoward.c",
952 "math" ++ path.sep_str ++ "nexttowardf.c",
953};
954
955const mingw32_x86_32_src = [_][]const u8{
956 // ucrtbase
957 "math" ++ path.sep_str ++ "coshf.c",
958 "math" ++ path.sep_str ++ "expf.c",
959 "math" ++ path.sep_str ++ "log10f.c",
960 "math" ++ path.sep_str ++ "logf.c",
961 "math" ++ path.sep_str ++ "modff.c",
962 "math" ++ path.sep_str ++ "powf.c",
963 "math" ++ path.sep_str ++ "sinhf.c",
964 "math" ++ path.sep_str ++ "sqrtf.c",
965 "math" ++ path.sep_str ++ "tanhf.c",
966 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosf.c",
967 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c",
968 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",
969 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",
970 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S",
971 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosf.c",
972 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "floorf.S",
973 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",
974 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinf.c",
975 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanf.c",
976};
977
978const mingw32_arm_src = [_][]const u8{
979 // mingwex
980 "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c",
981};
982
983const mingw32_arm32_src = [_][]const u8{
984 // mingwex
985 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S",
986 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c",
987 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c",
988 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S",
989 "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincosf.S",
990};
991
992const mingw32_arm64_src = [_][]const u8{
993 // mingwex
994 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S",
995 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c",
996 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c",
997 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S",
998 "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincosf.S",
999};
1000
1001const mingw32_winpthreads_src = [_][]const u8{
1002 // winpthreads
1003 "winpthreads" ++ path.sep_str ++ "barrier.c",
1004 "winpthreads" ++ path.sep_str ++ "clock.c",
1005 "winpthreads" ++ path.sep_str ++ "cond.c",
1006 "winpthreads" ++ path.sep_str ++ "misc.c",
1007 "winpthreads" ++ path.sep_str ++ "mutex.c",
1008 "winpthreads" ++ path.sep_str ++ "nanosleep.c",
1009 "winpthreads" ++ path.sep_str ++ "ref.c",
1010 "winpthreads" ++ path.sep_str ++ "rwlock.c",
1011 "winpthreads" ++ path.sep_str ++ "sched.c",
1012 "winpthreads" ++ path.sep_str ++ "sem.c",
1013 "winpthreads" ++ path.sep_str ++ "spinlock.c",
1014 "winpthreads" ++ path.sep_str ++ "thread.c",
1015};
1016
1017pub const always_link_libs = [_][]const u8{
1018 "api-ms-win-crt-conio-l1-1-0",
1019 "api-ms-win-crt-convert-l1-1-0",
1020 "api-ms-win-crt-environment-l1-1-0",
1021 "api-ms-win-crt-filesystem-l1-1-0",
1022 "api-ms-win-crt-heap-l1-1-0",
1023 "api-ms-win-crt-locale-l1-1-0",
1024 "api-ms-win-crt-math-l1-1-0",
1025 "api-ms-win-crt-multibyte-l1-1-0",
1026 "api-ms-win-crt-private-l1-1-0",
1027 "api-ms-win-crt-process-l1-1-0",
1028 "api-ms-win-crt-runtime-l1-1-0",
1029 "api-ms-win-crt-stdio-l1-1-0",
1030 "api-ms-win-crt-string-l1-1-0",
1031 "api-ms-win-crt-time-l1-1-0",
1032 "api-ms-win-crt-utility-l1-1-0",
1033 "advapi32",
1034 "kernel32",
1035 "ntdll",
1036 "shell32",
1037 "user32",
1038};
src/musl.zig deleted-2313
...@@ -1,2313 +0,0 @@
1const std = @import("std");
2const Allocator = std.mem.Allocator;
3const mem = std.mem;
4const path = std.fs.path;
5const assert = std.debug.assert;
6const Module = @import("Package/Module.zig");
7
8const Compilation = @import("Compilation.zig");
9const build_options = @import("build_options");
10
11pub const CrtFile = enum {
12 crt1_o,
13 rcrt1_o,
14 scrt1_o,
15 libc_a,
16 libc_so,
17};
18
19/// TODO replace anyerror with explicit error set, recording user-friendly errors with
20/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
21pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
22 if (!build_options.have_llvm) {
23 return error.ZigCompilerNotBuiltWithLLVMExtensions;
24 }
25 const gpa = comp.gpa;
26 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
27 defer arena_allocator.deinit();
28 const arena = arena_allocator.allocator();
29
30 switch (in_crt_file) {
31 .crt1_o => {
32 var args = std.ArrayList([]const u8).init(arena);
33 try addCcArgs(comp, arena, &args, false);
34 try args.append("-DCRT");
35 var files = [_]Compilation.CSourceFile{
36 .{
37 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
38 "libc", "musl", "crt", "crt1.c",
39 }),
40 .extra_flags = args.items,
41 .owner = undefined,
42 },
43 };
44 return comp.build_crt_file("crt1", .Obj, .@"musl crt1.o", prog_node, &files, .{
45 .function_sections = true,
46 .data_sections = true,
47 .omit_frame_pointer = true,
48 .no_builtin = true,
49 });
50 },
51 .rcrt1_o => {
52 var args = std.ArrayList([]const u8).init(arena);
53 try addCcArgs(comp, arena, &args, false);
54 try args.append("-DCRT");
55 var files = [_]Compilation.CSourceFile{
56 .{
57 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
58 "libc", "musl", "crt", "rcrt1.c",
59 }),
60 .extra_flags = args.items,
61 .owner = undefined,
62 },
63 };
64 return comp.build_crt_file("rcrt1", .Obj, .@"musl rcrt1.o", prog_node, &files, .{
65 .function_sections = true,
66 .data_sections = true,
67 .omit_frame_pointer = true,
68 .pic = true,
69 .no_builtin = true,
70 });
71 },
72 .scrt1_o => {
73 var args = std.ArrayList([]const u8).init(arena);
74 try addCcArgs(comp, arena, &args, false);
75 try args.append("-DCRT");
76 var files = [_]Compilation.CSourceFile{
77 .{
78 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
79 "libc", "musl", "crt", "Scrt1.c",
80 }),
81 .extra_flags = args.items,
82 .owner = undefined,
83 },
84 };
85 return comp.build_crt_file("Scrt1", .Obj, .@"musl Scrt1.o", prog_node, &files, .{
86 .function_sections = true,
87 .data_sections = true,
88 .omit_frame_pointer = true,
89 .pic = true,
90 .no_builtin = true,
91 });
92 },
93 .libc_a => {
94 // When there is a src/<arch>/foo.* then it should substitute for src/foo.*
95 // Even a .s file can substitute for a .c file.
96 const target = comp.getTarget();
97 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
98 var source_table = std.StringArrayHashMap(Ext).init(comp.gpa);
99 defer source_table.deinit();
100
101 try source_table.ensureTotalCapacity(compat_time32_files.len + src_files.len);
102
103 for (src_files) |src_file| {
104 try addSrcFile(arena, &source_table, src_file);
105 }
106
107 for (time32_compat_arch_list) |time32_compat_arch| {
108 if (mem.eql(u8, arch_name, time32_compat_arch)) {
109 for (compat_time32_files) |compat_time32_file| {
110 try addSrcFile(arena, &source_table, compat_time32_file);
111 }
112 }
113 }
114
115 var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa);
116 defer c_source_files.deinit();
117
118 var override_path = std.ArrayList(u8).init(comp.gpa);
119 defer override_path.deinit();
120
121 const s = path.sep_str;
122
123 var it = source_table.iterator();
124 while (it.next()) |entry| {
125 const src_file = entry.key_ptr.*;
126 const ext = entry.value_ptr.*;
127
128 const dirname = path.dirname(src_file).?;
129 const basename = path.basename(src_file);
130 const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
131 const dirbasename = path.basename(dirname);
132
133 var is_arch_specific = false;
134 // Architecture-specific implementations are under a <arch>/ folder.
135 if (isArchName(dirbasename)) {
136 if (!mem.eql(u8, dirbasename, arch_name))
137 continue; // Not the architecture we're compiling for.
138 is_arch_specific = true;
139 }
140 if (!is_arch_specific) {
141 // Look for an arch specific override.
142 override_path.shrinkRetainingCapacity(0);
143 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{
144 dirname, arch_name, noextbasename,
145 });
146 if (source_table.contains(override_path.items))
147 continue;
148
149 override_path.shrinkRetainingCapacity(0);
150 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{
151 dirname, arch_name, noextbasename,
152 });
153 if (source_table.contains(override_path.items))
154 continue;
155
156 override_path.shrinkRetainingCapacity(0);
157 try override_path.writer().print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{
158 dirname, arch_name, noextbasename,
159 });
160 if (source_table.contains(override_path.items))
161 continue;
162 }
163
164 var args = std.ArrayList([]const u8).init(arena);
165 try addCcArgs(comp, arena, &args, ext == .o3);
166 const c_source_file = try c_source_files.addOne();
167 c_source_file.* = .{
168 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", src_file }),
169 .extra_flags = args.items,
170 .owner = undefined,
171 };
172 }
173 return comp.build_crt_file("c", .Lib, .@"musl libc.a", prog_node, c_source_files.items, .{
174 .function_sections = true,
175 .data_sections = true,
176 .omit_frame_pointer = true,
177 .no_builtin = true,
178 });
179 },
180 .libc_so => {
181 const optimize_mode = comp.compilerRtOptMode();
182 const strip = comp.compilerRtStrip();
183 const output_mode: std.builtin.OutputMode = .Lib;
184 const config = try Compilation.Config.resolve(.{
185 .output_mode = output_mode,
186 .link_mode = .dynamic,
187 .resolved_target = comp.root_mod.resolved_target,
188 .is_test = false,
189 .have_zcu = false,
190 .emit_bin = true,
191 .root_optimize_mode = optimize_mode,
192 .root_strip = strip,
193 .link_libc = false,
194 });
195
196 const target = comp.root_mod.resolved_target.result;
197 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
198 const time32 = for (time32_compat_arch_list) |time32_compat_arch| {
199 if (mem.eql(u8, arch_name, time32_compat_arch)) break true;
200 } else false;
201 const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{arch_name});
202 const family_define = switch (target.cpu.arch) {
203 .arm, .armeb, .thumb, .thumbeb => "-DFAMILY_arm",
204 .aarch64, .aarch64_be => "-DFAMILY_aarch64",
205 .hexagon => "-DFAMILY_hexagon",
206 .loongarch64 => "-DFAMILY_loongarch",
207 .m68k => "-DFAMILY_m68k",
208 .mips, .mipsel, .mips64, .mips64el => "-DFAMILY_mips",
209 .powerpc, .powerpc64, .powerpc64le => "-DFAMILY_powerpc",
210 .riscv32, .riscv64 => "-DFAMILY_riscv",
211 .s390x => "-DFAMILY_s390x",
212 .x86, .x86_64 => "-DFAMILY_x86",
213 else => unreachable,
214 };
215 const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64)
216 &.{ "-DPTR64", arch_define, family_define }
217 else if (time32)
218 &.{ "-DTIME32", arch_define, family_define }
219 else
220 &.{ arch_define, family_define };
221
222 const root_mod = try Module.create(arena, .{
223 .global_cache_directory = comp.global_cache_directory,
224 .paths = .{
225 .root = .{ .root_dir = comp.zig_lib_directory },
226 .root_src_path = "",
227 },
228 .fully_qualified_name = "root",
229 .inherited = .{
230 .resolved_target = comp.root_mod.resolved_target,
231 .strip = strip,
232 .stack_check = false,
233 .stack_protector = 0,
234 .sanitize_c = .off,
235 .sanitize_thread = false,
236 .red_zone = comp.root_mod.red_zone,
237 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
238 .valgrind = false,
239 .optimize_mode = optimize_mode,
240 .structured_cfg = comp.root_mod.structured_cfg,
241 },
242 .global = config,
243 .cc_argv = cc_argv,
244 .parent = null,
245 .builtin_mod = null,
246 .builtin_modules = null, // there is only one module in this compilation
247 });
248
249 const sub_compilation = try Compilation.create(comp.gpa, arena, .{
250 .local_cache_directory = comp.global_cache_directory,
251 .global_cache_directory = comp.global_cache_directory,
252 .zig_lib_directory = comp.zig_lib_directory,
253 .self_exe_path = comp.self_exe_path,
254 .cache_mode = .whole,
255 .config = config,
256 .root_mod = root_mod,
257 .thread_pool = comp.thread_pool,
258 .root_name = "c",
259 .libc_installation = comp.libc_installation,
260 .emit_bin = .{ .directory = null, .basename = "libc.so" },
261 .emit_h = null,
262 .verbose_cc = comp.verbose_cc,
263 .verbose_link = comp.verbose_link,
264 .verbose_air = comp.verbose_air,
265 .verbose_llvm_ir = comp.verbose_llvm_ir,
266 .verbose_cimport = comp.verbose_cimport,
267 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
268 .clang_passthrough_mode = comp.clang_passthrough_mode,
269 .c_source_files = &[_]Compilation.CSourceFile{
270 .{
271 .src_path = try comp.zig_lib_directory.join(arena, &.{ "libc", "musl", "libc.S" }),
272 .owner = root_mod,
273 },
274 },
275 .skip_linker_dependencies = true,
276 .soname = "libc.so",
277 });
278 defer sub_compilation.destroy();
279
280 try comp.updateSubCompilation(sub_compilation, .@"musl libc.so", prog_node);
281
282 const basename = try comp.gpa.dupe(u8, "libc.so");
283 errdefer comp.gpa.free(basename);
284
285 const crt_file = try sub_compilation.toCrtFile();
286 comp.queueLinkTaskMode(crt_file.full_object_path, output_mode);
287 {
288 comp.mutex.lock();
289 defer comp.mutex.unlock();
290 try comp.crt_files.ensureUnusedCapacity(comp.gpa, 1);
291 comp.crt_files.putAssumeCapacityNoClobber(basename, crt_file);
292 }
293 },
294 }
295}
296
297pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.LinkMode, pie: bool) ?CrtFile {
298 return switch (output_mode) {
299 .Obj, .Lib => null,
300 .Exe => switch (link_mode) {
301 .dynamic => if (pie) .scrt1_o else .crt1_o,
302 .static => if (pie) .rcrt1_o else .crt1_o,
303 },
304 };
305}
306
307const time32_compat_arch_list = [_][]const u8{
308 "arm",
309 "i386",
310 "m68k",
311 "microblaze",
312 "mips",
313 "mipsn32",
314 "or1k",
315 "powerpc",
316 "sh",
317};
318
319fn isArchName(name: []const u8) bool {
320 const musl_arch_names = [_][]const u8{
321 "aarch64",
322 "arm",
323 "generic",
324 "hexagon",
325 "i386",
326 "loongarch64",
327 "m68k",
328 "microblaze",
329 "mips",
330 "mips64",
331 "mipsn32",
332 "or1k",
333 "powerpc",
334 "powerpc64",
335 "riscv32",
336 "riscv64",
337 "s390x",
338 "sh",
339 "x32",
340 "x86_64",
341 };
342 for (musl_arch_names) |musl_arch_name| {
343 if (mem.eql(u8, musl_arch_name, name)) {
344 return true;
345 }
346 }
347 return false;
348}
349
350const Ext = enum {
351 assembly,
352 o3,
353};
354
355fn addSrcFile(arena: Allocator, source_table: *std.StringArrayHashMap(Ext), file_path: []const u8) !void {
356 const ext: Ext = ext: {
357 if (mem.endsWith(u8, file_path, ".c")) {
358 if (mem.startsWith(u8, file_path, "musl/src/malloc/") or
359 mem.startsWith(u8, file_path, "musl/src/string/") or
360 mem.startsWith(u8, file_path, "musl/src/internal/"))
361 {
362 break :ext .o3;
363 } else {
364 break :ext .assembly;
365 }
366 } else if (mem.endsWith(u8, file_path, ".s") or mem.endsWith(u8, file_path, ".S")) {
367 break :ext .assembly;
368 } else {
369 unreachable;
370 }
371 };
372 // TODO do this at comptime on the comptime data rather than at runtime
373 // probably best to wait until self-hosted is done and our comptime execution
374 // is faster and uses less memory.
375 const key = if (path.sep != '/') blk: {
376 const mutable_file_path = try arena.dupe(u8, file_path);
377 for (mutable_file_path) |*c| {
378 if (c.* == '/') {
379 c.* = path.sep;
380 }
381 }
382 break :blk mutable_file_path;
383 } else file_path;
384 source_table.putAssumeCapacityNoClobber(key, ext);
385}
386
387fn addCcArgs(
388 comp: *Compilation,
389 arena: Allocator,
390 args: *std.ArrayList([]const u8),
391 want_O3: bool,
392) error{OutOfMemory}!void {
393 const target = comp.getTarget();
394 const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
395 const os_name = @tagName(target.os.tag);
396 const triple = try std.fmt.allocPrint(arena, "{s}-{s}-{s}", .{
397 std.zig.target.muslArchNameHeaders(target.cpu.arch),
398 os_name,
399 std.zig.target.muslAbiNameHeaders(target.abi),
400 });
401 const o_arg = if (want_O3) "-O3" else "-Os";
402
403 try args.appendSlice(&[_][]const u8{
404 "-std=c99",
405 "-ffreestanding",
406 "-fexcess-precision=standard",
407 "-frounding-math",
408 "-ffp-contract=off",
409 "-fno-strict-aliasing",
410 "-Wa,--noexecstack",
411 "-D_XOPEN_SOURCE=700",
412
413 "-I",
414 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", arch_name }),
415
416 "-I",
417 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "arch", "generic" }),
418
419 "-I",
420 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "include" }),
421
422 "-I",
423 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "src", "internal" }),
424
425 "-I",
426 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "musl", "include" }),
427
428 "-I",
429 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
430
431 "-I",
432 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
433
434 o_arg,
435
436 "-Qunused-arguments",
437 "-w", // disable all warnings
438 });
439
440 if (target.cpu.arch.isThumb()) {
441 try args.append("-mimplicit-it=always");
442 }
443}
444
445fn start_asm_path(comp: *Compilation, arena: Allocator, basename: []const u8) ![]const u8 {
446 const target = comp.getTarget();
447 return comp.zig_lib_directory.join(arena, &[_][]const u8{
448 "libc", "musl", "crt", std.zig.target.muslArchName(target.cpu.arch, target.abi), basename,
449 });
450}
451
452const src_files = [_][]const u8{
453 "musl/src/aio/aio.c",
454 "musl/src/aio/aio_suspend.c",
455 "musl/src/aio/lio_listio.c",
456 "musl/src/complex/cabs.c",
457 "musl/src/complex/cabsf.c",
458 "musl/src/complex/cabsl.c",
459 "musl/src/complex/cacos.c",
460 "musl/src/complex/cacosf.c",
461 "musl/src/complex/cacosh.c",
462 "musl/src/complex/cacoshf.c",
463 "musl/src/complex/cacoshl.c",
464 "musl/src/complex/cacosl.c",
465 "musl/src/complex/carg.c",
466 "musl/src/complex/cargf.c",
467 "musl/src/complex/cargl.c",
468 "musl/src/complex/casin.c",
469 "musl/src/complex/casinf.c",
470 "musl/src/complex/casinh.c",
471 "musl/src/complex/casinhf.c",
472 "musl/src/complex/casinhl.c",
473 "musl/src/complex/casinl.c",
474 "musl/src/complex/catan.c",
475 "musl/src/complex/catanf.c",
476 "musl/src/complex/catanh.c",
477 "musl/src/complex/catanhf.c",
478 "musl/src/complex/catanhl.c",
479 "musl/src/complex/catanl.c",
480 "musl/src/complex/ccos.c",
481 "musl/src/complex/ccosf.c",
482 "musl/src/complex/ccosh.c",
483 "musl/src/complex/ccoshf.c",
484 "musl/src/complex/ccoshl.c",
485 "musl/src/complex/ccosl.c",
486 "musl/src/complex/__cexp.c",
487 "musl/src/complex/cexp.c",
488 "musl/src/complex/__cexpf.c",
489 "musl/src/complex/cexpf.c",
490 "musl/src/complex/cexpl.c",
491 "musl/src/complex/cimag.c",
492 "musl/src/complex/cimagf.c",
493 "musl/src/complex/cimagl.c",
494 "musl/src/complex/clog.c",
495 "musl/src/complex/clogf.c",
496 "musl/src/complex/clogl.c",
497 "musl/src/complex/conj.c",
498 "musl/src/complex/conjf.c",
499 "musl/src/complex/conjl.c",
500 "musl/src/complex/cpow.c",
501 "musl/src/complex/cpowf.c",
502 "musl/src/complex/cpowl.c",
503 "musl/src/complex/cproj.c",
504 "musl/src/complex/cprojf.c",
505 "musl/src/complex/cprojl.c",
506 "musl/src/complex/creal.c",
507 "musl/src/complex/crealf.c",
508 "musl/src/complex/creall.c",
509 "musl/src/complex/csin.c",
510 "musl/src/complex/csinf.c",
511 "musl/src/complex/csinh.c",
512 "musl/src/complex/csinhf.c",
513 "musl/src/complex/csinhl.c",
514 "musl/src/complex/csinl.c",
515 "musl/src/complex/csqrt.c",
516 "musl/src/complex/csqrtf.c",
517 "musl/src/complex/csqrtl.c",
518 "musl/src/complex/ctan.c",
519 "musl/src/complex/ctanf.c",
520 "musl/src/complex/ctanh.c",
521 "musl/src/complex/ctanhf.c",
522 "musl/src/complex/ctanhl.c",
523 "musl/src/complex/ctanl.c",
524 "musl/src/conf/confstr.c",
525 "musl/src/conf/fpathconf.c",
526 "musl/src/conf/legacy.c",
527 "musl/src/conf/pathconf.c",
528 "musl/src/conf/sysconf.c",
529 "musl/src/crypt/crypt_blowfish.c",
530 "musl/src/crypt/crypt.c",
531 "musl/src/crypt/crypt_des.c",
532 "musl/src/crypt/crypt_md5.c",
533 "musl/src/crypt/crypt_r.c",
534 "musl/src/crypt/crypt_sha256.c",
535 "musl/src/crypt/crypt_sha512.c",
536 "musl/src/crypt/encrypt.c",
537 "musl/src/ctype/__ctype_b_loc.c",
538 "musl/src/ctype/__ctype_get_mb_cur_max.c",
539 "musl/src/ctype/__ctype_tolower_loc.c",
540 "musl/src/ctype/__ctype_toupper_loc.c",
541 "musl/src/ctype/isalnum.c",
542 "musl/src/ctype/isalpha.c",
543 "musl/src/ctype/isascii.c",
544 "musl/src/ctype/isblank.c",
545 "musl/src/ctype/iscntrl.c",
546 "musl/src/ctype/isdigit.c",
547 "musl/src/ctype/isgraph.c",
548 "musl/src/ctype/islower.c",
549 "musl/src/ctype/isprint.c",
550 "musl/src/ctype/ispunct.c",
551 "musl/src/ctype/isspace.c",
552 "musl/src/ctype/isupper.c",
553 "musl/src/ctype/iswalnum.c",
554 "musl/src/ctype/iswalpha.c",
555 "musl/src/ctype/iswblank.c",
556 "musl/src/ctype/iswcntrl.c",
557 "musl/src/ctype/iswctype.c",
558 "musl/src/ctype/iswdigit.c",
559 "musl/src/ctype/iswgraph.c",
560 "musl/src/ctype/iswlower.c",
561 "musl/src/ctype/iswprint.c",
562 "musl/src/ctype/iswpunct.c",
563 "musl/src/ctype/iswspace.c",
564 "musl/src/ctype/iswupper.c",
565 "musl/src/ctype/iswxdigit.c",
566 "musl/src/ctype/isxdigit.c",
567 "musl/src/ctype/toascii.c",
568 "musl/src/ctype/tolower.c",
569 "musl/src/ctype/toupper.c",
570 "musl/src/ctype/towctrans.c",
571 "musl/src/ctype/wcswidth.c",
572 "musl/src/ctype/wctrans.c",
573 "musl/src/ctype/wcwidth.c",
574 "musl/src/dirent/alphasort.c",
575 "musl/src/dirent/closedir.c",
576 "musl/src/dirent/dirfd.c",
577 "musl/src/dirent/fdopendir.c",
578 "musl/src/dirent/opendir.c",
579 "musl/src/dirent/readdir.c",
580 "musl/src/dirent/readdir_r.c",
581 "musl/src/dirent/rewinddir.c",
582 "musl/src/dirent/scandir.c",
583 "musl/src/dirent/seekdir.c",
584 "musl/src/dirent/telldir.c",
585 "musl/src/dirent/versionsort.c",
586 "musl/src/env/clearenv.c",
587 "musl/src/env/__environ.c",
588 "musl/src/env/getenv.c",
589 "musl/src/env/__init_tls.c",
590 "musl/src/env/__libc_start_main.c",
591 "musl/src/env/putenv.c",
592 "musl/src/env/__reset_tls.c",
593 "musl/src/env/secure_getenv.c",
594 "musl/src/env/setenv.c",
595 "musl/src/env/__stack_chk_fail.c",
596 "musl/src/env/unsetenv.c",
597 "musl/src/errno/__errno_location.c",
598 "musl/src/errno/strerror.c",
599 "musl/src/exit/abort.c",
600 "musl/src/exit/abort_lock.c",
601 "musl/src/exit/arm/__aeabi_atexit.c",
602 "musl/src/exit/assert.c",
603 "musl/src/exit/atexit.c",
604 "musl/src/exit/at_quick_exit.c",
605 "musl/src/exit/exit.c",
606 "musl/src/exit/_Exit.c",
607 "musl/src/exit/quick_exit.c",
608 "musl/src/fcntl/creat.c",
609 "musl/src/fcntl/fcntl.c",
610 "musl/src/fcntl/openat.c",
611 "musl/src/fcntl/open.c",
612 "musl/src/fcntl/posix_fadvise.c",
613 "musl/src/fcntl/posix_fallocate.c",
614 "musl/src/fenv/aarch64/fenv.s",
615 "musl/src/fenv/arm/fenv.c",
616 "musl/src/fenv/arm/fenv-hf.S",
617 "musl/src/fenv/fegetexceptflag.c",
618 "musl/src/fenv/feholdexcept.c",
619 "musl/src/fenv/fenv.c",
620 "musl/src/fenv/fesetexceptflag.c",
621 "musl/src/fenv/fesetround.c",
622 "musl/src/fenv/feupdateenv.c",
623 "musl/src/fenv/__flt_rounds.c",
624 "musl/src/fenv/hexagon/fenv.S",
625 "musl/src/fenv/i386/fenv.s",
626 "musl/src/fenv/loongarch64/fenv.S",
627 "musl/src/fenv/m68k/fenv.c",
628 "musl/src/fenv/mips64/fenv.S",
629 "musl/src/fenv/mips64/fenv-sf.c",
630 "musl/src/fenv/mips/fenv.S",
631 "musl/src/fenv/mips/fenv-sf.c",
632 "musl/src/fenv/mipsn32/fenv.S",
633 "musl/src/fenv/mipsn32/fenv-sf.c",
634 "musl/src/fenv/powerpc64/fenv.c",
635 "musl/src/fenv/powerpc/fenv.S",
636 "musl/src/fenv/powerpc/fenv-sf.c",
637 "musl/src/fenv/riscv32/fenv.S",
638 "musl/src/fenv/riscv32/fenv-sf.c",
639 "musl/src/fenv/riscv64/fenv.S",
640 "musl/src/fenv/riscv64/fenv-sf.c",
641 "musl/src/fenv/s390x/fenv.c",
642 "musl/src/fenv/x32/fenv.s",
643 "musl/src/fenv/x86_64/fenv.s",
644 "musl/src/internal/defsysinfo.c",
645 "musl/src/internal/emulate_wait4.c",
646 "musl/src/internal/floatscan.c",
647 "musl/src/internal/i386/defsysinfo.s",
648 "musl/src/internal/intscan.c",
649 "musl/src/internal/libc.c",
650 "musl/src/internal/procfdname.c",
651 "musl/src/internal/shgetc.c",
652 "musl/src/internal/syscall_ret.c",
653 "musl/src/internal/vdso.c",
654 "musl/src/internal/version.c",
655 "musl/src/ipc/ftok.c",
656 "musl/src/ipc/msgctl.c",
657 "musl/src/ipc/msgget.c",
658 "musl/src/ipc/msgrcv.c",
659 "musl/src/ipc/msgsnd.c",
660 "musl/src/ipc/semctl.c",
661 "musl/src/ipc/semget.c",
662 "musl/src/ipc/semop.c",
663 "musl/src/ipc/semtimedop.c",
664 "musl/src/ipc/shmat.c",
665 "musl/src/ipc/shmctl.c",
666 "musl/src/ipc/shmdt.c",
667 "musl/src/ipc/shmget.c",
668 "musl/src/ldso/aarch64/dlsym.s",
669 "musl/src/ldso/aarch64/tlsdesc.s",
670 "musl/src/ldso/arm/dlsym.s",
671 "musl/src/ldso/arm/dlsym_time64.S",
672 "musl/src/ldso/arm/find_exidx.c",
673 "musl/src/ldso/arm/tlsdesc.S",
674 "musl/src/ldso/dladdr.c",
675 "musl/src/ldso/dlclose.c",
676 "musl/src/ldso/dlerror.c",
677 "musl/src/ldso/dlinfo.c",
678 "musl/src/ldso/dl_iterate_phdr.c",
679 "musl/src/ldso/dlopen.c",
680 "musl/src/ldso/__dlsym.c",
681 "musl/src/ldso/dlsym.c",
682 "musl/src/ldso/i386/dlsym.s",
683 "musl/src/ldso/i386/dlsym_time64.S",
684 "musl/src/ldso/i386/tlsdesc.s",
685 "musl/src/ldso/loongarch64/dlsym.s",
686 "musl/src/ldso/m68k/dlsym.s",
687 "musl/src/ldso/m68k/dlsym_time64.S",
688 "musl/src/ldso/mips64/dlsym.s",
689 "musl/src/ldso/mips/dlsym.s",
690 "musl/src/ldso/mips/dlsym_time64.S",
691 "musl/src/ldso/mipsn32/dlsym.s",
692 "musl/src/ldso/mipsn32/dlsym_time64.S",
693 "musl/src/ldso/powerpc64/dlsym.s",
694 "musl/src/ldso/powerpc/dlsym.s",
695 "musl/src/ldso/powerpc/dlsym_time64.S",
696 "musl/src/ldso/riscv32/dlsym.s",
697 "musl/src/ldso/riscv64/dlsym.s",
698 "musl/src/ldso/riscv64/tlsdesc.s",
699 "musl/src/ldso/s390x/dlsym.s",
700 "musl/src/ldso/tlsdesc.c",
701 "musl/src/ldso/x32/dlsym.s",
702 "musl/src/ldso/x86_64/dlsym.s",
703 "musl/src/ldso/x86_64/tlsdesc.s",
704 "musl/src/legacy/cuserid.c",
705 "musl/src/legacy/daemon.c",
706 "musl/src/legacy/err.c",
707 "musl/src/legacy/euidaccess.c",
708 "musl/src/legacy/ftw.c",
709 "musl/src/legacy/futimes.c",
710 "musl/src/legacy/getdtablesize.c",
711 "musl/src/legacy/getloadavg.c",
712 "musl/src/legacy/getpagesize.c",
713 "musl/src/legacy/getpass.c",
714 "musl/src/legacy/getusershell.c",
715 "musl/src/legacy/isastream.c",
716 "musl/src/legacy/lutimes.c",
717 "musl/src/legacy/ulimit.c",
718 "musl/src/legacy/utmpx.c",
719 "musl/src/legacy/valloc.c",
720 "musl/src/linux/adjtime.c",
721 "musl/src/linux/adjtimex.c",
722 "musl/src/linux/arch_prctl.c",
723 "musl/src/linux/brk.c",
724 "musl/src/linux/cache.c",
725 "musl/src/linux/cap.c",
726 "musl/src/linux/chroot.c",
727 "musl/src/linux/clock_adjtime.c",
728 "musl/src/linux/clone.c",
729 "musl/src/linux/copy_file_range.c",
730 "musl/src/linux/epoll.c",
731 "musl/src/linux/eventfd.c",
732 "musl/src/linux/fallocate.c",
733 "musl/src/linux/fanotify.c",
734 "musl/src/linux/flock.c",
735 "musl/src/linux/getdents.c",
736 "musl/src/linux/getrandom.c",
737 "musl/src/linux/gettid.c",
738 "musl/src/linux/inotify.c",
739 "musl/src/linux/ioperm.c",
740 "musl/src/linux/iopl.c",
741 "musl/src/linux/klogctl.c",
742 "musl/src/linux/membarrier.c",
743 "musl/src/linux/memfd_create.c",
744 "musl/src/linux/mlock2.c",
745 "musl/src/linux/module.c",
746 "musl/src/linux/mount.c",
747 "musl/src/linux/name_to_handle_at.c",
748 "musl/src/linux/open_by_handle_at.c",
749 "musl/src/linux/personality.c",
750 "musl/src/linux/pivot_root.c",
751 "musl/src/linux/prctl.c",
752 "musl/src/linux/preadv2.c",
753 "musl/src/linux/prlimit.c",
754 "musl/src/linux/process_vm.c",
755 "musl/src/linux/ptrace.c",
756 "musl/src/linux/pwritev2.c",
757 "musl/src/linux/quotactl.c",
758 "musl/src/linux/readahead.c",
759 "musl/src/linux/reboot.c",
760 "musl/src/linux/remap_file_pages.c",
761 "musl/src/linux/sbrk.c",
762 "musl/src/linux/sendfile.c",
763 "musl/src/linux/setfsgid.c",
764 "musl/src/linux/setfsuid.c",
765 "musl/src/linux/setgroups.c",
766 "musl/src/linux/sethostname.c",
767 "musl/src/linux/setns.c",
768 "musl/src/linux/settimeofday.c",
769 "musl/src/linux/signalfd.c",
770 "musl/src/linux/splice.c",
771 "musl/src/linux/statx.c",
772 "musl/src/linux/stime.c",
773 "musl/src/linux/swap.c",
774 "musl/src/linux/sync_file_range.c",
775 "musl/src/linux/syncfs.c",
776 "musl/src/linux/sysinfo.c",
777 "musl/src/linux/tee.c",
778 "musl/src/linux/timerfd.c",
779 "musl/src/linux/unshare.c",
780 "musl/src/linux/utimes.c",
781 "musl/src/linux/vhangup.c",
782 "musl/src/linux/vmsplice.c",
783 "musl/src/linux/wait3.c",
784 "musl/src/linux/wait4.c",
785 "musl/src/linux/x32/sysinfo.c",
786 "musl/src/linux/xattr.c",
787 "musl/src/locale/bind_textdomain_codeset.c",
788 "musl/src/locale/catclose.c",
789 "musl/src/locale/catgets.c",
790 "musl/src/locale/catopen.c",
791 "musl/src/locale/c_locale.c",
792 "musl/src/locale/dcngettext.c",
793 "musl/src/locale/duplocale.c",
794 "musl/src/locale/freelocale.c",
795 "musl/src/locale/iconv.c",
796 "musl/src/locale/iconv_close.c",
797 "musl/src/locale/langinfo.c",
798 "musl/src/locale/__lctrans.c",
799 "musl/src/locale/localeconv.c",
800 "musl/src/locale/locale_map.c",
801 "musl/src/locale/__mo_lookup.c",
802 "musl/src/locale/newlocale.c",
803 "musl/src/locale/pleval.c",
804 "musl/src/locale/setlocale.c",
805 "musl/src/locale/strcoll.c",
806 "musl/src/locale/strfmon.c",
807 "musl/src/locale/strtod_l.c",
808 "musl/src/locale/strxfrm.c",
809 "musl/src/locale/textdomain.c",
810 "musl/src/locale/uselocale.c",
811 "musl/src/locale/wcscoll.c",
812 "musl/src/locale/wcsxfrm.c",
813 "musl/src/malloc/calloc.c",
814 "musl/src/malloc/free.c",
815 "musl/src/malloc/libc_calloc.c",
816 "musl/src/malloc/lite_malloc.c",
817 "musl/src/malloc/mallocng/aligned_alloc.c",
818 "musl/src/malloc/mallocng/donate.c",
819 "musl/src/malloc/mallocng/free.c",
820 "musl/src/malloc/mallocng/malloc.c",
821 "musl/src/malloc/mallocng/malloc_usable_size.c",
822 "musl/src/malloc/mallocng/realloc.c",
823 "musl/src/malloc/memalign.c",
824 "musl/src/malloc/oldmalloc/aligned_alloc.c",
825 "musl/src/malloc/oldmalloc/malloc.c",
826 "musl/src/malloc/oldmalloc/malloc_usable_size.c",
827 "musl/src/malloc/posix_memalign.c",
828 "musl/src/malloc/reallocarray.c",
829 "musl/src/malloc/realloc.c",
830 "musl/src/malloc/replaced.c",
831 "musl/src/math/aarch64/ceil.c",
832 "musl/src/math/aarch64/ceilf.c",
833 "musl/src/math/aarch64/fabs.c",
834 "musl/src/math/aarch64/fabsf.c",
835 "musl/src/math/aarch64/floor.c",
836 "musl/src/math/aarch64/floorf.c",
837 "musl/src/math/aarch64/fma.c",
838 "musl/src/math/aarch64/fmaf.c",
839 "musl/src/math/aarch64/fmax.c",
840 "musl/src/math/aarch64/fmaxf.c",
841 "musl/src/math/aarch64/fmin.c",
842 "musl/src/math/aarch64/fminf.c",
843 "musl/src/math/aarch64/llrint.c",
844 "musl/src/math/aarch64/llrintf.c",
845 "musl/src/math/aarch64/llround.c",
846 "musl/src/math/aarch64/llroundf.c",
847 "musl/src/math/aarch64/lrint.c",
848 "musl/src/math/aarch64/lrintf.c",
849 "musl/src/math/aarch64/lround.c",
850 "musl/src/math/aarch64/lroundf.c",
851 "musl/src/math/aarch64/nearbyint.c",
852 "musl/src/math/aarch64/nearbyintf.c",
853 "musl/src/math/aarch64/rint.c",
854 "musl/src/math/aarch64/rintf.c",
855 "musl/src/math/aarch64/round.c",
856 "musl/src/math/aarch64/roundf.c",
857 "musl/src/math/aarch64/sqrt.c",
858 "musl/src/math/aarch64/sqrtf.c",
859 "musl/src/math/aarch64/trunc.c",
860 "musl/src/math/aarch64/truncf.c",
861 "musl/src/math/acos.c",
862 "musl/src/math/acosf.c",
863 "musl/src/math/acosh.c",
864 "musl/src/math/acoshf.c",
865 "musl/src/math/acoshl.c",
866 "musl/src/math/acosl.c",
867 "musl/src/math/arm/fabs.c",
868 "musl/src/math/arm/fabsf.c",
869 "musl/src/math/arm/fma.c",
870 "musl/src/math/arm/fmaf.c",
871 "musl/src/math/arm/sqrt.c",
872 "musl/src/math/arm/sqrtf.c",
873 "musl/src/math/asin.c",
874 "musl/src/math/asinf.c",
875 "musl/src/math/asinh.c",
876 "musl/src/math/asinhf.c",
877 "musl/src/math/asinhl.c",
878 "musl/src/math/asinl.c",
879 "musl/src/math/atan2.c",
880 "musl/src/math/atan2f.c",
881 "musl/src/math/atan2l.c",
882 "musl/src/math/atan.c",
883 "musl/src/math/atanf.c",
884 "musl/src/math/atanh.c",
885 "musl/src/math/atanhf.c",
886 "musl/src/math/atanhl.c",
887 "musl/src/math/atanl.c",
888 "musl/src/math/cbrt.c",
889 "musl/src/math/cbrtf.c",
890 "musl/src/math/cbrtl.c",
891 "musl/src/math/ceil.c",
892 "musl/src/math/ceilf.c",
893 "musl/src/math/ceill.c",
894 "musl/src/math/copysign.c",
895 "musl/src/math/copysignf.c",
896 "musl/src/math/copysignl.c",
897 "musl/src/math/__cos.c",
898 "musl/src/math/cos.c",
899 "musl/src/math/__cosdf.c",
900 "musl/src/math/cosf.c",
901 "musl/src/math/cosh.c",
902 "musl/src/math/coshf.c",
903 "musl/src/math/coshl.c",
904 "musl/src/math/__cosl.c",
905 "musl/src/math/cosl.c",
906 "musl/src/math/erf.c",
907 "musl/src/math/erff.c",
908 "musl/src/math/erfl.c",
909 "musl/src/math/exp10.c",
910 "musl/src/math/exp10f.c",
911 "musl/src/math/exp10l.c",
912 "musl/src/math/exp2.c",
913 "musl/src/math/exp2f.c",
914 "musl/src/math/exp2f_data.c",
915 "musl/src/math/exp2l.c",
916 "musl/src/math/exp.c",
917 "musl/src/math/exp_data.c",
918 "musl/src/math/expf.c",
919 "musl/src/math/expl.c",
920 "musl/src/math/expm1.c",
921 "musl/src/math/expm1f.c",
922 "musl/src/math/expm1l.c",
923 "musl/src/math/__expo2.c",
924 "musl/src/math/__expo2f.c",
925 "musl/src/math/fabs.c",
926 "musl/src/math/fabsf.c",
927 "musl/src/math/fabsl.c",
928 "musl/src/math/fdim.c",
929 "musl/src/math/fdimf.c",
930 "musl/src/math/fdiml.c",
931 "musl/src/math/finite.c",
932 "musl/src/math/finitef.c",
933 "musl/src/math/floor.c",
934 "musl/src/math/floorf.c",
935 "musl/src/math/floorl.c",
936 "musl/src/math/fma.c",
937 "musl/src/math/fmaf.c",
938 "musl/src/math/fmal.c",
939 "musl/src/math/fmax.c",
940 "musl/src/math/fmaxf.c",
941 "musl/src/math/fmaxl.c",
942 "musl/src/math/fmin.c",
943 "musl/src/math/fminf.c",
944 "musl/src/math/fminl.c",
945 "musl/src/math/fmod.c",
946 "musl/src/math/fmodf.c",
947 "musl/src/math/fmodl.c",
948 "musl/src/math/__fpclassify.c",
949 "musl/src/math/__fpclassifyf.c",
950 "musl/src/math/__fpclassifyl.c",
951 "musl/src/math/frexp.c",
952 "musl/src/math/frexpf.c",
953 "musl/src/math/frexpl.c",
954 "musl/src/math/hypot.c",
955 "musl/src/math/hypotf.c",
956 "musl/src/math/hypotl.c",
957 "musl/src/math/i386/acosf.s",
958 "musl/src/math/i386/acosl.s",
959 "musl/src/math/i386/acos.s",
960 "musl/src/math/i386/asinf.s",
961 "musl/src/math/i386/asinl.s",
962 "musl/src/math/i386/asin.s",
963 "musl/src/math/i386/atan2f.s",
964 "musl/src/math/i386/atan2l.s",
965 "musl/src/math/i386/atan2.s",
966 "musl/src/math/i386/atanf.s",
967 "musl/src/math/i386/atanl.s",
968 "musl/src/math/i386/atan.s",
969 "musl/src/math/i386/ceilf.s",
970 "musl/src/math/i386/ceill.s",
971 "musl/src/math/i386/ceil.s",
972 "musl/src/math/i386/exp2l.s",
973 "musl/src/math/i386/exp_ld.s",
974 "musl/src/math/i386/expl.s",
975 "musl/src/math/i386/expm1l.s",
976 "musl/src/math/i386/fabs.c",
977 "musl/src/math/i386/fabsf.c",
978 "musl/src/math/i386/fabsl.c",
979 "musl/src/math/i386/floorf.s",
980 "musl/src/math/i386/floorl.s",
981 "musl/src/math/i386/floor.s",
982 "musl/src/math/i386/fmod.c",
983 "musl/src/math/i386/fmodf.c",
984 "musl/src/math/i386/fmodl.c",
985 "musl/src/math/i386/hypotf.s",
986 "musl/src/math/i386/hypot.s",
987 "musl/src/math/i386/__invtrigl.s",
988 "musl/src/math/i386/ldexpf.s",
989 "musl/src/math/i386/ldexpl.s",
990 "musl/src/math/i386/ldexp.s",
991 "musl/src/math/i386/llrint.c",
992 "musl/src/math/i386/llrintf.c",
993 "musl/src/math/i386/llrintl.c",
994 "musl/src/math/i386/log10f.s",
995 "musl/src/math/i386/log10l.s",
996 "musl/src/math/i386/log10.s",
997 "musl/src/math/i386/log1pf.s",
998 "musl/src/math/i386/log1pl.s",
999 "musl/src/math/i386/log1p.s",
1000 "musl/src/math/i386/log2f.s",
1001 "musl/src/math/i386/log2l.s",
1002 "musl/src/math/i386/log2.s",
1003 "musl/src/math/i386/logf.s",
1004 "musl/src/math/i386/logl.s",
1005 "musl/src/math/i386/log.s",
1006 "musl/src/math/i386/lrint.c",
1007 "musl/src/math/i386/lrintf.c",
1008 "musl/src/math/i386/lrintl.c",
1009 "musl/src/math/i386/remainder.c",
1010 "musl/src/math/i386/remainderf.c",
1011 "musl/src/math/i386/remainderl.c",
1012 "musl/src/math/i386/remquof.s",
1013 "musl/src/math/i386/remquol.s",
1014 "musl/src/math/i386/remquo.s",
1015 "musl/src/math/i386/rint.c",
1016 "musl/src/math/i386/rintf.c",
1017 "musl/src/math/i386/rintl.c",
1018 "musl/src/math/i386/scalblnf.s",
1019 "musl/src/math/i386/scalblnl.s",
1020 "musl/src/math/i386/scalbln.s",
1021 "musl/src/math/i386/scalbnf.s",
1022 "musl/src/math/i386/scalbnl.s",
1023 "musl/src/math/i386/scalbn.s",
1024 "musl/src/math/i386/sqrt.c",
1025 "musl/src/math/i386/sqrtf.c",
1026 "musl/src/math/i386/sqrtl.c",
1027 "musl/src/math/i386/truncf.s",
1028 "musl/src/math/i386/truncl.s",
1029 "musl/src/math/i386/trunc.s",
1030 "musl/src/math/ilogb.c",
1031 "musl/src/math/ilogbf.c",
1032 "musl/src/math/ilogbl.c",
1033 "musl/src/math/__invtrigl.c",
1034 "musl/src/math/j0.c",
1035 "musl/src/math/j0f.c",
1036 "musl/src/math/j1.c",
1037 "musl/src/math/j1f.c",
1038 "musl/src/math/jn.c",
1039 "musl/src/math/jnf.c",
1040 "musl/src/math/ldexp.c",
1041 "musl/src/math/ldexpf.c",
1042 "musl/src/math/ldexpl.c",
1043 "musl/src/math/lgamma.c",
1044 "musl/src/math/lgammaf.c",
1045 "musl/src/math/lgammaf_r.c",
1046 "musl/src/math/lgammal.c",
1047 "musl/src/math/lgamma_r.c",
1048 "musl/src/math/llrint.c",
1049 "musl/src/math/llrintf.c",
1050 "musl/src/math/llrintl.c",
1051 "musl/src/math/llround.c",
1052 "musl/src/math/llroundf.c",
1053 "musl/src/math/llroundl.c",
1054 "musl/src/math/log10.c",
1055 "musl/src/math/log10f.c",
1056 "musl/src/math/log10l.c",
1057 "musl/src/math/log1p.c",
1058 "musl/src/math/log1pf.c",
1059 "musl/src/math/log1pl.c",
1060 "musl/src/math/log2.c",
1061 "musl/src/math/log2_data.c",
1062 "musl/src/math/log2f.c",
1063 "musl/src/math/log2f_data.c",
1064 "musl/src/math/log2l.c",
1065 "musl/src/math/logb.c",
1066 "musl/src/math/logbf.c",
1067 "musl/src/math/logbl.c",
1068 "musl/src/math/log.c",
1069 "musl/src/math/log_data.c",
1070 "musl/src/math/logf.c",
1071 "musl/src/math/logf_data.c",
1072 "musl/src/math/logl.c",
1073 "musl/src/math/lrint.c",
1074 "musl/src/math/lrintf.c",
1075 "musl/src/math/lrintl.c",
1076 "musl/src/math/lround.c",
1077 "musl/src/math/lroundf.c",
1078 "musl/src/math/lroundl.c",
1079 "musl/src/math/m68k/sqrtl.c",
1080 "musl/src/math/__math_divzero.c",
1081 "musl/src/math/__math_divzerof.c",
1082 "musl/src/math/__math_invalid.c",
1083 "musl/src/math/__math_invalidf.c",
1084 "musl/src/math/__math_invalidl.c",
1085 "musl/src/math/__math_oflow.c",
1086 "musl/src/math/__math_oflowf.c",
1087 "musl/src/math/__math_uflow.c",
1088 "musl/src/math/__math_uflowf.c",
1089 "musl/src/math/__math_xflow.c",
1090 "musl/src/math/__math_xflowf.c",
1091 "musl/src/math/mips/fabs.c",
1092 "musl/src/math/mips/fabsf.c",
1093 "musl/src/math/mips/sqrt.c",
1094 "musl/src/math/mips/sqrtf.c",
1095 "musl/src/math/modf.c",
1096 "musl/src/math/modff.c",
1097 "musl/src/math/modfl.c",
1098 "musl/src/math/nan.c",
1099 "musl/src/math/nanf.c",
1100 "musl/src/math/nanl.c",
1101 "musl/src/math/nearbyint.c",
1102 "musl/src/math/nearbyintf.c",
1103 "musl/src/math/nearbyintl.c",
1104 "musl/src/math/nextafter.c",
1105 "musl/src/math/nextafterf.c",
1106 "musl/src/math/nextafterl.c",
1107 "musl/src/math/nexttoward.c",
1108 "musl/src/math/nexttowardf.c",
1109 "musl/src/math/nexttowardl.c",
1110 "musl/src/math/__polevll.c",
1111 "musl/src/math/pow.c",
1112 "musl/src/math/pow_data.c",
1113 "musl/src/math/powerpc64/ceil.c",
1114 "musl/src/math/powerpc64/ceilf.c",
1115 "musl/src/math/powerpc64/fabs.c",
1116 "musl/src/math/powerpc64/fabsf.c",
1117 "musl/src/math/powerpc64/floor.c",
1118 "musl/src/math/powerpc64/floorf.c",
1119 "musl/src/math/powerpc64/fma.c",
1120 "musl/src/math/powerpc64/fmaf.c",
1121 "musl/src/math/powerpc64/fmax.c",
1122 "musl/src/math/powerpc64/fmaxf.c",
1123 "musl/src/math/powerpc64/fmin.c",
1124 "musl/src/math/powerpc64/fminf.c",
1125 "musl/src/math/powerpc64/lrint.c",
1126 "musl/src/math/powerpc64/lrintf.c",
1127 "musl/src/math/powerpc64/lround.c",
1128 "musl/src/math/powerpc64/lroundf.c",
1129 "musl/src/math/powerpc64/round.c",
1130 "musl/src/math/powerpc64/roundf.c",
1131 "musl/src/math/powerpc64/sqrt.c",
1132 "musl/src/math/powerpc64/sqrtf.c",
1133 "musl/src/math/powerpc64/trunc.c",
1134 "musl/src/math/powerpc64/truncf.c",
1135 "musl/src/math/powerpc/fabs.c",
1136 "musl/src/math/powerpc/fabsf.c",
1137 "musl/src/math/powerpc/fma.c",
1138 "musl/src/math/powerpc/fmaf.c",
1139 "musl/src/math/powerpc/sqrt.c",
1140 "musl/src/math/powerpc/sqrtf.c",
1141 "musl/src/math/powf.c",
1142 "musl/src/math/powf_data.c",
1143 "musl/src/math/powl.c",
1144 "musl/src/math/remainder.c",
1145 "musl/src/math/remainderf.c",
1146 "musl/src/math/remainderl.c",
1147 "musl/src/math/__rem_pio2.c",
1148 "musl/src/math/__rem_pio2f.c",
1149 "musl/src/math/__rem_pio2_large.c",
1150 "musl/src/math/__rem_pio2l.c",
1151 "musl/src/math/remquo.c",
1152 "musl/src/math/remquof.c",
1153 "musl/src/math/remquol.c",
1154 "musl/src/math/rint.c",
1155 "musl/src/math/rintf.c",
1156 "musl/src/math/rintl.c",
1157 "musl/src/math/riscv32/copysign.c",
1158 "musl/src/math/riscv32/copysignf.c",
1159 "musl/src/math/riscv32/fabs.c",
1160 "musl/src/math/riscv32/fabsf.c",
1161 "musl/src/math/riscv32/fma.c",
1162 "musl/src/math/riscv32/fmaf.c",
1163 "musl/src/math/riscv32/fmax.c",
1164 "musl/src/math/riscv32/fmaxf.c",
1165 "musl/src/math/riscv32/fmin.c",
1166 "musl/src/math/riscv32/fminf.c",
1167 "musl/src/math/riscv32/sqrt.c",
1168 "musl/src/math/riscv32/sqrtf.c",
1169 "musl/src/math/riscv64/copysign.c",
1170 "musl/src/math/riscv64/copysignf.c",
1171 "musl/src/math/riscv64/fabs.c",
1172 "musl/src/math/riscv64/fabsf.c",
1173 "musl/src/math/riscv64/fma.c",
1174 "musl/src/math/riscv64/fmaf.c",
1175 "musl/src/math/riscv64/fmax.c",
1176 "musl/src/math/riscv64/fmaxf.c",
1177 "musl/src/math/riscv64/fmin.c",
1178 "musl/src/math/riscv64/fminf.c",
1179 "musl/src/math/riscv64/sqrt.c",
1180 "musl/src/math/riscv64/sqrtf.c",
1181 "musl/src/math/round.c",
1182 "musl/src/math/roundf.c",
1183 "musl/src/math/roundl.c",
1184 "musl/src/math/s390x/ceil.c",
1185 "musl/src/math/s390x/ceilf.c",
1186 "musl/src/math/s390x/ceill.c",
1187 "musl/src/math/s390x/fabs.c",
1188 "musl/src/math/s390x/fabsf.c",
1189 "musl/src/math/s390x/fabsl.c",
1190 "musl/src/math/s390x/floor.c",
1191 "musl/src/math/s390x/floorf.c",
1192 "musl/src/math/s390x/floorl.c",
1193 "musl/src/math/s390x/fma.c",
1194 "musl/src/math/s390x/fmaf.c",
1195 "musl/src/math/s390x/nearbyint.c",
1196 "musl/src/math/s390x/nearbyintf.c",
1197 "musl/src/math/s390x/nearbyintl.c",
1198 "musl/src/math/s390x/rint.c",
1199 "musl/src/math/s390x/rintf.c",
1200 "musl/src/math/s390x/rintl.c",
1201 "musl/src/math/s390x/round.c",
1202 "musl/src/math/s390x/roundf.c",
1203 "musl/src/math/s390x/roundl.c",
1204 "musl/src/math/s390x/sqrt.c",
1205 "musl/src/math/s390x/sqrtf.c",
1206 "musl/src/math/s390x/sqrtl.c",
1207 "musl/src/math/s390x/trunc.c",
1208 "musl/src/math/s390x/truncf.c",
1209 "musl/src/math/s390x/truncl.c",
1210 "musl/src/math/scalb.c",
1211 "musl/src/math/scalbf.c",
1212 "musl/src/math/scalbln.c",
1213 "musl/src/math/scalblnf.c",
1214 "musl/src/math/scalblnl.c",
1215 "musl/src/math/scalbn.c",
1216 "musl/src/math/scalbnf.c",
1217 "musl/src/math/scalbnl.c",
1218 "musl/src/math/__signbit.c",
1219 "musl/src/math/__signbitf.c",
1220 "musl/src/math/__signbitl.c",
1221 "musl/src/math/signgam.c",
1222 "musl/src/math/significand.c",
1223 "musl/src/math/significandf.c",
1224 "musl/src/math/__sin.c",
1225 "musl/src/math/sin.c",
1226 "musl/src/math/sincos.c",
1227 "musl/src/math/sincosf.c",
1228 "musl/src/math/sincosl.c",
1229 "musl/src/math/__sindf.c",
1230 "musl/src/math/sinf.c",
1231 "musl/src/math/sinh.c",
1232 "musl/src/math/sinhf.c",
1233 "musl/src/math/sinhl.c",
1234 "musl/src/math/__sinl.c",
1235 "musl/src/math/sinl.c",
1236 "musl/src/math/sqrt.c",
1237 "musl/src/math/sqrt_data.c",
1238 "musl/src/math/sqrtf.c",
1239 "musl/src/math/sqrtl.c",
1240 "musl/src/math/__tan.c",
1241 "musl/src/math/tan.c",
1242 "musl/src/math/__tandf.c",
1243 "musl/src/math/tanf.c",
1244 "musl/src/math/tanh.c",
1245 "musl/src/math/tanhf.c",
1246 "musl/src/math/tanhl.c",
1247 "musl/src/math/__tanl.c",
1248 "musl/src/math/tanl.c",
1249 "musl/src/math/tgamma.c",
1250 "musl/src/math/tgammaf.c",
1251 "musl/src/math/tgammal.c",
1252 "musl/src/math/trunc.c",
1253 "musl/src/math/truncf.c",
1254 "musl/src/math/truncl.c",
1255 "musl/src/math/x32/acosl.s",
1256 "musl/src/math/x32/asinl.s",
1257 "musl/src/math/x32/atan2l.s",
1258 "musl/src/math/x32/atanl.s",
1259 "musl/src/math/x32/ceill.s",
1260 "musl/src/math/x32/exp2l.s",
1261 "musl/src/math/x32/expl.s",
1262 "musl/src/math/x32/expm1l.s",
1263 "musl/src/math/x32/fabsf.s",
1264 "musl/src/math/x32/fabsl.s",
1265 "musl/src/math/x32/fabs.s",
1266 "musl/src/math/x32/floorl.s",
1267 "musl/src/math/x32/fma.c",
1268 "musl/src/math/x32/fmaf.c",
1269 "musl/src/math/x32/fmodl.s",
1270 "musl/src/math/x32/__invtrigl.s",
1271 "musl/src/math/x32/llrintf.s",
1272 "musl/src/math/x32/llrintl.s",
1273 "musl/src/math/x32/llrint.s",
1274 "musl/src/math/x32/log10l.s",
1275 "musl/src/math/x32/log1pl.s",
1276 "musl/src/math/x32/log2l.s",
1277 "musl/src/math/x32/logl.s",
1278 "musl/src/math/x32/lrintf.s",
1279 "musl/src/math/x32/lrintl.s",
1280 "musl/src/math/x32/lrint.s",
1281 "musl/src/math/x32/remainderl.s",
1282 "musl/src/math/x32/rintl.s",
1283 "musl/src/math/x32/sqrtf.s",
1284 "musl/src/math/x32/sqrtl.s",
1285 "musl/src/math/x32/sqrt.s",
1286 "musl/src/math/x32/truncl.s",
1287 "musl/src/math/x86_64/acosl.s",
1288 "musl/src/math/x86_64/asinl.s",
1289 "musl/src/math/x86_64/atan2l.s",
1290 "musl/src/math/x86_64/atanl.s",
1291 "musl/src/math/x86_64/ceill.s",
1292 "musl/src/math/x86_64/exp2l.s",
1293 "musl/src/math/x86_64/expl.s",
1294 "musl/src/math/x86_64/expm1l.s",
1295 "musl/src/math/x86_64/fabs.c",
1296 "musl/src/math/x86_64/fabsf.c",
1297 "musl/src/math/x86_64/fabsl.c",
1298 "musl/src/math/x86_64/floorl.s",
1299 "musl/src/math/x86_64/fma.c",
1300 "musl/src/math/x86_64/fmaf.c",
1301 "musl/src/math/x86_64/fmodl.c",
1302 "musl/src/math/x86_64/__invtrigl.s",
1303 "musl/src/math/x86_64/llrint.c",
1304 "musl/src/math/x86_64/llrintf.c",
1305 "musl/src/math/x86_64/llrintl.c",
1306 "musl/src/math/x86_64/log10l.s",
1307 "musl/src/math/x86_64/log1pl.s",
1308 "musl/src/math/x86_64/log2l.s",
1309 "musl/src/math/x86_64/logl.s",
1310 "musl/src/math/x86_64/lrint.c",
1311 "musl/src/math/x86_64/lrintf.c",
1312 "musl/src/math/x86_64/lrintl.c",
1313 "musl/src/math/x86_64/remainderl.c",
1314 "musl/src/math/x86_64/remquol.c",
1315 "musl/src/math/x86_64/rintl.c",
1316 "musl/src/math/x86_64/sqrt.c",
1317 "musl/src/math/x86_64/sqrtf.c",
1318 "musl/src/math/x86_64/sqrtl.c",
1319 "musl/src/math/x86_64/truncl.s",
1320 "musl/src/misc/a64l.c",
1321 "musl/src/misc/basename.c",
1322 "musl/src/misc/dirname.c",
1323 "musl/src/misc/ffs.c",
1324 "musl/src/misc/ffsl.c",
1325 "musl/src/misc/ffsll.c",
1326 "musl/src/misc/fmtmsg.c",
1327 "musl/src/misc/forkpty.c",
1328 "musl/src/misc/getauxval.c",
1329 "musl/src/misc/get_current_dir_name.c",
1330 "musl/src/misc/getdomainname.c",
1331 "musl/src/misc/getentropy.c",
1332 "musl/src/misc/gethostid.c",
1333 "musl/src/misc/getopt.c",
1334 "musl/src/misc/getopt_long.c",
1335 "musl/src/misc/getpriority.c",
1336 "musl/src/misc/getresgid.c",
1337 "musl/src/misc/getresuid.c",
1338 "musl/src/misc/getrlimit.c",
1339 "musl/src/misc/getrusage.c",
1340 "musl/src/misc/getsubopt.c",
1341 "musl/src/misc/initgroups.c",
1342 "musl/src/misc/ioctl.c",
1343 "musl/src/misc/issetugid.c",
1344 "musl/src/misc/lockf.c",
1345 "musl/src/misc/login_tty.c",
1346 "musl/src/misc/mntent.c",
1347 "musl/src/misc/nftw.c",
1348 "musl/src/misc/openpty.c",
1349 "musl/src/misc/ptsname.c",
1350 "musl/src/misc/pty.c",
1351 "musl/src/misc/realpath.c",
1352 "musl/src/misc/setdomainname.c",
1353 "musl/src/misc/setpriority.c",
1354 "musl/src/misc/setrlimit.c",
1355 "musl/src/misc/syscall.c",
1356 "musl/src/misc/syslog.c",
1357 "musl/src/misc/uname.c",
1358 "musl/src/misc/wordexp.c",
1359 "musl/src/mman/madvise.c",
1360 "musl/src/mman/mincore.c",
1361 "musl/src/mman/mlockall.c",
1362 "musl/src/mman/mlock.c",
1363 "musl/src/mman/mmap.c",
1364 "musl/src/mman/mprotect.c",
1365 "musl/src/mman/mremap.c",
1366 "musl/src/mman/msync.c",
1367 "musl/src/mman/munlockall.c",
1368 "musl/src/mman/munlock.c",
1369 "musl/src/mman/munmap.c",
1370 "musl/src/mman/posix_madvise.c",
1371 "musl/src/mman/shm_open.c",
1372 "musl/src/mq/mq_close.c",
1373 "musl/src/mq/mq_getattr.c",
1374 "musl/src/mq/mq_notify.c",
1375 "musl/src/mq/mq_open.c",
1376 "musl/src/mq/mq_receive.c",
1377 "musl/src/mq/mq_send.c",
1378 "musl/src/mq/mq_setattr.c",
1379 "musl/src/mq/mq_timedreceive.c",
1380 "musl/src/mq/mq_timedsend.c",
1381 "musl/src/mq/mq_unlink.c",
1382 "musl/src/multibyte/btowc.c",
1383 "musl/src/multibyte/c16rtomb.c",
1384 "musl/src/multibyte/c32rtomb.c",
1385 "musl/src/multibyte/internal.c",
1386 "musl/src/multibyte/mblen.c",
1387 "musl/src/multibyte/mbrlen.c",
1388 "musl/src/multibyte/mbrtoc16.c",
1389 "musl/src/multibyte/mbrtoc32.c",
1390 "musl/src/multibyte/mbrtowc.c",
1391 "musl/src/multibyte/mbsinit.c",
1392 "musl/src/multibyte/mbsnrtowcs.c",
1393 "musl/src/multibyte/mbsrtowcs.c",
1394 "musl/src/multibyte/mbstowcs.c",
1395 "musl/src/multibyte/mbtowc.c",
1396 "musl/src/multibyte/wcrtomb.c",
1397 "musl/src/multibyte/wcsnrtombs.c",
1398 "musl/src/multibyte/wcsrtombs.c",
1399 "musl/src/multibyte/wcstombs.c",
1400 "musl/src/multibyte/wctob.c",
1401 "musl/src/multibyte/wctomb.c",
1402 "musl/src/network/accept4.c",
1403 "musl/src/network/accept.c",
1404 "musl/src/network/bind.c",
1405 "musl/src/network/connect.c",
1406 "musl/src/network/dn_comp.c",
1407 "musl/src/network/dn_expand.c",
1408 "musl/src/network/dn_skipname.c",
1409 "musl/src/network/dns_parse.c",
1410 "musl/src/network/ent.c",
1411 "musl/src/network/ether.c",
1412 "musl/src/network/freeaddrinfo.c",
1413 "musl/src/network/gai_strerror.c",
1414 "musl/src/network/getaddrinfo.c",
1415 "musl/src/network/gethostbyaddr.c",
1416 "musl/src/network/gethostbyaddr_r.c",
1417 "musl/src/network/gethostbyname2.c",
1418 "musl/src/network/gethostbyname2_r.c",
1419 "musl/src/network/gethostbyname.c",
1420 "musl/src/network/gethostbyname_r.c",
1421 "musl/src/network/getifaddrs.c",
1422 "musl/src/network/getnameinfo.c",
1423 "musl/src/network/getpeername.c",
1424 "musl/src/network/getservbyname.c",
1425 "musl/src/network/getservbyname_r.c",
1426 "musl/src/network/getservbyport.c",
1427 "musl/src/network/getservbyport_r.c",
1428 "musl/src/network/getsockname.c",
1429 "musl/src/network/getsockopt.c",
1430 "musl/src/network/h_errno.c",
1431 "musl/src/network/herror.c",
1432 "musl/src/network/hstrerror.c",
1433 "musl/src/network/htonl.c",
1434 "musl/src/network/htons.c",
1435 "musl/src/network/if_freenameindex.c",
1436 "musl/src/network/if_indextoname.c",
1437 "musl/src/network/if_nameindex.c",
1438 "musl/src/network/if_nametoindex.c",
1439 "musl/src/network/in6addr_any.c",
1440 "musl/src/network/in6addr_loopback.c",
1441 "musl/src/network/inet_addr.c",
1442 "musl/src/network/inet_aton.c",
1443 "musl/src/network/inet_legacy.c",
1444 "musl/src/network/inet_ntoa.c",
1445 "musl/src/network/inet_ntop.c",
1446 "musl/src/network/inet_pton.c",
1447 "musl/src/network/listen.c",
1448 "musl/src/network/lookup_ipliteral.c",
1449 "musl/src/network/lookup_name.c",
1450 "musl/src/network/lookup_serv.c",
1451 "musl/src/network/netlink.c",
1452 "musl/src/network/netname.c",
1453 "musl/src/network/ns_parse.c",
1454 "musl/src/network/ntohl.c",
1455 "musl/src/network/ntohs.c",
1456 "musl/src/network/proto.c",
1457 "musl/src/network/recv.c",
1458 "musl/src/network/recvfrom.c",
1459 "musl/src/network/recvmmsg.c",
1460 "musl/src/network/recvmsg.c",
1461 "musl/src/network/res_init.c",
1462 "musl/src/network/res_mkquery.c",
1463 "musl/src/network/res_msend.c",
1464 "musl/src/network/resolvconf.c",
1465 "musl/src/network/res_query.c",
1466 "musl/src/network/res_querydomain.c",
1467 "musl/src/network/res_send.c",
1468 "musl/src/network/res_state.c",
1469 "musl/src/network/send.c",
1470 "musl/src/network/sendmmsg.c",
1471 "musl/src/network/sendmsg.c",
1472 "musl/src/network/sendto.c",
1473 "musl/src/network/serv.c",
1474 "musl/src/network/setsockopt.c",
1475 "musl/src/network/shutdown.c",
1476 "musl/src/network/sockatmark.c",
1477 "musl/src/network/socket.c",
1478 "musl/src/network/socketpair.c",
1479 "musl/src/passwd/fgetgrent.c",
1480 "musl/src/passwd/fgetpwent.c",
1481 "musl/src/passwd/fgetspent.c",
1482 "musl/src/passwd/getgr_a.c",
1483 "musl/src/passwd/getgrent_a.c",
1484 "musl/src/passwd/getgrent.c",
1485 "musl/src/passwd/getgrouplist.c",
1486 "musl/src/passwd/getgr_r.c",
1487 "musl/src/passwd/getpw_a.c",
1488 "musl/src/passwd/getpwent_a.c",
1489 "musl/src/passwd/getpwent.c",
1490 "musl/src/passwd/getpw_r.c",
1491 "musl/src/passwd/getspent.c",
1492 "musl/src/passwd/getspnam.c",
1493 "musl/src/passwd/getspnam_r.c",
1494 "musl/src/passwd/lckpwdf.c",
1495 "musl/src/passwd/nscd_query.c",
1496 "musl/src/passwd/putgrent.c",
1497 "musl/src/passwd/putpwent.c",
1498 "musl/src/passwd/putspent.c",
1499 "musl/src/prng/drand48.c",
1500 "musl/src/prng/lcong48.c",
1501 "musl/src/prng/lrand48.c",
1502 "musl/src/prng/mrand48.c",
1503 "musl/src/prng/__rand48_step.c",
1504 "musl/src/prng/rand.c",
1505 "musl/src/prng/random.c",
1506 "musl/src/prng/rand_r.c",
1507 "musl/src/prng/__seed48.c",
1508 "musl/src/prng/seed48.c",
1509 "musl/src/prng/srand48.c",
1510 "musl/src/process/aarch64/vfork.s",
1511 "musl/src/process/arm/vfork.s",
1512 "musl/src/process/execl.c",
1513 "musl/src/process/execle.c",
1514 "musl/src/process/execlp.c",
1515 "musl/src/process/execv.c",
1516 "musl/src/process/execve.c",
1517 "musl/src/process/execvp.c",
1518 "musl/src/process/fexecve.c",
1519 "musl/src/process/fork.c",
1520 "musl/src/process/_Fork.c",
1521 "musl/src/process/i386/vfork.s",
1522 "musl/src/process/posix_spawnattr_destroy.c",
1523 "musl/src/process/posix_spawnattr_getflags.c",
1524 "musl/src/process/posix_spawnattr_getpgroup.c",
1525 "musl/src/process/posix_spawnattr_getsigdefault.c",
1526 "musl/src/process/posix_spawnattr_getsigmask.c",
1527 "musl/src/process/posix_spawnattr_init.c",
1528 "musl/src/process/posix_spawnattr_sched.c",
1529 "musl/src/process/posix_spawnattr_setflags.c",
1530 "musl/src/process/posix_spawnattr_setpgroup.c",
1531 "musl/src/process/posix_spawnattr_setsigdefault.c",
1532 "musl/src/process/posix_spawnattr_setsigmask.c",
1533 "musl/src/process/posix_spawn.c",
1534 "musl/src/process/posix_spawn_file_actions_addchdir.c",
1535 "musl/src/process/posix_spawn_file_actions_addclose.c",
1536 "musl/src/process/posix_spawn_file_actions_adddup2.c",
1537 "musl/src/process/posix_spawn_file_actions_addfchdir.c",
1538 "musl/src/process/posix_spawn_file_actions_addopen.c",
1539 "musl/src/process/posix_spawn_file_actions_destroy.c",
1540 "musl/src/process/posix_spawn_file_actions_init.c",
1541 "musl/src/process/posix_spawnp.c",
1542 "musl/src/process/riscv64/vfork.s",
1543 "musl/src/process/s390x/vfork.s",
1544 "musl/src/process/system.c",
1545 "musl/src/process/vfork.c",
1546 "musl/src/process/wait.c",
1547 "musl/src/process/waitid.c",
1548 "musl/src/process/waitpid.c",
1549 "musl/src/process/x32/vfork.s",
1550 "musl/src/process/x86_64/vfork.s",
1551 "musl/src/regex/fnmatch.c",
1552 "musl/src/regex/glob.c",
1553 "musl/src/regex/regcomp.c",
1554 "musl/src/regex/regerror.c",
1555 "musl/src/regex/regexec.c",
1556 "musl/src/regex/tre-mem.c",
1557 "musl/src/sched/affinity.c",
1558 "musl/src/sched/sched_cpucount.c",
1559 "musl/src/sched/sched_getcpu.c",
1560 "musl/src/sched/sched_getparam.c",
1561 "musl/src/sched/sched_get_priority_max.c",
1562 "musl/src/sched/sched_getscheduler.c",
1563 "musl/src/sched/sched_rr_get_interval.c",
1564 "musl/src/sched/sched_setparam.c",
1565 "musl/src/sched/sched_setscheduler.c",
1566 "musl/src/sched/sched_yield.c",
1567 "musl/src/search/hsearch.c",
1568 "musl/src/search/insque.c",
1569 "musl/src/search/lsearch.c",
1570 "musl/src/search/tdelete.c",
1571 "musl/src/search/tdestroy.c",
1572 "musl/src/search/tfind.c",
1573 "musl/src/search/tsearch.c",
1574 "musl/src/search/twalk.c",
1575 "musl/src/select/poll.c",
1576 "musl/src/select/ppoll.c",
1577 "musl/src/select/pselect.c",
1578 "musl/src/select/select.c",
1579 "musl/src/setjmp/aarch64/longjmp.s",
1580 "musl/src/setjmp/aarch64/setjmp.s",
1581 "musl/src/setjmp/arm/longjmp.S",
1582 "musl/src/setjmp/arm/setjmp.S",
1583 "musl/src/setjmp/hexagon/longjmp.s",
1584 "musl/src/setjmp/hexagon/setjmp.s",
1585 "musl/src/setjmp/i386/longjmp.s",
1586 "musl/src/setjmp/i386/setjmp.s",
1587 "musl/src/setjmp/longjmp.c",
1588 "musl/src/setjmp/loongarch64/longjmp.S",
1589 "musl/src/setjmp/loongarch64/setjmp.S",
1590 "musl/src/setjmp/m68k/longjmp.s",
1591 "musl/src/setjmp/m68k/setjmp.s",
1592 "musl/src/setjmp/mips64/longjmp.S",
1593 "musl/src/setjmp/mips64/setjmp.S",
1594 "musl/src/setjmp/mips/longjmp.S",
1595 "musl/src/setjmp/mipsn32/longjmp.S",
1596 "musl/src/setjmp/mipsn32/setjmp.S",
1597 "musl/src/setjmp/mips/setjmp.S",
1598 "musl/src/setjmp/powerpc64/longjmp.s",
1599 "musl/src/setjmp/powerpc64/setjmp.s",
1600 "musl/src/setjmp/powerpc/longjmp.S",
1601 "musl/src/setjmp/powerpc/setjmp.S",
1602 "musl/src/setjmp/riscv32/longjmp.S",
1603 "musl/src/setjmp/riscv32/setjmp.S",
1604 "musl/src/setjmp/riscv64/longjmp.S",
1605 "musl/src/setjmp/riscv64/setjmp.S",
1606 "musl/src/setjmp/s390x/longjmp.s",
1607 "musl/src/setjmp/s390x/setjmp.s",
1608 "musl/src/setjmp/setjmp.c",
1609 "musl/src/setjmp/x32/longjmp.s",
1610 "musl/src/setjmp/x32/setjmp.s",
1611 "musl/src/setjmp/x86_64/longjmp.s",
1612 "musl/src/setjmp/x86_64/setjmp.s",
1613 "musl/src/signal/aarch64/restore.s",
1614 "musl/src/signal/aarch64/sigsetjmp.s",
1615 "musl/src/signal/arm/restore.s",
1616 "musl/src/signal/arm/sigsetjmp.s",
1617 "musl/src/signal/block.c",
1618 "musl/src/signal/getitimer.c",
1619 "musl/src/signal/hexagon/restore.s",
1620 "musl/src/signal/hexagon/sigsetjmp.s",
1621 "musl/src/signal/i386/restore.s",
1622 "musl/src/signal/i386/sigsetjmp.s",
1623 "musl/src/signal/kill.c",
1624 "musl/src/signal/killpg.c",
1625 "musl/src/signal/loongarch64/restore.s",
1626 "musl/src/signal/loongarch64/sigsetjmp.s",
1627 "musl/src/signal/m68k/sigsetjmp.s",
1628 "musl/src/signal/mips64/sigsetjmp.s",
1629 "musl/src/signal/mipsn32/sigsetjmp.s",
1630 "musl/src/signal/mips/sigsetjmp.s",
1631 "musl/src/signal/powerpc64/restore.s",
1632 "musl/src/signal/powerpc64/sigsetjmp.s",
1633 "musl/src/signal/powerpc/restore.s",
1634 "musl/src/signal/powerpc/sigsetjmp.s",
1635 "musl/src/signal/psiginfo.c",
1636 "musl/src/signal/psignal.c",
1637 "musl/src/signal/raise.c",
1638 "musl/src/signal/restore.c",
1639 "musl/src/signal/riscv32/restore.s",
1640 "musl/src/signal/riscv32/sigsetjmp.s",
1641 "musl/src/signal/riscv64/restore.s",
1642 "musl/src/signal/riscv64/sigsetjmp.s",
1643 "musl/src/signal/s390x/restore.s",
1644 "musl/src/signal/s390x/sigsetjmp.s",
1645 "musl/src/signal/setitimer.c",
1646 "musl/src/signal/sigaction.c",
1647 "musl/src/signal/sigaddset.c",
1648 "musl/src/signal/sigaltstack.c",
1649 "musl/src/signal/sigandset.c",
1650 "musl/src/signal/sigdelset.c",
1651 "musl/src/signal/sigemptyset.c",
1652 "musl/src/signal/sigfillset.c",
1653 "musl/src/signal/sighold.c",
1654 "musl/src/signal/sigignore.c",
1655 "musl/src/signal/siginterrupt.c",
1656 "musl/src/signal/sigisemptyset.c",
1657 "musl/src/signal/sigismember.c",
1658 "musl/src/signal/siglongjmp.c",
1659 "musl/src/signal/signal.c",
1660 "musl/src/signal/sigorset.c",
1661 "musl/src/signal/sigpause.c",
1662 "musl/src/signal/sigpending.c",
1663 "musl/src/signal/sigprocmask.c",
1664 "musl/src/signal/sigqueue.c",
1665 "musl/src/signal/sigrelse.c",
1666 "musl/src/signal/sigrtmax.c",
1667 "musl/src/signal/sigrtmin.c",
1668 "musl/src/signal/sigset.c",
1669 "musl/src/signal/sigsetjmp.c",
1670 "musl/src/signal/sigsetjmp_tail.c",
1671 "musl/src/signal/sigsuspend.c",
1672 "musl/src/signal/sigtimedwait.c",
1673 "musl/src/signal/sigwait.c",
1674 "musl/src/signal/sigwaitinfo.c",
1675 "musl/src/signal/x32/getitimer.c",
1676 "musl/src/signal/x32/restore.s",
1677 "musl/src/signal/x32/setitimer.c",
1678 "musl/src/signal/x32/sigsetjmp.s",
1679 "musl/src/signal/x86_64/restore.s",
1680 "musl/src/signal/x86_64/sigsetjmp.s",
1681 "musl/src/stat/chmod.c",
1682 "musl/src/stat/fchmodat.c",
1683 "musl/src/stat/fchmod.c",
1684 "musl/src/stat/fstatat.c",
1685 "musl/src/stat/fstat.c",
1686 "musl/src/stat/futimens.c",
1687 "musl/src/stat/futimesat.c",
1688 "musl/src/stat/lchmod.c",
1689 "musl/src/stat/lstat.c",
1690 "musl/src/stat/mkdirat.c",
1691 "musl/src/stat/mkdir.c",
1692 "musl/src/stat/mkfifoat.c",
1693 "musl/src/stat/mkfifo.c",
1694 "musl/src/stat/mknodat.c",
1695 "musl/src/stat/mknod.c",
1696 "musl/src/stat/stat.c",
1697 "musl/src/stat/statvfs.c",
1698 "musl/src/stat/umask.c",
1699 "musl/src/stat/utimensat.c",
1700 "musl/src/stat/__xstat.c",
1701 "musl/src/stdio/asprintf.c",
1702 "musl/src/stdio/clearerr.c",
1703 "musl/src/stdio/dprintf.c",
1704 "musl/src/stdio/ext2.c",
1705 "musl/src/stdio/ext.c",
1706 "musl/src/stdio/fclose.c",
1707 "musl/src/stdio/__fclose_ca.c",
1708 "musl/src/stdio/__fdopen.c",
1709 "musl/src/stdio/feof.c",
1710 "musl/src/stdio/ferror.c",
1711 "musl/src/stdio/fflush.c",
1712 "musl/src/stdio/fgetc.c",
1713 "musl/src/stdio/fgetln.c",
1714 "musl/src/stdio/fgetpos.c",
1715 "musl/src/stdio/fgets.c",
1716 "musl/src/stdio/fgetwc.c",
1717 "musl/src/stdio/fgetws.c",
1718 "musl/src/stdio/fileno.c",
1719 "musl/src/stdio/flockfile.c",
1720 "musl/src/stdio/fmemopen.c",
1721 "musl/src/stdio/__fmodeflags.c",
1722 "musl/src/stdio/fopen.c",
1723 "musl/src/stdio/fopencookie.c",
1724 "musl/src/stdio/__fopen_rb_ca.c",
1725 "musl/src/stdio/fprintf.c",
1726 "musl/src/stdio/fputc.c",
1727 "musl/src/stdio/fputs.c",
1728 "musl/src/stdio/fputwc.c",
1729 "musl/src/stdio/fputws.c",
1730 "musl/src/stdio/fread.c",
1731 "musl/src/stdio/freopen.c",
1732 "musl/src/stdio/fscanf.c",
1733 "musl/src/stdio/fseek.c",
1734 "musl/src/stdio/fsetpos.c",
1735 "musl/src/stdio/ftell.c",
1736 "musl/src/stdio/ftrylockfile.c",
1737 "musl/src/stdio/funlockfile.c",
1738 "musl/src/stdio/fwide.c",
1739 "musl/src/stdio/fwprintf.c",
1740 "musl/src/stdio/fwrite.c",
1741 "musl/src/stdio/fwscanf.c",
1742 "musl/src/stdio/getc.c",
1743 "musl/src/stdio/getchar.c",
1744 "musl/src/stdio/getchar_unlocked.c",
1745 "musl/src/stdio/getc_unlocked.c",
1746 "musl/src/stdio/getdelim.c",
1747 "musl/src/stdio/getline.c",
1748 "musl/src/stdio/gets.c",
1749 "musl/src/stdio/getw.c",
1750 "musl/src/stdio/getwc.c",
1751 "musl/src/stdio/getwchar.c",
1752 "musl/src/stdio/__lockfile.c",
1753 "musl/src/stdio/ofl_add.c",
1754 "musl/src/stdio/ofl.c",
1755 "musl/src/stdio/open_memstream.c",
1756 "musl/src/stdio/open_wmemstream.c",
1757 "musl/src/stdio/__overflow.c",
1758 "musl/src/stdio/pclose.c",
1759 "musl/src/stdio/perror.c",
1760 "musl/src/stdio/popen.c",
1761 "musl/src/stdio/printf.c",
1762 "musl/src/stdio/putc.c",
1763 "musl/src/stdio/putchar.c",
1764 "musl/src/stdio/putchar_unlocked.c",
1765 "musl/src/stdio/putc_unlocked.c",
1766 "musl/src/stdio/puts.c",
1767 "musl/src/stdio/putw.c",
1768 "musl/src/stdio/putwc.c",
1769 "musl/src/stdio/putwchar.c",
1770 "musl/src/stdio/remove.c",
1771 "musl/src/stdio/rename.c",
1772 "musl/src/stdio/rewind.c",
1773 "musl/src/stdio/scanf.c",
1774 "musl/src/stdio/setbuf.c",
1775 "musl/src/stdio/setbuffer.c",
1776 "musl/src/stdio/setlinebuf.c",
1777 "musl/src/stdio/setvbuf.c",
1778 "musl/src/stdio/snprintf.c",
1779 "musl/src/stdio/sprintf.c",
1780 "musl/src/stdio/sscanf.c",
1781 "musl/src/stdio/stderr.c",
1782 "musl/src/stdio/stdin.c",
1783 "musl/src/stdio/__stdio_close.c",
1784 "musl/src/stdio/__stdio_exit.c",
1785 "musl/src/stdio/__stdio_read.c",
1786 "musl/src/stdio/__stdio_seek.c",
1787 "musl/src/stdio/__stdio_write.c",
1788 "musl/src/stdio/stdout.c",
1789 "musl/src/stdio/__stdout_write.c",
1790 "musl/src/stdio/swprintf.c",
1791 "musl/src/stdio/swscanf.c",
1792 "musl/src/stdio/tempnam.c",
1793 "musl/src/stdio/tmpfile.c",
1794 "musl/src/stdio/tmpnam.c",
1795 "musl/src/stdio/__toread.c",
1796 "musl/src/stdio/__towrite.c",
1797 "musl/src/stdio/__uflow.c",
1798 "musl/src/stdio/ungetc.c",
1799 "musl/src/stdio/ungetwc.c",
1800 "musl/src/stdio/vasprintf.c",
1801 "musl/src/stdio/vdprintf.c",
1802 "musl/src/stdio/vfprintf.c",
1803 "musl/src/stdio/vfscanf.c",
1804 "musl/src/stdio/vfwprintf.c",
1805 "musl/src/stdio/vfwscanf.c",
1806 "musl/src/stdio/vprintf.c",
1807 "musl/src/stdio/vscanf.c",
1808 "musl/src/stdio/vsnprintf.c",
1809 "musl/src/stdio/vsprintf.c",
1810 "musl/src/stdio/vsscanf.c",
1811 "musl/src/stdio/vswprintf.c",
1812 "musl/src/stdio/vswscanf.c",
1813 "musl/src/stdio/vwprintf.c",
1814 "musl/src/stdio/vwscanf.c",
1815 "musl/src/stdio/wprintf.c",
1816 "musl/src/stdio/wscanf.c",
1817 "musl/src/stdlib/abs.c",
1818 "musl/src/stdlib/atof.c",
1819 "musl/src/stdlib/atoi.c",
1820 "musl/src/stdlib/atol.c",
1821 "musl/src/stdlib/atoll.c",
1822 "musl/src/stdlib/bsearch.c",
1823 "musl/src/stdlib/div.c",
1824 "musl/src/stdlib/ecvt.c",
1825 "musl/src/stdlib/fcvt.c",
1826 "musl/src/stdlib/gcvt.c",
1827 "musl/src/stdlib/imaxabs.c",
1828 "musl/src/stdlib/imaxdiv.c",
1829 "musl/src/stdlib/labs.c",
1830 "musl/src/stdlib/ldiv.c",
1831 "musl/src/stdlib/llabs.c",
1832 "musl/src/stdlib/lldiv.c",
1833 "musl/src/stdlib/qsort.c",
1834 "musl/src/stdlib/qsort_nr.c",
1835 "musl/src/stdlib/strtod.c",
1836 "musl/src/stdlib/strtol.c",
1837 "musl/src/stdlib/wcstod.c",
1838 "musl/src/stdlib/wcstol.c",
1839 "musl/src/string/aarch64/memset.S",
1840 "musl/src/string/arm/__aeabi_memset.s",
1841 "musl/src/string/bcmp.c",
1842 "musl/src/string/bcopy.c",
1843 "musl/src/string/explicit_bzero.c",
1844 "musl/src/string/i386/memset.s",
1845 "musl/src/string/index.c",
1846 "musl/src/string/memccpy.c",
1847 "musl/src/string/memchr.c",
1848 "musl/src/string/memcmp.c",
1849 "musl/src/string/memmem.c",
1850 "musl/src/string/mempcpy.c",
1851 "musl/src/string/memrchr.c",
1852 "musl/src/string/memset.c",
1853 "musl/src/string/rindex.c",
1854 "musl/src/string/stpcpy.c",
1855 "musl/src/string/stpncpy.c",
1856 "musl/src/string/strcasecmp.c",
1857 "musl/src/string/strcasestr.c",
1858 "musl/src/string/strcat.c",
1859 "musl/src/string/strchr.c",
1860 "musl/src/string/strchrnul.c",
1861 "musl/src/string/strcpy.c",
1862 "musl/src/string/strcspn.c",
1863 "musl/src/string/strdup.c",
1864 "musl/src/string/strerror_r.c",
1865 "musl/src/string/strlcat.c",
1866 "musl/src/string/strlcpy.c",
1867 "musl/src/string/strncasecmp.c",
1868 "musl/src/string/strncat.c",
1869 "musl/src/string/strncpy.c",
1870 "musl/src/string/strndup.c",
1871 "musl/src/string/strnlen.c",
1872 "musl/src/string/strpbrk.c",
1873 "musl/src/string/strrchr.c",
1874 "musl/src/string/strsep.c",
1875 "musl/src/string/strsignal.c",
1876 "musl/src/string/strspn.c",
1877 "musl/src/string/strstr.c",
1878 "musl/src/string/strtok.c",
1879 "musl/src/string/strtok_r.c",
1880 "musl/src/string/strverscmp.c",
1881 "musl/src/string/swab.c",
1882 "musl/src/string/wcpcpy.c",
1883 "musl/src/string/wcpncpy.c",
1884 "musl/src/string/wcscasecmp.c",
1885 "musl/src/string/wcscasecmp_l.c",
1886 "musl/src/string/wcscat.c",
1887 "musl/src/string/wcschr.c",
1888 "musl/src/string/wcscmp.c",
1889 "musl/src/string/wcscpy.c",
1890 "musl/src/string/wcscspn.c",
1891 "musl/src/string/wcsdup.c",
1892 "musl/src/string/wcslen.c",
1893 "musl/src/string/wcsncasecmp.c",
1894 "musl/src/string/wcsncasecmp_l.c",
1895 "musl/src/string/wcsncat.c",
1896 "musl/src/string/wcsncmp.c",
1897 "musl/src/string/wcsncpy.c",
1898 "musl/src/string/wcsnlen.c",
1899 "musl/src/string/wcspbrk.c",
1900 "musl/src/string/wcsrchr.c",
1901 "musl/src/string/wcsspn.c",
1902 "musl/src/string/wcsstr.c",
1903 "musl/src/string/wcstok.c",
1904 "musl/src/string/wcswcs.c",
1905 "musl/src/string/wmemchr.c",
1906 "musl/src/string/wmemcmp.c",
1907 "musl/src/string/wmemcpy.c",
1908 "musl/src/string/wmemmove.c",
1909 "musl/src/string/wmemset.c",
1910 "musl/src/string/x86_64/memset.s",
1911 "musl/src/temp/mkdtemp.c",
1912 "musl/src/temp/mkostemp.c",
1913 "musl/src/temp/mkostemps.c",
1914 "musl/src/temp/mkstemp.c",
1915 "musl/src/temp/mkstemps.c",
1916 "musl/src/temp/mktemp.c",
1917 "musl/src/temp/__randname.c",
1918 "musl/src/termios/cfgetospeed.c",
1919 "musl/src/termios/cfmakeraw.c",
1920 "musl/src/termios/cfsetospeed.c",
1921 "musl/src/termios/tcdrain.c",
1922 "musl/src/termios/tcflow.c",
1923 "musl/src/termios/tcflush.c",
1924 "musl/src/termios/tcgetattr.c",
1925 "musl/src/termios/tcgetsid.c",
1926 "musl/src/termios/tcgetwinsize.c",
1927 "musl/src/termios/tcsendbreak.c",
1928 "musl/src/termios/tcsetattr.c",
1929 "musl/src/termios/tcsetwinsize.c",
1930 "musl/src/thread/aarch64/clone.s",
1931 "musl/src/thread/aarch64/__set_thread_area.s",
1932 "musl/src/thread/aarch64/syscall_cp.s",
1933 "musl/src/thread/aarch64/__unmapself.s",
1934 "musl/src/thread/arm/__aeabi_read_tp.s",
1935 "musl/src/thread/arm/atomics.s",
1936 "musl/src/thread/arm/clone.s",
1937 "musl/src/thread/arm/__set_thread_area.c",
1938 "musl/src/thread/arm/syscall_cp.s",
1939 "musl/src/thread/arm/__unmapself.s",
1940 "musl/src/thread/call_once.c",
1941 "musl/src/thread/clone.c",
1942 "musl/src/thread/cnd_broadcast.c",
1943 "musl/src/thread/cnd_destroy.c",
1944 "musl/src/thread/cnd_init.c",
1945 "musl/src/thread/cnd_signal.c",
1946 "musl/src/thread/cnd_timedwait.c",
1947 "musl/src/thread/cnd_wait.c",
1948 "musl/src/thread/default_attr.c",
1949 "musl/src/thread/hexagon/clone.s",
1950 "musl/src/thread/hexagon/__set_thread_area.s",
1951 "musl/src/thread/hexagon/syscall_cp.s",
1952 "musl/src/thread/hexagon/__unmapself.s",
1953 "musl/src/thread/i386/clone.s",
1954 "musl/src/thread/i386/__set_thread_area.s",
1955 "musl/src/thread/i386/syscall_cp.s",
1956 "musl/src/thread/i386/tls.s",
1957 "musl/src/thread/i386/__unmapself.s",
1958 "musl/src/thread/__lock.c",
1959 "musl/src/thread/lock_ptc.c",
1960 "musl/src/thread/loongarch64/clone.s",
1961 "musl/src/thread/loongarch64/__set_thread_area.s",
1962 "musl/src/thread/loongarch64/syscall_cp.s",
1963 "musl/src/thread/loongarch64/__unmapself.s",
1964 "musl/src/thread/m68k/clone.s",
1965 "musl/src/thread/m68k/__m68k_read_tp.s",
1966 "musl/src/thread/m68k/syscall_cp.s",
1967 "musl/src/thread/mips64/clone.s",
1968 "musl/src/thread/mips64/syscall_cp.s",
1969 "musl/src/thread/mips64/__unmapself.s",
1970 "musl/src/thread/mips/clone.s",
1971 "musl/src/thread/mipsn32/clone.s",
1972 "musl/src/thread/mipsn32/syscall_cp.s",
1973 "musl/src/thread/mipsn32/__unmapself.s",
1974 "musl/src/thread/mips/syscall_cp.s",
1975 "musl/src/thread/mips/__unmapself.s",
1976 "musl/src/thread/mtx_destroy.c",
1977 "musl/src/thread/mtx_init.c",
1978 "musl/src/thread/mtx_lock.c",
1979 "musl/src/thread/mtx_timedlock.c",
1980 "musl/src/thread/mtx_trylock.c",
1981 "musl/src/thread/mtx_unlock.c",
1982 "musl/src/thread/powerpc64/clone.s",
1983 "musl/src/thread/powerpc64/__set_thread_area.s",
1984 "musl/src/thread/powerpc64/syscall_cp.s",
1985 "musl/src/thread/powerpc64/__unmapself.s",
1986 "musl/src/thread/powerpc/clone.s",
1987 "musl/src/thread/powerpc/__set_thread_area.s",
1988 "musl/src/thread/powerpc/syscall_cp.s",
1989 "musl/src/thread/powerpc/__unmapself.s",
1990 "musl/src/thread/pthread_atfork.c",
1991 "musl/src/thread/pthread_attr_destroy.c",
1992 "musl/src/thread/pthread_attr_get.c",
1993 "musl/src/thread/pthread_attr_init.c",
1994 "musl/src/thread/pthread_attr_setdetachstate.c",
1995 "musl/src/thread/pthread_attr_setguardsize.c",
1996 "musl/src/thread/pthread_attr_setinheritsched.c",
1997 "musl/src/thread/pthread_attr_setschedparam.c",
1998 "musl/src/thread/pthread_attr_setschedpolicy.c",
1999 "musl/src/thread/pthread_attr_setscope.c",
2000 "musl/src/thread/pthread_attr_setstack.c",
2001 "musl/src/thread/pthread_attr_setstacksize.c",
2002 "musl/src/thread/pthread_barrierattr_destroy.c",
2003 "musl/src/thread/pthread_barrierattr_init.c",
2004 "musl/src/thread/pthread_barrierattr_setpshared.c",
2005 "musl/src/thread/pthread_barrier_destroy.c",
2006 "musl/src/thread/pthread_barrier_init.c",
2007 "musl/src/thread/pthread_barrier_wait.c",
2008 "musl/src/thread/pthread_cancel.c",
2009 "musl/src/thread/pthread_cleanup_push.c",
2010 "musl/src/thread/pthread_condattr_destroy.c",
2011 "musl/src/thread/pthread_condattr_init.c",
2012 "musl/src/thread/pthread_condattr_setclock.c",
2013 "musl/src/thread/pthread_condattr_setpshared.c",
2014 "musl/src/thread/pthread_cond_broadcast.c",
2015 "musl/src/thread/pthread_cond_destroy.c",
2016 "musl/src/thread/pthread_cond_init.c",
2017 "musl/src/thread/pthread_cond_signal.c",
2018 "musl/src/thread/pthread_cond_timedwait.c",
2019 "musl/src/thread/pthread_cond_wait.c",
2020 "musl/src/thread/pthread_create.c",
2021 "musl/src/thread/pthread_detach.c",
2022 "musl/src/thread/pthread_equal.c",
2023 "musl/src/thread/pthread_getattr_np.c",
2024 "musl/src/thread/pthread_getconcurrency.c",
2025 "musl/src/thread/pthread_getcpuclockid.c",
2026 "musl/src/thread/pthread_getname_np.c",
2027 "musl/src/thread/pthread_getschedparam.c",
2028 "musl/src/thread/pthread_getspecific.c",
2029 "musl/src/thread/pthread_join.c",
2030 "musl/src/thread/pthread_key_create.c",
2031 "musl/src/thread/pthread_kill.c",
2032 "musl/src/thread/pthread_mutexattr_destroy.c",
2033 "musl/src/thread/pthread_mutexattr_init.c",
2034 "musl/src/thread/pthread_mutexattr_setprotocol.c",
2035 "musl/src/thread/pthread_mutexattr_setpshared.c",
2036 "musl/src/thread/pthread_mutexattr_setrobust.c",
2037 "musl/src/thread/pthread_mutexattr_settype.c",
2038 "musl/src/thread/pthread_mutex_consistent.c",
2039 "musl/src/thread/pthread_mutex_destroy.c",
2040 "musl/src/thread/pthread_mutex_getprioceiling.c",
2041 "musl/src/thread/pthread_mutex_init.c",
2042 "musl/src/thread/pthread_mutex_lock.c",
2043 "musl/src/thread/pthread_mutex_setprioceiling.c",
2044 "musl/src/thread/pthread_mutex_timedlock.c",
2045 "musl/src/thread/pthread_mutex_trylock.c",
2046 "musl/src/thread/pthread_mutex_unlock.c",
2047 "musl/src/thread/pthread_once.c",
2048 "musl/src/thread/pthread_rwlockattr_destroy.c",
2049 "musl/src/thread/pthread_rwlockattr_init.c",
2050 "musl/src/thread/pthread_rwlockattr_setpshared.c",
2051 "musl/src/thread/pthread_rwlock_destroy.c",
2052 "musl/src/thread/pthread_rwlock_init.c",
2053 "musl/src/thread/pthread_rwlock_rdlock.c",
2054 "musl/src/thread/pthread_rwlock_timedrdlock.c",
2055 "musl/src/thread/pthread_rwlock_timedwrlock.c",
2056 "musl/src/thread/pthread_rwlock_tryrdlock.c",
2057 "musl/src/thread/pthread_rwlock_trywrlock.c",
2058 "musl/src/thread/pthread_rwlock_unlock.c",
2059 "musl/src/thread/pthread_rwlock_wrlock.c",
2060 "musl/src/thread/pthread_self.c",
2061 "musl/src/thread/pthread_setattr_default_np.c",
2062 "musl/src/thread/pthread_setcancelstate.c",
2063 "musl/src/thread/pthread_setcanceltype.c",
2064 "musl/src/thread/pthread_setconcurrency.c",
2065 "musl/src/thread/pthread_setname_np.c",
2066 "musl/src/thread/pthread_setschedparam.c",
2067 "musl/src/thread/pthread_setschedprio.c",
2068 "musl/src/thread/pthread_setspecific.c",
2069 "musl/src/thread/pthread_sigmask.c",
2070 "musl/src/thread/pthread_spin_destroy.c",
2071 "musl/src/thread/pthread_spin_init.c",
2072 "musl/src/thread/pthread_spin_lock.c",
2073 "musl/src/thread/pthread_spin_trylock.c",
2074 "musl/src/thread/pthread_spin_unlock.c",
2075 "musl/src/thread/pthread_testcancel.c",
2076 "musl/src/thread/riscv32/clone.s",
2077 "musl/src/thread/riscv32/__set_thread_area.s",
2078 "musl/src/thread/riscv32/syscall_cp.s",
2079 "musl/src/thread/riscv32/__unmapself.s",
2080 "musl/src/thread/riscv64/clone.s",
2081 "musl/src/thread/riscv64/__set_thread_area.s",
2082 "musl/src/thread/riscv64/syscall_cp.s",
2083 "musl/src/thread/riscv64/__unmapself.s",
2084 "musl/src/thread/s390x/clone.s",
2085 "musl/src/thread/s390x/__set_thread_area.s",
2086 "musl/src/thread/s390x/syscall_cp.s",
2087 "musl/src/thread/s390x/__tls_get_offset.s",
2088 "musl/src/thread/s390x/__unmapself.s",
2089 "musl/src/thread/sem_destroy.c",
2090 "musl/src/thread/sem_getvalue.c",
2091 "musl/src/thread/sem_init.c",
2092 "musl/src/thread/sem_open.c",
2093 "musl/src/thread/sem_post.c",
2094 "musl/src/thread/sem_timedwait.c",
2095 "musl/src/thread/sem_trywait.c",
2096 "musl/src/thread/sem_unlink.c",
2097 "musl/src/thread/sem_wait.c",
2098 "musl/src/thread/__set_thread_area.c",
2099 "musl/src/thread/synccall.c",
2100 "musl/src/thread/__syscall_cp.c",
2101 "musl/src/thread/syscall_cp.c",
2102 "musl/src/thread/thrd_create.c",
2103 "musl/src/thread/thrd_exit.c",
2104 "musl/src/thread/thrd_join.c",
2105 "musl/src/thread/thrd_sleep.c",
2106 "musl/src/thread/thrd_yield.c",
2107 "musl/src/thread/__timedwait.c",
2108 "musl/src/thread/tls.c",
2109 "musl/src/thread/__tls_get_addr.c",
2110 "musl/src/thread/tss_create.c",
2111 "musl/src/thread/tss_delete.c",
2112 "musl/src/thread/tss_set.c",
2113 "musl/src/thread/__unmapself.c",
2114 "musl/src/thread/vmlock.c",
2115 "musl/src/thread/__wait.c",
2116 "musl/src/thread/x32/clone.s",
2117 "musl/src/thread/x32/__set_thread_area.s",
2118 "musl/src/thread/x32/syscall_cp.s",
2119 "musl/src/thread/x32/__unmapself.s",
2120 "musl/src/thread/x86_64/clone.s",
2121 "musl/src/thread/x86_64/__set_thread_area.s",
2122 "musl/src/thread/x86_64/syscall_cp.s",
2123 "musl/src/thread/x86_64/__unmapself.s",
2124 "musl/src/time/asctime.c",
2125 "musl/src/time/asctime_r.c",
2126 "musl/src/time/clock.c",
2127 "musl/src/time/clock_getcpuclockid.c",
2128 "musl/src/time/clock_getres.c",
2129 "musl/src/time/clock_gettime.c",
2130 "musl/src/time/clock_nanosleep.c",
2131 "musl/src/time/clock_settime.c",
2132 "musl/src/time/ctime.c",
2133 "musl/src/time/ctime_r.c",
2134 "musl/src/time/difftime.c",
2135 "musl/src/time/ftime.c",
2136 "musl/src/time/getdate.c",
2137 "musl/src/time/gettimeofday.c",
2138 "musl/src/time/gmtime.c",
2139 "musl/src/time/gmtime_r.c",
2140 "musl/src/time/localtime.c",
2141 "musl/src/time/localtime_r.c",
2142 "musl/src/time/__map_file.c",
2143 "musl/src/time/mktime.c",
2144 "musl/src/time/__month_to_secs.c",
2145 "musl/src/time/nanosleep.c",
2146 "musl/src/time/__secs_to_tm.c",
2147 "musl/src/time/strftime.c",
2148 "musl/src/time/strptime.c",
2149 "musl/src/time/time.c",
2150 "musl/src/time/timegm.c",
2151 "musl/src/time/timer_create.c",
2152 "musl/src/time/timer_delete.c",
2153 "musl/src/time/timer_getoverrun.c",
2154 "musl/src/time/timer_gettime.c",
2155 "musl/src/time/timer_settime.c",
2156 "musl/src/time/times.c",
2157 "musl/src/time/timespec_get.c",
2158 "musl/src/time/__tm_to_secs.c",
2159 "musl/src/time/__tz.c",
2160 "musl/src/time/utime.c",
2161 "musl/src/time/wcsftime.c",
2162 "musl/src/time/__year_to_secs.c",
2163 "musl/src/unistd/access.c",
2164 "musl/src/unistd/acct.c",
2165 "musl/src/unistd/alarm.c",
2166 "musl/src/unistd/chdir.c",
2167 "musl/src/unistd/chown.c",
2168 "musl/src/unistd/close.c",
2169 "musl/src/unistd/ctermid.c",
2170 "musl/src/unistd/dup2.c",
2171 "musl/src/unistd/dup3.c",
2172 "musl/src/unistd/dup.c",
2173 "musl/src/unistd/_exit.c",
2174 "musl/src/unistd/faccessat.c",
2175 "musl/src/unistd/fchdir.c",
2176 "musl/src/unistd/fchownat.c",
2177 "musl/src/unistd/fchown.c",
2178 "musl/src/unistd/fdatasync.c",
2179 "musl/src/unistd/fsync.c",
2180 "musl/src/unistd/ftruncate.c",
2181 "musl/src/unistd/getcwd.c",
2182 "musl/src/unistd/getegid.c",
2183 "musl/src/unistd/geteuid.c",
2184 "musl/src/unistd/getgid.c",
2185 "musl/src/unistd/getgroups.c",
2186 "musl/src/unistd/gethostname.c",
2187 "musl/src/unistd/getlogin.c",
2188 "musl/src/unistd/getlogin_r.c",
2189 "musl/src/unistd/getpgid.c",
2190 "musl/src/unistd/getpgrp.c",
2191 "musl/src/unistd/getpid.c",
2192 "musl/src/unistd/getppid.c",
2193 "musl/src/unistd/getsid.c",
2194 "musl/src/unistd/getuid.c",
2195 "musl/src/unistd/isatty.c",
2196 "musl/src/unistd/lchown.c",
2197 "musl/src/unistd/linkat.c",
2198 "musl/src/unistd/link.c",
2199 "musl/src/unistd/lseek.c",
2200 "musl/src/unistd/mips64/pipe.s",
2201 "musl/src/unistd/mipsn32/lseek.c",
2202 "musl/src/unistd/mipsn32/pipe.s",
2203 "musl/src/unistd/mips/pipe.s",
2204 "musl/src/unistd/nice.c",
2205 "musl/src/unistd/pause.c",
2206 "musl/src/unistd/pipe2.c",
2207 "musl/src/unistd/pipe.c",
2208 "musl/src/unistd/posix_close.c",
2209 "musl/src/unistd/pread.c",
2210 "musl/src/unistd/preadv.c",
2211 "musl/src/unistd/pwrite.c",
2212 "musl/src/unistd/pwritev.c",
2213 "musl/src/unistd/read.c",
2214 "musl/src/unistd/readlinkat.c",
2215 "musl/src/unistd/readlink.c",
2216 "musl/src/unistd/readv.c",
2217 "musl/src/unistd/renameat.c",
2218 "musl/src/unistd/rmdir.c",
2219 "musl/src/unistd/setegid.c",
2220 "musl/src/unistd/seteuid.c",
2221 "musl/src/unistd/setgid.c",
2222 "musl/src/unistd/setpgid.c",
2223 "musl/src/unistd/setpgrp.c",
2224 "musl/src/unistd/setregid.c",
2225 "musl/src/unistd/setresgid.c",
2226 "musl/src/unistd/setresuid.c",
2227 "musl/src/unistd/setreuid.c",
2228 "musl/src/unistd/setsid.c",
2229 "musl/src/unistd/setuid.c",
2230 "musl/src/unistd/setxid.c",
2231 "musl/src/unistd/sleep.c",
2232 "musl/src/unistd/symlinkat.c",
2233 "musl/src/unistd/symlink.c",
2234 "musl/src/unistd/sync.c",
2235 "musl/src/unistd/tcgetpgrp.c",
2236 "musl/src/unistd/tcsetpgrp.c",
2237 "musl/src/unistd/truncate.c",
2238 "musl/src/unistd/ttyname.c",
2239 "musl/src/unistd/ttyname_r.c",
2240 "musl/src/unistd/ualarm.c",
2241 "musl/src/unistd/unlinkat.c",
2242 "musl/src/unistd/unlink.c",
2243 "musl/src/unistd/usleep.c",
2244 "musl/src/unistd/write.c",
2245 "musl/src/unistd/writev.c",
2246 "musl/src/unistd/x32/lseek.c",
2247};
2248
2249const compat_time32_files = [_][]const u8{
2250 "musl/compat/time32/adjtime32.c",
2251 "musl/compat/time32/adjtimex_time32.c",
2252 "musl/compat/time32/aio_suspend_time32.c",
2253 "musl/compat/time32/clock_adjtime32.c",
2254 "musl/compat/time32/clock_getres_time32.c",
2255 "musl/compat/time32/clock_gettime32.c",
2256 "musl/compat/time32/clock_nanosleep_time32.c",
2257 "musl/compat/time32/clock_settime32.c",
2258 "musl/compat/time32/cnd_timedwait_time32.c",
2259 "musl/compat/time32/ctime32.c",
2260 "musl/compat/time32/ctime32_r.c",
2261 "musl/compat/time32/difftime32.c",
2262 "musl/compat/time32/fstatat_time32.c",
2263 "musl/compat/time32/fstat_time32.c",
2264 "musl/compat/time32/ftime32.c",
2265 "musl/compat/time32/futimens_time32.c",
2266 "musl/compat/time32/futimesat_time32.c",
2267 "musl/compat/time32/futimes_time32.c",
2268 "musl/compat/time32/getitimer_time32.c",
2269 "musl/compat/time32/getrusage_time32.c",
2270 "musl/compat/time32/gettimeofday_time32.c",
2271 "musl/compat/time32/gmtime32.c",
2272 "musl/compat/time32/gmtime32_r.c",
2273 "musl/compat/time32/localtime32.c",
2274 "musl/compat/time32/localtime32_r.c",
2275 "musl/compat/time32/lstat_time32.c",
2276 "musl/compat/time32/lutimes_time32.c",
2277 "musl/compat/time32/mktime32.c",
2278 "musl/compat/time32/mq_timedreceive_time32.c",
2279 "musl/compat/time32/mq_timedsend_time32.c",
2280 "musl/compat/time32/mtx_timedlock_time32.c",
2281 "musl/compat/time32/nanosleep_time32.c",
2282 "musl/compat/time32/ppoll_time32.c",
2283 "musl/compat/time32/pselect_time32.c",
2284 "musl/compat/time32/pthread_cond_timedwait_time32.c",
2285 "musl/compat/time32/pthread_mutex_timedlock_time32.c",
2286 "musl/compat/time32/pthread_rwlock_timedrdlock_time32.c",
2287 "musl/compat/time32/pthread_rwlock_timedwrlock_time32.c",
2288 "musl/compat/time32/pthread_timedjoin_np_time32.c",
2289 "musl/compat/time32/recvmmsg_time32.c",
2290 "musl/compat/time32/sched_rr_get_interval_time32.c",
2291 "musl/compat/time32/select_time32.c",
2292 "musl/compat/time32/semtimedop_time32.c",
2293 "musl/compat/time32/sem_timedwait_time32.c",
2294 "musl/compat/time32/setitimer_time32.c",
2295 "musl/compat/time32/settimeofday_time32.c",
2296 "musl/compat/time32/sigtimedwait_time32.c",
2297 "musl/compat/time32/stat_time32.c",
2298 "musl/compat/time32/stime32.c",
2299 "musl/compat/time32/thrd_sleep_time32.c",
2300 "musl/compat/time32/time32.c",
2301 "musl/compat/time32/time32gm.c",
2302 "musl/compat/time32/timerfd_gettime32.c",
2303 "musl/compat/time32/timerfd_settime32.c",
2304 "musl/compat/time32/timer_gettime32.c",
2305 "musl/compat/time32/timer_settime32.c",
2306 "musl/compat/time32/timespec_get_time32.c",
2307 "musl/compat/time32/utimensat_time32.c",
2308 "musl/compat/time32/utimes_time32.c",
2309 "musl/compat/time32/utime_time32.c",
2310 "musl/compat/time32/wait3_time32.c",
2311 "musl/compat/time32/wait4_time32.c",
2312 "musl/compat/time32/__xstat.c",
2313};
src/print_targets.zig+1-1
...@@ -7,7 +7,7 @@ const Allocator = std.mem.Allocator;...@@ -7,7 +7,7 @@ const Allocator = std.mem.Allocator;
7const Target = std.Target;7const Target = std.Target;
8const target = @import("target.zig");8const target = @import("target.zig");
9const assert = std.debug.assert;9const assert = std.debug.assert;
10const glibc = @import("glibc.zig");10const glibc = @import("libs/glibc.zig");
11const introspect = @import("introspect.zig");11const introspect = @import("introspect.zig");
12const fatal = @import("main.zig").fatal;12const fatal = @import("main.zig").fatal;
1313
src/wasi_libc.zig deleted-1256
...@@ -1,1256 +0,0 @@
1const std = @import("std");
2const mem = std.mem;
3const path = std.fs.path;
4
5const Allocator = std.mem.Allocator;
6const Compilation = @import("Compilation.zig");
7const build_options = @import("build_options");
8
9pub const CrtFile = enum {
10 crt1_reactor_o,
11 crt1_command_o,
12 libc_a,
13 libdl_a,
14 libwasi_emulated_process_clocks_a,
15 libwasi_emulated_getpid_a,
16 libwasi_emulated_mman_a,
17 libwasi_emulated_signal_a,
18};
19
20pub fn getEmulatedLibCrtFile(lib_name: []const u8) ?CrtFile {
21 if (mem.eql(u8, lib_name, "dl")) {
22 return .libdl_a;
23 }
24 if (mem.eql(u8, lib_name, "wasi-emulated-process-clocks")) {
25 return .libwasi_emulated_process_clocks_a;
26 }
27 if (mem.eql(u8, lib_name, "wasi-emulated-getpid")) {
28 return .libwasi_emulated_getpid_a;
29 }
30 if (mem.eql(u8, lib_name, "wasi-emulated-mman")) {
31 return .libwasi_emulated_mman_a;
32 }
33 if (mem.eql(u8, lib_name, "wasi-emulated-signal")) {
34 return .libwasi_emulated_signal_a;
35 }
36 return null;
37}
38
39pub fn emulatedLibCRFileLibName(crt_file: CrtFile) []const u8 {
40 return switch (crt_file) {
41 .libdl_a => "libdl.a",
42 .libwasi_emulated_process_clocks_a => "libwasi-emulated-process-clocks.a",
43 .libwasi_emulated_getpid_a => "libwasi-emulated-getpid.a",
44 .libwasi_emulated_mman_a => "libwasi-emulated-mman.a",
45 .libwasi_emulated_signal_a => "libwasi-emulated-signal.a",
46 else => unreachable,
47 };
48}
49
50pub fn execModelCrtFile(wasi_exec_model: std.builtin.WasiExecModel) CrtFile {
51 return switch (wasi_exec_model) {
52 .reactor => CrtFile.crt1_reactor_o,
53 .command => CrtFile.crt1_command_o,
54 };
55}
56
57pub fn execModelCrtFileFullName(wasi_exec_model: std.builtin.WasiExecModel) []const u8 {
58 return switch (execModelCrtFile(wasi_exec_model)) {
59 .crt1_reactor_o => "crt1-reactor.o",
60 .crt1_command_o => "crt1-command.o",
61 else => unreachable,
62 };
63}
64
65/// TODO replace anyerror with explicit error set, recording user-friendly errors with
66/// setMiscFailure and returning error.SubCompilationFailed. see libcxx.zig for example.
67pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progress.Node) anyerror!void {
68 if (!build_options.have_llvm) {
69 return error.ZigCompilerNotBuiltWithLLVMExtensions;
70 }
71
72 const gpa = comp.gpa;
73 var arena_allocator = std.heap.ArenaAllocator.init(gpa);
74 defer arena_allocator.deinit();
75 const arena = arena_allocator.allocator();
76
77 switch (crt_file) {
78 .crt1_reactor_o => {
79 var args = std.ArrayList([]const u8).init(arena);
80 try addCCArgs(comp, arena, &args, .{});
81 try addLibcBottomHalfIncludes(comp, arena, &args);
82 var files = [_]Compilation.CSourceFile{
83 .{
84 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
85 "libc", try sanitize(arena, crt1_reactor_src_file),
86 }),
87 .extra_flags = args.items,
88 .owner = undefined,
89 },
90 };
91 return comp.build_crt_file("crt1-reactor", .Obj, .@"wasi crt1-reactor.o", prog_node, &files, .{});
92 },
93 .crt1_command_o => {
94 var args = std.ArrayList([]const u8).init(arena);
95 try addCCArgs(comp, arena, &args, .{});
96 try addLibcBottomHalfIncludes(comp, arena, &args);
97 var files = [_]Compilation.CSourceFile{
98 .{
99 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
100 "libc", try sanitize(arena, crt1_command_src_file),
101 }),
102 .extra_flags = args.items,
103 .owner = undefined,
104 },
105 };
106 return comp.build_crt_file("crt1-command", .Obj, .@"wasi crt1-command.o", prog_node, &files, .{});
107 },
108 .libc_a => {
109 var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
110
111 {
112 // Compile emmalloc.
113 var args = std.ArrayList([]const u8).init(arena);
114 try addCCArgs(comp, arena, &args, .{ .want_O3 = true, .no_strict_aliasing = true });
115 for (emmalloc_src_files) |file_path| {
116 try libc_sources.append(.{
117 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
118 "libc", try sanitize(arena, file_path),
119 }),
120 .extra_flags = args.items,
121 .owner = undefined,
122 });
123 }
124 }
125
126 {
127 // Compile libc-bottom-half.
128 var args = std.ArrayList([]const u8).init(arena);
129 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
130 try addLibcBottomHalfIncludes(comp, arena, &args);
131
132 for (libc_bottom_half_src_files) |file_path| {
133 try libc_sources.append(.{
134 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
135 "libc", try sanitize(arena, file_path),
136 }),
137 .extra_flags = args.items,
138 .owner = undefined,
139 });
140 }
141 }
142
143 {
144 // Compile libc-top-half.
145 var args = std.ArrayList([]const u8).init(arena);
146 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
147 try addLibcTopHalfIncludes(comp, arena, &args);
148
149 for (libc_top_half_src_files) |file_path| {
150 try libc_sources.append(.{
151 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
152 "libc", try sanitize(arena, file_path),
153 }),
154 .extra_flags = args.items,
155 .owner = undefined,
156 });
157 }
158 }
159
160 try comp.build_crt_file("c", .Lib, .@"wasi libc.a", prog_node, libc_sources.items, .{});
161 },
162
163 .libdl_a => {
164 var args = std.ArrayList([]const u8).init(arena);
165 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
166 try addLibcBottomHalfIncludes(comp, arena, &args);
167
168 var emu_dl_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
169 for (emulated_dl_src_files) |file_path| {
170 try emu_dl_sources.append(.{
171 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
172 "libc", try sanitize(arena, file_path),
173 }),
174 .extra_flags = args.items,
175 .owner = undefined,
176 });
177 }
178 try comp.build_crt_file("dl", .Lib, .@"wasi libdl.a", prog_node, emu_dl_sources.items, .{});
179 },
180
181 .libwasi_emulated_process_clocks_a => {
182 var args = std.ArrayList([]const u8).init(arena);
183 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
184 try addLibcBottomHalfIncludes(comp, arena, &args);
185
186 var emu_clocks_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
187 for (emulated_process_clocks_src_files) |file_path| {
188 try emu_clocks_sources.append(.{
189 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
190 "libc", try sanitize(arena, file_path),
191 }),
192 .extra_flags = args.items,
193 .owner = undefined,
194 });
195 }
196 try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, .@"libwasi-emulated-process-clocks.a", prog_node, emu_clocks_sources.items, .{});
197 },
198 .libwasi_emulated_getpid_a => {
199 var args = std.ArrayList([]const u8).init(arena);
200 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
201 try addLibcBottomHalfIncludes(comp, arena, &args);
202
203 var emu_getpid_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
204 for (emulated_getpid_src_files) |file_path| {
205 try emu_getpid_sources.append(.{
206 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
207 "libc", try sanitize(arena, file_path),
208 }),
209 .extra_flags = args.items,
210 .owner = undefined,
211 });
212 }
213 try comp.build_crt_file("wasi-emulated-getpid", .Lib, .@"libwasi-emulated-getpid.a", prog_node, emu_getpid_sources.items, .{});
214 },
215 .libwasi_emulated_mman_a => {
216 var args = std.ArrayList([]const u8).init(arena);
217 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
218 try addLibcBottomHalfIncludes(comp, arena, &args);
219
220 var emu_mman_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
221 for (emulated_mman_src_files) |file_path| {
222 try emu_mman_sources.append(.{
223 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
224 "libc", try sanitize(arena, file_path),
225 }),
226 .extra_flags = args.items,
227 .owner = undefined,
228 });
229 }
230 try comp.build_crt_file("wasi-emulated-mman", .Lib, .@"libwasi-emulated-mman.a", prog_node, emu_mman_sources.items, .{});
231 },
232 .libwasi_emulated_signal_a => {
233 var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena);
234
235 {
236 var args = std.ArrayList([]const u8).init(arena);
237 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
238
239 for (emulated_signal_bottom_half_src_files) |file_path| {
240 try emu_signal_sources.append(.{
241 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
242 "libc", try sanitize(arena, file_path),
243 }),
244 .extra_flags = args.items,
245 .owner = undefined,
246 });
247 }
248 }
249
250 {
251 var args = std.ArrayList([]const u8).init(arena);
252 try addCCArgs(comp, arena, &args, .{ .want_O3 = true });
253 try addLibcTopHalfIncludes(comp, arena, &args);
254 try args.append("-D_WASI_EMULATED_SIGNAL");
255
256 for (emulated_signal_top_half_src_files) |file_path| {
257 try emu_signal_sources.append(.{
258 .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{
259 "libc", try sanitize(arena, file_path),
260 }),
261 .extra_flags = args.items,
262 .owner = undefined,
263 });
264 }
265 }
266
267 try comp.build_crt_file("wasi-emulated-signal", .Lib, .@"libwasi-emulated-signal.a", prog_node, emu_signal_sources.items, .{});
268 },
269 }
270}
271
272fn sanitize(arena: Allocator, file_path: []const u8) ![]const u8 {
273 // TODO do this at comptime on the comptime data rather than at runtime
274 // probably best to wait until self-hosted is done and our comptime execution
275 // is faster and uses less memory.
276 const out_path = if (path.sep != '/') blk: {
277 const mutable_file_path = try arena.dupe(u8, file_path);
278 for (mutable_file_path) |*c| {
279 if (c.* == '/') {
280 c.* = path.sep;
281 }
282 }
283 break :blk mutable_file_path;
284 } else file_path;
285 return out_path;
286}
287
288const CCOptions = struct {
289 want_O3: bool = false,
290 no_strict_aliasing: bool = false,
291};
292
293fn addCCArgs(
294 comp: *Compilation,
295 arena: Allocator,
296 args: *std.ArrayList([]const u8),
297 options: CCOptions,
298) error{OutOfMemory}!void {
299 const target = comp.getTarget();
300 const arch_name = std.zig.target.muslArchNameHeaders(target.cpu.arch);
301 const os_name = @tagName(target.os.tag);
302 const triple = try std.fmt.allocPrint(arena, "{s}-{s}-musl", .{ arch_name, os_name });
303 const o_arg = if (options.want_O3) "-O3" else "-Os";
304
305 try args.appendSlice(&[_][]const u8{
306 "-std=gnu17",
307 "-fno-trapping-math",
308 "-w", // ignore all warnings
309
310 o_arg,
311
312 "-mthread-model",
313 "single",
314
315 "-isysroot",
316 "/",
317
318 "-iwithsysroot",
319 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", triple }),
320
321 "-iwithsysroot",
322 try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "generic-musl" }),
323
324 "-DBULK_MEMORY_THRESHOLD=32",
325 });
326
327 if (options.no_strict_aliasing) {
328 try args.appendSlice(&[_][]const u8{"-fno-strict-aliasing"});
329 }
330}
331
332fn addLibcBottomHalfIncludes(
333 comp: *Compilation,
334 arena: Allocator,
335 args: *std.ArrayList([]const u8),
336) error{OutOfMemory}!void {
337 try args.appendSlice(&[_][]const u8{
338 "-I",
339 try comp.zig_lib_directory.join(arena, &[_][]const u8{
340 "libc",
341 "wasi",
342 "libc-bottom-half",
343 "headers",
344 "private",
345 }),
346
347 "-I",
348 try comp.zig_lib_directory.join(arena, &[_][]const u8{
349 "libc",
350 "wasi",
351 "libc-bottom-half",
352 "cloudlibc",
353 "src",
354 "include",
355 }),
356
357 "-I",
358 try comp.zig_lib_directory.join(arena, &[_][]const u8{
359 "libc",
360 "wasi",
361 "libc-bottom-half",
362 "cloudlibc",
363 "src",
364 }),
365
366 "-I",
367 try comp.zig_lib_directory.join(arena, &[_][]const u8{
368 "libc",
369 "wasi",
370 "libc-top-half",
371 "musl",
372 "src",
373 "include",
374 }),
375
376 "-I",
377 try comp.zig_lib_directory.join(arena, &[_][]const u8{
378 "libc",
379 "musl",
380 "src",
381 "include",
382 }),
383
384 "-I",
385 try comp.zig_lib_directory.join(arena, &[_][]const u8{
386 "libc",
387 "wasi",
388 "libc-top-half",
389 "musl",
390 "src",
391 "internal",
392 }),
393
394 "-I",
395 try comp.zig_lib_directory.join(arena, &[_][]const u8{
396 "libc",
397 "musl",
398 "src",
399 "internal",
400 }),
401 });
402}
403
404fn addLibcTopHalfIncludes(
405 comp: *Compilation,
406 arena: Allocator,
407 args: *std.ArrayList([]const u8),
408) error{OutOfMemory}!void {
409 try args.appendSlice(&[_][]const u8{
410 "-I",
411 try comp.zig_lib_directory.join(arena, &[_][]const u8{
412 "libc",
413 "wasi",
414 "libc-top-half",
415 "musl",
416 "src",
417 "include",
418 }),
419
420 "-I",
421 try comp.zig_lib_directory.join(arena, &[_][]const u8{
422 "libc",
423 "musl",
424 "src",
425 "include",
426 }),
427
428 "-I",
429 try comp.zig_lib_directory.join(arena, &[_][]const u8{
430 "libc",
431 "wasi",
432 "libc-top-half",
433 "musl",
434 "src",
435 "internal",
436 }),
437
438 "-I",
439 try comp.zig_lib_directory.join(arena, &[_][]const u8{
440 "libc",
441 "musl",
442 "src",
443 "internal",
444 }),
445
446 "-I",
447 try comp.zig_lib_directory.join(arena, &[_][]const u8{
448 "libc",
449 "wasi",
450 "libc-top-half",
451 "musl",
452 "arch",
453 "wasm32",
454 }),
455
456 "-I",
457 try comp.zig_lib_directory.join(arena, &[_][]const u8{
458 "libc",
459 "musl",
460 "arch",
461 "generic",
462 }),
463
464 "-I",
465 try comp.zig_lib_directory.join(arena, &[_][]const u8{
466 "libc",
467 "wasi",
468 "libc-top-half",
469 "headers",
470 "private",
471 }),
472 });
473}
474
475const emmalloc_src_files = [_][]const u8{
476 "wasi/emmalloc/emmalloc.c",
477};
478
479const libc_bottom_half_src_files = [_][]const u8{
480 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/closedir.c",
481 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/dirfd.c",
482 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdclosedir.c",
483 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/fdopendir.c",
484 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/opendirat.c",
485 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/readdir.c",
486 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/rewinddir.c",
487 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/scandirat.c",
488 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/seekdir.c",
489 "wasi/libc-bottom-half/cloudlibc/src/libc/dirent/telldir.c",
490 "wasi/libc-bottom-half/cloudlibc/src/libc/errno/errno.c",
491 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/fcntl.c",
492 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c",
493 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fadvise.c",
494 "wasi/libc-bottom-half/cloudlibc/src/libc/fcntl/posix_fallocate.c",
495 "wasi/libc-bottom-half/cloudlibc/src/libc/poll/poll.c",
496 "wasi/libc-bottom-half/cloudlibc/src/libc/sched/sched_yield.c",
497 "wasi/libc-bottom-half/cloudlibc/src/libc/stdio/renameat.c",
498 "wasi/libc-bottom-half/cloudlibc/src/libc/stdlib/_Exit.c",
499 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c",
500 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c",
501 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/select/select.c",
502 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/getsockopt.c",
503 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/recv.c",
504 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/send.c",
505 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/socket/shutdown.c",
506 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstat.c",
507 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/fstatat.c",
508 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/futimens.c",
509 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/mkdirat.c",
510 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/stat/utimensat.c",
511 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/time/gettimeofday.c",
512 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/preadv.c",
513 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/pwritev.c",
514 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/readv.c",
515 "wasi/libc-bottom-half/cloudlibc/src/libc/sys/uio/writev.c",
516 "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_MONOTONIC.c",
517 "wasi/libc-bottom-half/cloudlibc/src/libc/time/CLOCK_REALTIME.c",
518 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_getres.c",
519 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_gettime.c",
520 "wasi/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c",
521 "wasi/libc-bottom-half/cloudlibc/src/libc/time/nanosleep.c",
522 "wasi/libc-bottom-half/cloudlibc/src/libc/time/time.c",
523 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/faccessat.c",
524 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fdatasync.c",
525 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/fsync.c",
526 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/ftruncate.c",
527 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c",
528 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c",
529 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pread.c",
530 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/pwrite.c",
531 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/read.c",
532 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c",
533 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/sleep.c",
534 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/symlinkat.c",
535 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/unlinkat.c",
536 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/usleep.c",
537 "wasi/libc-bottom-half/cloudlibc/src/libc/unistd/write.c",
538 "wasi/libc-bottom-half/sources/__errno_location.c",
539 "wasi/libc-bottom-half/sources/__main_void.c",
540 "wasi/libc-bottom-half/sources/__wasilibc_dt.c",
541 "wasi/libc-bottom-half/sources/__wasilibc_environ.c",
542 "wasi/libc-bottom-half/sources/__wasilibc_fd_renumber.c",
543 "wasi/libc-bottom-half/sources/__wasilibc_initialize_environ.c",
544 "wasi/libc-bottom-half/sources/__wasilibc_real.c",
545 "wasi/libc-bottom-half/sources/__wasilibc_rmdirat.c",
546 "wasi/libc-bottom-half/sources/__wasilibc_tell.c",
547 "wasi/libc-bottom-half/sources/__wasilibc_unlinkat.c",
548 "wasi/libc-bottom-half/sources/abort.c",
549 "wasi/libc-bottom-half/sources/accept-wasip1.c",
550 "wasi/libc-bottom-half/sources/at_fdcwd.c",
551 "wasi/libc-bottom-half/sources/complex-builtins.c",
552 "wasi/libc-bottom-half/sources/environ.c",
553 "wasi/libc-bottom-half/sources/errno.c",
554 "wasi/libc-bottom-half/sources/getcwd.c",
555 "wasi/libc-bottom-half/sources/getentropy.c",
556 "wasi/libc-bottom-half/sources/isatty.c",
557 "wasi/libc-bottom-half/sources/math/fmin-fmax.c",
558 "wasi/libc-bottom-half/sources/math/math-builtins.c",
559 "wasi/libc-bottom-half/sources/posix.c",
560 "wasi/libc-bottom-half/sources/preopens.c",
561 "wasi/libc-bottom-half/sources/reallocarray.c",
562 "wasi/libc-bottom-half/sources/sbrk.c",
563 "wasi/libc-bottom-half/sources/truncate.c",
564 "wasi/libc-bottom-half/sources/chdir.c",
565};
566
567const libc_top_half_src_files = [_][]const u8{
568 "musl/src/complex/cabs.c",
569 "musl/src/complex/cabsf.c",
570 "musl/src/complex/cabsl.c",
571 "musl/src/complex/cacos.c",
572 "musl/src/complex/cacosf.c",
573 "musl/src/complex/cacosh.c",
574 "musl/src/complex/cacoshf.c",
575 "musl/src/complex/cacoshl.c",
576 "musl/src/complex/cacosl.c",
577 "musl/src/complex/carg.c",
578 "musl/src/complex/cargf.c",
579 "musl/src/complex/cargl.c",
580 "musl/src/complex/casin.c",
581 "musl/src/complex/casinf.c",
582 "musl/src/complex/casinh.c",
583 "musl/src/complex/casinhf.c",
584 "musl/src/complex/casinhl.c",
585 "musl/src/complex/casinl.c",
586 "musl/src/complex/catan.c",
587 "musl/src/complex/catanf.c",
588 "musl/src/complex/catanh.c",
589 "musl/src/complex/catanhf.c",
590 "musl/src/complex/catanhl.c",
591 "musl/src/complex/catanl.c",
592 "musl/src/complex/ccos.c",
593 "musl/src/complex/ccosf.c",
594 "musl/src/complex/ccosh.c",
595 "musl/src/complex/ccoshf.c",
596 "musl/src/complex/ccoshl.c",
597 "musl/src/complex/ccosl.c",
598 "musl/src/complex/__cexp.c",
599 "musl/src/complex/cexp.c",
600 "musl/src/complex/__cexpf.c",
601 "musl/src/complex/cexpf.c",
602 "musl/src/complex/cexpl.c",
603 "musl/src/complex/clog.c",
604 "musl/src/complex/clogf.c",
605 "musl/src/complex/clogl.c",
606 "musl/src/complex/conj.c",
607 "musl/src/complex/conjf.c",
608 "musl/src/complex/conjl.c",
609 "musl/src/complex/cpow.c",
610 "musl/src/complex/cpowf.c",
611 "musl/src/complex/cpowl.c",
612 "musl/src/complex/cproj.c",
613 "musl/src/complex/cprojf.c",
614 "musl/src/complex/cprojl.c",
615 "musl/src/complex/csin.c",
616 "musl/src/complex/csinf.c",
617 "musl/src/complex/csinh.c",
618 "musl/src/complex/csinhf.c",
619 "musl/src/complex/csinhl.c",
620 "musl/src/complex/csinl.c",
621 "musl/src/complex/csqrt.c",
622 "musl/src/complex/csqrtf.c",
623 "musl/src/complex/csqrtl.c",
624 "musl/src/complex/ctan.c",
625 "musl/src/complex/ctanf.c",
626 "musl/src/complex/ctanh.c",
627 "musl/src/complex/ctanhf.c",
628 "musl/src/complex/ctanhl.c",
629 "musl/src/complex/ctanl.c",
630 "musl/src/conf/legacy.c",
631 "musl/src/conf/pathconf.c",
632 "musl/src/crypt/crypt_blowfish.c",
633 "musl/src/crypt/crypt.c",
634 "musl/src/crypt/crypt_des.c",
635 "musl/src/crypt/crypt_md5.c",
636 "musl/src/crypt/crypt_r.c",
637 "musl/src/crypt/crypt_sha256.c",
638 "musl/src/crypt/crypt_sha512.c",
639 "musl/src/crypt/encrypt.c",
640 "musl/src/ctype/__ctype_b_loc.c",
641 "musl/src/ctype/__ctype_get_mb_cur_max.c",
642 "musl/src/ctype/__ctype_tolower_loc.c",
643 "musl/src/ctype/__ctype_toupper_loc.c",
644 "musl/src/ctype/isalnum.c",
645 "musl/src/ctype/isalpha.c",
646 "musl/src/ctype/isascii.c",
647 "musl/src/ctype/isblank.c",
648 "musl/src/ctype/iscntrl.c",
649 "musl/src/ctype/isdigit.c",
650 "musl/src/ctype/isgraph.c",
651 "musl/src/ctype/islower.c",
652 "musl/src/ctype/isprint.c",
653 "musl/src/ctype/ispunct.c",
654 "musl/src/ctype/isspace.c",
655 "musl/src/ctype/isupper.c",
656 "musl/src/ctype/iswalnum.c",
657 "musl/src/ctype/iswalpha.c",
658 "musl/src/ctype/iswblank.c",
659 "musl/src/ctype/iswcntrl.c",
660 "musl/src/ctype/iswctype.c",
661 "musl/src/ctype/iswdigit.c",
662 "musl/src/ctype/iswgraph.c",
663 "musl/src/ctype/iswlower.c",
664 "musl/src/ctype/iswprint.c",
665 "musl/src/ctype/iswpunct.c",
666 "musl/src/ctype/iswspace.c",
667 "musl/src/ctype/iswupper.c",
668 "musl/src/ctype/iswxdigit.c",
669 "musl/src/ctype/isxdigit.c",
670 "musl/src/ctype/toascii.c",
671 "musl/src/ctype/tolower.c",
672 "musl/src/ctype/toupper.c",
673 "musl/src/ctype/towctrans.c",
674 "musl/src/ctype/wcswidth.c",
675 "musl/src/ctype/wctrans.c",
676 "musl/src/ctype/wcwidth.c",
677 "musl/src/env/setenv.c",
678 "musl/src/exit/assert.c",
679 "musl/src/exit/quick_exit.c",
680 "musl/src/fenv/fegetexceptflag.c",
681 "musl/src/fenv/feholdexcept.c",
682 "musl/src/fenv/fenv.c",
683 "musl/src/fenv/fesetexceptflag.c",
684 "musl/src/fenv/fesetround.c",
685 "musl/src/fenv/feupdateenv.c",
686 "musl/src/legacy/getpagesize.c",
687 "musl/src/locale/c_locale.c",
688 "musl/src/locale/duplocale.c",
689 "musl/src/locale/freelocale.c",
690 "musl/src/locale/iconv.c",
691 "musl/src/locale/iconv_close.c",
692 "musl/src/locale/langinfo.c",
693 "musl/src/locale/__lctrans.c",
694 "musl/src/locale/localeconv.c",
695 "musl/src/locale/__mo_lookup.c",
696 "musl/src/locale/pleval.c",
697 "musl/src/locale/setlocale.c",
698 "musl/src/locale/strcoll.c",
699 "musl/src/locale/strfmon.c",
700 "musl/src/locale/strtod_l.c",
701 "musl/src/locale/strxfrm.c",
702 "musl/src/locale/wcscoll.c",
703 "musl/src/locale/wcsxfrm.c",
704 "musl/src/math/acos.c",
705 "musl/src/math/acosf.c",
706 "musl/src/math/acosh.c",
707 "musl/src/math/acoshf.c",
708 "musl/src/math/acoshl.c",
709 "musl/src/math/acosl.c",
710 "musl/src/math/asin.c",
711 "musl/src/math/asinf.c",
712 "musl/src/math/asinh.c",
713 "musl/src/math/asinhf.c",
714 "musl/src/math/asinhl.c",
715 "musl/src/math/asinl.c",
716 "musl/src/math/atan2.c",
717 "musl/src/math/atan2f.c",
718 "musl/src/math/atan2l.c",
719 "musl/src/math/atan.c",
720 "musl/src/math/atanf.c",
721 "musl/src/math/atanh.c",
722 "musl/src/math/atanhf.c",
723 "musl/src/math/atanhl.c",
724 "musl/src/math/atanl.c",
725 "musl/src/math/cbrt.c",
726 "musl/src/math/cbrtf.c",
727 "musl/src/math/cbrtl.c",
728 "musl/src/math/ceill.c",
729 "musl/src/math/copysignl.c",
730 "musl/src/math/__cos.c",
731 "musl/src/math/cos.c",
732 "musl/src/math/__cosdf.c",
733 "musl/src/math/cosf.c",
734 "musl/src/math/coshl.c",
735 "musl/src/math/__cosl.c",
736 "musl/src/math/cosl.c",
737 "musl/src/math/erf.c",
738 "musl/src/math/erff.c",
739 "musl/src/math/erfl.c",
740 "musl/src/math/exp10.c",
741 "musl/src/math/exp10f.c",
742 "musl/src/math/exp10l.c",
743 "musl/src/math/exp2.c",
744 "musl/src/math/exp2f.c",
745 "musl/src/math/exp2f_data.c",
746 "musl/src/math/exp2l.c",
747 "musl/src/math/exp.c",
748 "musl/src/math/exp_data.c",
749 "musl/src/math/expf.c",
750 "musl/src/math/expl.c",
751 "musl/src/math/expm1.c",
752 "musl/src/math/expm1f.c",
753 "musl/src/math/expm1l.c",
754 "musl/src/math/fabsl.c",
755 "musl/src/math/fdim.c",
756 "musl/src/math/fdimf.c",
757 "musl/src/math/fdiml.c",
758 "musl/src/math/finite.c",
759 "musl/src/math/finitef.c",
760 "musl/src/math/floorl.c",
761 "musl/src/math/fma.c",
762 "musl/src/math/fmaf.c",
763 "musl/src/math/fmaxl.c",
764 "musl/src/math/fminl.c",
765 "musl/src/math/fmod.c",
766 "musl/src/math/fmodf.c",
767 "musl/src/math/fmodl.c",
768 "musl/src/math/frexp.c",
769 "musl/src/math/frexpf.c",
770 "musl/src/math/frexpl.c",
771 "musl/src/math/hypot.c",
772 "musl/src/math/hypotf.c",
773 "musl/src/math/hypotl.c",
774 "musl/src/math/ilogb.c",
775 "musl/src/math/ilogbf.c",
776 "musl/src/math/ilogbl.c",
777 "musl/src/math/__invtrigl.c",
778 "musl/src/math/j0.c",
779 "musl/src/math/j0f.c",
780 "musl/src/math/j1.c",
781 "musl/src/math/j1f.c",
782 "musl/src/math/jn.c",
783 "musl/src/math/jnf.c",
784 "musl/src/math/ldexp.c",
785 "musl/src/math/ldexpf.c",
786 "musl/src/math/ldexpl.c",
787 "musl/src/math/lgamma.c",
788 "musl/src/math/lgammaf.c",
789 "musl/src/math/lgammaf_r.c",
790 "musl/src/math/lgammal.c",
791 "musl/src/math/lgamma_r.c",
792 "musl/src/math/llrint.c",
793 "musl/src/math/llrintf.c",
794 "musl/src/math/llrintl.c",
795 "musl/src/math/llround.c",
796 "musl/src/math/llroundf.c",
797 "musl/src/math/llroundl.c",
798 "musl/src/math/log10.c",
799 "musl/src/math/log10f.c",
800 "musl/src/math/log10l.c",
801 "musl/src/math/log1p.c",
802 "musl/src/math/log1pf.c",
803 "musl/src/math/log1pl.c",
804 "musl/src/math/log2.c",
805 "musl/src/math/log2_data.c",
806 "musl/src/math/log2f.c",
807 "musl/src/math/log2f_data.c",
808 "musl/src/math/log2l.c",
809 "musl/src/math/logb.c",
810 "musl/src/math/logbf.c",
811 "musl/src/math/logbl.c",
812 "musl/src/math/log.c",
813 "musl/src/math/log_data.c",
814 "musl/src/math/logf.c",
815 "musl/src/math/logf_data.c",
816 "musl/src/math/logl.c",
817 "musl/src/math/lrint.c",
818 "musl/src/math/lrintf.c",
819 "musl/src/math/lrintl.c",
820 "musl/src/math/lround.c",
821 "musl/src/math/lroundf.c",
822 "musl/src/math/lroundl.c",
823 "musl/src/math/__math_divzero.c",
824 "musl/src/math/__math_divzerof.c",
825 "musl/src/math/__math_invalid.c",
826 "musl/src/math/__math_invalidf.c",
827 "musl/src/math/__math_invalidl.c",
828 "musl/src/math/__math_oflow.c",
829 "musl/src/math/__math_oflowf.c",
830 "musl/src/math/__math_uflow.c",
831 "musl/src/math/__math_uflowf.c",
832 "musl/src/math/__math_xflow.c",
833 "musl/src/math/__math_xflowf.c",
834 "musl/src/math/modf.c",
835 "musl/src/math/modff.c",
836 "musl/src/math/modfl.c",
837 "musl/src/math/nan.c",
838 "musl/src/math/nanf.c",
839 "musl/src/math/nanl.c",
840 "musl/src/math/nearbyintl.c",
841 "musl/src/math/nextafter.c",
842 "musl/src/math/nextafterf.c",
843 "musl/src/math/nextafterl.c",
844 "musl/src/math/nexttoward.c",
845 "musl/src/math/nexttowardf.c",
846 "musl/src/math/nexttowardl.c",
847 "musl/src/math/__polevll.c",
848 "musl/src/math/pow.c",
849 "musl/src/math/pow_data.c",
850 "musl/src/math/powf.c",
851 "musl/src/math/powf_data.c",
852 "musl/src/math/remainder.c",
853 "musl/src/math/remainderf.c",
854 "musl/src/math/remainderl.c",
855 "musl/src/math/__rem_pio2_large.c",
856 "musl/src/math/remquo.c",
857 "musl/src/math/remquof.c",
858 "musl/src/math/remquol.c",
859 "musl/src/math/rintl.c",
860 "musl/src/math/round.c",
861 "musl/src/math/roundf.c",
862 "musl/src/math/roundl.c",
863 "musl/src/math/scalb.c",
864 "musl/src/math/scalbf.c",
865 "musl/src/math/scalbln.c",
866 "musl/src/math/scalblnf.c",
867 "musl/src/math/scalblnl.c",
868 "musl/src/math/scalbn.c",
869 "musl/src/math/scalbnf.c",
870 "musl/src/math/scalbnl.c",
871 "musl/src/math/signgam.c",
872 "musl/src/math/significand.c",
873 "musl/src/math/significandf.c",
874 "musl/src/math/__sin.c",
875 "musl/src/math/sin.c",
876 "musl/src/math/sincos.c",
877 "musl/src/math/sincosf.c",
878 "musl/src/math/sincosl.c",
879 "musl/src/math/__sindf.c",
880 "musl/src/math/sinf.c",
881 "musl/src/math/sinhl.c",
882 "musl/src/math/__sinl.c",
883 "musl/src/math/sinl.c",
884 "musl/src/math/sqrt_data.c",
885 "musl/src/math/sqrtl.c",
886 "musl/src/math/__tan.c",
887 "musl/src/math/tan.c",
888 "musl/src/math/__tandf.c",
889 "musl/src/math/tanf.c",
890 "musl/src/math/tanh.c",
891 "musl/src/math/tanhf.c",
892 "musl/src/math/tanhl.c",
893 "musl/src/math/__tanl.c",
894 "musl/src/math/tanl.c",
895 "musl/src/math/tgamma.c",
896 "musl/src/math/tgammaf.c",
897 "musl/src/math/tgammal.c",
898 "musl/src/math/truncl.c",
899 "musl/src/misc/a64l.c",
900 "musl/src/misc/basename.c",
901 "musl/src/misc/dirname.c",
902 "musl/src/misc/ffs.c",
903 "musl/src/misc/ffsl.c",
904 "musl/src/misc/ffsll.c",
905 "musl/src/misc/getdomainname.c",
906 "musl/src/misc/gethostid.c",
907 "musl/src/misc/getopt.c",
908 "musl/src/misc/getopt_long.c",
909 "musl/src/misc/getsubopt.c",
910 "musl/src/misc/realpath.c",
911 "musl/src/multibyte/btowc.c",
912 "musl/src/multibyte/c16rtomb.c",
913 "musl/src/multibyte/c32rtomb.c",
914 "musl/src/multibyte/internal.c",
915 "musl/src/multibyte/mblen.c",
916 "musl/src/multibyte/mbrlen.c",
917 "musl/src/multibyte/mbrtoc16.c",
918 "musl/src/multibyte/mbrtoc32.c",
919 "musl/src/multibyte/mbrtowc.c",
920 "musl/src/multibyte/mbsinit.c",
921 "musl/src/multibyte/mbsnrtowcs.c",
922 "musl/src/multibyte/mbsrtowcs.c",
923 "musl/src/multibyte/mbstowcs.c",
924 "musl/src/multibyte/mbtowc.c",
925 "musl/src/multibyte/wcrtomb.c",
926 "musl/src/multibyte/wcsnrtombs.c",
927 "musl/src/multibyte/wcsrtombs.c",
928 "musl/src/multibyte/wcstombs.c",
929 "musl/src/multibyte/wctob.c",
930 "musl/src/multibyte/wctomb.c",
931 "musl/src/network/htonl.c",
932 "musl/src/network/htons.c",
933 "musl/src/network/in6addr_any.c",
934 "musl/src/network/in6addr_loopback.c",
935 "musl/src/network/inet_aton.c",
936 "musl/src/network/inet_ntop.c",
937 "musl/src/network/inet_pton.c",
938 "musl/src/network/ntohl.c",
939 "musl/src/network/ntohs.c",
940 "musl/src/prng/drand48.c",
941 "musl/src/prng/lcong48.c",
942 "musl/src/prng/lrand48.c",
943 "musl/src/prng/mrand48.c",
944 "musl/src/prng/__rand48_step.c",
945 "musl/src/prng/rand.c",
946 "musl/src/prng/rand_r.c",
947 "musl/src/prng/__seed48.c",
948 "musl/src/prng/seed48.c",
949 "musl/src/prng/srand48.c",
950 "musl/src/regex/fnmatch.c",
951 "musl/src/regex/regerror.c",
952 "musl/src/search/hsearch.c",
953 "musl/src/search/insque.c",
954 "musl/src/search/lsearch.c",
955 "musl/src/search/tdelete.c",
956 "musl/src/search/tdestroy.c",
957 "musl/src/search/tfind.c",
958 "musl/src/search/tsearch.c",
959 "musl/src/search/twalk.c",
960 "musl/src/stdio/asprintf.c",
961 "musl/src/stdio/clearerr.c",
962 "musl/src/stdio/dprintf.c",
963 "musl/src/stdio/ext2.c",
964 "musl/src/stdio/ext.c",
965 "musl/src/stdio/fclose.c",
966 "musl/src/stdio/__fclose_ca.c",
967 "musl/src/stdio/feof.c",
968 "musl/src/stdio/ferror.c",
969 "musl/src/stdio/fflush.c",
970 "musl/src/stdio/fgetln.c",
971 "musl/src/stdio/fgets.c",
972 "musl/src/stdio/fgetwc.c",
973 "musl/src/stdio/fgetws.c",
974 "musl/src/stdio/fileno.c",
975 "musl/src/stdio/__fmodeflags.c",
976 "musl/src/stdio/fopencookie.c",
977 "musl/src/stdio/fprintf.c",
978 "musl/src/stdio/fputs.c",
979 "musl/src/stdio/fputwc.c",
980 "musl/src/stdio/fputws.c",
981 "musl/src/stdio/fread.c",
982 "musl/src/stdio/fscanf.c",
983 "musl/src/stdio/fwide.c",
984 "musl/src/stdio/fwprintf.c",
985 "musl/src/stdio/fwrite.c",
986 "musl/src/stdio/fwscanf.c",
987 "musl/src/stdio/getchar_unlocked.c",
988 "musl/src/stdio/getc_unlocked.c",
989 "musl/src/stdio/getdelim.c",
990 "musl/src/stdio/getline.c",
991 "musl/src/stdio/getw.c",
992 "musl/src/stdio/getwc.c",
993 "musl/src/stdio/getwchar.c",
994 "musl/src/stdio/ofl_add.c",
995 "musl/src/stdio/__overflow.c",
996 "musl/src/stdio/perror.c",
997 "musl/src/stdio/putchar_unlocked.c",
998 "musl/src/stdio/putc_unlocked.c",
999 "musl/src/stdio/puts.c",
1000 "musl/src/stdio/putw.c",
1001 "musl/src/stdio/putwc.c",
1002 "musl/src/stdio/putwchar.c",
1003 "musl/src/stdio/rewind.c",
1004 "musl/src/stdio/scanf.c",
1005 "musl/src/stdio/setbuf.c",
1006 "musl/src/stdio/setbuffer.c",
1007 "musl/src/stdio/setlinebuf.c",
1008 "musl/src/stdio/setvbuf.c",
1009 "musl/src/stdio/snprintf.c",
1010 "musl/src/stdio/sprintf.c",
1011 "musl/src/stdio/sscanf.c",
1012 "musl/src/stdio/__stdio_exit.c",
1013 "musl/src/stdio/swprintf.c",
1014 "musl/src/stdio/swscanf.c",
1015 "musl/src/stdio/__toread.c",
1016 "musl/src/stdio/__towrite.c",
1017 "musl/src/stdio/__uflow.c",
1018 "musl/src/stdio/ungetwc.c",
1019 "musl/src/stdio/vasprintf.c",
1020 "musl/src/stdio/vprintf.c",
1021 "musl/src/stdio/vscanf.c",
1022 "musl/src/stdio/vsprintf.c",
1023 "musl/src/stdio/vwprintf.c",
1024 "musl/src/stdio/vwscanf.c",
1025 "musl/src/stdio/wprintf.c",
1026 "musl/src/stdio/wscanf.c",
1027 "musl/src/stdlib/abs.c",
1028 "musl/src/stdlib/atof.c",
1029 "musl/src/stdlib/atoi.c",
1030 "musl/src/stdlib/atol.c",
1031 "musl/src/stdlib/atoll.c",
1032 "musl/src/stdlib/bsearch.c",
1033 "musl/src/stdlib/div.c",
1034 "musl/src/stdlib/ecvt.c",
1035 "musl/src/stdlib/fcvt.c",
1036 "musl/src/stdlib/gcvt.c",
1037 "musl/src/stdlib/imaxabs.c",
1038 "musl/src/stdlib/imaxdiv.c",
1039 "musl/src/stdlib/labs.c",
1040 "musl/src/stdlib/ldiv.c",
1041 "musl/src/stdlib/llabs.c",
1042 "musl/src/stdlib/lldiv.c",
1043 "musl/src/stdlib/qsort.c",
1044 "musl/src/stdlib/qsort_nr.c",
1045 "musl/src/string/bcmp.c",
1046 "musl/src/string/bcopy.c",
1047 "musl/src/string/explicit_bzero.c",
1048 "musl/src/string/index.c",
1049 "musl/src/string/memccpy.c",
1050 "musl/src/string/memchr.c",
1051 "musl/src/string/memcmp.c",
1052 "musl/src/string/memmem.c",
1053 "musl/src/string/mempcpy.c",
1054 "musl/src/string/memrchr.c",
1055 "musl/src/string/rindex.c",
1056 "musl/src/string/stpcpy.c",
1057 "musl/src/string/stpncpy.c",
1058 "musl/src/string/strcasecmp.c",
1059 "musl/src/string/strcasestr.c",
1060 "musl/src/string/strcat.c",
1061 "musl/src/string/strchr.c",
1062 "musl/src/string/strchrnul.c",
1063 "musl/src/string/strcpy.c",
1064 "musl/src/string/strcspn.c",
1065 "musl/src/string/strdup.c",
1066 "musl/src/string/strerror_r.c",
1067 "musl/src/string/strlcat.c",
1068 "musl/src/string/strlcpy.c",
1069 "musl/src/string/strncasecmp.c",
1070 "musl/src/string/strncat.c",
1071 "musl/src/string/strncpy.c",
1072 "musl/src/string/strndup.c",
1073 "musl/src/string/strnlen.c",
1074 "musl/src/string/strpbrk.c",
1075 "musl/src/string/strrchr.c",
1076 "musl/src/string/strsep.c",
1077 "musl/src/string/strspn.c",
1078 "musl/src/string/strstr.c",
1079 "musl/src/string/strtok.c",
1080 "musl/src/string/strtok_r.c",
1081 "musl/src/string/strverscmp.c",
1082 "musl/src/string/swab.c",
1083 "musl/src/string/wcpcpy.c",
1084 "musl/src/string/wcpncpy.c",
1085 "musl/src/string/wcscasecmp.c",
1086 "musl/src/string/wcscasecmp_l.c",
1087 "musl/src/string/wcscat.c",
1088 "musl/src/string/wcschr.c",
1089 "musl/src/string/wcscmp.c",
1090 "musl/src/string/wcscpy.c",
1091 "musl/src/string/wcscspn.c",
1092 "musl/src/string/wcsdup.c",
1093 "musl/src/string/wcslen.c",
1094 "musl/src/string/wcsncasecmp.c",
1095 "musl/src/string/wcsncasecmp_l.c",
1096 "musl/src/string/wcsncat.c",
1097 "musl/src/string/wcsncmp.c",
1098 "musl/src/string/wcsncpy.c",
1099 "musl/src/string/wcsnlen.c",
1100 "musl/src/string/wcspbrk.c",
1101 "musl/src/string/wcsrchr.c",
1102 "musl/src/string/wcsspn.c",
1103 "musl/src/string/wcsstr.c",
1104 "musl/src/string/wcstok.c",
1105 "musl/src/string/wcswcs.c",
1106 "musl/src/string/wmemchr.c",
1107 "musl/src/string/wmemcmp.c",
1108 "musl/src/string/wmemcpy.c",
1109 "musl/src/string/wmemmove.c",
1110 "musl/src/string/wmemset.c",
1111 "musl/src/thread/thrd_sleep.c",
1112 "musl/src/time/asctime.c",
1113 "musl/src/time/asctime_r.c",
1114 "musl/src/time/ctime.c",
1115 "musl/src/time/ctime_r.c",
1116 "musl/src/time/difftime.c",
1117 "musl/src/time/ftime.c",
1118 "musl/src/time/__month_to_secs.c",
1119 "musl/src/time/strptime.c",
1120 "musl/src/time/timespec_get.c",
1121 "musl/src/time/__year_to_secs.c",
1122 "musl/src/unistd/posix_close.c",
1123
1124 "wasi/libc-top-half/musl/src/conf/confstr.c",
1125 "wasi/libc-top-half/musl/src/conf/fpathconf.c",
1126 "wasi/libc-top-half/musl/src/conf/sysconf.c",
1127 "wasi/libc-top-half/musl/src/dirent/alphasort.c",
1128 "wasi/libc-top-half/musl/src/dirent/versionsort.c",
1129 "wasi/libc-top-half/musl/src/env/clearenv.c",
1130 "wasi/libc-top-half/musl/src/env/getenv.c",
1131 "wasi/libc-top-half/musl/src/env/putenv.c",
1132 "wasi/libc-top-half/musl/src/env/__stack_chk_fail.c",
1133 "wasi/libc-top-half/musl/src/env/unsetenv.c",
1134 "wasi/libc-top-half/musl/src/errno/strerror.c",
1135 "wasi/libc-top-half/musl/src/exit/atexit.c",
1136 "wasi/libc-top-half/musl/src/exit/at_quick_exit.c",
1137 "wasi/libc-top-half/musl/src/exit/exit.c",
1138 "wasi/libc-top-half/musl/src/fcntl/creat.c",
1139 "wasi/libc-top-half/musl/src/internal/defsysinfo.c",
1140 "wasi/libc-top-half/musl/src/internal/floatscan.c",
1141 "wasi/libc-top-half/musl/src/internal/intscan.c",
1142 "wasi/libc-top-half/musl/src/internal/libc.c",
1143 "wasi/libc-top-half/musl/src/internal/shgetc.c",
1144 "wasi/libc-top-half/musl/src/locale/catclose.c",
1145 "wasi/libc-top-half/musl/src/locale/catgets.c",
1146 "wasi/libc-top-half/musl/src/locale/catopen.c",
1147 "wasi/libc-top-half/musl/src/locale/locale_map.c",
1148 "wasi/libc-top-half/musl/src/locale/newlocale.c",
1149 "wasi/libc-top-half/musl/src/locale/uselocale.c",
1150 "wasi/libc-top-half/musl/src/math/cosh.c",
1151 "wasi/libc-top-half/musl/src/math/coshf.c",
1152 "wasi/libc-top-half/musl/src/math/__expo2.c",
1153 "wasi/libc-top-half/musl/src/math/__expo2f.c",
1154 "wasi/libc-top-half/musl/src/math/fmal.c",
1155 "wasi/libc-top-half/musl/src/math/powl.c",
1156 "wasi/libc-top-half/musl/src/math/__rem_pio2.c",
1157 "wasi/libc-top-half/musl/src/math/__rem_pio2f.c",
1158 "wasi/libc-top-half/musl/src/math/__rem_pio2l.c",
1159 "wasi/libc-top-half/musl/src/math/sinh.c",
1160 "wasi/libc-top-half/musl/src/math/sinhf.c",
1161 "wasi/libc-top-half/musl/src/misc/fmtmsg.c",
1162 "wasi/libc-top-half/musl/src/misc/nftw.c",
1163 "wasi/libc-top-half/musl/src/misc/uname.c",
1164 "wasi/libc-top-half/musl/src/prng/random.c",
1165 "wasi/libc-top-half/musl/src/regex/regcomp.c",
1166 "wasi/libc-top-half/musl/src/regex/regexec.c",
1167 "wasi/libc-top-half/musl/src/regex/glob.c",
1168 "wasi/libc-top-half/musl/src/regex/tre-mem.c",
1169 "wasi/libc-top-half/musl/src/stat/futimesat.c",
1170 "wasi/libc-top-half/musl/src/stdio/__fdopen.c",
1171 "wasi/libc-top-half/musl/src/stdio/fgetc.c",
1172 "wasi/libc-top-half/musl/src/stdio/fgetpos.c",
1173 "wasi/libc-top-half/musl/src/stdio/fmemopen.c",
1174 "wasi/libc-top-half/musl/src/stdio/fopen.c",
1175 "wasi/libc-top-half/musl/src/stdio/__fopen_rb_ca.c",
1176 "wasi/libc-top-half/musl/src/stdio/fputc.c",
1177 "wasi/libc-top-half/musl/src/stdio/freopen.c",
1178 "wasi/libc-top-half/musl/src/stdio/fseek.c",
1179 "wasi/libc-top-half/musl/src/stdio/fsetpos.c",
1180 "wasi/libc-top-half/musl/src/stdio/ftell.c",
1181 "wasi/libc-top-half/musl/src/stdio/getc.c",
1182 "wasi/libc-top-half/musl/src/stdio/getchar.c",
1183 "wasi/libc-top-half/musl/src/stdio/ofl.c",
1184 "wasi/libc-top-half/musl/src/stdio/open_memstream.c",
1185 "wasi/libc-top-half/musl/src/stdio/open_wmemstream.c",
1186 "wasi/libc-top-half/musl/src/stdio/printf.c",
1187 "wasi/libc-top-half/musl/src/stdio/putc.c",
1188 "wasi/libc-top-half/musl/src/stdio/putchar.c",
1189 "wasi/libc-top-half/musl/src/stdio/stderr.c",
1190 "wasi/libc-top-half/musl/src/stdio/stdin.c",
1191 "wasi/libc-top-half/musl/src/stdio/__stdio_close.c",
1192 "wasi/libc-top-half/musl/src/stdio/__stdio_read.c",
1193 "wasi/libc-top-half/musl/src/stdio/__stdio_seek.c",
1194 "wasi/libc-top-half/musl/src/stdio/__stdio_write.c",
1195 "wasi/libc-top-half/musl/src/stdio/stdout.c",
1196 "wasi/libc-top-half/musl/src/stdio/__stdout_write.c",
1197 "wasi/libc-top-half/musl/src/stdio/ungetc.c",
1198 "wasi/libc-top-half/musl/src/stdio/vdprintf.c",
1199 "wasi/libc-top-half/musl/src/stdio/vfprintf.c",
1200 "wasi/libc-top-half/musl/src/stdio/vfscanf.c",
1201 "wasi/libc-top-half/musl/src/stdio/vfwprintf.c",
1202 "wasi/libc-top-half/musl/src/stdio/vfwscanf.c",
1203 "wasi/libc-top-half/musl/src/stdio/vsnprintf.c",
1204 "wasi/libc-top-half/musl/src/stdio/vsscanf.c",
1205 "wasi/libc-top-half/musl/src/stdio/vswprintf.c",
1206 "wasi/libc-top-half/musl/src/stdio/vswscanf.c",
1207 "wasi/libc-top-half/musl/src/stdlib/strtod.c",
1208 "wasi/libc-top-half/musl/src/stdlib/strtol.c",
1209 "wasi/libc-top-half/musl/src/stdlib/wcstod.c",
1210 "wasi/libc-top-half/musl/src/stdlib/wcstol.c",
1211 "wasi/libc-top-half/musl/src/string/memset.c",
1212 "wasi/libc-top-half/musl/src/time/getdate.c",
1213 "wasi/libc-top-half/musl/src/time/gmtime.c",
1214 "wasi/libc-top-half/musl/src/time/gmtime_r.c",
1215 "wasi/libc-top-half/musl/src/time/localtime.c",
1216 "wasi/libc-top-half/musl/src/time/localtime_r.c",
1217 "wasi/libc-top-half/musl/src/time/mktime.c",
1218 "wasi/libc-top-half/musl/src/time/__secs_to_tm.c",
1219 "wasi/libc-top-half/musl/src/time/strftime.c",
1220 "wasi/libc-top-half/musl/src/time/timegm.c",
1221 "wasi/libc-top-half/musl/src/time/__tm_to_secs.c",
1222 "wasi/libc-top-half/musl/src/time/__tz.c",
1223 "wasi/libc-top-half/musl/src/time/wcsftime.c",
1224
1225 "wasi/libc-top-half/sources/arc4random.c",
1226};
1227
1228const crt1_command_src_file = "wasi/libc-bottom-half/crt/crt1-command.c";
1229const crt1_reactor_src_file = "wasi/libc-bottom-half/crt/crt1-reactor.c";
1230
1231const emulated_dl_src_files = &[_][]const u8{
1232 "wasi/libc-top-half/musl/src/misc/dl.c",
1233};
1234
1235const emulated_process_clocks_src_files = &[_][]const u8{
1236 "wasi/libc-bottom-half/clocks/clock.c",
1237 "wasi/libc-bottom-half/clocks/getrusage.c",
1238 "wasi/libc-bottom-half/clocks/times.c",
1239};
1240
1241const emulated_getpid_src_files = &[_][]const u8{
1242 "wasi/libc-bottom-half/getpid/getpid.c",
1243};
1244
1245const emulated_mman_src_files = &[_][]const u8{
1246 "wasi/libc-bottom-half/mman/mman.c",
1247};
1248
1249const emulated_signal_bottom_half_src_files = &[_][]const u8{
1250 "wasi/libc-bottom-half/signal/signal.c",
1251};
1252
1253const emulated_signal_top_half_src_files = &[_][]const u8{
1254 "musl/src/signal/psignal.c",
1255 "musl/src/string/strsignal.c",
1256};