| ... | ... | @@ -21,35 +21,7 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 21 | 21 | // Compile crt sources. |
| 22 | 22 | var args = std.ArrayList([]const u8).init(arena); |
| 23 | 23 | try addCCArgs(comp, arena, &args, false); |
| 24 | | try args.appendSlice(&[_][]const u8{ |
| 25 | | "-I", |
| 26 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 27 | | "libc", |
| 28 | | "wasi", |
| 29 | | "libc-bottom-half", |
| 30 | | "headers", |
| 31 | | "private", |
| 32 | | }), |
| 33 | | |
| 34 | | "-I", |
| 35 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 36 | | "libc", |
| 37 | | "wasi", |
| 38 | | "libc-bottom-half", |
| 39 | | "cloudlibc", |
| 40 | | "src", |
| 41 | | "include", |
| 42 | | }), |
| 43 | | |
| 44 | | "-I", |
| 45 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 46 | | "libc", |
| 47 | | "wasi", |
| 48 | | "libc-bottom-half", |
| 49 | | "cloudlibc", |
| 50 | | "src", |
| 51 | | }), |
| 52 | | }); |
| 24 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 53 | 25 | |
| 54 | 26 | var comp_sources = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 55 | 27 | for (crt_src_files) |file_path| { |
| ... | ... | @@ -95,37 +67,43 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 95 | 67 | // Compile libc-bottom-half. |
| 96 | 68 | var args = std.ArrayList([]const u8).init(arena); |
| 97 | 69 | try addCCArgs(comp, arena, &args, true); |
| 98 | | try args.appendSlice(&[_][]const u8{ |
| 99 | | "-I", |
| 100 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 101 | | "libc", |
| 102 | | "wasi", |
| 103 | | "libc-bottom-half", |
| 104 | | "headers", |
| 105 | | "private", |
| 106 | | }), |
| 70 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 107 | 71 | |
| 108 | | "-I", |
| 109 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 110 | | "libc", |
| 111 | | "wasi", |
| 112 | | "libc-bottom-half", |
| 113 | | "cloudlibc", |
| 114 | | "src", |
| 115 | | }), |
| 72 | for (libc_bottom_half_src_files) |file_path| { |
| 73 | try comp_sources.append(.{ |
| 74 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 75 | "libc", try sanitize(arena, file_path), |
| 76 | }), |
| 77 | .extra_flags = args.items, |
| 78 | }); |
| 79 | } |
| 80 | } |
| 116 | 81 | |
| 117 | | "-I", |
| 118 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 119 | | "libc", |
| 120 | | "wasi", |
| 121 | | "libc-bottom-half", |
| 122 | | "cloudlibc", |
| 123 | | "src", |
| 124 | | "include", |
| 125 | | }), |
| 126 | | }); |
| 82 | { |
| 83 | // Compile emulated sources depending only on libc-bottom-half. |
| 84 | var args = std.ArrayList([]const u8).init(arena); |
| 85 | try addCCArgs(comp, arena, &args, true); |
| 86 | try addLibcBottomHalfIncludes(comp, arena, &args); |
| 127 | 87 | |
| 128 | | for (libc_bottom_half_src_files) |file_path| { |
| 88 | for (emulated_process_clocks_src_files) |file_path| { |
| 89 | try comp_sources.append(.{ |
| 90 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 91 | "libc", try sanitize(arena, file_path), |
| 92 | }), |
| 93 | .extra_flags = args.items, |
| 94 | }); |
| 95 | } |
| 96 | |
| 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 | } |
| 105 | |
| 106 | for (emulated_mman_src_files) |file_path| { |
| 129 | 107 | try comp_sources.append(.{ |
| 130 | 108 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 131 | 109 | "libc", try sanitize(arena, file_path), |
| ... | ... | @@ -136,59 +114,42 @@ pub fn buildWasiLibcSysroot(comp: *Compilation) !void { |
| 136 | 114 | } |
| 137 | 115 | |
| 138 | 116 | { |
| 139 | | // Compile libc-top-half. |
| 117 | // Compile emulated signals (bottom-half). |
| 140 | 118 | var args = std.ArrayList([]const u8).init(arena); |
| 141 | 119 | try addCCArgs(comp, arena, &args, true); |
| 142 | | try args.appendSlice(&[_][]const u8{ |
| 143 | | "-I", |
| 144 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 145 | | "libc", |
| 146 | | "wasi", |
| 147 | | "libc-top-half", |
| 148 | | "musl", |
| 149 | | "src", |
| 150 | | "include", |
| 151 | | }), |
| 152 | 120 | |
| 153 | | "-I", |
| 154 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 155 | | "libc", |
| 156 | | "wasi", |
| 157 | | "libc-top-half", |
| 158 | | "musl", |
| 159 | | "src", |
| 160 | | "internal", |
| 161 | | }), |
| 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 | } |
| 129 | } |
| 162 | 130 | |
| 163 | | "-I", |
| 164 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 165 | | "libc", |
| 166 | | "wasi", |
| 167 | | "libc-top-half", |
| 168 | | "musl", |
| 169 | | "arch", |
| 170 | | "wasm32", |
| 171 | | }), |
| 131 | { |
| 132 | // Compile emulated signals (top-half). |
| 133 | var args = std.ArrayList([]const u8).init(arena); |
| 134 | try addCCArgs(comp, arena, &args, true); |
| 135 | try addLibcTopHalfIncludes(comp, arena, &args); |
| 136 | try args.append("-D_WASI_EMULATED_SIGNAL"); |
| 172 | 137 | |
| 173 | | "-I", |
| 174 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 175 | | "libc", |
| 176 | | "wasi", |
| 177 | | "libc-top-half", |
| 178 | | "musl", |
| 179 | | "arch", |
| 180 | | "generic", |
| 181 | | }), |
| 138 | for (emulated_signal_top_half_src_files) |file_path| { |
| 139 | try comp_sources.append(.{ |
| 140 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 141 | "libc", try sanitize(arena, file_path), |
| 142 | }), |
| 143 | .extra_flags = args.items, |
| 144 | }); |
| 145 | } |
| 146 | } |
| 182 | 147 | |
| 183 | | "-I", |
| 184 | | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 185 | | "libc", |
| 186 | | "wasi", |
| 187 | | "libc-top-half", |
| 188 | | "headers", |
| 189 | | "private", |
| 190 | | }), |
| 191 | | }); |
| 148 | { |
| 149 | // Compile libc-top-half. |
| 150 | var args = std.ArrayList([]const u8).init(arena); |
| 151 | try addCCArgs(comp, arena, &args, true); |
| 152 | try addLibcTopHalfIncludes(comp, arena, &args); |
| 192 | 153 | |
| 193 | 154 | for (libc_top_half_src_files) |file_path| { |
| 194 | 155 | try comp_sources.append(.{ |
| ... | ... | @@ -251,6 +212,99 @@ fn addCCArgs( |
| 251 | 212 | }); |
| 252 | 213 | } |
| 253 | 214 | |
| 215 | fn addLibcBottomHalfIncludes( |
| 216 | comp: *Compilation, |
| 217 | arena: *Allocator, |
| 218 | args: *std.ArrayList([]const u8), |
| 219 | ) error{OutOfMemory}!void { |
| 220 | try args.appendSlice(&[_][]const u8{ |
| 221 | "-I", |
| 222 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 223 | "libc", |
| 224 | "wasi", |
| 225 | "libc-bottom-half", |
| 226 | "headers", |
| 227 | "private", |
| 228 | }), |
| 229 | |
| 230 | "-I", |
| 231 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 232 | "libc", |
| 233 | "wasi", |
| 234 | "libc-bottom-half", |
| 235 | "cloudlibc", |
| 236 | "src", |
| 237 | "include", |
| 238 | }), |
| 239 | |
| 240 | "-I", |
| 241 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 242 | "libc", |
| 243 | "wasi", |
| 244 | "libc-bottom-half", |
| 245 | "cloudlibc", |
| 246 | "src", |
| 247 | }), |
| 248 | }); |
| 249 | } |
| 250 | |
| 251 | fn addLibcTopHalfIncludes( |
| 252 | comp: *Compilation, |
| 253 | arena: *Allocator, |
| 254 | args: *std.ArrayList([]const u8), |
| 255 | ) error{OutOfMemory}!void { |
| 256 | try args.appendSlice(&[_][]const u8{ |
| 257 | "-I", |
| 258 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 259 | "libc", |
| 260 | "wasi", |
| 261 | "libc-top-half", |
| 262 | "musl", |
| 263 | "src", |
| 264 | "include", |
| 265 | }), |
| 266 | |
| 267 | "-I", |
| 268 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 269 | "libc", |
| 270 | "wasi", |
| 271 | "libc-top-half", |
| 272 | "musl", |
| 273 | "src", |
| 274 | "internal", |
| 275 | }), |
| 276 | |
| 277 | "-I", |
| 278 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 279 | "libc", |
| 280 | "wasi", |
| 281 | "libc-top-half", |
| 282 | "musl", |
| 283 | "arch", |
| 284 | "wasm32", |
| 285 | }), |
| 286 | |
| 287 | "-I", |
| 288 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 289 | "libc", |
| 290 | "wasi", |
| 291 | "libc-top-half", |
| 292 | "musl", |
| 293 | "arch", |
| 294 | "generic", |
| 295 | }), |
| 296 | |
| 297 | "-I", |
| 298 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| 299 | "libc", |
| 300 | "wasi", |
| 301 | "libc-top-half", |
| 302 | "headers", |
| 303 | "private", |
| 304 | }), |
| 305 | }); |
| 306 | } |
| 307 | |
| 254 | 308 | const dlmalloc_src_files = [_][]const u8{ |
| 255 | 309 | "wasi/dlmalloc/src/dlmalloc.c", |
| 256 | 310 | }; |
| ... | ... | @@ -1025,6 +1079,11 @@ const emulated_mman_src_files = &[_][]const u8{ |
| 1025 | 1079 | "wasi/libc-bottom-half/mman/mman.c", |
| 1026 | 1080 | }; |
| 1027 | 1081 | |
| 1028 | | const emulated_signal_src_files = &[_][]const u8{ |
| 1082 | const emulated_signal_bottom_half_src_files = &[_][]const u8{ |
| 1029 | 1083 | "wasi/libc-bottom-half/signal/signal.c", |
| 1030 | 1084 | }; |
| 1085 | |
| 1086 | const emulated_signal_top_half_src_files = &[_][]const u8{ |
| 1087 | "wasi/libc-top-half/musl/src/signal/psignal.c", |
| 1088 | "wasi/libc-top-half/musl/src/string/strsignal.c", |
| 1089 | }; |