File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ else()
129
129
add_library (embedded_lld_elf ${EMBEDDED_LLD_ELF_SOURCES} )
130
130
add_library (embedded_lld_coff ${EMBEDDED_LLD_COFF_SOURCES} )
131
131
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 " )
133
133
else ()
134
134
set (ZIG_LLD_COMPILE_FLAGS "-std=c++11 -fno-exceptions -fno-rtti -Wno-comment" )
135
135
endif ()
Original file line number Diff line number Diff line change @@ -711,9 +711,7 @@ int main(int argc, char **argv) {
711
711
codegen_build (g);
712
712
codegen_link (g, buf_ptr (test_exe_name));
713
713
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)) {
717
715
fprintf (stderr, " Created %s but skipping execution because it is non-native.\n " ,
718
716
buf_ptr (test_exe_name));
719
717
return 0 ;
Original file line number Diff line number Diff line change @@ -640,3 +640,28 @@ Buf *target_dynamic_linker(ZigTarget *target) {
640
640
return buf_create_from_str (" /lib64/ld-linux-x86-64.so.2" );
641
641
}
642
642
}
643
+
644
+ bool 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
+ }
Original file line number Diff line number Diff line change @@ -77,5 +77,7 @@ const char *target_exe_file_ext(ZigTarget *target);
77
77
78
78
Buf *target_dynamic_linker (ZigTarget *target);
79
79
80
+ bool target_can_exec (const ZigTarget *host_target, const ZigTarget *guest_target);
81
+
80
82
81
83
#endif
You can’t perform that action at this time.
0 commit comments