@@ -93,12 +93,16 @@ def _check_nvvm_arch(arch: str) -> bool:
9393
9494
9595def _check_nvvm_supports_numba_debug () -> bool :
96- """Check if the installed libNVVM recognizes --numba-debug (CTK 13.2+)."""
96+ """Check if the installed libNVVM recognizes -numba-debug.
97+
98+ libNVVM only accepts single-dashed options, so the double-dashed spelling
99+ used by NVRTC is rejected by every libNVVM version.
100+ """
97101 if not _has_check_nvvm_compiler_options ():
98102 return False
99103 from cuda .bindings .utils import check_nvvm_compiler_options
100104
101- return check_nvvm_compiler_options (["-- numba-debug" ])
105+ return check_nvvm_compiler_options (["-numba-debug" ])
102106
103107
104108@pytest .fixture (scope = "session" )
@@ -773,18 +777,53 @@ def test_program_options_as_bytes_nvvm_unsupported_option():
773777
774778@nvvm_available
775779def test_nvvm_program_options_as_bytes_numba_debug ():
776- """numba_debug must be plumbed through to libNVVM as -- numba-debug
777- (see #1287) ."""
780+ """numba_debug must be plumbed through to libNVVM as -numba-debug
781+ (see #1287, #2570). libNVVM rejects the double-dashed spelling ."""
778782 options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
779783 nvvm_bytes = options .as_bytes ("nvvm" )
780- assert b"--numba-debug" in nvvm_bytes
784+ assert b"-numba-debug" in nvvm_bytes
785+ assert b"--numba-debug" not in nvvm_bytes
781786 assert b"-g" in nvvm_bytes
782787
783788
789+ @pytest .mark .agent_authored (model = "claude-opus-5[1m]" )
790+ def test_nvvm_options_reject_double_dash ():
791+ """The guard must name a double-dashed option rather than let libNVVM
792+ reject it with an opaque error (see #2570)."""
793+ from cuda .core ._program import _assert_single_dashed_nvvm_options
794+
795+ _assert_single_dashed_nvvm_options (["-arch=compute_80" , "-g" , "-numba-debug" ])
796+
797+ with pytest .raises (RuntimeError , match = r"--numba-debug.*double-dashed" ):
798+ _assert_single_dashed_nvvm_options (["-arch=compute_80" , "--numba-debug" ])
799+
800+
801+ @nvvm_available
802+ @pytest .mark .agent_authored (model = "claude-opus-5[1m]" )
803+ def test_nvvm_program_options_as_bytes_all_single_dashed ():
804+ """Every option cuda.core emits to libNVVM must be single-dashed, because
805+ libNVVM rejects the double-dashed spelling of all of them (see #2570).
806+ This covers every NVVM-supported field of ProgramOptions."""
807+ options = ProgramOptions (
808+ arch = "sm_80" ,
809+ debug = True ,
810+ numba_debug = True ,
811+ device_code_optimize = True ,
812+ ftz = True ,
813+ prec_sqrt = True ,
814+ prec_div = True ,
815+ fma = True ,
816+ )
817+ nvvm_bytes = options .as_bytes ("nvvm" )
818+ assert nvvm_bytes , "expected at least one emitted option"
819+ offenders = [o for o in nvvm_bytes if o .startswith (b"--" )]
820+ assert not offenders , f"double-dashed options are rejected by libNVVM: { offenders } "
821+
822+
784823@nvvm_available
785824@pytest .mark .skipif (
786825 not _check_nvvm_supports_numba_debug (),
787- reason = "installed libNVVM does not recognize -- numba-debug (needs CTK 13.2+) " ,
826+ reason = "installed libNVVM does not recognize -numba-debug" ,
788827)
789828def test_nvvm_program_numba_debug (init_cuda , nvvm_ir ):
790829 options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
0 commit comments