authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-05-15 17:56:51+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-05-22 17:45:07+02:00
logf8a1a2c4a18a2a5f274029c4c59f3a8e83f36b6b
tree67541059c1b35597907ab5ce14729d42b849a0bb
parent5b813f1a2acdc1668e39008b02a234f3da724552

stage2: append min version to target triple when lowering to LLVM


2 files changed, 71 insertions(+), 48 deletions(-)

src/codegen/llvm.zig+67-44
......@@ -86,50 +86,73 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {
8686 .spirv64 => return error.@"LLVM backend does not support SPIR-V",
8787 };
8888
89 const llvm_os = switch (target.os.tag) {
90 .freestanding => "unknown",
91 .ananas => "ananas",
92 .cloudabi => "cloudabi",
93 .dragonfly => "dragonfly",
94 .freebsd => "freebsd",
95 .fuchsia => "fuchsia",
96 .ios => "ios",
97 .kfreebsd => "kfreebsd",
98 .linux => "linux",
99 .lv2 => "lv2",
100 .macos => "macosx",
101 .netbsd => "netbsd",
102 .openbsd => "openbsd",
103 .solaris => "solaris",
104 .windows => "windows",
105 .zos => "zos",
106 .haiku => "haiku",
107 .minix => "minix",
108 .rtems => "rtems",
109 .nacl => "nacl",
110 .aix => "aix",
111 .cuda => "cuda",
112 .nvcl => "nvcl",
113 .amdhsa => "amdhsa",
114 .ps4 => "ps4",
115 .elfiamcu => "elfiamcu",
116 .tvos => "tvos",
117 .watchos => "watchos",
118 .mesa3d => "mesa3d",
119 .contiki => "contiki",
120 .amdpal => "amdpal",
121 .hermit => "hermit",
122 .hurd => "hurd",
123 .wasi => "wasi",
124 .emscripten => "emscripten",
125 .uefi => "windows",
126
127 .opencl,
128 .glsl450,
129 .vulkan,
130 .plan9,
131 .other,
132 => "unknown",
89 const llvm_os = blk: {
90 if (target.os.tag.isDarwin()) {
91 const min_version = target.os.version_range.semver.min;
92 const llvm_os = switch (target.os.tag) {
93 .macos => "macosx",
94 .ios => "ios",
95 .tvos => "tvos",
96 .watchos => "watchos",
97 else => unreachable,
98 };
99 break :blk try std.fmt.allocPrintZ(allocator, "{s}{d}.{d}.{d}", .{
100 llvm_os,
101 min_version.major,
102 min_version.minor,
103 min_version.patch,
104 });
105 }
106
107 const llvm_os = switch (target.os.tag) {
108 .freestanding => "unknown",
109 .ananas => "ananas",
110 .cloudabi => "cloudabi",
111 .dragonfly => "dragonfly",
112 .freebsd => "freebsd",
113 .fuchsia => "fuchsia",
114 .kfreebsd => "kfreebsd",
115 .linux => "linux",
116 .lv2 => "lv2",
117 .netbsd => "netbsd",
118 .openbsd => "openbsd",
119 .solaris => "solaris",
120 .windows => "windows",
121 .zos => "zos",
122 .haiku => "haiku",
123 .minix => "minix",
124 .rtems => "rtems",
125 .nacl => "nacl",
126 .aix => "aix",
127 .cuda => "cuda",
128 .nvcl => "nvcl",
129 .amdhsa => "amdhsa",
130 .ps4 => "ps4",
131 .elfiamcu => "elfiamcu",
132 .mesa3d => "mesa3d",
133 .contiki => "contiki",
134 .amdpal => "amdpal",
135 .hermit => "hermit",
136 .hurd => "hurd",
137 .wasi => "wasi",
138 .emscripten => "emscripten",
139 .uefi => "windows",
140
141 .opencl,
142 .glsl450,
143 .vulkan,
144 .plan9,
145 .other,
146 => "unknown",
147
148 .macos,
149 .ios,
150 .tvos,
151 .watchos,
152 => unreachable,
153 };
154
155 break :blk llvm_os;
133156 };
134157
135158 const llvm_abi = switch (target.abi) {
test/tests.zig+4-4
......@@ -95,7 +95,7 @@ const test_targets = blk: {
9595 .target = .{
9696 .cpu_arch = .aarch64,
9797 .os_tag = .macos,
98 .abi = .gnu,
98 .abi = .none,
9999 },
100100 .backend = .stage2_aarch64,
101101 },
......@@ -103,7 +103,7 @@ const test_targets = blk: {
103103 .target = .{
104104 .cpu_arch = .x86_64,
105105 .os_tag = .macos,
106 .abi = .gnu,
106 .abi = .none,
107107 },
108108 .backend = .stage2_x86_64,
109109 },
......@@ -337,7 +337,7 @@ const test_targets = blk: {
337337 .target = .{
338338 .cpu_arch = .x86_64,
339339 .os_tag = .macos,
340 .abi = .gnu,
340 .abi = .none,
341341 },
342342 },
343343
......@@ -345,7 +345,7 @@ const test_targets = blk: {
345345 .target = .{
346346 .cpu_arch = .aarch64,
347347 .os_tag = .macos,
348 .abi = .gnu,
348 .abi = .none,
349349 },
350350 },
351351