authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2021-05-05 00:02:16-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-05 03:15:44-04:00
log70a9a3a562582173c140a064762b674e3c761a41
tree06897ff50e2b4ac3df4881bf0c86df478fe5e78a
parent785a6c1aa9a7979a962db9d741a53897c423cb92

stage1: Fix other OS target

PR #7827 added some new `std.Target.Os.Tag` before `other`. The corresponding enum in stage1.h was not updated, which caused a mismatch in the underlying integer values. While attempting to target `other`, I encountered crashes. This PR updates the stage1.h enum to include the added OS tags. The new tags also had to be added to various switch cases to fix compiler warnings, but have not been tested in any way.

2 files changed, 20 insertions(+), 1 deletions(-)

src/stage1/stage1.h+4-1
......@@ -56,7 +56,7 @@ enum TargetSubsystem {
5656
5757
5858// ABI warning
59// Synchronize with target.cpp::os_list
59// Synchronize with std.Target.Os.Tag and target.cpp::os_list
6060enum Os {
6161 OsFreestanding,
6262 OsAnanas,
......@@ -94,6 +94,9 @@ enum Os {
9494 OsWASI,
9595 OsEmscripten,
9696 OsUefi,
97 OsOpenCL,
98 OsGLSL450,
99 OsVulkan,
97100 OsOther,
98101};
99102
src/stage1/target.cpp+16
......@@ -122,6 +122,9 @@ static const Os os_list[] = {
122122 OsWASI,
123123 OsEmscripten,
124124 OsUefi,
125 OsOpenCL,
126 OsGLSL450,
127 OsVulkan,
125128 OsOther,
126129};
127130
......@@ -213,6 +216,9 @@ Os target_os_enum(size_t index) {
213216ZigLLVM_OSType get_llvm_os_type(Os os_type) {
214217 switch (os_type) {
215218 case OsFreestanding:
219 case OsOpenCL:
220 case OsGLSL450:
221 case OsVulkan:
216222 case OsOther:
217223 return ZigLLVM_UnknownOS;
218224 case OsAnanas:
......@@ -330,6 +336,9 @@ const char *target_os_name(Os os_type) {
330336 case OsHurd:
331337 case OsWASI:
332338 case OsEmscripten:
339 case OsOpenCL:
340 case OsGLSL450:
341 case OsVulkan:
333342 return ZigLLVMGetOSTypeName(get_llvm_os_type(os_type));
334343 }
335344 zig_unreachable();
......@@ -733,6 +742,9 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
733742 case OsAMDPAL:
734743 case OsHermitCore:
735744 case OsHurd:
745 case OsOpenCL:
746 case OsGLSL450:
747 case OsVulkan:
736748 zig_panic("TODO c type size in bits for this target");
737749 }
738750 zig_unreachable();
......@@ -999,6 +1011,10 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
9991011 case OsWASI:
10001012 case OsEmscripten:
10011013 return ZigLLVM_Musl;
1014 case OsOpenCL:
1015 case OsGLSL450:
1016 case OsVulkan:
1017 return ZigLLVM_UnknownEnvironment;
10021018 }
10031019 zig_unreachable();
10041020}