authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-26 17:35:43-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-02-28 14:51:54-05:00
log34d2700af42d8f45caaa168b34c34b33bb14cf8d
tree754d0f1128e5ee49249445c8f8e20166fab52690
parent622b5b62c293b767787786e753cecff40f29d7e7
signaturelock-open Commit is signed but in an unrecognized format.

clean up CrossTarget.getExternalExecutor


1 files changed, 8 insertions(+), 3 deletions(-)

lib/std/zig/cross_target.zig+8-3
...@@ -5,6 +5,7 @@ const mem = std.mem;...@@ -5,6 +5,7 @@ const mem = std.mem;
55
6/// Contains all the same data as `Target`, additionally introducing the concept of "the native target".6/// Contains all the same data as `Target`, additionally introducing the concept of "the native target".
7/// The purpose of this abstraction is to provide meaningful and unsurprising defaults.7/// The purpose of this abstraction is to provide meaningful and unsurprising defaults.
8/// This struct does reference any resources and it is copyable.
8pub const CrossTarget = struct {9pub const CrossTarget = struct {
9 /// `null` means native.10 /// `null` means native.
10 cpu_arch: ?Target.Cpu.Arch = null,11 cpu_arch: ?Target.Cpu.Arch = null,
...@@ -554,9 +555,13 @@ pub const CrossTarget = struct {...@@ -554,9 +555,13 @@ pub const CrossTarget = struct {
554 const os_tag = self.getOsTag();555 const os_tag = self.getOsTag();
555 const os_match = os_tag == Target.current.os.tag;556 const os_match = os_tag == Target.current.os.tag;
556557
557 // If the OS matches, and the CPU arch matches, the binary is considered native.558 // If the OS and CPU arch match, the binary can be considered native.
558 if (self.os_tag == null and cpu_arch == Target.current.cpu.arch) {559 if (os_match and cpu_arch == Target.current.cpu.arch) {
559 return .native;560 // However, we also need to verify that the dynamic linker path is valid.
561 // TODO Until that is implemented, we prevent returning `.native` when the OS is non-native.
562 if (self.os_tag == null) {
563 return .native;
564 }
560 }565 }
561566
562 // If the OS matches, we can use QEMU to emulate a foreign architecture.567 // If the OS matches, we can use QEMU to emulate a foreign architecture.