| ... | ... | @@ -23,21 +23,21 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 23 | 23 | try addCCArgs(comp, arena, &args, false); |
| 24 | 24 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 25 | 25 | |
| 26 | | var comp_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 26 | var crt_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 27 | 27 | for (crt_src_files) |file_path| { |
| 28 | | try comp_sources.append(.{ |
| 28 | try crt_sources.append(.{ |
| 29 | 29 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 30 | 30 | "libc", try sanitize(arena, file_path), |
| 31 | 31 | }), |
| 32 | 32 | .extra_flags = args.items, |
| 33 | 33 | }); |
| 34 | 34 | } |
| 35 | | try comp.build_crt_file("crt", .Obj, comp_sources.items); |
| 35 | try comp.build_crt_file("crt", .Obj, crt_sources.items); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | { |
| 39 | 39 | // Compile WASI libc (sysroot). |
| 40 | | var comp_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 40 | var libc_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 41 | 41 | |
| 42 | 42 | { |
| 43 | 43 | // Compile dlmalloc. |
| ... | ... | @@ -54,7 +54,7 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 54 | 54 | }); |
| 55 | 55 | |
| 56 | 56 | for (dlmalloc_src_files) |file_path| { |
| 57 | | try comp_sources.append(.{ |
| 57 | try libc_sources.append(.{ |
| 58 | 58 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 59 | 59 | "libc", try sanitize(arena, file_path), |
| 60 | 60 | }), |
| ... | ... | @@ -70,7 +70,7 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 70 | 70 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 71 | 71 | |
| 72 | 72 | for (libc_bottom_half_src_files) |file_path| { |
| 73 | | try comp_sources.append(.{ |
| 73 | try libc_sources.append(.{ |
| 74 | 74 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 75 | 75 | "libc", try sanitize(arena, file_path), |
| 76 | 76 | }), |
| ... | ... | @@ -80,63 +80,88 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | { |
| 83 | | // Compile emulated sources depending only on libc-bottom-half. |
| 83 | // Compile libc-top-half. |
| 84 | 84 | var args = std.ArrayList([]const u8).init(arena); |
| 85 | 85 | try addCCArgs(comp, arena, &args, true); |
| 86 | | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 86 | try addLibcTopHalfIncludes(comp, arena, &args); |
| 87 | 87 | |
| 88 | | for (emulated_process_clocks_src_files) |file_path| { |
| 89 | | try comp_sources.append(.{ |
| 88 | for (libc_top_half_src_files) |file_path| { |
| 89 | try libc_sources.append(.{ |
| 90 | 90 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 91 | 91 | "libc", try sanitize(arena, file_path), |
| 92 | 92 | }), |
| 93 | 93 | .extra_flags = args.items, |
| 94 | 94 | }); |
| 95 | 95 | } |
| 96 | } |
| 96 | 97 | |
| 97 | | for (emulated_getpid_src_files) |file_path| { |
| 98 | | try comp_sources.append(.{ |
| 99 | | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 100 | | "libc", try sanitize(arena, file_path), |
| 101 | | }), |
| 102 | | .extra_flags = args.items, |
| 103 | | }); |
| 104 | | } |
| 98 | try comp.build_crt_file("c", .Lib, libc_sources.items); |
| 99 | } |
| 105 | 100 | |
| 106 | | for (emulated_mman_src_files) |file_path| { |
| 107 | | try comp_sources.append(.{ |
| 108 | | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 109 | | "libc", try sanitize(arena, file_path), |
| 110 | | }), |
| 111 | | .extra_flags = args.items, |
| 112 | | }); |
| 113 | | } |
| 101 | { |
| 102 | // Compile emulated process clocks. |
| 103 | var args = std.ArrayList([]const u8).init(arena); |
| 104 | try addCCArgs(comp, arena, &args, true); |
| 105 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 106 | |
| 107 | var emu_clocks_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 108 | for (emulated_process_clocks_src_files) |file_path| { |
| 109 | try emu_clocks_sources.append(.{ |
| 110 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 111 | "libc", try sanitize(arena, file_path), |
| 112 | }), |
| 113 | .extra_flags = args.items, |
| 114 | }); |
| 114 | 115 | } |
| 116 | try comp.build_crt_file("wasi-emulated-process-clocks", .Lib, emu_clocks_sources.items); |
| 117 | } |
| 115 | 118 | |
| 116 | | { |
| 117 | | // Compile emulated signals (bottom-half). |
| 118 | | var args = std.ArrayList([]const u8).init(arena); |
| 119 | | try addCCArgs(comp, arena, &args, true); |
| 119 | { |
| 120 | // Compile emulated getpid. |
| 121 | var args = std.ArrayList([]const u8).init(arena); |
| 122 | try addCCArgs(comp, arena, &args, true); |
| 123 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 120 | 124 | |
| 121 | | for (emulated_signal_bottom_half_src_files) |file_path| { |
| 122 | | try comp_sources.append(.{ |
| 123 | | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 124 | | "libc", try sanitize(arena, file_path), |
| 125 | | }), |
| 126 | | .extra_flags = args.items, |
| 127 | | }); |
| 128 | | } |
| 125 | var emu_getpid_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 126 | for (emulated_getpid_src_files) |file_path| { |
| 127 | try emu_getpid_sources.append(.{ |
| 128 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 129 | "libc", try sanitize(arena, file_path), |
| 130 | }), |
| 131 | .extra_flags = args.items, |
| 132 | }); |
| 133 | } |
| 134 | try comp.build_crt_file("wasi-emulated-getpid", .Lib, emu_getpid_sources.items); |
| 135 | } |
| 136 | |
| 137 | { |
| 138 | // Compile emulated mman. |
| 139 | var args = std.ArrayList([]const u8).init(arena); |
| 140 | try addCCArgs(comp, arena, &args, true); |
| 141 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 142 | |
| 143 | var emu_mman_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 144 | for (emulated_mman_src_files) |file_path| { |
| 145 | try emu_mman_sources.append(.{ |
| 146 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 147 | "libc", try sanitize(arena, file_path), |
| 148 | }), |
| 149 | .extra_flags = args.items, |
| 150 | }); |
| 129 | 151 | } |
| 152 | try comp.build_crt_file("wasi-emulated-mman", .Lib, emu_mman_sources.items); |
| 153 | } |
| 154 | |
| 155 | { |
| 156 | // Compile emulated signals. |
| 157 | var emu_signal_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 130 | 158 | |
| 131 | 159 | { |
| 132 | | // Compile emulated signals (top-half). |
| 133 | 160 | var args = std.ArrayList([]const u8).init(arena); |
| 134 | 161 | try addCCArgs(comp, arena, &args, true); |
| 135 | | try addLibcTopHalfIncludes(comp, arena, &args); |
| 136 | | try args.append("-D_WASI_EMULATED_SIGNAL"); |
| 137 | 162 | |
| 138 | | for (emulated_signal_top_half_src_files) |file_path| { |
| 139 | | try comp_sources.append(.{ |
| 163 | for (emulated_signal_bottom_half_src_files) |file_path| { |
| 164 | try emu_signal_sources.append(.{ |
| 140 | 165 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 141 | 166 | "libc", try sanitize(arena, file_path), |
| 142 | 167 | }), |
| ... | ... | @@ -146,13 +171,13 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 146 | 171 | } |
| 147 | 172 | |
| 148 | 173 | { |
| 149 | | // Compile libc-top-half. |
| 150 | 174 | var args = std.ArrayList([]const u8).init(arena); |
| 151 | 175 | try addCCArgs(comp, arena, &args, true); |
| 152 | 176 | try addLibcTopHalfIncludes(comp, arena, &args); |
| 177 | try args.append("-D_WASI_EMULATED_SIGNAL"); |
| 153 | 178 | |
| 154 | | for (libc_top_half_src_files) |file_path| { |
| 155 | | try comp_sources.append(.{ |
| 179 | for (emulated_signal_top_half_src_files) |file_path| { |
| 180 | try emu_signal_sources.append(.{ |
| 156 | 181 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 157 | 182 | "libc", try sanitize(arena, file_path), |
| 158 | 183 | }), |
| ... | ... | @@ -161,7 +186,7 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 161 | 186 | } |
| 162 | 187 | } |
| 163 | 188 | |
| 164 | | try comp.build_crt_file("c", .Lib, comp_sources.items); |
| 189 | try comp.build_crt_file("wasi-emulated-signal", .Lib, emu_signal_sources.items); |
| 165 | 190 | } |
| 166 | 191 | } |
| 167 | 192 | |