diff options
| author | Guillaume Wenzek <gwenzek@users.noreply.github.com> | 2022-03-01 23:26:43 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-12 14:25:59 -0500 |
| commit | f000f8a59a8bf1121ecbe9b60ae50cc0218d3ba3 (patch) | |
| tree | f4578be5065b377c3c158562206311ed4d28f99d /src/link | |
| parent | 5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63 (diff) | |
| download | zig-f000f8a59a8bf1121ecbe9b60ae50cc0218d3ba3.tar.gz zig-f000f8a59a8bf1121ecbe9b60ae50cc0218d3ba3.zip | |
fix nvptx test failure #10968
allow test cases to chose wether to link libc or not.
default behavior is to not link libc, except for `exeUsingLLVMBackend`
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/NvPtx.zig | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/link/NvPtx.zig b/src/link/NvPtx.zig index 77613cdc1d..5d0f578d1d 100644 --- a/src/link/NvPtx.zig +++ b/src/link/NvPtx.zig @@ -25,8 +25,21 @@ base: link.File, llvm_object: *LlvmObject, pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { - if (!build_options.have_llvm) return error.TODOArchNotSupported; + if (!build_options.have_llvm) return error.PtxArchNotSupported; + if (!options.use_llvm) return error.PtxArchNotSupported; + switch (options.target.cpu.arch) { + .nvptx, .nvptx64 => {}, + else => return error.PtxArchNotSupported, + } + + switch (options.target.os.tag) { + // TODO: does it also work with nvcl ? + .cuda => {}, + else => return error.PtxArchNotSupported, + } + + const llvm_object = try LlvmObject.create(gpa, options); const nvptx = try gpa.create(NvPtx); nvptx.* = .{ .base = .{ @@ -35,32 +48,19 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx { .file = null, .allocator = gpa, }, - .llvm_object = undefined, + .llvm_object = llvm_object, }; - switch (options.target.cpu.arch) { - .nvptx, .nvptx64 => {}, - else => return error.TODOArchNotSupported, - } - - switch (options.target.os.tag) { - // TODO: does it also work with nvcl ? - .cuda => {}, - else => return error.TODOOsNotSupported, - } - return nvptx; } pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Options) !*NvPtx { if (!build_options.have_llvm) @panic("nvptx target requires a zig compiler with llvm enabled."); - if (!options.use_llvm) return error.TODOArchNotSupported; + if (!options.use_llvm) return error.PtxArchNotSupported; assert(options.object_format == .nvptx); const nvptx = try createEmpty(allocator, options); - errdefer nvptx.base.destroy(); log.info("Opening .ptx target file {s}", .{sub_path}); - nvptx.llvm_object = try LlvmObject.create(allocator, options); return nvptx; } @@ -117,6 +117,5 @@ pub fn flushModule(self: *NvPtx, comp: *Compilation) !void { }; hack_comp.bin_file.options.emit = null; } - return try self.llvm_object.flushModule(hack_comp); } |
