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

This commit is contained in:
Jakub Konka 2022-05-15 17:56:51 +02:00
parent 5b813f1a2a
commit f8a1a2c4a1
2 changed files with 70 additions and 47 deletions

View File

@ -86,50 +86,73 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 {
.spirv64 => return error.@"LLVM backend does not support SPIR-V",
};
const llvm_os = switch (target.os.tag) {
.freestanding => "unknown",
.ananas => "ananas",
.cloudabi => "cloudabi",
.dragonfly => "dragonfly",
.freebsd => "freebsd",
.fuchsia => "fuchsia",
.ios => "ios",
.kfreebsd => "kfreebsd",
.linux => "linux",
.lv2 => "lv2",
.macos => "macosx",
.netbsd => "netbsd",
.openbsd => "openbsd",
.solaris => "solaris",
.windows => "windows",
.zos => "zos",
.haiku => "haiku",
.minix => "minix",
.rtems => "rtems",
.nacl => "nacl",
.aix => "aix",
.cuda => "cuda",
.nvcl => "nvcl",
.amdhsa => "amdhsa",
.ps4 => "ps4",
.elfiamcu => "elfiamcu",
.tvos => "tvos",
.watchos => "watchos",
.mesa3d => "mesa3d",
.contiki => "contiki",
.amdpal => "amdpal",
.hermit => "hermit",
.hurd => "hurd",
.wasi => "wasi",
.emscripten => "emscripten",
.uefi => "windows",
const llvm_os = blk: {
if (target.os.tag.isDarwin()) {
const min_version = target.os.version_range.semver.min;
const llvm_os = switch (target.os.tag) {
.macos => "macosx",
.ios => "ios",
.tvos => "tvos",
.watchos => "watchos",
else => unreachable,
};
break :blk try std.fmt.allocPrintZ(allocator, "{s}{d}.{d}.{d}", .{
llvm_os,
min_version.major,
min_version.minor,
min_version.patch,
});
}
.opencl,
.glsl450,
.vulkan,
.plan9,
.other,
=> "unknown",
const llvm_os = switch (target.os.tag) {
.freestanding => "unknown",
.ananas => "ananas",
.cloudabi => "cloudabi",
.dragonfly => "dragonfly",
.freebsd => "freebsd",
.fuchsia => "fuchsia",
.kfreebsd => "kfreebsd",
.linux => "linux",
.lv2 => "lv2",
.netbsd => "netbsd",
.openbsd => "openbsd",
.solaris => "solaris",
.windows => "windows",
.zos => "zos",
.haiku => "haiku",
.minix => "minix",
.rtems => "rtems",
.nacl => "nacl",
.aix => "aix",
.cuda => "cuda",
.nvcl => "nvcl",
.amdhsa => "amdhsa",
.ps4 => "ps4",
.elfiamcu => "elfiamcu",
.mesa3d => "mesa3d",
.contiki => "contiki",
.amdpal => "amdpal",
.hermit => "hermit",
.hurd => "hurd",
.wasi => "wasi",
.emscripten => "emscripten",
.uefi => "windows",
.opencl,
.glsl450,
.vulkan,
.plan9,
.other,
=> "unknown",
.macos,
.ios,
.tvos,
.watchos,
=> unreachable,
};
break :blk llvm_os;
};
const llvm_abi = switch (target.abi) {

View File

@ -95,7 +95,7 @@ const test_targets = blk: {
.target = .{
.cpu_arch = .aarch64,
.os_tag = .macos,
.abi = .gnu,
.abi = .none,
},
.backend = .stage2_aarch64,
},
@ -103,7 +103,7 @@ const test_targets = blk: {
.target = .{
.cpu_arch = .x86_64,
.os_tag = .macos,
.abi = .gnu,
.abi = .none,
},
.backend = .stage2_x86_64,
},
@ -337,7 +337,7 @@ const test_targets = blk: {
.target = .{
.cpu_arch = .x86_64,
.os_tag = .macos,
.abi = .gnu,
.abi = .none,
},
},
@ -345,7 +345,7 @@ const test_targets = blk: {
.target = .{
.cpu_arch = .aarch64,
.os_tag = .macos,
.abi = .gnu,
.abi = .none,
},
},