diff options
Diffstat (limited to 'src/target.cpp')
| -rw-r--r-- | src/target.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/target.cpp b/src/target.cpp index 8b533f4af6..ca66107bb7 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -504,6 +504,16 @@ Error target_parse_glibc_version(ZigGLibCVersion *glibc_ver, const char *text) { return ErrorNone; } +static ZigLLVM_EnvironmentType target_get_win32_abi() { + FILE* files[] = { stdin, stdout, stderr, nullptr }; + for (int i = 0; files[i] != nullptr; i++) { + if (os_is_cygwin_pty(fileno(files[i]))) { + return ZigLLVM_GNU; + } + } + return ZigLLVM_MSVC; +} + void get_native_target(ZigTarget *target) { // first zero initialize *target = {}; @@ -518,6 +528,9 @@ void get_native_target(ZigTarget *target) { &target->abi, &oformat); target->os = get_zig_os_type(os_type); + if (target->os == OsWindows) { + target->abi = target_get_win32_abi(); + } target->is_native = true; if (target->abi == ZigLLVM_UnknownEnvironment) { target->abi = target_default_abi(target->arch, target->os); @@ -1651,7 +1664,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) { return ZigLLVM_GNU; case OsUefi: case OsWindows: - return ZigLLVM_MSVC; + return ZigLLVM_MSVC; case OsLinux: case OsWASI: case OsEmscripten: |
