zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 373e53d7c5940c875a3423a6797f7b5d4a7f36c8 (tree)
parent bc28454b43b717dee47cf8c1a1abfb7e8ad09a1e
Author: kcbanner <kcbanner@gmail.com>
Date:   Sat, 13 Jul 2024 19:04:55 -0400

Compile: Pass the default --zig-lib-dir along to child processes
main: print the self_exe_path when `findZigLibDirFromSelfExe` fails in all cases

Diffstat:
Mlib/std/Build/Step/Compile.zig | 11+++++++++--
Msrc/main.zig | 4++--
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig @@ -1635,9 +1635,16 @@ fn getZigArgs(compile: *Compile) ![][]const u8 { }); } - if (compile.zig_lib_dir) |dir| { + const opt_zig_lib_dir = if (compile.zig_lib_dir) |dir| + dir.getPath2(b, step) + else if (b.graph.zig_lib_directory.path) |_| + b.fmt("{}", .{b.graph.zig_lib_directory}) + else + null; + + if (opt_zig_lib_dir) |zig_lib_dir| { try zig_args.append("--zig-lib-dir"); - try zig_args.append(dir.getPath2(b, step)); + try zig_args.append(zig_lib_dir); } try addFlag(&zig_args, "PIE", compile.pie); diff --git a/src/main.zig b/src/main.zig @@ -2710,7 +2710,7 @@ fn buildOutputType( break :d getWasiPreopen("/lib"); } else if (self_exe_path) |p| { break :d introspect.findZigLibDirFromSelfExe(arena, p) catch |err| { - fatal("unable to find zig installation directory: {s}", .{@errorName(err)}); + fatal("unable to find zig installation directory '{s}': {s}", .{ p, @errorName(err) }); }; } else { unreachable; @@ -7403,7 +7403,7 @@ fn findTemplates(gpa: Allocator, arena: Allocator) Templates { fatal("unable to find self exe path: {s}", .{@errorName(err)}); }; var zig_lib_directory = introspect.findZigLibDirFromSelfExe(arena, self_exe_path) catch |err| { - fatal("unable to find zig installation directory: {s}", .{@errorName(err)}); + fatal("unable to find zig installation directory '{s}': {s}", .{ self_exe_path, @errorName(err) }); }; const s = fs.path.sep_str;