| ... | ... | @@ -5,6 +5,7 @@ const mem = std.mem; |
| 5 | 5 | |
| 6 | 6 | /// Contains all the same data as `Target`, additionally introducing the concept of "the native target". |
| 7 | 7 | /// The purpose of this abstraction is to provide meaningful and unsurprising defaults. |
| 8 | /// This struct does reference any resources and it is copyable. |
| 8 | 9 | pub const CrossTarget = struct { |
| 9 | 10 | /// `null` means native. |
| 10 | 11 | cpu_arch: ?Target.Cpu.Arch = null, |
| ... | ... | @@ -554,9 +555,13 @@ pub const CrossTarget = struct { |
| 554 | 555 | const os_tag = self.getOsTag(); |
| 555 | 556 | const os_match = os_tag == Target.current.os.tag; |
| 556 | 557 | |
| 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 | } |
| 560 | 565 | } |
| 561 | 566 | |
| 562 | 567 | // If the OS matches, we can use QEMU to emulate a foreign architecture. |