authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2024-07-13 19:04:55-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2024-07-13 19:04:55-04:00
log373e53d7c5940c875a3423a6797f7b5d4a7f36c8
tree3c43e2df0120e715ec170475a6bb2d49e77a1e8c
parentbc28454b43b717dee47cf8c1a1abfb7e8ad09a1e

Compile: Pass the default --zig-lib-dir along to child processes

main: print the self_exe_path when `findZigLibDirFromSelfExe` fails in all cases

2 files changed, 11 insertions(+), 4 deletions(-)

lib/std/Build/Step/Compile.zig+9-2
...@@ -1635,9 +1635,16 @@ fn getZigArgs(compile: *Compile) ![][]const u8 {...@@ -1635,9 +1635,16 @@ fn getZigArgs(compile: *Compile) ![][]const u8 {
1635 });1635 });
1636 }1636 }
16371637
1638 if (compile.zig_lib_dir) |dir| {1638 const opt_zig_lib_dir = if (compile.zig_lib_dir) |dir|
1639 dir.getPath2(b, step)
1640 else if (b.graph.zig_lib_directory.path) |_|
1641 b.fmt("{}", .{b.graph.zig_lib_directory})
1642 else
1643 null;
1644
1645 if (opt_zig_lib_dir) |zig_lib_dir| {
1639 try zig_args.append("--zig-lib-dir");1646 try zig_args.append("--zig-lib-dir");
1640 try zig_args.append(dir.getPath2(b, step));1647 try zig_args.append(zig_lib_dir);
1641 }1648 }
16421649
1643 try addFlag(&zig_args, "PIE", compile.pie);1650 try addFlag(&zig_args, "PIE", compile.pie);
src/main.zig+2-2
...@@ -2710,7 +2710,7 @@ fn buildOutputType(...@@ -2710,7 +2710,7 @@ fn buildOutputType(
2710 break :d getWasiPreopen("/lib");2710 break :d getWasiPreopen("/lib");
2711 } else if (self_exe_path) |p| {2711 } else if (self_exe_path) |p| {
2712 break :d introspect.findZigLibDirFromSelfExe(arena, p) catch |err| {2712 break :d introspect.findZigLibDirFromSelfExe(arena, p) catch |err| {
2713 fatal("unable to find zig installation directory: {s}", .{@errorName(err)});2713 fatal("unable to find zig installation directory '{s}': {s}", .{ p, @errorName(err) });
2714 };2714 };
2715 } else {2715 } else {
2716 unreachable;2716 unreachable;
...@@ -7403,7 +7403,7 @@ fn findTemplates(gpa: Allocator, arena: Allocator) Templates {...@@ -7403,7 +7403,7 @@ fn findTemplates(gpa: Allocator, arena: Allocator) Templates {
7403 fatal("unable to find self exe path: {s}", .{@errorName(err)});7403 fatal("unable to find self exe path: {s}", .{@errorName(err)});
7404 };7404 };
7405 var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {7405 var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| {
7406 fatal("unable to find zig installation directory: {s}", .{@errorName(err)});7406 fatal("unable to find zig installation directory '{s}': {s}", .{ self_exe_path, @errorName(err) });
7407 };7407 };
74087408
7409 const s = fs.path.sep_str;7409 const s = fs.path.sep_str;