From 34d2700af42d8f45caaa168b34c34b33bb14cf8d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 26 Feb 2020 17:35:43 -0500 Subject: [PATCH] clean up CrossTarget.getExternalExecutor --- lib/std/zig/cross_target.zig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig index 1e16072815..fac90ddba8 100644 --- a/lib/std/zig/cross_target.zig +++ b/lib/std/zig/cross_target.zig @@ -5,6 +5,7 @@ const mem = std.mem; /// Contains all the same data as `Target`, additionally introducing the concept of "the native target". /// The purpose of this abstraction is to provide meaningful and unsurprising defaults. +/// This struct does reference any resources and it is copyable. pub const CrossTarget = struct { /// `null` means native. cpu_arch: ?Target.Cpu.Arch = null, @@ -554,9 +555,13 @@ pub const CrossTarget = struct { const os_tag = self.getOsTag(); const os_match = os_tag == Target.current.os.tag; - // If the OS matches, and the CPU arch matches, the binary is considered native. - if (self.os_tag == null and cpu_arch == Target.current.cpu.arch) { - return .native; + // If the OS and CPU arch match, the binary can be considered native. + if (os_match and cpu_arch == Target.current.cpu.arch) { + // However, we also need to verify that the dynamic linker path is valid. + // TODO Until that is implemented, we prevent returning `.native` when the OS is non-native. + if (self.os_tag == null) { + return .native; + } } // If the OS matches, we can use QEMU to emulate a foreign architecture.