| ... | @@ -2221,6 +2221,41 @@ fn runCommand( | ... | @@ -2221,6 +2221,41 @@ fn runCommand( |
| 2221 | } | 2221 | } |
| 2222 | } | 2222 | } |
| 2223 | | 2223 | |
| | 2224 | if (graph.enable_qemu) runtime_dir: { |
| | 2225 | const libc_runtimes_dir = graph.libc_runtimes_dir orelse break :runtime_dir; |
| | 2226 | if (environ_map.contains("QEMU_LD_PREFIX")) break :runtime_dir; |
| | 2227 | |
| | 2228 | const producer_index = arg0.producer.value orelse break :runtime_dir; |
| | 2229 | const producer_step = producer_index.ptr(conf); |
| | 2230 | const producer = producer_step.extended.get(conf.extra).compile; |
| | 2231 | switch (producer.flags3.kind) { |
| | 2232 | .exe, .@"test" => {}, |
| | 2233 | else => break :runtime_dir, |
| | 2234 | } |
| | 2235 | const root_module = producer.root_module.get(conf); |
| | 2236 | const root_module_target = root_module.resolved_target.get(conf).?.result.get(conf); |
| | 2237 | const root_target = root_module_target.unwrapTarget(conf); |
| | 2238 | const config = maker.stepByIndex(producer_index).extended.compile.config.?; |
| | 2239 | |
| | 2240 | const need_cross_libc = root_target.os.tag == .linux and |
| | 2241 | config.flags.link_libc and config.flags.link_mode == .dynamic; |
| | 2242 | if (!need_cross_libc) break :runtime_dir; |
| | 2243 | |
| | 2244 | try environ_map.put("QEMU_LD_PREFIX", try Dir.path.join(graph.arena, &.{ |
| | 2245 | libc_runtimes_dir, |
| | 2246 | try if (root_target.isGnuLibC()) std.zig.target.glibcRuntimeTriple( |
| | 2247 | graph.arena, |
| | 2248 | root_target.cpu.arch, |
| | 2249 | root_target.os.tag, |
| | 2250 | root_target.abi, |
| | 2251 | ) else if (root_target.isMuslLibC()) std.zig.target.muslRuntimeTriple( |
| | 2252 | graph.arena, |
| | 2253 | root_target.cpu.arch, |
| | 2254 | root_target.abi, |
| | 2255 | ) else unreachable, |
| | 2256 | })); |
| | 2257 | } |
| | 2258 | |
| 2224 | const cwd_string = switch (cwd) { | 2259 | const cwd_string = switch (cwd) { |
| 2225 | .path => |p| p, | 2260 | .path => |p| p, |
| 2226 | .dir => unreachable, | 2261 | .dir => unreachable, |