Skip to content

Commit 3fb0ab5

Browse files
committed
std.Build.Step.Run: Use std.zig.target.glibcRuntimeTriple() in runCommand().
1 parent 80ac911 commit 3fb0ab5

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,8 @@ fn runCommand(
10091009
else => break :interpret,
10101010
}
10111011

1012-
const need_cross_glibc = exe.rootModuleTarget().isGnuLibC() and
1012+
const root_target = exe.rootModuleTarget();
1013+
const need_cross_glibc = root_target.isGnuLibC() and
10131014
exe.is_linking_libc;
10141015
const other_target = exe.root_module.resolved_target.?.result;
10151016
switch (std.zig.system.getExternalExecutor(b.graph.host.result, &other_target, .{
@@ -1039,23 +1040,16 @@ fn runCommand(
10391040
try interp_argv.append(bin_name);
10401041

10411042
if (glibc_dir_arg) |dir| {
1042-
// TODO look into making this a call to `linuxTriple`. This
1043-
// needs the directory to be called "i686" rather than
1044-
// "x86" which is why we do it manually here.
1045-
const fmt_str = "{s}" ++ fs.path.sep_str ++ "{s}-{s}-{s}";
1046-
const cpu_arch = exe.rootModuleTarget().cpu.arch;
1047-
const os_tag = exe.rootModuleTarget().os.tag;
1048-
const abi = exe.rootModuleTarget().abi;
1049-
const cpu_arch_name: []const u8 = if (cpu_arch == .x86)
1050-
"i686"
1051-
else
1052-
@tagName(cpu_arch);
1053-
const full_dir = try std.fmt.allocPrint(b.allocator, fmt_str, .{
1054-
dir, cpu_arch_name, @tagName(os_tag), @tagName(abi),
1055-
});
1056-
10571043
try interp_argv.append("-L");
1058-
try interp_argv.append(full_dir);
1044+
try interp_argv.append(b.pathJoin(&.{
1045+
dir,
1046+
try std.zig.target.glibcRuntimeTriple(
1047+
b.allocator,
1048+
root_target.cpu.arch,
1049+
root_target.os.tag,
1050+
root_target.abi,
1051+
),
1052+
}));
10591053
}
10601054

10611055
try interp_argv.appendSlice(argv);
@@ -1113,15 +1107,15 @@ fn runCommand(
11131107
if (allow_skip) return error.MakeSkipped;
11141108

11151109
const host_name = try b.graph.host.result.zigTriple(b.allocator);
1116-
const foreign_name = try exe.rootModuleTarget().zigTriple(b.allocator);
1110+
const foreign_name = try root_target.zigTriple(b.allocator);
11171111

11181112
return step.fail("the host system ({s}) is unable to execute binaries from the target ({s})", .{
11191113
host_name, foreign_name,
11201114
});
11211115
},
11221116
}
11231117

1124-
if (exe.rootModuleTarget().os.tag == .windows) {
1118+
if (root_target.os.tag == .windows) {
11251119
// On Windows we don't have rpaths so we have to add .dll search paths to PATH
11261120
run.addPathForDynLibs(exe);
11271121
}

0 commit comments

Comments
 (0)