implemented runtime abi detetction for windows

This commit is contained in:
emekoi
2019-08-01 17:51:53 -05:00
parent e68fee3984
commit f15ec9a59b
3 changed files with 32 additions and 18 deletions

View File

@@ -506,7 +506,7 @@ void get_native_target(ZigTarget *target) {
&oformat);
target->os = get_zig_os_type(os_type);
target->is_native = true;
if (target->abi == ZigLLVM_UnknownEnvironment) {
if (target->os == OsWindows || target->abi == ZigLLVM_UnknownEnvironment) {
target->abi = target_default_abi(target->arch, target->os);
}
if (target_is_glibc(target)) {
@@ -1504,6 +1504,16 @@ bool target_is_single_threaded(const ZigTarget *target) {
return target_is_wasm(target);
}
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;
}
ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
if (arch == ZigLLVM_wasm32 || arch == ZigLLVM_wasm64) {
return ZigLLVM_Musl;
@@ -1544,8 +1554,9 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
case OsHurd:
return ZigLLVM_GNU;
case OsUefi:
case OsWindows:
return ZigLLVM_MSVC;
case OsWindows:
return target_get_win32_abi();
case OsLinux:
case OsWASI:
return ZigLLVM_Musl;