authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-24 23:23:24-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:36-07:00
log65c96c403589607f882468891c4e2c329a28fde9
treed5a834e53ae52b79af9b2a8d1bda76217781496c
parentd1a446203222bb5bbd1d46139b93a13367c1e8bb

Maker.Step.Run: add missing PATH entries for DLLs


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

lib/compiler/Maker/Step/Run.zig+14-6
...@@ -1782,6 +1782,20 @@ fn runCommand(...@@ -1782,6 +1782,20 @@ fn runCommand(
1782 } else {1782 } else {
1783 try environ_map.putAll(&graph.environ_map);1783 try environ_map.putAll(&graph.environ_map);
1784 }1784 }
1785
1786 // Now that we have the environ map, we might need to mutate it to insert
1787 // .dll search paths because Windows doesn't have rpaths.
1788 const arg0 = conf_run.args.slice[0].get(conf);
1789 if (arg0.producer.value) |producer_index| {
1790 const producer_step = producer_index.ptr(conf);
1791 const producer = producer_step.extended.get(conf.extra).compile;
1792 const root_module = producer.root_module.get(conf);
1793 const root_module_target = root_module.resolved_target.get(conf).?.result.get(conf);
1794 if (root_module_target.flags.os_tag == .windows) {
1795 try addPathForDynLibs(maker, producer_index, environ_map, argv[0]);
1796 }
1797 }
1798
1785 try graph.handleVerbose(cwd, environ_map, argv);1799 try graph.handleVerbose(cwd, environ_map, argv);
17861800
1787 const opt_generic_result = spawnChildAndCollect(1801 const opt_generic_result = spawnChildAndCollect(
...@@ -1802,7 +1816,6 @@ fn runCommand(...@@ -1802,7 +1816,6 @@ fn runCommand(
1802 // relying on it being a Compile step. This will make this logic1816 // relying on it being a Compile step. This will make this logic
1803 // work even for the edge case that the binary was produced by a1817 // work even for the edge case that the binary was produced by a
1804 // third party.1818 // third party.
1805 const arg0 = conf_run.args.slice[0].get(conf);
1806 const producer_index = arg0.producer.value orelse break :interpret;1819 const producer_index = arg0.producer.value orelse break :interpret;
1807 const producer_step = producer_index.ptr(conf);1820 const producer_step = producer_index.ptr(conf);
1808 const producer = producer_step.extended.get(conf.extra).compile;1821 const producer = producer_step.extended.get(conf.extra).compile;
...@@ -1926,11 +1939,6 @@ fn runCommand(...@@ -1926,11 +1939,6 @@ fn runCommand(
1926 },1939 },
1927 }1940 }
19281941
1929 if (root_target.os.tag == .windows) {
1930 // On Windows we don't have rpaths so we have to add .dll search paths to PATH
1931 try addPathForDynLibs(maker, producer_index, environ_map, argv[0]);
1932 }
1933
1934 gpa.free(step.result_failed_command.?);1942 gpa.free(step.result_failed_command.?);
1935 step.result_failed_command = null;1943 step.result_failed_command = null;
1936 try graph.handleVerbose(cwd, environ_map, interp_argv.items);1944 try graph.handleVerbose(cwd, environ_map, interp_argv.items);