From 845f22101b1efb2d8898d8ba7310cd78151a42d5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 30 Sep 2017 14:40:16 -0400 Subject: zig test on 64-bit windows runs 32-bit tests --- src/target.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/target.cpp') diff --git a/src/target.cpp b/src/target.cpp index 8a58a42b59..68969b3821 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -640,3 +640,28 @@ Buf *target_dynamic_linker(ZigTarget *target) { return buf_create_from_str("/lib64/ld-linux-x86-64.so.2"); } } + +bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target) { + assert(host_target != nullptr); + + if (guest_target == nullptr) { + // null guest target means that the guest target is native + return true; + } + + if (guest_target->os == host_target->os && guest_target->arch.arch == host_target->arch.arch && + guest_target->arch.sub_arch == host_target->arch.sub_arch) + { + // OS, arch, and sub-arch match + return true; + } + + if (guest_target->os == ZigLLVM_Win32 && guest_target->os == ZigLLVM_Win32 && + host_target->arch.arch == ZigLLVM_x86_64 && guest_target->arch.arch == ZigLLVM_x86) + { + // 64-bit windows can run 32-bit programs + return true; + } + + return false; +} -- cgit v1.2.3