@@ -443,10 +443,18 @@ def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
443443        output_name  =  os .path .join (work_dir , 'dtest' )
444444        with  open (source_name , 'w' , encoding = 'utf-8' ) as  ofile :
445445            ofile .write ('''void main() { }''' )
446-         pc  =  subprocess .Popen (self .exelist  +  self .get_output_args (output_name ) +  self ._get_target_arch_args () +  [source_name ], cwd = work_dir )
446+ 
447+         compile_cmdlist  =  self .exelist  +  self .get_output_args (output_name ) +  self ._get_target_arch_args () +  [source_name ]
448+ 
449+         # If cross-compiling, we can't run the sanity check, only compile it. 
450+         if  environment .need_exe_wrapper (self .for_machine ) and  not  environment .has_exe_wrapper ():
451+             compile_cmdlist  +=  self .get_compile_only_args ()
452+ 
453+         pc  =  subprocess .Popen (compile_cmdlist , cwd = work_dir )
447454        pc .wait ()
448455        if  pc .returncode  !=  0 :
449456            raise  EnvironmentException ('D compiler %s cannot compile programs.'  %  self .name_string ())
457+ 
450458        if  environment .need_exe_wrapper (self .for_machine ):
451459            if  not  environment .has_exe_wrapper ():
452460                # Can't check if the binaries run so we have to assume they do 
@@ -545,7 +553,9 @@ def _get_target_arch_args(self) -> T.List[str]:
545553        # LDC2 on Windows targets to current OS architecture, but 
546554        # it should follow the target specified by the MSVC toolchain. 
547555        if  self .info .is_windows ():
548-             if  self .arch  ==  'x86_64' :
556+             if  self .is_cross :
557+                 return  [f'-mtriple={ self .arch }  -windows-msvc' ]
558+             elif  self .arch  ==  'x86_64' :
549559                return  ['-m64' ]
550560            return  ['-m32' ]
551561        return  []
0 commit comments