Commit ffd85ffcda

Ali Cheraghi <alichraghi@proton.me>
2025-04-20 19:15:01
revive nvptx linkage
1 parent 13541bc
Changed files (2)
src/link/NvPtx.zig
@@ -53,6 +53,7 @@ pub fn createEmpty(
             .tag = .nvptx,
             .comp = comp,
             .emit = emit,
+            .zcu_object_sub_path = emit.sub_path,
             .gc_sections = options.gc_sections orelse false,
             .print_gc_sections = options.print_gc_sections,
             .stack_size = options.stack_size orelse 0,
@@ -116,11 +117,7 @@ pub fn flushModule(self: *NvPtx, arena: Allocator, tid: Zcu.PerThread.Id, prog_n
     if (build_options.skip_non_native)
         @panic("Attempted to compile for architecture that was disabled by build configuration");
 
-    // The code that was here before mutated the Compilation's file emission mechanism.
-    // That's not supposed to happen in flushModule, so I deleted the code.
-    _ = arena;
-    _ = self;
-    _ = prog_node;
     _ = tid;
-    @panic("TODO: rewrite the NvPtx.flushModule function");
+
+    try self.base.emitLlvmObject(arena, self.llvm_object, prog_node);
 }
src/main.zig
@@ -3081,6 +3081,12 @@ fn buildOutputType(
 
     const target = main_mod.resolved_target.result;
 
+    if (target.cpu.arch.isNvptx()) {
+        if (emit_bin != .no and create_module.resolved_options.use_llvm) {
+            fatal("cannot emit PTX binary with the LLVM backend; only '-femit-asm' is supported", .{});
+        }
+    }
+
     if (target.os.tag == .windows and major_subsystem_version == null and minor_subsystem_version == null) {
         major_subsystem_version, minor_subsystem_version = switch (target.os.version_range.windows.min) {
             .nt4 => .{ 4, 0 },