@@ -518,24 +518,31 @@ def get_target(host: str) -> _COFF | _ELF | _MachO:
518518 # ghccc currently crashes Clang when combined with musttail on aarch64. :(
519519 target : _COFF | _ELF | _MachO
520520 if re .fullmatch (r"aarch64-apple-darwin.*" , host ):
521- target = _MachO (host , alignment = 8 , prefix = "_" )
521+ condition = "defined(__aarch64__)" and "defined(__APPLE__)"
522+ target = _MachO (host , condition , alignment = 8 , prefix = "_" )
522523 elif re .fullmatch (r"aarch64-pc-windows-msvc" , host ):
523524 args = ["-fms-runtime-lib=dll" ]
524- target = _COFF (host , alignment = 8 , args = args )
525+ condition = "defined(_M_ARM64)"
526+ target = _COFF (host , condition , alignment = 8 , args = args )
525527 elif re .fullmatch (r"aarch64-.*-linux-gnu" , host ):
526528 args = ["-fpic" ]
527- target = _ELF (host , alignment = 8 , args = args )
529+ condition = "defined(__aarch64__)" and "defined(__linux__)"
530+ target = _ELF (host , condition , alignment = 8 , args = args )
528531 elif re .fullmatch (r"i686-pc-windows-msvc" , host ):
529532 args = ["-DPy_NO_ENABLE_SHARED" ]
530- target = _COFF (host , args = args , ghccc = True , prefix = "_" )
533+ condition = "defined(_M_IX86)"
534+ target = _COFF (host , condition , args = args , ghccc = True , prefix = "_" )
531535 elif re .fullmatch (r"x86_64-apple-darwin.*" , host ):
532- target = _MachO (host , ghccc = True , prefix = "_" )
536+ condition = "defined(__x86_64__)" and "defined(__APPLE__)"
537+ target = _MachO (host , condition , ghccc = True , prefix = "_" )
533538 elif re .fullmatch (r"x86_64-pc-windows-msvc" , host ):
534539 args = ["-fms-runtime-lib=dll" ]
535- target = _COFF (host , args = args , ghccc = True )
540+ condition = "defined(_M_X64)"
541+ target = _COFF (host , condition , args = args , ghccc = True )
536542 elif re .fullmatch (r"x86_64-.*-linux-gnu" , host ):
537543 args = ["-fpic" ]
538- target = _ELF (host , args = args , ghccc = True )
544+ condition = "defined(__x86_64__)" and "defined(__linux__)"
545+ target = _ELF (host , condition , args = args , ghccc = True )
539546 else :
540547 raise ValueError (host )
541548 return target
0 commit comments