authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-28 17:11:12+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-11-28 17:18:00+01:00
log3fb0ab5195f2dff47f2d2c043ad1677a0b3767e5
treef884610da49dfa3793a72c380631be0ee5003179
parent80ac91172f36be763222b2089c9dc4fee8e351eb
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Build.Step.Run: Use std.zig.target.glibcRuntimeTriple() in runCommand().


1 files changed, 13 insertions(+), 19 deletions(-)

lib/std/Build/Step/Run.zig+13-19
...@@ -1009,7 +1009,8 @@ fn runCommand(...@@ -1009,7 +1009,8 @@ fn runCommand(
1009 else => break :interpret,1009 else => break :interpret,
1010 }1010 }
10111011
1012 const need_cross_glibc = exe.rootModuleTarget().isGnuLibC() and1012 const root_target = exe.rootModuleTarget();
1013 const need_cross_glibc = root_target.isGnuLibC() and
1013 exe.is_linking_libc;1014 exe.is_linking_libc;
1014 const other_target = exe.root_module.resolved_target.?.result;1015 const other_target = exe.root_module.resolved_target.?.result;
1015 switch (std.zig.system.getExternalExecutor(b.graph.host.result, &other_target, .{1016 switch (std.zig.system.getExternalExecutor(b.graph.host.result, &other_target, .{
...@@ -1039,23 +1040,16 @@ fn runCommand(...@@ -1039,23 +1040,16 @@ fn runCommand(
1039 try interp_argv.append(bin_name);1040 try interp_argv.append(bin_name);
10401041
1041 if (glibc_dir_arg) |dir| {1042 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
1057 try interp_argv.append("-L");1043 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 }));
1059 }1053 }
10601054
1061 try interp_argv.appendSlice(argv);1055 try interp_argv.appendSlice(argv);
...@@ -1113,7 +1107,7 @@ fn runCommand(...@@ -1113,7 +1107,7 @@ fn runCommand(
1113 if (allow_skip) return error.MakeSkipped;1107 if (allow_skip) return error.MakeSkipped;
11141108
1115 const host_name = try b.graph.host.result.zigTriple(b.allocator);1109 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
1118 return step.fail("the host system ({s}) is unable to execute binaries from the target ({s})", .{1112 return step.fail("the host system ({s}) is unable to execute binaries from the target ({s})", .{
1119 host_name, foreign_name,1113 host_name, foreign_name,
...@@ -1121,7 +1115,7 @@ fn runCommand(...@@ -1121,7 +1115,7 @@ fn runCommand(
1121 },1115 },
1122 }1116 }
11231117
1124 if (exe.rootModuleTarget().os.tag == .windows) {1118 if (root_target.os.tag == .windows) {
1125 // On Windows we don't have rpaths so we have to add .dll search paths to PATH1119 // On Windows we don't have rpaths so we have to add .dll search paths to PATH
1126 run.addPathForDynLibs(exe);1120 run.addPathForDynLibs(exe);
1127 }1121 }