authorgravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2026-06-16 19:33:01+05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-04 17:04:27-07:00
log9688e6e6208910b3e8dce5a6b93ea743fd46a575
treeb2f70053c3905cf6f8c7df23c55ca9d561735110
parentab14beeaadc4bae0dfcad1bf798f6f2bc4bb8aaf

Resolve relative install directories against install prefix

This fixes a regression introduced on the master branch in commit 0505318efe0d2757a344dded9ae1607f948f7511 (PR https://codeberg.org/ziglang/zig/pulls/35428). In Zig 0.16 and earlier, overriding install sub-directories (such as `--prefix-lib-dir`) with a relative path correctly resolved them against the "install prefix". The mentioned PR changed this behavior (though this was not mentioned in its description), causing relative path overrides to resolve against the "current working directory" instead. This commit restores the old behavior and brings the logic back in line with existing build system conventions (CMake, Autotools, Meson): * Absolute paths are used as-is. * Relative paths are resolved relative to the install prefix path, rather than CWD. Ecosystem context: https://github.com/mesonbuild/meson/pull/9903 Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>

1 files changed, 23 insertions(+), 12 deletions(-)

lib/compiler/Maker.zig+23-12
......@@ -648,20 +648,31 @@ pub fn main(init: process.Init.Minimal) !void {
648648 .sub_path = "zig-out",
649649 };
650650
651 const install_lib_path: Path = if (override_lib_dir) |cwd_relative| .{
652 .root_dir = .cwd(),
653 .sub_path = cwd_relative,
654 } else try install_prefix_path.join(arena, "lib");
651 // These three overrides are meant to be relative to the install prefix,
652 // not current working directory, unless absolute paths are used.
653 const install_lib_path: Path = if (override_lib_dir) |lib_dir|
654 if (Dir.path.isAbsolute(lib_dir)) .{
655 .root_dir = .cwd(),
656 .sub_path = lib_dir,
657 } else try install_prefix_path.join(arena, lib_dir)
658 else
659 try install_prefix_path.join(arena, "lib");
655660
656 const install_bin_path: Path = if (override_bin_dir) |cwd_relative| .{
657 .root_dir = .cwd(),
658 .sub_path = cwd_relative,
659 } else try install_prefix_path.join(arena, "bin");
661 const install_bin_path: Path = if (override_bin_dir) |bin_dir|
662 if (Dir.path.isAbsolute(bin_dir)) .{
663 .root_dir = .cwd(),
664 .sub_path = bin_dir,
665 } else try install_prefix_path.join(arena, bin_dir)
666 else
667 try install_prefix_path.join(arena, "bin");
660668
661 const install_include_path: Path = if (override_include_dir) |cwd_relative| .{
662 .root_dir = .cwd(),
663 .sub_path = cwd_relative,
664 } else try install_prefix_path.join(arena, "include");
669 const install_include_path: Path = if (override_include_dir) |include_dir|
670 if (Dir.path.isAbsolute(include_dir)) .{
671 .root_dir = .cwd(),
672 .sub_path = include_dir,
673 } else try install_prefix_path.join(arena, include_dir)
674 else
675 try install_prefix_path.join(arena, "include");
665676
666677 const now = Io.Clock.Timestamp.now(io, .awake);
667678