authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 14:40:16-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-30 14:40:16-04:00
log845f22101b1efb2d8898d8ba7310cd78151a42d5
tree214478004045621b4a089a7b381bb5934c355aaa
parentd43204c950a24467a85e14fe5ba026e1eac2a19f

zig test on 64-bit windows runs 32-bit tests


4 files changed, 29 insertions(+), 4 deletions(-)

CMakeLists.txt+1-1
......@@ -129,7 +129,7 @@ else()
129129 add_library(embedded_lld_elf ${EMBEDDED_LLD_ELF_SOURCES})
130130 add_library(embedded_lld_coff ${EMBEDDED_LLD_COFF_SOURCES})
131131 if(MSVC)
132 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11")
132 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -D_CRT_SECURE_NO_WARNINGS")
133133 else()
134134 set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fno-exceptions -fno-rtti -Wno-comment")
135135 endif()
src/main.cpp+1-3
......@@ -711,9 +711,7 @@ int main(int argc, char **argv) {
711711 codegen_build(g);
712712 codegen_link(g, buf_ptr(test_exe_name));
713713
714 bool is_native_target = target == nullptr || (target->os == native.os &&
715 target->arch.arch == native.arch.arch && target->arch.sub_arch == native.arch.sub_arch);
716 if (!is_native_target) {
714 if (!target_can_exec(&native, target)) {
717715 fprintf(stderr, "Created %s but skipping execution because it is non-native.\n",
718716 buf_ptr(test_exe_name));
719717 return 0;
src/target.cpp+25
......@@ -640,3 +640,28 @@ Buf *target_dynamic_linker(ZigTarget *target) {
640640 return buf_create_from_str("/lib64/ld-linux-x86-64.so.2");
641641 }
642642}
643
644bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target) {
645 assert(host_target != nullptr);
646
647 if (guest_target == nullptr) {
648 // null guest target means that the guest target is native
649 return true;
650 }
651
652 if (guest_target->os == host_target->os && guest_target->arch.arch == host_target->arch.arch &&
653 guest_target->arch.sub_arch == host_target->arch.sub_arch)
654 {
655 // OS, arch, and sub-arch match
656 return true;
657 }
658
659 if (guest_target->os == ZigLLVM_Win32 && guest_target->os == ZigLLVM_Win32 &&
660 host_target->arch.arch == ZigLLVM_x86_64 && guest_target->arch.arch == ZigLLVM_x86)
661 {
662 // 64-bit windows can run 32-bit programs
663 return true;
664 }
665
666 return false;
667}
src/target.hpp+2
......@@ -77,5 +77,7 @@ const char *target_exe_file_ext(ZigTarget *target);
7777
7878Buf *target_dynamic_linker(ZigTarget *target);
7979
80bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target);
81
8082
8183#endif