authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-06 16:36:45-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-10-06 16:36:45-07:00
log41a4908dcc123818315ad26de90fd8d157268484
tree56d3fcab61d2abe4986834f6d7362c1dd93d1b74
parent2d0ddce309cbc0cac8a91e7aed5b3cdb988c9fa8
parent91ef6d11734bd6976749aa373fa19a17f6ed85dd
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17419 from ziglang/unsound-native-target-info

std: fix memory bug in getExternalExecutor

5 files changed, 7 insertions(+), 7 deletions(-)

lib/std/Build/Step/Run.zig+1-1
...@@ -679,7 +679,7 @@ fn runCommand(...@@ -679,7 +679,7 @@ fn runCommand(
679 }679 }
680680
681 const need_cross_glibc = exe.target.isGnuLibC() and exe.is_linking_libc;681 const need_cross_glibc = exe.target.isGnuLibC() and exe.is_linking_libc;
682 switch (b.host.getExternalExecutor(exe.target_info, .{682 switch (b.host.getExternalExecutor(&exe.target_info, .{
683 .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,683 .qemu_fixes_dl = need_cross_glibc and b.glibc_runtimes_dir != null,
684 .link_libc = exe.is_linking_libc,684 .link_libc = exe.is_linking_libc,
685 })) {685 })) {
lib/std/zig/system/NativeTargetInfo.zig+1-1
...@@ -1002,7 +1002,7 @@ pub const GetExternalExecutorOptions = struct {...@@ -1002,7 +1002,7 @@ pub const GetExternalExecutorOptions = struct {
1002/// of the other target.1002/// of the other target.
1003pub fn getExternalExecutor(1003pub fn getExternalExecutor(
1004 host: NativeTargetInfo,1004 host: NativeTargetInfo,
1005 candidate: NativeTargetInfo,1005 candidate: *const NativeTargetInfo,
1006 options: GetExternalExecutorOptions,1006 options: GetExternalExecutorOptions,
1007) Executor {1007) Executor {
1008 const os_match = host.target.os.tag == candidate.target.os.tag;1008 const os_match = host.target.os.tag == candidate.target.os.tag;
src/main.zig+3-3
...@@ -3667,7 +3667,7 @@ fn buildOutputType(...@@ -3667,7 +3667,7 @@ fn buildOutputType(
3667 test_exec_args.items,3667 test_exec_args.items,
3668 self_exe_path.?,3668 self_exe_path.?,
3669 arg_mode,3669 arg_mode,
3670 target_info,3670 &target_info,
3671 &comp_destroyed,3671 &comp_destroyed,
3672 all_args,3672 all_args,
3673 runtime_args_start,3673 runtime_args_start,
...@@ -3995,7 +3995,7 @@ fn runOrTest(...@@ -3995,7 +3995,7 @@ fn runOrTest(
3995 test_exec_args: []const ?[]const u8,3995 test_exec_args: []const ?[]const u8,
3996 self_exe_path: []const u8,3996 self_exe_path: []const u8,
3997 arg_mode: ArgMode,3997 arg_mode: ArgMode,
3998 target_info: std.zig.system.NativeTargetInfo,3998 target_info: *const std.zig.system.NativeTargetInfo,
3999 comp_destroyed: *bool,3999 comp_destroyed: *bool,
4000 all_args: []const []const u8,4000 all_args: []const []const u8,
4001 runtime_args_start: ?usize,4001 runtime_args_start: ?usize,
...@@ -6256,7 +6256,7 @@ fn parseIntSuffix(arg: []const u8, prefix_len: usize) u64 {...@@ -6256,7 +6256,7 @@ fn parseIntSuffix(arg: []const u8, prefix_len: usize) u64 {
6256fn warnAboutForeignBinaries(6256fn warnAboutForeignBinaries(
6257 arena: Allocator,6257 arena: Allocator,
6258 arg_mode: ArgMode,6258 arg_mode: ArgMode,
6259 target_info: std.zig.system.NativeTargetInfo,6259 target_info: *const std.zig.system.NativeTargetInfo,
6260 link_libc: bool,6260 link_libc: bool,
6261) !void {6261) !void {
6262 const host_cross_target: std.zig.CrossTarget = .{};6262 const host_cross_target: std.zig.CrossTarget = .{};
test/src/Cases.zig+1-1
...@@ -590,7 +590,7 @@ pub fn lowerToBuildSteps(...@@ -590,7 +590,7 @@ pub fn lowerToBuildSteps(
590 const run = if (case.target.ofmt == .c) run_step: {590 const run = if (case.target.ofmt == .c) run_step: {
591 const target_info = std.zig.system.NativeTargetInfo.detect(case.target) catch |err|591 const target_info = std.zig.system.NativeTargetInfo.detect(case.target) catch |err|
592 std.debug.panic("unable to detect notive host: {s}\n", .{@errorName(err)});592 std.debug.panic("unable to detect notive host: {s}\n", .{@errorName(err)});
593 if (host.getExternalExecutor(target_info, .{ .link_libc = true }) != .native) {593 if (host.getExternalExecutor(&target_info, .{ .link_libc = true }) != .native) {
594 // We wouldn't be able to run the compiled C code.594 // We wouldn't be able to run the compiled C code.
595 break :no_exec;595 break :no_exec;
596 }596 }
tools/docgen.zig+1-1
...@@ -1571,7 +1571,7 @@ fn genHtml(...@@ -1571,7 +1571,7 @@ fn genHtml(
1571 const target_info = try std.zig.system.NativeTargetInfo.detect(1571 const target_info = try std.zig.system.NativeTargetInfo.detect(
1572 cross_target,1572 cross_target,
1573 );1573 );
1574 switch (host.getExternalExecutor(target_info, .{1574 switch (host.getExternalExecutor(&target_info, .{
1575 .link_libc = code.link_libc,1575 .link_libc = code.link_libc,
1576 })) {1576 })) {
1577 .native => {},1577 .native => {},