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 {...@@ -86,50 +86,73 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {
86 .spirv64 => return error.@"LLVM backend does not support SPIR-V",86 .spirv64 => return error.@"LLVM backend does not support SPIR-V",
87 };87 };
8888
89 const llvm_os = switch (target.os.tag) {89 const llvm_os = blk: {
90 .freestanding => "unknown",90 if (target.os.tag.isDarwin()) {
91 .ananas => "ananas",91 const min_version = target.os.version_range.semver.min;
92 .cloudabi => "cloudabi",92 const llvm_os = switch (target.os.tag) {
93 .dragonfly => "dragonfly",93 .macos => "macosx",
94 .freebsd => "freebsd",94 .ios => "ios",
95 .fuchsia => "fuchsia",95 .tvos => "tvos",
96 .ios => "ios",96 .watchos => "watchos",
97 .kfreebsd => "kfreebsd",97 else => unreachable,
98 .linux => "linux",98 };
99 .lv2 => "lv2",99 break :blk try std.fmt.allocPrintZ(allocator, "{s}{d}.{d}.{d}", .{
100 .macos => "macosx",100 llvm_os,
101 .netbsd => "netbsd",101 min_version.major,
102 .openbsd => "openbsd",102 min_version.minor,
103 .solaris => "solaris",103 min_version.patch,
104 .windows => "windows",104 });
105 .zos => "zos",105 }
106 .haiku => "haiku",106
107 .minix => "minix",107 const llvm_os = switch (target.os.tag) {
108 .rtems => "rtems",108 .freestanding => "unknown",
109 .nacl => "nacl",109 .ananas => "ananas",
110 .aix => "aix",110 .cloudabi => "cloudabi",
111 .cuda => "cuda",111 .dragonfly => "dragonfly",
112 .nvcl => "nvcl",112 .freebsd => "freebsd",
113 .amdhsa => "amdhsa",113 .fuchsia => "fuchsia",
114 .ps4 => "ps4",114 .kfreebsd => "kfreebsd",
115 .elfiamcu => "elfiamcu",115 .linux => "linux",
116 .tvos => "tvos",116 .lv2 => "lv2",
117 .watchos => "watchos",117 .netbsd => "netbsd",
118 .mesa3d => "mesa3d",118 .openbsd => "openbsd",
119 .contiki => "contiki",119 .solaris => "solaris",
120 .amdpal => "amdpal",120 .windows => "windows",
121 .hermit => "hermit",121 .zos => "zos",
122 .hurd => "hurd",122 .haiku => "haiku",
123 .wasi => "wasi",123 .minix => "minix",
124 .emscripten => "emscripten",124 .rtems => "rtems",
125 .uefi => "windows",125 .nacl => "nacl",
126126 .aix => "aix",
127 .opencl,127 .cuda => "cuda",
128 .glsl450,128 .nvcl => "nvcl",
129 .vulkan,129 .amdhsa => "amdhsa",
130 .plan9,130 .ps4 => "ps4",
131 .other,131 .elfiamcu => "elfiamcu",
132 => "unknown",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;
133 };156 };
134157
135 const llvm_abi = switch (target.abi) {158 const llvm_abi = switch (target.abi) {
test/tests.zig+4-4
...@@ -95,7 +95,7 @@ const test_targets = blk: {...@@ -95,7 +95,7 @@ const test_targets = blk: {
95 .target = .{95 .target = .{
96 .cpu_arch = .aarch64,96 .cpu_arch = .aarch64,
97 .os_tag = .macos,97 .os_tag = .macos,
98 .abi = .gnu,98 .abi = .none,
99 },99 },
100 .backend = .stage2_aarch64,100 .backend = .stage2_aarch64,
101 },101 },
...@@ -103,7 +103,7 @@ const test_targets = blk: {...@@ -103,7 +103,7 @@ const test_targets = blk: {
103 .target = .{103 .target = .{
104 .cpu_arch = .x86_64,104 .cpu_arch = .x86_64,
105 .os_tag = .macos,105 .os_tag = .macos,
106 .abi = .gnu,106 .abi = .none,
107 },107 },
108 .backend = .stage2_x86_64,108 .backend = .stage2_x86_64,
109 },109 },
...@@ -337,7 +337,7 @@ const test_targets = blk: {...@@ -337,7 +337,7 @@ const test_targets = blk: {
337 .target = .{337 .target = .{
338 .cpu_arch = .x86_64,338 .cpu_arch = .x86_64,
339 .os_tag = .macos,339 .os_tag = .macos,
340 .abi = .gnu,340 .abi = .none,
341 },341 },
342 },342 },
343343
...@@ -345,7 +345,7 @@ const test_targets = blk: {...@@ -345,7 +345,7 @@ const test_targets = blk: {
345 .target = .{345 .target = .{
346 .cpu_arch = .aarch64,346 .cpu_arch = .aarch64,
347 .os_tag = .macos,347 .os_tag = .macos,
348 .abi = .gnu,348 .abi = .none,
349 },349 },
350 },350 },
351351