@@ -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" )
@@ -762,18 +766,53 @@ def test_program_options_as_bytes_nvvm_unsupported_option():
762766
763767@nvvm_available
764768def test_nvvm_program_options_as_bytes_numba_debug ():
765- """numba_debug must be plumbed through to libNVVM as -- numba-debug
766- (see #1287) ."""
769+ """numba_debug must be plumbed through to libNVVM as -numba-debug
770+ (see #1287, #2570). libNVVM rejects the double-dashed spelling ."""
767771 options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
768772 nvvm_bytes = options .as_bytes ("nvvm" )
769- assert b"--numba-debug" in nvvm_bytes
773+ assert b"-numba-debug" in nvvm_bytes
774+ assert b"--numba-debug" not in nvvm_bytes
770775 assert b"-g" in nvvm_bytes
771776
772777
778+ @pytest .mark .agent_authored (model = "claude-opus-5[1m]" )
779+ def test_nvvm_options_reject_double_dash ():
780+ """The guard must name a double-dashed option rather than let libNVVM
781+ reject it with an opaque error (see #2570)."""
782+ from cuda .core ._program import _assert_single_dashed_nvvm_options
783+
784+ _assert_single_dashed_nvvm_options (["-arch=compute_80" , "-g" , "-numba-debug" ])
785+
786+ with pytest .raises (RuntimeError , match = r"--numba-debug.*double-dashed" ):
787+ _assert_single_dashed_nvvm_options (["-arch=compute_80" , "--numba-debug" ])
788+
789+
790+ @nvvm_available
791+ @pytest .mark .agent_authored (model = "claude-opus-5[1m]" )
792+ def test_nvvm_program_options_as_bytes_all_single_dashed ():
793+ """Every option cuda.core emits to libNVVM must be single-dashed, because
794+ libNVVM rejects the double-dashed spelling of all of them (see #2570).
795+ This covers every NVVM-supported field of ProgramOptions."""
796+ options = ProgramOptions (
797+ arch = "sm_80" ,
798+ debug = True ,
799+ numba_debug = True ,
800+ device_code_optimize = True ,
801+ ftz = True ,
802+ prec_sqrt = True ,
803+ prec_div = True ,
804+ fma = True ,
805+ )
806+ nvvm_bytes = options .as_bytes ("nvvm" )
807+ assert nvvm_bytes , "expected at least one emitted option"
808+ offenders = [o for o in nvvm_bytes if o .startswith (b"--" )]
809+ assert not offenders , f"double-dashed options are rejected by libNVVM: { offenders } "
810+
811+
773812@nvvm_available
774813@pytest .mark .skipif (
775814 not _check_nvvm_supports_numba_debug (),
776- reason = "installed libNVVM does not recognize -- numba-debug (needs CTK 13.2+) " ,
815+ reason = "installed libNVVM does not recognize -numba-debug" ,
777816)
778817def test_nvvm_program_numba_debug (init_cuda , nvvm_ir ):
779818 options = ProgramOptions (arch = "sm_80" , debug = True , numba_debug = True )
0 commit comments