aboutsummaryrefslogtreecommitdiff
path: root/src/target.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-23 11:43:37 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-23 11:43:37 -0400
commit3865b6ad8f8ba71dca06c81828ec2e29f3019879 (patch)
treecfadbebe532708c931bddcc8e5b262d63946c78d /src/target.cpp
parent79a4b7a2365dc50d01eb6bc29bbb77244a1620cf (diff)
parentec2f9ef4e8be5995ab652dde59b12ee340a9e28d (diff)
downloadzig-3865b6ad8f8ba71dca06c81828ec2e29f3019879.tar.gz
zig-3865b6ad8f8ba71dca06c81828ec2e29f3019879.zip
Merge remote-tracking branch 'origin/master' into fix-field-alignment-kludge
Diffstat (limited to 'src/target.cpp')
-rw-r--r--src/target.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/target.cpp b/src/target.cpp
index 8d73af6a01..65d72bf5f2 100644
--- a/src/target.cpp
+++ b/src/target.cpp
@@ -491,6 +491,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 = {};
@@ -505,6 +515,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);
@@ -1601,7 +1614,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:
return ZigLLVM_Musl;