| author | |
| committer | |
| log | 78df3c9301891a3333eb5420074c9b0d56d54a54 |
| tree | f472f17d9afaa3f4d3c5853817628da8e58ccc91 |
| parent | 5ed8bd5c85e34d200a504418ebd2fc3d902460ac |
| parent | 711e055f1852be93dd74dcbbb5777efc30f43506 |
| signature |
5 files changed, 73 insertions(+), 29 deletions(-)
src/link/Elf.zig+12-1| ... | ... | @@ -1663,7 +1663,18 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s |
| 1663 | 1663 | // copy when generating relocatables. Normally, we would expect `lld -r` to work. |
| 1664 | 1664 | // However, because LLD wants to resolve BPF relocations which it shouldn't, it fails |
| 1665 | 1665 | // before even generating the relocatable. |
| 1666 | if (output_mode == .Obj and (comp.config.lto != .none or target.cpu.arch.isBpf())) { | |
| 1666 | // | |
| 1667 | // For m68k, we go through this path because LLD doesn't support it yet, but LLVM can | |
| 1668 | // produce usable object files. | |
| 1669 | if (output_mode == .Obj and | |
| 1670 | (comp.config.lto != .none or | |
| 1671 | target.cpu.arch.isBpf() or | |
| 1672 | target.cpu.arch == .lanai or | |
| 1673 | target.cpu.arch == .m68k or | |
| 1674 | target.cpu.arch.isSPARC() or | |
| 1675 | target.cpu.arch == .ve or | |
| 1676 | target.cpu.arch == .xcore)) | |
| 1677 | { | |
| 1667 | 1678 | // In this case we must do a simple file copy |
| 1668 | 1679 | // here. TODO: think carefully about how we can avoid this redundant operation when doing |
| 1669 | 1680 | // build-obj. See also the corresponding TODO in linkAsArchive. |
src/main.zig+4-2| ... | ... | @@ -3169,9 +3169,11 @@ fn buildOutputType( |
| 3169 | 3169 | |
| 3170 | 3170 | const target = main_mod.resolved_target.result; |
| 3171 | 3171 | |
| 3172 | if (target.cpu.arch.isNvptx()) { | |
| 3172 | if (target.cpu.arch == .arc or target.cpu.arch.isNvptx()) { | |
| 3173 | 3173 | if (emit_bin != .no and create_module.resolved_options.use_llvm) { |
| 3174 | fatal("cannot emit PTX binary with the LLVM backend; only '-femit-asm' is supported", .{}); | |
| 3174 | fatal("cannot emit {s} binary with the LLVM backend; only '-femit-asm' is supported", .{ | |
| 3175 | @tagName(target.cpu.arch), | |
| 3176 | }); | |
| 3175 | 3177 | } |
| 3176 | 3178 | } |
| 3177 | 3179 |
src/target.zig+5-2| ... | ... | @@ -153,7 +153,6 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { |
| 153 | 153 | .avr, |
| 154 | 154 | .bpfel, |
| 155 | 155 | .bpfeb, |
| 156 | .csky, | |
| 157 | 156 | .hexagon, |
| 158 | 157 | .loongarch32, |
| 159 | 158 | .loongarch64, |
| ... | ... | @@ -181,7 +180,6 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { |
| 181 | 180 | .x86, |
| 182 | 181 | .x86_64, |
| 183 | 182 | .xcore, |
| 184 | .xtensa, | |
| 185 | 183 | .nvptx, |
| 186 | 184 | .nvptx64, |
| 187 | 185 | .lanai, |
| ... | ... | @@ -190,6 +188,11 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool { |
| 190 | 188 | .ve, |
| 191 | 189 | => true, |
| 192 | 190 | |
| 191 | // LLVM backend exists but can produce neither assembly nor object files. | |
| 192 | .csky, | |
| 193 | .xtensa, | |
| 194 | => false, | |
| 195 | ||
| 193 | 196 | // No LLVM backend exists. |
| 194 | 197 | .kalimba, |
| 195 | 198 | .propeller, |
test/llvm_targets.zig+23-23| ... | ... | @@ -44,9 +44,9 @@ const targets = [_]std.Target.Query{ |
| 44 | 44 | // .{ .cpu_arch = .amdgcn, .os_tag = .amdpal, .abi = .none }, |
| 45 | 45 | // .{ .cpu_arch = .amdgcn, .os_tag = .mesa3d, .abi = .none }, |
| 46 | 46 | |
| 47 | // .{ .cpu_arch = .arc, .os_tag = .freestanding, .abi = .none }, | |
| 48 | // .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .gnu }, | |
| 49 | // .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .none }, | |
| 47 | .{ .cpu_arch = .arc, .os_tag = .freestanding, .abi = .none }, | |
| 48 | .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .gnu }, | |
| 49 | .{ .cpu_arch = .arc, .os_tag = .linux, .abi = .none }, | |
| 50 | 50 | |
| 51 | 51 | .{ .cpu_arch = .arm, .os_tag = .freebsd, .abi = .eabi }, |
| 52 | 52 | .{ .cpu_arch = .arm, .os_tag = .freebsd, .abi = .eabihf }, |
| ... | ... | @@ -101,7 +101,7 @@ const targets = [_]std.Target.Query{ |
| 101 | 101 | .{ .cpu_arch = .hexagon, .os_tag = .freestanding, .abi = .none }, |
| 102 | 102 | .{ .cpu_arch = .hexagon, .os_tag = .linux, .abi = .none }, |
| 103 | 103 | |
| 104 | // .{ .cpu_arch = .lanai, .os_tag = .freestanding, .abi = .none }, | |
| 104 | .{ .cpu_arch = .lanai, .os_tag = .freestanding, .abi = .none }, | |
| 105 | 105 | |
| 106 | 106 | // .{ .cpu_arch = .loongarch32, .os_tag = .freestanding, .abi = .none }, |
| 107 | 107 | // .{ .cpu_arch = .loongarch32, .os_tag = .linux, .abi = .none }, |
| ... | ... | @@ -117,13 +117,13 @@ const targets = [_]std.Target.Query{ |
| 117 | 117 | .{ .cpu_arch = .loongarch64, .os_tag = .linux, .abi = .none }, |
| 118 | 118 | // .{ .cpu_arch = .loongarch64, .os_tag = .uefi, .abi = .none }, |
| 119 | 119 | |
| 120 | // .{ .cpu_arch = .m68k, .os_tag = .freestanding, .abi = .none }, | |
| 121 | // .{ .cpu_arch = .m68k, .os_tag = .haiku, .abi = .none }, | |
| 122 | // .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .gnu }, | |
| 123 | // .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .musl }, | |
| 124 | // .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .none }, | |
| 125 | // .{ .cpu_arch = .m68k, .os_tag = .netbsd, .abi = .none }, | |
| 126 | // .{ .cpu_arch = .m68k, .os_tag = .rtems, .abi = .none }, | |
| 120 | .{ .cpu_arch = .m68k, .os_tag = .freestanding, .abi = .none }, | |
| 121 | .{ .cpu_arch = .m68k, .os_tag = .haiku, .abi = .none }, | |
| 122 | .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .gnu }, | |
| 123 | .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .musl }, | |
| 124 | .{ .cpu_arch = .m68k, .os_tag = .linux, .abi = .none }, | |
| 125 | .{ .cpu_arch = .m68k, .os_tag = .netbsd, .abi = .none }, | |
| 126 | .{ .cpu_arch = .m68k, .os_tag = .rtems, .abi = .none }, | |
| 127 | 127 | |
| 128 | 128 | .{ .cpu_arch = .mips, .os_tag = .freestanding, .abi = .eabi }, |
| 129 | 129 | .{ .cpu_arch = .mips, .os_tag = .freestanding, .abi = .eabihf }, |
| ... | ... | @@ -171,10 +171,10 @@ const targets = [_]std.Target.Query{ |
| 171 | 171 | |
| 172 | 172 | .{ .cpu_arch = .msp430, .os_tag = .freestanding, .abi = .none }, |
| 173 | 173 | |
| 174 | // .{ .cpu_arch = .nvptx, .os_tag = .cuda, .abi = .none }, | |
| 175 | // .{ .cpu_arch = .nvptx, .os_tag = .nvcl, .abi = .none }, | |
| 176 | // .{ .cpu_arch = .nvptx64, .os_tag = .cuda, .abi = .none }, | |
| 177 | // .{ .cpu_arch = .nvptx64, .os_tag = .nvcl, .abi = .none }, | |
| 174 | .{ .cpu_arch = .nvptx, .os_tag = .cuda, .abi = .none }, | |
| 175 | .{ .cpu_arch = .nvptx, .os_tag = .nvcl, .abi = .none }, | |
| 176 | .{ .cpu_arch = .nvptx64, .os_tag = .cuda, .abi = .none }, | |
| 177 | .{ .cpu_arch = .nvptx64, .os_tag = .nvcl, .abi = .none }, | |
| 178 | 178 | |
| 179 | 179 | // .{ .cpu_arch = .powerpc, .os_tag = .aix, .abi = .eabihf }, |
| 180 | 180 | .{ .cpu_arch = .powerpc, .os_tag = .freebsd, .abi = .eabi }, |
| ... | ... | @@ -241,11 +241,11 @@ const targets = [_]std.Target.Query{ |
| 241 | 241 | .{ .cpu_arch = .s390x, .os_tag = .linux, .abi = .none }, |
| 242 | 242 | // .{ .cpu_arch = .s390x, .os_tag = .zos, .abi = .none }, |
| 243 | 243 | |
| 244 | // .{ .cpu_arch = .sparc, .os_tag = .freestanding, .abi = .none }, | |
| 245 | // .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .gnu }, | |
| 246 | // .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .none }, | |
| 247 | // .{ .cpu_arch = .sparc, .os_tag = .netbsd, .abi = .none }, | |
| 248 | // .{ .cpu_arch = .sparc, .os_tag = .rtems, .abi = .none }, | |
| 244 | .{ .cpu_arch = .sparc, .os_tag = .freestanding, .abi = .none }, | |
| 245 | .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .gnu }, | |
| 246 | .{ .cpu_arch = .sparc, .os_tag = .linux, .abi = .none }, | |
| 247 | .{ .cpu_arch = .sparc, .os_tag = .netbsd, .abi = .none }, | |
| 248 | .{ .cpu_arch = .sparc, .os_tag = .rtems, .abi = .none }, | |
| 249 | 249 | |
| 250 | 250 | .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none }, |
| 251 | 251 | .{ .cpu_arch = .sparc64, .os_tag = .haiku, .abi = .none }, |
| ... | ... | @@ -279,8 +279,8 @@ const targets = [_]std.Target.Query{ |
| 279 | 279 | .{ .cpu_arch = .thumbeb, .os_tag = .rtems, .abi = .eabi }, |
| 280 | 280 | .{ .cpu_arch = .thumbeb, .os_tag = .rtems, .abi = .eabihf }, |
| 281 | 281 | |
| 282 | // .{ .cpu_arch = .ve, .os_tag = .freestanding, .abi = .none }, | |
| 283 | // .{ .cpu_arch = .ve, .os_tag = .linux, .abi = .none }, | |
| 282 | .{ .cpu_arch = .ve, .os_tag = .freestanding, .abi = .none }, | |
| 283 | .{ .cpu_arch = .ve, .os_tag = .linux, .abi = .none }, | |
| 284 | 284 | |
| 285 | 285 | .{ .cpu_arch = .wasm32, .os_tag = .emscripten, .abi = .none }, |
| 286 | 286 | .{ .cpu_arch = .wasm32, .os_tag = .freestanding, .abi = .none }, |
| ... | ... | @@ -350,7 +350,7 @@ const targets = [_]std.Target.Query{ |
| 350 | 350 | .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .itanium }, |
| 351 | 351 | .{ .cpu_arch = .x86_64, .os_tag = .windows, .abi = .msvc }, |
| 352 | 352 | |
| 353 | // .{ .cpu_arch = .xcore, .os_tag = .freestanding, .abi = .none }, | |
| 353 | .{ .cpu_arch = .xcore, .os_tag = .freestanding, .abi = .none }, | |
| 354 | 354 | |
| 355 | 355 | // .{ .cpu_arch = .xtensa, .os_tag = .freestanding, .abi = .none }, |
| 356 | 356 | // .{ .cpu_arch = .xtensa, .os_tag = .linux, .abi = .none }, |
test/src/Cases.zig+29-1| ... | ... | @@ -62,6 +62,7 @@ pub const Case = struct { |
| 62 | 62 | Header: []const u8, |
| 63 | 63 | }, |
| 64 | 64 | |
| 65 | emit_asm: bool = false, | |
| 65 | 66 | emit_bin: bool = true, |
| 66 | 67 | emit_h: bool = false, |
| 67 | 68 | is_test: bool = false, |
| ... | ... | @@ -173,6 +174,23 @@ pub fn exeFromCompiledC(ctx: *Cases, name: []const u8, target_query: std.Target. |
| 173 | 174 | } |
| 174 | 175 | |
| 175 | 176 | pub fn addObjLlvm(ctx: *Cases, name: []const u8, target: std.Build.ResolvedTarget) *Case { |
| 177 | const can_emit_asm = switch (target.result.cpu.arch) { | |
| 178 | .csky, | |
| 179 | .xtensa, | |
| 180 | => false, | |
| 181 | else => true, | |
| 182 | }; | |
| 183 | const can_emit_bin = switch (target.result.cpu.arch) { | |
| 184 | .arc, | |
| 185 | .csky, | |
| 186 | .nvptx, | |
| 187 | .nvptx64, | |
| 188 | .xcore, | |
| 189 | .xtensa, | |
| 190 | => false, | |
| 191 | else => true, | |
| 192 | }; | |
| 193 | ||
| 176 | 194 | ctx.cases.append(.{ |
| 177 | 195 | .name = name, |
| 178 | 196 | .target = target, |
| ... | ... | @@ -181,6 +199,8 @@ pub fn addObjLlvm(ctx: *Cases, name: []const u8, target: std.Build.ResolvedTarge |
| 181 | 199 | .output_mode = .Obj, |
| 182 | 200 | .deps = std.ArrayList(DepModule).init(ctx.arena), |
| 183 | 201 | .backend = .llvm, |
| 202 | .emit_bin = can_emit_bin, | |
| 203 | .emit_asm = can_emit_asm, | |
| 184 | 204 | }) catch @panic("out of memory"); |
| 185 | 205 | return &ctx.cases.items[ctx.cases.items.len - 1]; |
| 186 | 206 | } |
| ... | ... | @@ -371,6 +391,7 @@ fn addFromDirInner( |
| 371 | 391 | const output_mode = try manifest.getConfigForKeyAssertSingle("output_mode", std.builtin.OutputMode); |
| 372 | 392 | const pic = try manifest.getConfigForKeyAssertSingle("pic", ?bool); |
| 373 | 393 | const pie = try manifest.getConfigForKeyAssertSingle("pie", ?bool); |
| 394 | const emit_asm = try manifest.getConfigForKeyAssertSingle("emit_asm", bool); | |
| 374 | 395 | const emit_bin = try manifest.getConfigForKeyAssertSingle("emit_bin", bool); |
| 375 | 396 | const imports = try manifest.getConfigForKeyAlloc(ctx.arena, "imports", []const u8); |
| 376 | 397 | |
| ... | ... | @@ -438,6 +459,7 @@ fn addFromDirInner( |
| 438 | 459 | .backend = backend, |
| 439 | 460 | .files = .init(ctx.arena), |
| 440 | 461 | .case = null, |
| 462 | .emit_asm = emit_asm, | |
| 441 | 463 | .emit_bin = emit_bin, |
| 442 | 464 | .is_test = is_test, |
| 443 | 465 | .output_mode = output_mode, |
| ... | ... | @@ -663,7 +685,10 @@ pub fn lowerToBuildSteps( |
| 663 | 685 | |
| 664 | 686 | switch (case.case.?) { |
| 665 | 687 | .Compile => { |
| 666 | // Force the binary to be emitted if requested. | |
| 688 | // Force the assembly/binary to be emitted if requested. | |
| 689 | if (case.emit_asm) { | |
| 690 | _ = artifact.getEmittedAsm(); | |
| 691 | } | |
| 667 | 692 | if (case.emit_bin) { |
| 668 | 693 | _ = artifact.getEmittedBin(); |
| 669 | 694 | } |
| ... | ... | @@ -761,6 +786,8 @@ const TestManifestConfigDefaults = struct { |
| 761 | 786 | .run_translated_c => "Obj", |
| 762 | 787 | .cli => @panic("TODO test harness for CLI tests"), |
| 763 | 788 | }; |
| 789 | } else if (std.mem.eql(u8, key, "emit_asm")) { | |
| 790 | return "false"; | |
| 764 | 791 | } else if (std.mem.eql(u8, key, "emit_bin")) { |
| 765 | 792 | return "true"; |
| 766 | 793 | } else if (std.mem.eql(u8, key, "is_test")) { |
| ... | ... | @@ -802,6 +829,7 @@ const TestManifest = struct { |
| 802 | 829 | trailing_bytes: []const u8 = "", |
| 803 | 830 | |
| 804 | 831 | const valid_keys = std.StaticStringMap(void).initComptime(.{ |
| 832 | .{ "emit_asm", {} }, | |
| 805 | 833 | .{ "emit_bin", {} }, |
| 806 | 834 | .{ "is_test", {} }, |
| 807 | 835 | .{ "output_mode", {} }, |