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
signature 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;
55
66/// Contains all the same data as `Target`, additionally introducing the concept of "the native target".
77/// The purpose of this abstraction is to provide meaningful and unsurprising defaults.
8/// This struct does reference any resources and it is copyable.
89pub const CrossTarget = struct {
910 /// `null` means native.
1011 cpu_arch: ?Target.Cpu.Arch = null,
......@@ -554,9 +555,13 @@ pub const CrossTarget = struct {
554555 const os_tag = self.getOsTag();
555556 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 (self.os_tag == null and cpu_arch == Target.current.cpu.arch) {
559 return .native;
558 // If the OS and CPU arch match, the binary can be considered native.
559 if (os_match and cpu_arch == Target.current.cpu.arch) {
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 }
560565 }
561566
562567 // If the OS matches, we can use QEMU to emulate a foreign architecture.