aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-09-30 14:40:16 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-09-30 14:40:16 -0400
commit845f22101b1efb2d8898d8ba7310cd78151a42d5 (patch)
tree214478004045621b4a089a7b381bb5934c355aaa
parentd43204c950a24467a85e14fe5ba026e1eac2a19f (diff)
downloadzig-845f22101b1efb2d8898d8ba7310cd78151a42d5.tar.gz
zig-845f22101b1efb2d8898d8ba7310cd78151a42d5.zip
zig test on 64-bit windows runs 32-bit tests
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/main.cpp4
-rw-r--r--src/target.cpp25
-rw-r--r--src/target.hpp2
4 files changed, 29 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 162c39ae6e..b6c82a090c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -129,7 +129,7 @@ else()
add_library(embedded_lld_elf ${EMBEDDED_LLD_ELF_SOURCES})
add_library(embedded_lld_coff ${EMBEDDED_LLD_COFF_SOURCES})
if(MSVC)
- set(ZIG_LLD_COMPILE_FLAGS "-std=c++11")
+ set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -D_CRT_SECURE_NO_WARNINGS")
else()
set(ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fno-exceptions -fno-rtti -Wno-comment")
endif()
diff --git a/src/main.cpp b/src/main.cpp
index 2dc500b1bb..ca5e99ed3f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -711,9 +711,7 @@ int main(int argc, char **argv) {
codegen_build(g);
codegen_link(g, buf_ptr(test_exe_name));
- bool is_native_target = target == nullptr || (target->os == native.os &&
- target->arch.arch == native.arch.arch && target->arch.sub_arch == native.arch.sub_arch);
- if (!is_native_target) {
+ if (!target_can_exec(&native, target)) {
fprintf(stderr, "Created %s but skipping execution because it is non-native.\n",
buf_ptr(test_exe_name));
return 0;
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;
+}
diff --git a/src/target.hpp b/src/target.hpp
index dbacd6a2c7..528e42d687 100644
--- a/src/target.hpp
+++ b/src/target.hpp
@@ -77,5 +77,7 @@ const char *target_exe_file_ext(ZigTarget *target);
Buf *target_dynamic_linker(ZigTarget *target);
+bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target);
+
#endif