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(
17821782 } else {
17831783 try environ_map.putAll(&graph.environ_map);
17841784 }
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
17851799 try graph.handleVerbose(cwd, environ_map, argv);
17861800
17871801 const opt_generic_result = spawnChildAndCollect(
......@@ -1802,7 +1816,6 @@ fn runCommand(
18021816 // relying on it being a Compile step. This will make this logic
18031817 // work even for the edge case that the binary was produced by a
18041818 // third party.
1805 const arg0 = conf_run.args.slice[0].get(conf);
18061819 const producer_index = arg0.producer.value orelse break :interpret;
18071820 const producer_step = producer_index.ptr(conf);
18081821 const producer = producer_step.extended.get(conf.extra).compile;
......@@ -1926,11 +1939,6 @@ fn runCommand(
19261939 },
19271940 }
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
19341942 gpa.free(step.result_failed_command.?);
19351943 step.result_failed_command = null;
19361944 try graph.handleVerbose(cwd, environ_map, interp_argv.items);