@@ -92,6 +92,15 @@ def _check_nvvm_arch(arch: str) -> bool:
9292 return check_nvvm_compiler_options ([f"-arch={ arch } " ])
9393
9494
95+ def _check_nvvm_supports_numba_debug () -> bool :
96+ """Check if the installed libNVVM recognizes --numba-debug (CTK 13.2+)."""
97+ if not _has_check_nvvm_compiler_options ():
98+ return False
99+ from cuda .bindings .utils import check_nvvm_compiler_options
100+
101+ return check_nvvm_compiler_options (["--numba-debug" ])
102+
103+
95104@pytest .fixture (scope = "session" )
96105def nvvm_ir ():
97106 """Generate working NVVM IR with proper version metadata.
@@ -303,6 +312,8 @@ def test_cpp_program_pch_status_none_without_pch(init_cuda):
303312 ProgramOptions (prec_div = True ),
304313 ProgramOptions (prec_sqrt = True ),
305314 ProgramOptions (fma = True ),
315+ # Plumb-through; no-op at link time. See #1287.
316+ ProgramOptions (debug = True , numba_debug = True ),
306317]
307318if not is_culink_backend :
308319 options += [
@@ -552,7 +563,6 @@ def test_nvvm_program_with_single_extra_source(nvvm_ir):
552563
553564 nvvm = _get_nvvm_module ()
554565 major , minor , debug_major , debug_minor = nvvm .ir_version ()
555- # helper nvvm ir for multiple module loading
556566 helper_nvvmir = f"""target triple = "nvptx64-unknown-cuda"
557567target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
558568
@@ -740,6 +750,33 @@ def test_program_options_as_bytes_nvvm_unsupported_option():
740750 options .as_bytes ("nvvm" )
741751
742752
753+ @nvvm_available
754+ def test_nvvm_program_options_as_bytes_numba_debug ():
755+ """numba_debug must be plumbed through to libNVVM as --numba-debug
756+ (see #1287)."""
757+ options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
758+ nvvm_bytes = options .as_bytes ("nvvm" )
759+ assert b"--numba-debug" in nvvm_bytes
760+ assert b"-g" in nvvm_bytes
761+
762+
763+ @nvvm_available
764+ @pytest .mark .skipif (
765+ not _check_nvvm_supports_numba_debug (),
766+ reason = "installed libNVVM does not recognize --numba-debug (needs CTK 13.2+)" ,
767+ )
768+ def test_nvvm_program_numba_debug (init_cuda , nvvm_ir ):
769+ options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
770+ program = Program (nvvm_ir , "nvvm" , options )
771+ try :
772+ assert program .backend == "NVVM"
773+ result = program .compile ("ptx" )
774+ assert isinstance (result , ObjectCode )
775+ assert len (result .code ) > 0
776+ finally :
777+ program .close ()
778+
779+
743780def test_program_options_repr ():
744781 """ProgramOptions.__repr__ returns a human-readable string."""
745782 opts = ProgramOptions (name = "mykernel" , arch = "sm_80" )
0 commit comments