diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-05-06 01:52:47 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-05-06 01:52:47 +0200 |
| commit | 35f30558ad2836b83859d8ba64a593a0603d4e0e (patch) | |
| tree | df204d0928ab8378e295a46acf5de3a1fb51c2e9 /lib/std/Build | |
| parent | a14352b0b24b295e1857f306de5877680dd80d2b (diff) | |
| download | zig-35f30558ad2836b83859d8ba64a593a0603d4e0e.tar.gz zig-35f30558ad2836b83859d8ba64a593a0603d4e0e.zip | |
std.Build: Rename --glibc-runtimes to --libc-runtimes and enable it for musl.
Diffstat (limited to 'lib/std/Build')
| -rw-r--r-- | lib/std/Build/Step/Run.zig | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 3d0b0a7068..eede464ab6 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1026,11 +1026,11 @@ fn runCommand( } const root_target = exe.rootModuleTarget(); - const need_cross_glibc = root_target.isGnuLibC() and - exe.is_linking_libc; + const need_cross_libc = exe.is_linking_libc and + (root_target.isGnuLibC() or (root_target.isMuslLibC() and exe.linkage == .dynamic)); const other_target = exe.root_module.resolved_target.?.result; switch (std.zig.system.getExternalExecutor(b.graph.host.result, &other_target, .{ - .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null, + .qemu_fixes_dl = need_cross_libc and b.libc_runtimes_dir != null, .link_libc = exe.is_linking_libc, })) { .native, .rosetta => { @@ -1047,31 +1047,29 @@ fn runCommand( }, .qemu => |bin_name| { if (b.enable_qemu) { - const glibc_dir_arg = if (need_cross_glibc) - b.glibc_runtimes_dir orelse - return failForeign(run, "--glibc-runtimes", argv[0], exe) - else - null; - try interp_argv.append(bin_name); - if (glibc_dir_arg) |dir| { - try interp_argv.append("-L"); - try interp_argv.append(b.pathJoin(&.{ - dir, - try std.zig.target.glibcRuntimeTriple( - b.allocator, - root_target.cpu.arch, - root_target.os.tag, - root_target.abi, - ), - })); + if (need_cross_libc) { + if (b.libc_runtimes_dir) |dir| { + try interp_argv.append("-L"); + try interp_argv.append(b.pathJoin(&.{ + dir, + try if (root_target.isGnuLibC()) std.zig.target.glibcRuntimeTriple( + b.allocator, + root_target.cpu.arch, + root_target.os.tag, + root_target.abi, + ) else if (root_target.isMuslLibC()) std.zig.target.muslRuntimeTriple( + b.allocator, + root_target.cpu.arch, + root_target.abi, + ) else unreachable, + })); + } else return failForeign(run, "--libc-runtimes", argv[0], exe); } try interp_argv.appendSlice(argv); - } else { - return failForeign(run, "-fqemu", argv[0], exe); - } + } else return failForeign(run, "-fqemu", argv[0], exe); }, .darling => |bin_name| { if (b.enable_darling) { |
