| author | |
| committer | |
| log | 85fe35d246d0076d403fc5ee90f4434da7206fd5 |
| tree | 611e789c83a8257d8f8b0b0c5a8f860e783e4d36 |
| parent | f28802a9c6c3bd36368101981243aab7cf4f453f |
11 files changed, 67 insertions(+), 54 deletions(-)
lib/std/Io/Threaded.zig-11| ... | ... | @@ -14279,17 +14279,6 @@ fn testArgvToCommandLineWindows(argv: []const []const u8, expected_cmd_line: []c |
| 14279 | 14279 | try std.testing.expectEqualStrings(expected_cmd_line, cmd_line); |
| 14280 | 14280 | } |
| 14281 | 14281 | |
| 14282 | /// Replaces the current process image with the executed process. If this | |
| 14283 | /// function succeeds, it does not return. | |
| 14284 | /// | |
| 14285 | /// This operation is not available on all targets. `can_execv` | |
| 14286 | /// | |
| 14287 | /// This function also uses the PATH environment variable to get the full path to the executable. | |
| 14288 | /// If `file` is an absolute path, this is the same as `execveZ`. | |
| 14289 | /// | |
| 14290 | /// Like `execvpeZ` except if `arg0_expand` is `.expand`, then `argv` is mutable, | |
| 14291 | /// and `argv[0]` is expanded to be the same absolute path that is passed to the execve syscall. | |
| 14292 | /// If this function returns with an error, `argv[0]` will be restored to the value it was when it was passed in. | |
| 14293 | 14282 | fn execvpeZ_expandArg0( |
| 14294 | 14283 | arg0_expand: process.ArgExpansion, |
| 14295 | 14284 | file: [*:0]const u8, |
src/Compilation.zig+53-40| ... | ... | @@ -54,7 +54,7 @@ gpa: Allocator, |
| 54 | 54 | /// threads at once. |
| 55 | 55 | arena: Allocator, |
| 56 | 56 | io: Io, |
| 57 | environ_map: *std.process.Environ.Map, | |
| 57 | environ_map: *const std.process.Environ.Map, | |
| 58 | 58 | thread_limit: usize, |
| 59 | 59 | /// Not every Compilation compiles .zig code! For example you could do `zig build-exe foo.o`. |
| 60 | 60 | zcu: ?*Zcu, |
| ... | ... | @@ -762,12 +762,12 @@ pub const Directories = struct { |
| 762 | 762 | .wasi => void, |
| 763 | 763 | else => []const u8, |
| 764 | 764 | }, |
| 765 | env_map: *std.process.Environ.Map, | |
| 765 | env_map: *const std.process.Environ.Map, | |
| 766 | 766 | ) Directories { |
| 767 | 767 | const wasi = builtin.target.os.tag == .wasi; |
| 768 | 768 | |
| 769 | 769 | const cwd = introspect.getResolvedCwd(arena) catch |err| { |
| 770 | fatal("unable to get cwd: {s}", .{@errorName(err)}); | |
| 770 | fatal("unable to get cwd: {t}", .{err}); | |
| 771 | 771 | }; |
| 772 | 772 | |
| 773 | 773 | const zig_lib: Cache.Directory = d: { |
| ... | ... | @@ -1799,7 +1799,7 @@ pub const CreateOptions = struct { |
| 1799 | 1799 | |
| 1800 | 1800 | parent_whole_cache: ?ParentWholeCache = null, |
| 1801 | 1801 | |
| 1802 | environ_map: *std.process.Environ.Map, | |
| 1802 | environ_map: *const std.process.Environ.Map, | |
| 1803 | 1803 | |
| 1804 | 1804 | pub const Entry = link.File.OpenOptions.Entry; |
| 1805 | 1805 | |
| ... | ... | @@ -5713,7 +5713,7 @@ pub fn translateC( |
| 5713 | 5713 | translated_basename: []const u8, |
| 5714 | 5714 | owner_mod: *Package.Module, |
| 5715 | 5715 | prog_node: std.Progress.Node, |
| 5716 | env_map: *std.process.Environ.Map, | |
| 5716 | env_map: *const std.process.Environ.Map, | |
| 5717 | 5717 | ) !CImportResult { |
| 5718 | 5718 | dev.check(.translate_c_command); |
| 5719 | 5719 | |
| ... | ... | @@ -6260,7 +6260,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6260 | 6260 | // that we could "tail call" clang by doing an execve, and any use of |
| 6261 | 6261 | // the caching system would actually be problematic since the user is |
| 6262 | 6262 | // presumably doing their own caching by using dep file flags. |
| 6263 | if (std.process.can_execv and direct_o and | |
| 6263 | if (std.process.can_replace and direct_o and | |
| 6264 | 6264 | comp.disable_c_depfile and comp.clang_passthrough_mode) |
| 6265 | 6265 | { |
| 6266 | 6266 | try comp.addCCArgs(arena, &argv, ext, null, c_object.src.owner); |
| ... | ... | @@ -6292,8 +6292,8 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6292 | 6292 | try dumpArgv(io, argv.items); |
| 6293 | 6293 | } |
| 6294 | 6294 | |
| 6295 | const err = std.process.execv(arena, argv.items); | |
| 6296 | fatal("unable to execv clang: {s}", .{@errorName(err)}); | |
| 6295 | const err = std.process.replace(io, .{ .argv = argv.items }); | |
| 6296 | fatal("unable to replace process with clang: {t}", .{err}); | |
| 6297 | 6297 | } |
| 6298 | 6298 | |
| 6299 | 6299 | // We can't know the digest until we do the C compiler invocation, |
| ... | ... | @@ -6348,14 +6348,21 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6348 | 6348 | else => log.warn("failed to delete '{s}': {s}", .{ dep_file_path, @errorName(err) }), |
| 6349 | 6349 | }; |
| 6350 | 6350 | if (std.process.can_spawn) { |
| 6351 | var child = std.process.Child.init(argv.items, arena); | |
| 6352 | 6351 | if (comp.clang_passthrough_mode) { |
| 6353 | child.stdin_behavior = .inherit; | |
| 6354 | child.stdout_behavior = .inherit; | |
| 6355 | child.stderr_behavior = .inherit; | |
| 6356 | ||
| 6357 | const term = child.spawnAndWait(io) catch |err| { | |
| 6358 | return comp.failCObj(c_object, "failed to spawn zig clang (passthrough mode) {s}: {s}", .{ argv.items[0], @errorName(err) }); | |
| 6352 | var child = std.process.spawn(io, .{ | |
| 6353 | .argv = argv.items, | |
| 6354 | .stdin = .inherit, | |
| 6355 | .stdout = .inherit, | |
| 6356 | .stderr = .inherit, | |
| 6357 | }) catch |err| { | |
| 6358 | return comp.failCObj(c_object, "failed to spawn zig clang (passthrough mode) {s}: {t}", .{ | |
| 6359 | argv.items[0], err, | |
| 6360 | }); | |
| 6361 | }; | |
| 6362 | const term = child.wait(io) catch |err| { | |
| 6363 | return comp.failCObj(c_object, "failed to wait zig clang (passthrough mode) {s}: {t}", .{ | |
| 6364 | argv.items[0], err, | |
| 6365 | }); | |
| 6359 | 6366 | }; |
| 6360 | 6367 | switch (term) { |
| 6361 | 6368 | .exited => |code| { |
| ... | ... | @@ -6367,36 +6374,41 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr |
| 6367 | 6374 | }, |
| 6368 | 6375 | else => std.process.abort(), |
| 6369 | 6376 | } |
| 6370 | } else { | |
| 6371 | child.stdin_behavior = .ignore; | |
| 6372 | child.stdout_behavior = .ignore; | |
| 6373 | child.stderr_behavior = .pipe; | |
| 6377 | unreachable; | |
| 6378 | } | |
| 6374 | 6379 | |
| 6375 | try child.spawn(io); | |
| 6380 | var child = try std.process.spawn(io, .{ | |
| 6381 | .argv = argv.items, | |
| 6382 | .stdin = .ignore, | |
| 6383 | .stdout = .ignore, | |
| 6384 | .stderr = .pipe, | |
| 6385 | }); | |
| 6376 | 6386 | |
| 6377 | var stderr_reader = child.stderr.?.readerStreaming(io, &.{}); | |
| 6378 | const stderr = try stderr_reader.interface.allocRemaining(arena, .limited(std.math.maxInt(u32))); | |
| 6387 | var stderr_reader = child.stderr.?.readerStreaming(io, &.{}); | |
| 6388 | const stderr = try stderr_reader.interface.allocRemaining(arena, .limited(std.math.maxInt(u32))); | |
| 6379 | 6389 | |
| 6380 | const term = child.wait(io) catch |err| { | |
| 6381 | return comp.failCObj(c_object, "failed to spawn zig clang {s}: {s}", .{ argv.items[0], @errorName(err) }); | |
| 6382 | }; | |
| 6390 | const term = child.wait(io) catch |err| | |
| 6391 | return comp.failCObj(c_object, "failed to spawn zig clang {s}: {t}", .{ argv.items[0], err }); | |
| 6383 | 6392 | |
| 6384 | switch (term) { | |
| 6385 | .exited => |code| if (code != 0) if (out_diag_path) |diag_file_path| { | |
| 6386 | const bundle = CObject.Diag.Bundle.parse(gpa, io, diag_file_path) catch |err| { | |
| 6387 | log.err("{}: failed to parse clang diagnostics: {s}", .{ err, stderr }); | |
| 6388 | return comp.failCObj(c_object, "clang exited with code {d}", .{code}); | |
| 6389 | }; | |
| 6390 | return comp.failCObjWithOwnedDiagBundle(c_object, bundle); | |
| 6391 | } else { | |
| 6392 | log.err("clang failed with stderr: {s}", .{stderr}); | |
| 6393 | switch (term) { | |
| 6394 | .exited => |code| if (code != 0) if (out_diag_path) |diag_file_path| { | |
| 6395 | const bundle = CObject.Diag.Bundle.parse(gpa, io, diag_file_path) catch |err| { | |
| 6396 | log.err("{}: failed to parse clang diagnostics: {s}", .{ err, stderr }); | |
| 6393 | 6397 | return comp.failCObj(c_object, "clang exited with code {d}", .{code}); |
| 6394 | }, | |
| 6395 | else => { | |
| 6396 | log.err("clang terminated with stderr: {s}", .{stderr}); | |
| 6397 | return comp.failCObj(c_object, "clang terminated unexpectedly", .{}); | |
| 6398 | }, | |
| 6399 | } | |
| 6398 | }; | |
| 6399 | return comp.failCObjWithOwnedDiagBundle(c_object, bundle); | |
| 6400 | } else { | |
| 6401 | log.err("clang failed with stderr: {s}", .{stderr}); | |
| 6402 | return comp.failCObj(c_object, "clang exited with code {d}", .{code}); | |
| 6403 | }, | |
| 6404 | .signal => |sig| { | |
| 6405 | log.err("clang failed with stderr: {s}", .{stderr}); | |
| 6406 | return comp.failCObj(c_object, "clang terminated with signal {t}", .{sig}); | |
| 6407 | }, | |
| 6408 | else => { | |
| 6409 | log.err("clang terminated with stderr: {s}", .{stderr}); | |
| 6410 | return comp.failCObj(c_object, "clang terminated unexpectedly", .{}); | |
| 6411 | }, | |
| 6400 | 6412 | } |
| 6401 | 6413 | } else { |
| 6402 | 6414 | const exit_code = try clangMain(arena, argv.items); |
| ... | ... | @@ -8113,6 +8125,7 @@ pub fn build_crt_file( |
| 8113 | 8125 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 8114 | 8126 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 8115 | 8127 | .skip_linker_dependencies = true, |
| 8128 | .environ_map = comp.environ_map, | |
| 8116 | 8129 | }) catch |err| switch (err) { |
| 8117 | 8130 | error.CreateFail => { |
| 8118 | 8131 | comp.lockAndSetMiscFailure(misc_task_tag, "sub-compilation of {t} failed: {f}", .{ misc_task_tag, sub_create_diag }); |
src/introspect.zig+1-1| ... | ... | @@ -102,7 +102,7 @@ pub fn findZigLibDirFromSelfExe( |
| 102 | 102 | return error.FileNotFound; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *std.process.Environ.Map) ![]const u8 { | |
| 105 | pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *const std.process.Environ.Map) ![]const u8 { | |
| 106 | 106 | if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map)) |value| return value; |
| 107 | 107 | |
| 108 | 108 | const app_name = "zig"; |
src/libs/freebsd.zig+2| ... | ... | @@ -445,6 +445,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 445 | 445 | .gpa = gpa, |
| 446 | 446 | .io = io, |
| 447 | 447 | .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}), |
| 448 | .cwd = comp.dirs.cwd, | |
| 448 | 449 | }; |
| 449 | 450 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); |
| 450 | 451 | cache.addPrefix(comp.dirs.zig_lib); |
| ... | ... | @@ -1119,6 +1120,7 @@ fn buildSharedLib( |
| 1119 | 1120 | .soname = soname, |
| 1120 | 1121 | .c_source_files = &c_source_files, |
| 1121 | 1122 | .skip_linker_dependencies = true, |
| 1123 | .environ_map = comp.environ_map, | |
| 1122 | 1124 | }) catch |err| switch (err) { |
| 1123 | 1125 | error.CreateFail => { |
| 1124 | 1126 | comp.lockAndSetMiscFailure(misc_task, "sub-compilation of {t} failed: {f}", .{ misc_task, sub_create_diag }); |
src/libs/glibc.zig+2| ... | ... | @@ -680,6 +680,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 680 | 680 | .gpa = gpa, |
| 681 | 681 | .io = io, |
| 682 | 682 | .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}), |
| 683 | .cwd = comp.dirs.cwd, | |
| 683 | 684 | }; |
| 684 | 685 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); |
| 685 | 686 | cache.addPrefix(comp.dirs.zig_lib); |
| ... | ... | @@ -1258,6 +1259,7 @@ fn buildSharedLib( |
| 1258 | 1259 | .soname = soname, |
| 1259 | 1260 | .c_source_files = &c_source_files, |
| 1260 | 1261 | .skip_linker_dependencies = true, |
| 1262 | .environ_map = comp.environ_map, | |
| 1261 | 1263 | }) catch |err| switch (err) { |
| 1262 | 1264 | error.CreateFail => { |
| 1263 | 1265 | comp.lockAndSetMiscFailure(misc_task, "sub-compilation of {t} failed: {f}", .{ misc_task, sub_create_diag }); |
src/libs/libcxx.zig+2| ... | ... | @@ -275,6 +275,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 275 | 275 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 276 | 276 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 277 | 277 | .skip_linker_dependencies = true, |
| 278 | .environ_map = comp.environ_map, | |
| 278 | 279 | }) catch |err| { |
| 279 | 280 | switch (err) { |
| 280 | 281 | else => comp.lockAndSetMiscFailure(misc_task, "unable to build libc++: create compilation failed: {t}", .{err}), |
| ... | ... | @@ -468,6 +469,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 468 | 469 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 469 | 470 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 470 | 471 | .skip_linker_dependencies = true, |
| 472 | .environ_map = comp.environ_map, | |
| 471 | 473 | }) catch |err| { |
| 472 | 474 | switch (err) { |
| 473 | 475 | else => comp.lockAndSetMiscFailure(misc_task, "unable to build libc++abi: create compilation failed: {t}", .{err}), |
src/libs/libtsan.zig+1| ... | ... | @@ -301,6 +301,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 301 | 301 | .linker_allow_shlib_undefined = linker_allow_shlib_undefined, |
| 302 | 302 | .install_name = install_name, |
| 303 | 303 | .headerpad_size = headerpad_size, |
| 304 | .environ_map = comp.environ_map, | |
| 304 | 305 | }) catch |err| { |
| 305 | 306 | switch (err) { |
| 306 | 307 | else => comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: create compilation failed: {t}", .{ misc_task, err }), |
src/libs/libunwind.zig+1| ... | ... | @@ -166,6 +166,7 @@ pub fn buildStaticLib(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 166 | 166 | .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, |
| 167 | 167 | .clang_passthrough_mode = comp.clang_passthrough_mode, |
| 168 | 168 | .skip_linker_dependencies = true, |
| 169 | .environ_map = comp.environ_map, | |
| 169 | 170 | }) catch |err| { |
| 170 | 171 | switch (err) { |
| 171 | 172 | else => comp.lockAndSetMiscFailure(misc_task, "unable to build {t}: create compilation failed: {t}", .{ misc_task, err }), |
src/libs/musl.zig+1| ... | ... | @@ -272,6 +272,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 272 | 272 | }, |
| 273 | 273 | .skip_linker_dependencies = true, |
| 274 | 274 | .soname = "libc.so", |
| 275 | .environ_map = comp.environ_map, | |
| 275 | 276 | }) catch |err| switch (err) { |
| 276 | 277 | error.CreateFail => { |
| 277 | 278 | comp.lockAndSetMiscFailure(misc_task, "sub-compilation of {t} failed: {f}", .{ misc_task, sub_create_diag }); |
src/libs/netbsd.zig+2| ... | ... | @@ -386,6 +386,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye |
| 386 | 386 | .gpa = gpa, |
| 387 | 387 | .io = io, |
| 388 | 388 | .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}), |
| 389 | .cwd = comp.dirs.cwd, | |
| 389 | 390 | }; |
| 390 | 391 | cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() }); |
| 391 | 392 | cache.addPrefix(comp.dirs.zig_lib); |
| ... | ... | @@ -761,6 +762,7 @@ fn buildSharedLib( |
| 761 | 762 | .soname = soname, |
| 762 | 763 | .c_source_files = &c_source_files, |
| 763 | 764 | .skip_linker_dependencies = true, |
| 765 | .environ_map = comp.environ_map, | |
| 764 | 766 | }) catch |err| switch (err) { |
| 765 | 767 | error.CreateFail => { |
| 766 | 768 | comp.lockAndSetMiscFailure(misc_task, "sub-compilation of {t} failed: {f}", .{ misc_task, sub_create_diag }); |
src/main.zig+2-2| ... | ... | @@ -4708,7 +4708,7 @@ pub fn translateC( |
| 4708 | 4708 | arena: Allocator, |
| 4709 | 4709 | io: Io, |
| 4710 | 4710 | argv: []const []const u8, |
| 4711 | env_map: *process.Environ.Map, | |
| 4711 | env_map: *const process.Environ.Map, | |
| 4712 | 4712 | prog_node: std.Progress.Node, |
| 4713 | 4713 | capture: ?*[]u8, |
| 4714 | 4714 | ) !void { |
| ... | ... | @@ -5516,7 +5516,7 @@ fn jitCmd( |
| 5516 | 5516 | arena: Allocator, |
| 5517 | 5517 | io: Io, |
| 5518 | 5518 | args: []const []const u8, |
| 5519 | env_map: *process.Environ.Map, | |
| 5519 | env_map: *const process.Environ.Map, | |
| 5520 | 5520 | options: JitCmdOptions, |
| 5521 | 5521 | ) !void { |
| 5522 | 5522 | dev.check(.jit_command); |