authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-23 16:01:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-24 00:13:54-04:00
log609207801a570508e58d9e02b6ce551fbf1dca30
tree55a32a7357a32ca14d9406f90963b1bddbae4c07
parent8fa6ca6daaca6f22f09ef22ff496f4dc010138ff

make "gnu" (mingw-w64) the default C ABI on Windows

Closes #6565

7 files changed, 31 insertions(+), 305 deletions(-)

lib/std/target.zig+22-13
...@@ -498,8 +498,8 @@ pub const Target = struct {...@@ -498,8 +498,8 @@ pub const Target = struct {
498 .netbsd,498 .netbsd,
499 .hurd,499 .hurd,
500 .haiku,500 .haiku,
501 => return .gnu,
502 .windows,501 .windows,
502 => return .gnu,
503 .uefi,503 .uefi,
504 => return .msvc,504 => return .msvc,
505 .linux,505 .linux,
...@@ -1258,15 +1258,18 @@ pub const Target = struct {...@@ -1258,15 +1258,18 @@ pub const Target = struct {
1258 return linuxTripleSimple(allocator, self.cpu.arch, self.os.tag, self.abi);1258 return linuxTripleSimple(allocator, self.cpu.arch, self.os.tag, self.abi);
1259 }1259 }
12601260
1261 pub fn oFileExt_cpu_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) [:0]const u8 {1261 pub fn oFileExt_os_abi(os_tag: Os.Tag, abi: Abi) [:0]const u8 {
1262 switch (abi) {1262 if (abi == .msvc) {
1263 .msvc => return ".obj",1263 return ".obj";
1264 }
1265 switch (os_tag) {
1266 .windows, .uefi => return ".obj",
1264 else => return ".o",1267 else => return ".o",
1265 }1268 }
1266 }1269 }
12671270
1268 pub fn oFileExt(self: Target) [:0]const u8 {1271 pub fn oFileExt(self: Target) [:0]const u8 {
1269 return oFileExt_cpu_arch_abi(self.cpu.arch, self.abi);1272 return oFileExt_os_abi(self.os.tag, self.abi);
1270 }1273 }
12711274
1272 pub fn exeFileExtSimple(cpu_arch: Cpu.Arch, os_tag: Os.Tag) [:0]const u8 {1275 pub fn exeFileExtSimple(cpu_arch: Cpu.Arch, os_tag: Os.Tag) [:0]const u8 {
...@@ -1285,30 +1288,36 @@ pub const Target = struct {...@@ -1285,30 +1288,36 @@ pub const Target = struct {
1285 return exeFileExtSimple(self.cpu.arch, self.os.tag);1288 return exeFileExtSimple(self.cpu.arch, self.os.tag);
1286 }1289 }
12871290
1288 pub fn staticLibSuffix_cpu_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) [:0]const u8 {1291 pub fn staticLibSuffix_os_abi(os_tag: Os.Tag, abi: Abi) [:0]const u8 {
1289 switch (abi) {1292 if (abi == .msvc) {
1290 .msvc => return ".lib",1293 return ".lib";
1294 }
1295 switch (os_tag) {
1296 .windows, .uefi => return ".lib",
1291 else => return ".a",1297 else => return ".a",
1292 }1298 }
1293 }1299 }
12941300
1295 pub fn staticLibSuffix(self: Target) [:0]const u8 {1301 pub fn staticLibSuffix(self: Target) [:0]const u8 {
1296 return staticLibSuffix_cpu_arch_abi(self.cpu.arch, self.abi);1302 return staticLibSuffix_os_abi(self.os.tag, self.abi);
1297 }1303 }
12981304
1299 pub fn dynamicLibSuffix(self: Target) [:0]const u8 {1305 pub fn dynamicLibSuffix(self: Target) [:0]const u8 {
1300 return self.os.tag.dynamicLibSuffix();1306 return self.os.tag.dynamicLibSuffix();
1301 }1307 }
13021308
1303 pub fn libPrefix_cpu_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) [:0]const u8 {1309 pub fn libPrefix_os_abi(os_tag: Os.Tag, abi: Abi) [:0]const u8 {
1304 switch (abi) {1310 if (abi == .msvc) {
1305 .msvc => return "",1311 return "";
1312 }
1313 switch (os_tag) {
1314 .windows, .uefi => return "",
1306 else => return "lib",1315 else => return "lib",
1307 }1316 }
1308 }1317 }
13091318
1310 pub fn libPrefix(self: Target) [:0]const u8 {1319 pub fn libPrefix(self: Target) [:0]const u8 {
1311 return libPrefix_cpu_arch_abi(self.cpu.arch, self.abi);1320 return libPrefix_os_abi(self.os.tag, self.abi);
1312 }1321 }
13131322
1314 pub fn getObjectFormatSimple(os_tag: Os.Tag, cpu_arch: Cpu.Arch) ObjectFormat {1323 pub fn getObjectFormatSimple(os_tag: Os.Tag, cpu_arch: Cpu.Arch) ObjectFormat {
lib/std/zig/cross_target.zig+3-3
...@@ -473,7 +473,7 @@ pub const CrossTarget = struct {...@@ -473,7 +473,7 @@ pub const CrossTarget = struct {
473 }473 }
474474
475 pub fn oFileExt(self: CrossTarget) [:0]const u8 {475 pub fn oFileExt(self: CrossTarget) [:0]const u8 {
476 return Target.oFileExt_cpu_arch_abi(self.getCpuArch(), self.getAbi());476 return Target.oFileExt_os_abi(self.getOsTag(), self.getAbi());
477 }477 }
478478
479 pub fn exeFileExt(self: CrossTarget) [:0]const u8 {479 pub fn exeFileExt(self: CrossTarget) [:0]const u8 {
...@@ -481,7 +481,7 @@ pub const CrossTarget = struct {...@@ -481,7 +481,7 @@ pub const CrossTarget = struct {
481 }481 }
482482
483 pub fn staticLibSuffix(self: CrossTarget) [:0]const u8 {483 pub fn staticLibSuffix(self: CrossTarget) [:0]const u8 {
484 return Target.staticLibSuffix_cpu_arch_abi(self.getCpuArch(), self.getAbi());484 return Target.staticLibSuffix_os_abi(self.getOsTag(), self.getAbi());
485 }485 }
486486
487 pub fn dynamicLibSuffix(self: CrossTarget) [:0]const u8 {487 pub fn dynamicLibSuffix(self: CrossTarget) [:0]const u8 {
...@@ -489,7 +489,7 @@ pub const CrossTarget = struct {...@@ -489,7 +489,7 @@ pub const CrossTarget = struct {
489 }489 }
490490
491 pub fn libPrefix(self: CrossTarget) [:0]const u8 {491 pub fn libPrefix(self: CrossTarget) [:0]const u8 {
492 return Target.libPrefix_cpu_arch_abi(self.getCpuArch(), self.getAbi());492 return Target.libPrefix_os_abi(self.getOsTag(), self.getAbi());
493 }493 }
494494
495 pub fn isNativeCpu(self: CrossTarget) bool {495 pub fn isNativeCpu(self: CrossTarget) bool {
src/Compilation.zig+1-1
...@@ -3164,7 +3164,7 @@ fn detectLibCIncludeDirs(...@@ -3164,7 +3164,7 @@ fn detectLibCIncludeDirs(
31643164
3165 // If linking system libraries and targeting the native abi, default to3165 // If linking system libraries and targeting the native abi, default to
3166 // using the system libc installation.3166 // using the system libc installation.
3167 if (link_system_libs and is_native_abi) {3167 if (link_system_libs and is_native_abi and !target.isMinGW()) {
3168 const libc = try arena.create(LibCInstallation);3168 const libc = try arena.create(LibCInstallation);
3169 libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true });3169 libc.* = try LibCInstallation.findNative(.{ .allocator = arena, .verbose = true });
3170 return detectLibCFromLibCInstallation(arena, target, libc);3170 return detectLibCFromLibCInstallation(arena, target, libc);
src/libc_installation.zig+2-3
...@@ -8,7 +8,6 @@ const build_options = @import("build_options");...@@ -8,7 +8,6 @@ const build_options = @import("build_options");
88
9const is_darwin = Target.current.isDarwin();9const is_darwin = Target.current.isDarwin();
10const is_windows = Target.current.os.tag == .windows;10const is_windows = Target.current.os.tag == .windows;
11const is_gnu = Target.current.isGnu();
12const is_haiku = Target.current.os.tag == .haiku;11const is_haiku = Target.current.os.tag == .haiku;
1312
14const log = std.log.scoped(.libc_installation);13const log = std.log.scoped(.libc_installation);
...@@ -100,14 +99,14 @@ pub const LibCInstallation = struct {...@@ -100,14 +99,14 @@ pub const LibCInstallation = struct {
100 log.err("crt_dir may not be empty for {s}\n", .{@tagName(Target.current.os.tag)});99 log.err("crt_dir may not be empty for {s}\n", .{@tagName(Target.current.os.tag)});
101 return error.ParseError;100 return error.ParseError;
102 }101 }
103 if (self.msvc_lib_dir == null and is_windows and !is_gnu) {102 if (self.msvc_lib_dir == null and is_windows) {
104 log.err("msvc_lib_dir may not be empty for {s}-{s}\n", .{103 log.err("msvc_lib_dir may not be empty for {s}-{s}\n", .{
105 @tagName(Target.current.os.tag),104 @tagName(Target.current.os.tag),
106 @tagName(Target.current.abi),105 @tagName(Target.current.abi),
107 });106 });
108 return error.ParseError;107 return error.ParseError;
109 }108 }
110 if (self.kernel32_lib_dir == null and is_windows and !is_gnu) {109 if (self.kernel32_lib_dir == null and is_windows) {
111 log.err("kernel32_lib_dir may not be empty for {s}-{s}\n", .{110 log.err("kernel32_lib_dir may not be empty for {s}-{s}\n", .{
112 @tagName(Target.current.os.tag),111 @tagName(Target.current.os.tag),
113 @tagName(Target.current.abi),112 @tagName(Target.current.abi),
src/link/Coff.zig+2-2
...@@ -1137,14 +1137,14 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {...@@ -1137,14 +1137,14 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
1137 }1137 }
11381138
1139 if (is_dyn_lib) {1139 if (is_dyn_lib) {
1140 try argv.append(try comp.get_libc_crt_file(arena, "dllcrt2.o"));1140 try argv.append(try comp.get_libc_crt_file(arena, "dllcrt2.obj"));
1141 if (target.cpu.arch == .i386) {1141 if (target.cpu.arch == .i386) {
1142 try argv.append("-ALTERNATENAME:__DllMainCRTStartup@12=_DllMainCRTStartup@12");1142 try argv.append("-ALTERNATENAME:__DllMainCRTStartup@12=_DllMainCRTStartup@12");
1143 } else {1143 } else {
1144 try argv.append("-ALTERNATENAME:_DllMainCRTStartup=DllMainCRTStartup");1144 try argv.append("-ALTERNATENAME:_DllMainCRTStartup=DllMainCRTStartup");
1145 }1145 }
1146 } else {1146 } else {
1147 try argv.append(try comp.get_libc_crt_file(arena, "crt2.o"));1147 try argv.append(try comp.get_libc_crt_file(arena, "crt2.obj"));
1148 }1148 }
11491149
1150 try argv.append(try comp.get_libc_crt_file(arena, "mingw32.lib"));1150 try argv.append(try comp.get_libc_crt_file(arena, "mingw32.lib"));
src/stage1/target.cpp+1-268
...@@ -756,8 +756,7 @@ bool target_allows_addr_zero(const ZigTarget *target) {...@@ -756,8 +756,7 @@ bool target_allows_addr_zero(const ZigTarget *target) {
756756
757const char *target_o_file_ext(const ZigTarget *target) {757const char *target_o_file_ext(const ZigTarget *target) {
758 if (target->abi == ZigLLVM_MSVC ||758 if (target->abi == ZigLLVM_MSVC ||
759 (target->os == OsWindows && !target_abi_is_gnu(target->abi)) ||759 target->os == OsWindows || target->os == OsUefi)
760 target->os == OsUefi)
761 {760 {
762 return ".obj";761 return ".obj";
763 } else {762 } else {
...@@ -777,29 +776,6 @@ bool target_is_android(const ZigTarget *target) {...@@ -777,29 +776,6 @@ bool target_is_android(const ZigTarget *target) {
777 return target->abi == ZigLLVM_Android;776 return target->abi == ZigLLVM_Android;
778}777}
779778
780bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target) {
781 assert(host_target != nullptr);
782
783 if (guest_target == nullptr) {
784 // null guest target means that the guest target is native
785 return true;
786 }
787
788 if (guest_target->os == host_target->os && guest_target->arch == host_target->arch) {
789 // OS and arch match
790 return true;
791 }
792
793 if (guest_target->os == OsWindows && host_target->os == OsWindows &&
794 host_target->arch == ZigLLVM_x86_64 && guest_target->arch == ZigLLVM_x86)
795 {
796 // 64-bit windows can run 32-bit programs
797 return true;
798 }
799
800 return false;
801}
802
803const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {779const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) {
804 switch (arch) {780 switch (arch) {
805 case ZigLLVM_UnknownArch:781 case ZigLLVM_UnknownArch:
...@@ -946,21 +922,6 @@ bool target_has_valgrind_support(const ZigTarget *target) {...@@ -946,21 +922,6 @@ bool target_has_valgrind_support(const ZigTarget *target) {
946 zig_unreachable();922 zig_unreachable();
947}923}
948924
949bool target_os_requires_libc(Os os) {
950 // On Darwin, we always link libSystem which contains libc.
951 // Similarly on FreeBSD and NetBSD we always link system libc
952 // since this is the stable syscall interface.
953 return (target_os_is_darwin(os) || os == OsFreeBSD || os == OsNetBSD || os == OsDragonFly);
954}
955
956bool target_is_glibc(const ZigTarget *target) {
957 return target->os == OsLinux && target_abi_is_gnu(target->abi);
958}
959
960bool target_is_musl(const ZigTarget *target) {
961 return target->os == OsLinux && target_abi_is_musl(target->abi);
962}
963
964bool target_is_wasm(const ZigTarget *target) {925bool target_is_wasm(const ZigTarget *target) {
965 return target->arch == ZigLLVM_wasm32 || target->arch == ZigLLVM_wasm64;926 return target->arch == ZigLLVM_wasm32 || target->arch == ZigLLVM_wasm64;
966}927}
...@@ -1019,238 +980,10 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {...@@ -1019,238 +980,10 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
1019 zig_unreachable();980 zig_unreachable();
1020}981}
1021982
1022bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi) {
1023 switch (abi) {
1024 case ZigLLVM_GNU:
1025 case ZigLLVM_GNUABIN32:
1026 case ZigLLVM_GNUABI64:
1027 case ZigLLVM_GNUEABI:
1028 case ZigLLVM_GNUEABIHF:
1029 case ZigLLVM_GNUX32:
1030 return true;
1031 default:
1032 return false;
1033 }
1034}
1035
1036bool target_abi_is_musl(ZigLLVM_EnvironmentType abi) {
1037 switch (abi) {
1038 case ZigLLVM_Musl:
1039 case ZigLLVM_MuslEABI:
1040 case ZigLLVM_MuslEABIHF:
1041 return true;
1042 default:
1043 return false;
1044 }
1045}
1046
1047struct AvailableLibC {
1048 ZigLLVM_ArchType arch;
1049 Os os;
1050 ZigLLVM_EnvironmentType abi;
1051};
1052
1053static const AvailableLibC libcs_available[] = {
1054 {ZigLLVM_aarch64_be, OsLinux, ZigLLVM_GNU},
1055 {ZigLLVM_aarch64_be, OsLinux, ZigLLVM_Musl},
1056 {ZigLLVM_aarch64_be, OsWindows, ZigLLVM_GNU},
1057 {ZigLLVM_aarch64, OsLinux, ZigLLVM_GNU},
1058 {ZigLLVM_aarch64, OsLinux, ZigLLVM_Musl},
1059 {ZigLLVM_aarch64, OsWindows, ZigLLVM_GNU},
1060 {ZigLLVM_armeb, OsLinux, ZigLLVM_GNUEABI},
1061 {ZigLLVM_armeb, OsLinux, ZigLLVM_GNUEABIHF},
1062 {ZigLLVM_armeb, OsLinux, ZigLLVM_MuslEABI},
1063 {ZigLLVM_armeb, OsLinux, ZigLLVM_MuslEABIHF},
1064 {ZigLLVM_armeb, OsWindows, ZigLLVM_GNU},
1065 {ZigLLVM_arm, OsLinux, ZigLLVM_GNUEABI},
1066 {ZigLLVM_arm, OsLinux, ZigLLVM_GNUEABIHF},
1067 {ZigLLVM_arm, OsLinux, ZigLLVM_MuslEABI},
1068 {ZigLLVM_arm, OsLinux, ZigLLVM_MuslEABIHF},
1069 {ZigLLVM_arm, OsWindows, ZigLLVM_GNU},
1070 {ZigLLVM_csky, OsLinux, ZigLLVM_GNUEABI},
1071 {ZigLLVM_csky, OsLinux, ZigLLVM_GNUEABIHF},
1072 {ZigLLVM_x86, OsLinux, ZigLLVM_GNU},
1073 {ZigLLVM_x86, OsLinux, ZigLLVM_Musl},
1074 {ZigLLVM_x86, OsWindows, ZigLLVM_GNU},
1075 {ZigLLVM_mips64el, OsLinux, ZigLLVM_GNUABI64},
1076 {ZigLLVM_mips64el, OsLinux, ZigLLVM_GNUABIN32},
1077 {ZigLLVM_mips64el, OsLinux, ZigLLVM_Musl},
1078 {ZigLLVM_mips64, OsLinux, ZigLLVM_GNUABI64},
1079 {ZigLLVM_mips64, OsLinux, ZigLLVM_GNUABIN32},
1080 {ZigLLVM_mips64, OsLinux, ZigLLVM_Musl},
1081 {ZigLLVM_mipsel, OsLinux, ZigLLVM_GNU},
1082 {ZigLLVM_mipsel, OsLinux, ZigLLVM_Musl},
1083 {ZigLLVM_mips, OsLinux, ZigLLVM_GNU},
1084 {ZigLLVM_mips, OsLinux, ZigLLVM_Musl},
1085 {ZigLLVM_ppc64le, OsLinux, ZigLLVM_GNU},
1086 {ZigLLVM_ppc64le, OsLinux, ZigLLVM_Musl},
1087 {ZigLLVM_ppc64, OsLinux, ZigLLVM_GNU},
1088 {ZigLLVM_ppc64, OsLinux, ZigLLVM_Musl},
1089 {ZigLLVM_ppc, OsLinux, ZigLLVM_GNU},
1090 {ZigLLVM_ppc, OsLinux, ZigLLVM_Musl},
1091 {ZigLLVM_riscv64, OsLinux, ZigLLVM_GNU},
1092 {ZigLLVM_riscv64, OsLinux, ZigLLVM_Musl},
1093 {ZigLLVM_systemz, OsLinux, ZigLLVM_GNU},
1094 {ZigLLVM_systemz, OsLinux, ZigLLVM_Musl},
1095 {ZigLLVM_sparc, OsLinux, ZigLLVM_GNU},
1096 {ZigLLVM_sparcv9, OsLinux, ZigLLVM_GNU},
1097 {ZigLLVM_wasm32, OsFreestanding, ZigLLVM_Musl},
1098 {ZigLLVM_x86_64, OsLinux, ZigLLVM_GNU},
1099 {ZigLLVM_x86_64, OsLinux, ZigLLVM_GNUX32},
1100 {ZigLLVM_x86_64, OsLinux, ZigLLVM_Musl},
1101 {ZigLLVM_x86_64, OsWindows, ZigLLVM_GNU},
1102};
1103
1104bool target_can_build_libc(const ZigTarget *target) {
1105 for (size_t i = 0; i < array_length(libcs_available); i += 1) {
1106 if (target->arch == libcs_available[i].arch &&
1107 target->os == libcs_available[i].os &&
1108 target->abi == libcs_available[i].abi)
1109 {
1110 return true;
1111 }
1112 }
1113 return false;
1114}
1115
1116const char *target_libc_generic_name(const ZigTarget *target) {
1117 if (target->os == OsWindows) {
1118 return "mingw";
1119 }
1120 switch (target->abi) {
1121 case ZigLLVM_GNU:
1122 case ZigLLVM_GNUABIN32:
1123 case ZigLLVM_GNUABI64:
1124 case ZigLLVM_GNUEABI:
1125 case ZigLLVM_GNUEABIHF:
1126 case ZigLLVM_GNUX32:
1127 case ZigLLVM_GNUILP32:
1128 return "glibc";
1129 case ZigLLVM_Musl:
1130 case ZigLLVM_MuslEABI:
1131 case ZigLLVM_MuslEABIHF:
1132 case ZigLLVM_UnknownEnvironment:
1133 return "musl";
1134 case ZigLLVM_CODE16:
1135 case ZigLLVM_EABI:
1136 case ZigLLVM_EABIHF:
1137 case ZigLLVM_Android:
1138 case ZigLLVM_MSVC:
1139 case ZigLLVM_Itanium:
1140 case ZigLLVM_Cygnus:
1141 case ZigLLVM_CoreCLR:
1142 case ZigLLVM_Simulator:
1143 case ZigLLVM_MacABI:
1144 zig_unreachable();
1145 }
1146 zig_unreachable();
1147}
1148
1149bool target_is_libc_lib_name(const ZigTarget *target, const char *name) {
1150 auto equal = str_eql_str;
1151 if (target->os == OsMacOSX)
1152 equal = str_eql_str_ignore_case;
1153
1154 if (equal(name, "c"))
1155 return true;
1156
1157 if (target_abi_is_gnu(target->abi) && target->os == OsWindows) {
1158 // mingw-w64
1159
1160 if (equal(name, "m"))
1161 return true;
1162
1163 return false;
1164 }
1165
1166 if (target_abi_is_gnu(target->abi) || target_abi_is_musl(target->abi) || target_os_is_darwin(target->os)) {
1167 if (equal(name, "m"))
1168 return true;
1169 if (equal(name, "rt"))
1170 return true;
1171 if (equal(name, "pthread"))
1172 return true;
1173 if (equal(name, "crypt"))
1174 return true;
1175 if (equal(name, "util"))
1176 return true;
1177 if (equal(name, "xnet"))
1178 return true;
1179 if (equal(name, "resolv"))
1180 return true;
1181 if (equal(name, "dl"))
1182 return true;
1183 }
1184
1185 if (target_os_is_darwin(target->os) && equal(name, "System"))
1186 return true;
1187
1188 return false;
1189}
1190
1191bool target_is_libcpp_lib_name(const ZigTarget *target, const char *name) {
1192 if (strcmp(name, "c++") == 0 || strcmp(name, "c++abi") == 0)
1193 return true;
1194
1195 return false;
1196}
1197
1198size_t target_libc_count(void) {
1199 return array_length(libcs_available);
1200}
1201
1202void target_libc_enum(size_t index, ZigTarget *out_target) {
1203 assert(index < array_length(libcs_available));
1204 out_target->arch = libcs_available[index].arch;
1205 out_target->os = libcs_available[index].os;
1206 out_target->abi = libcs_available[index].abi;
1207 out_target->is_native_os = false;
1208 out_target->is_native_cpu = false;
1209}
1210
1211bool target_has_debug_info(const ZigTarget *target) {983bool target_has_debug_info(const ZigTarget *target) {
1212 return !target_is_wasm(target);984 return !target_is_wasm(target);
1213}985}
1214986
1215const char *target_arch_musl_name(ZigLLVM_ArchType arch) {
1216 switch (arch) {
1217 case ZigLLVM_aarch64:
1218 case ZigLLVM_aarch64_be:
1219 return "aarch64";
1220 case ZigLLVM_arm:
1221 case ZigLLVM_armeb:
1222 return "arm";
1223 case ZigLLVM_mips:
1224 case ZigLLVM_mipsel:
1225 return "mips";
1226 case ZigLLVM_mips64el:
1227 case ZigLLVM_mips64:
1228 return "mips64";
1229 case ZigLLVM_ppc:
1230 return "powerpc";
1231 case ZigLLVM_ppc64:
1232 case ZigLLVM_ppc64le:
1233 return "powerpc64";
1234 case ZigLLVM_systemz:
1235 return "s390x";
1236 case ZigLLVM_x86:
1237 return "i386";
1238 case ZigLLVM_x86_64:
1239 return "x86_64";
1240 case ZigLLVM_riscv64:
1241 return "riscv64";
1242 default:
1243 zig_unreachable();
1244 }
1245}
1246
1247bool target_libc_needs_crti_crtn(const ZigTarget *target) {
1248 if (target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64 || target_is_android(target)) {
1249 return false;
1250 }
1251 return true;
1252}
1253
1254bool target_is_riscv(const ZigTarget *target) {987bool target_is_riscv(const ZigTarget *target) {
1255 return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64;988 return target->arch == ZigLLVM_riscv32 || target->arch == ZigLLVM_riscv64;
1256}989}
src/stage1/target.hpp-15
...@@ -66,7 +66,6 @@ const char *target_o_file_ext(const ZigTarget *target);...@@ -66,7 +66,6 @@ const char *target_o_file_ext(const ZigTarget *target);
66const char *target_asm_file_ext(const ZigTarget *target);66const char *target_asm_file_ext(const ZigTarget *target);
67const char *target_llvm_ir_file_ext(const ZigTarget *target);67const char *target_llvm_ir_file_ext(const ZigTarget *target);
6868
69bool target_can_exec(const ZigTarget *host_target, const ZigTarget *guest_target);
70ZigLLVM_OSType get_llvm_os_type(Os os_type);69ZigLLVM_OSType get_llvm_os_type(Os os_type);
7170
72bool target_is_arm(const ZigTarget *target);71bool target_is_arm(const ZigTarget *target);
...@@ -75,29 +74,15 @@ bool target_is_ppc(const ZigTarget *target);...@@ -75,29 +74,15 @@ bool target_is_ppc(const ZigTarget *target);
75bool target_allows_addr_zero(const ZigTarget *target);74bool target_allows_addr_zero(const ZigTarget *target);
76bool target_has_valgrind_support(const ZigTarget *target);75bool target_has_valgrind_support(const ZigTarget *target);
77bool target_os_is_darwin(Os os);76bool target_os_is_darwin(Os os);
78bool target_os_requires_libc(Os os);
79bool target_can_build_libc(const ZigTarget *target);
80const char *target_libc_generic_name(const ZigTarget *target);
81bool target_is_libc_lib_name(const ZigTarget *target, const char *name);
82bool target_is_libcpp_lib_name(const ZigTarget *target, const char *name);
83bool target_abi_is_gnu(ZigLLVM_EnvironmentType abi);
84bool target_abi_is_musl(ZigLLVM_EnvironmentType abi);
85bool target_is_glibc(const ZigTarget *target);
86bool target_is_musl(const ZigTarget *target);
87bool target_is_wasm(const ZigTarget *target);77bool target_is_wasm(const ZigTarget *target);
88bool target_is_riscv(const ZigTarget *target);78bool target_is_riscv(const ZigTarget *target);
89bool target_is_sparc(const ZigTarget *target);79bool target_is_sparc(const ZigTarget *target);
90bool target_is_android(const ZigTarget *target);80bool target_is_android(const ZigTarget *target);
91bool target_has_debug_info(const ZigTarget *target);81bool target_has_debug_info(const ZigTarget *target);
92const char *target_arch_musl_name(ZigLLVM_ArchType arch);
9382
94uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch);83uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch);
95uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch);84uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch);
9685
97size_t target_libc_count(void);
98void target_libc_enum(size_t index, ZigTarget *out_target);
99bool target_libc_needs_crti_crtn(const ZigTarget *target);
100
101unsigned target_fn_ptr_align(const ZigTarget *target);86unsigned target_fn_ptr_align(const ZigTarget *target);
102unsigned target_fn_align(const ZigTarget *target);87unsigned target_fn_align(const ZigTarget *target);
10388