| author | |
| committer | |
| log | 152462e2e1513ca9d7db5c2d6a2a61b547c5151c |
| tree | bb541574002b430386c403b1a45e7bc92b3c3c93 |
| parent | 902dc8c721c762bc5d1b9786bad47b21da45042c |
2 files changed, 19 insertions(+), 6 deletions(-)
src/Compilation.zig+1-5| ... | ... | @@ -1024,10 +1024,6 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1024 | 1024 | if (options.use_llvm) |explicit| |
| 1025 | 1025 | break :blk explicit; |
| 1026 | 1026 | |
| 1027 | // If we are outputting .c code we must use Zig backend. | |
| 1028 | if (ofmt == .c) | |
| 1029 | break :blk false; | |
| 1030 | ||
| 1031 | 1027 | // If emitting to LLVM bitcode object format, must use LLVM backend. |
| 1032 | 1028 | if (options.emit_llvm_ir != null or options.emit_llvm_bc != null) |
| 1033 | 1029 | break :blk true; |
| ... | ... | @@ -1042,7 +1038,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { |
| 1042 | 1038 | break :blk true; |
| 1043 | 1039 | |
| 1044 | 1040 | // If LLVM does not support the target, then we can't use it. |
| 1045 | if (!target_util.hasLlvmSupport(options.target)) | |
| 1041 | if (!target_util.hasLlvmSupport(options.target, ofmt)) | |
| 1046 | 1042 | break :blk false; |
| 1047 | 1043 | |
| 1048 | 1044 | // Prefer LLVM for release builds. |
src/target.zig+18-1| ... | ... | @@ -204,7 +204,24 @@ pub fn hasValgrindSupport(target: std.Target) bool { |
| 204 | 204 | /// The set of targets that LLVM has non-experimental support for. |
| 205 | 205 | /// Used to select between LLVM backend and self-hosted backend when compiling in |
| 206 | 206 | /// release modes. |
| 207 | pub fn hasLlvmSupport(target: std.Target) bool { | |
| 207 | pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { | |
| 208 | switch (ofmt) { | |
| 209 | // LLVM does not support these object formats: | |
| 210 | .c, | |
| 211 | .plan9, | |
| 212 | => return false, | |
| 213 | ||
| 214 | .coff, | |
| 215 | .elf, | |
| 216 | .macho, | |
| 217 | .wasm, | |
| 218 | .spirv, | |
| 219 | .hex, | |
| 220 | .raw, | |
| 221 | .nvptx, | |
| 222 | => {}, | |
| 223 | } | |
| 224 | ||
| 208 | 225 | return switch (target.cpu.arch) { |
| 209 | 226 | .arm, |
| 210 | 227 | .armeb, |