authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-11-05 20:17:07-08:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-11-06 03:40:33-08:00
loge0898f4e055d078020d14eefa14ea5879e070da0
treed5d2f7c743014320e4318ec6b14e9d8dce11ae21
parent416bf1de47154ba781082163f8a3509fa3916482

Step.Run: Fix for `convertPathArg` when cwd and path args are on different drives

Fixes #25805

1 files changed, 6 insertions(+), 1 deletions(-)

lib/std/Build/Step/Run.zig+6-1
...@@ -746,7 +746,12 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {...@@ -746,7 +746,12 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {
746 // Convert it from relative to *our* cwd, to relative to the *child's* cwd.746 // Convert it from relative to *our* cwd, to relative to the *child's* cwd.
747 break :rel std.fs.path.relative(b.graph.arena, child_cwd, path_str) catch @panic("OOM");747 break :rel std.fs.path.relative(b.graph.arena, child_cwd, path_str) catch @panic("OOM");
748 };748 };
749 assert(!std.fs.path.isAbsolute(child_cwd_rel));749 // Not every path can be made relative, e.g. if the path and the child cwd are on different
750 // disk designators on Windows. In that case, `relative` will return an absolute path which we can
751 // just return.
752 if (std.fs.path.isAbsolute(child_cwd_rel)) {
753 return child_cwd_rel;
754 }
750 // We're not done yet. In some cases this path must be prefixed with './':755 // We're not done yet. In some cases this path must be prefixed with './':
751 // * On POSIX, the executable name cannot be a single component like 'foo'756 // * On POSIX, the executable name cannot be a single component like 'foo'
752 // * Some executables might treat a leading '-' like a flag, which we must avoid757 // * Some executables might treat a leading '-' like a flag, which we must avoid