@@ -728,77 +728,6 @@ def test_llvm_keeps_sccache_prefix(self, monkeypatch):
728728 # The launcher prefixes CC/CXX only; the shared linker command is the bare compiler.
729729 assert os .environ ["LDCXXSHARED" ] == "clang++ -shared -Wl,-O1"
730730
731- @pytest .mark .agent_authored (model = "grok-4.6" )
732- def test_llvm_keeps_host_sccache_path (self , monkeypatch ):
733- if sys .platform == "win32" :
734- pytest .skip ("llvm only valid on Linux" )
735- launcher = "/host/usr/local/bin/sccache"
736- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "llvm" )
737- monkeypatch .setenv ("CC" , f"{ launcher } cc" )
738- monkeypatch .setenv ("CXX" , f"{ launcher } c++" )
739- _name , _cc , _cxx , _cargs , _largs = build_hooks ._resolve_toolchain ()
740- assert os .environ ["CC" ] == f"{ launcher } clang"
741- assert os .environ ["CXX" ] == f"{ launcher } clang++"
742-
743- @pytest .mark .agent_authored (model = "grok-4.6" )
744- def test_explicit_toolchain_preserves_sysconfig_ldcxxshared_extras (self , monkeypatch ):
745- if sys .platform == "win32" :
746- pytest .skip ("gnu/llvm only valid on Linux" )
747- extras = "-shared -Wl,-O1 -Wl,-Bsymbolic-functions"
748- values = {
749- "CC" : "gcc" ,
750- "CXX" : "g++" ,
751- "LDSHARED" : f"gcc { extras } " ,
752- "LDCXXSHARED" : f"g++ { extras } " ,
753- }
754- monkeypatch .setattr (build_hooks .sysconfig , "get_config_var" , lambda name : values .get (name ))
755- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "llvm" )
756- build_hooks ._resolve_toolchain ()
757- assert os .environ ["CC" ] == "clang"
758- assert os .environ ["CXX" ] == "clang++"
759- assert os .environ ["LDCXXSHARED" ] == f"clang++ { extras } "
760- assert "LDSHARED" not in os .environ
761-
762- @pytest .mark .agent_authored (model = "grok-4.6" )
763- def test_explicit_gnu_keeps_conda_sysconfig_flags (self , monkeypatch ):
764- if sys .platform == "win32" :
765- pytest .skip ("gnu/llvm only valid on Linux" )
766- prefix = "-pthread -B /compat"
767- extras = f"{ prefix } -shared -Wl,-rpath,/lib"
768- values = {
769- "CC" : f"gcc { prefix } " ,
770- "CXX" : f"g++ { prefix } " ,
771- "LDSHARED" : f"gcc { extras } " ,
772- "LDCXXSHARED" : f"g++ { extras } " ,
773- }
774- monkeypatch .setattr (build_hooks .sysconfig , "get_config_var" , lambda name : values .get (name ))
775- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "gnu" )
776- build_hooks ._resolve_toolchain ()
777- assert os .environ ["CC" ] == "gcc"
778- assert os .environ ["CXX" ] == "g++"
779- assert os .environ ["LDCXXSHARED" ] == values ["LDCXXSHARED" ]
780- assert "LDSHARED" not in os .environ
781-
782- @pytest .mark .agent_authored (model = "grok-4.6" )
783- def test_explicit_llvm_keeps_conda_sysconfig_flags (self , monkeypatch ):
784- if sys .platform == "win32" :
785- pytest .skip ("gnu/llvm only valid on Linux" )
786- prefix = "-pthread -B /compat"
787- extras = f"{ prefix } -shared -Wl,-rpath,/lib"
788- values = {
789- "CC" : f"gcc { prefix } " ,
790- "CXX" : f"g++ { prefix } " ,
791- "LDSHARED" : f"gcc { extras } " ,
792- "LDCXXSHARED" : f"g++ { extras } " ,
793- }
794- monkeypatch .setattr (build_hooks .sysconfig , "get_config_var" , lambda name : values .get (name ))
795- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "llvm" )
796- build_hooks ._resolve_toolchain ()
797- assert os .environ ["CC" ] == "clang"
798- assert os .environ ["CXX" ] == "clang++"
799- assert os .environ ["LDCXXSHARED" ] == f"clang++ { extras } "
800- assert "LDSHARED" not in os .environ
801-
802731 @pytest .mark .agent_authored (model = "claude-sonnet-5.5" )
803732 def test_explicit_toolchain_prefers_env_ldcxxshared (self , monkeypatch ):
804733 if sys .platform == "win32" :
@@ -822,17 +751,6 @@ def test_explicit_toolchain_falls_back_to_ldshared_then_shared_flag(self, monkey
822751 build_hooks ._resolve_toolchain ()
823752 assert os .environ ["LDCXXSHARED" ] == "clang++ -shared"
824753
825- @pytest .mark .agent_authored (model = "claude-sonnet-5.5" )
826- def test_explicit_toolchain_is_idempotent (self , monkeypatch ):
827- if sys .platform == "win32" :
828- pytest .skip ("gnu/llvm only valid on Linux" )
829- _fake_sysconfig (monkeypatch , LDCXXSHARED = "g++ -pthread -shared -Wl,-O1" )
830- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "llvm" )
831- build_hooks ._resolve_toolchain ()
832- first = os .environ ["LDCXXSHARED" ]
833- build_hooks ._resolve_toolchain ()
834- assert os .environ ["LDCXXSHARED" ] == first == "clang++ -pthread -shared -Wl,-O1"
835-
836754
837755class TestWithSccache :
838756 """_with_sccache: keep a leading sccache token, swap the compiler."""
@@ -857,24 +775,13 @@ def test_bare_or_unrelated_cc_returns_compiler(self):
857775class TestWithCompiler :
858776 """_with_compiler: replace the compiler executable, keep following flags."""
859777
860- @pytest .mark .agent_authored (model = "grok-4.6" )
861- def test_replaces_leading_compiler_keeps_flags (self ):
862- assert build_hooks ._with_compiler ("g++ -shared -Wl,-O1" , "clang++" ) == "clang++ -shared -Wl,-O1"
863-
864778 @pytest .mark .agent_authored (model = "grok-4.6" )
865779 def test_keeps_flags_that_were_part_of_sysconfig_cxx (self ):
866780 assert (
867781 build_hooks ._with_compiler ("g++ -pthread -B /compat -shared -Wl,-rpath,/lib" , "clang++" )
868782 == "clang++ -pthread -B /compat -shared -Wl,-rpath,/lib"
869783 )
870784
871- @pytest .mark .agent_authored (model = "grok-4.6" )
872- def test_replaces_prefixed_compiler_path (self ):
873- assert (
874- build_hooks ._with_compiler ("x86_64-linux-gnu-gcc -shared -Wl,-z,relro" , "clang" )
875- == "clang -shared -Wl,-z,relro"
876- )
877-
878785 @pytest .mark .agent_authored (model = "grok-4.6" )
879786 def test_compiler_only_command_returns_compiler (self ):
880787 assert build_hooks ._with_compiler ("g++" , "clang++" ) == "clang++"
@@ -898,10 +805,6 @@ def test_keeps_env_prefix(self):
898805 build_hooks ._with_compiler ("env LIBRARY_PATH=/custom/lib g++ -shared" , "clang++" )
899806 == "env LIBRARY_PATH=/custom/lib clang++ -shared"
900807 )
901- assert (
902- build_hooks ._with_compiler ("/usr/bin/env A=1 B=2 g++ -shared -Wl,-O1" , "clang++" )
903- == "/usr/bin/env A=1 B=2 clang++ -shared -Wl,-O1"
904- )
905808
906809
907810class TestDistutilsLinkerIntegration :
@@ -931,24 +834,20 @@ def _cxx_link_command(compiler, tmp_path, monkeypatch):
931834 return command
932835
933836 @pytest .mark .agent_authored (model = "claude-sonnet-5.5" )
934- @pytest .mark .parametrize ("toolchain, compiler_cxx" , [("gnu" , "g++" ), ("llvm" , "clang++" )])
935- def test_linker_so_cxx_swaps_compiler_and_keeps_sysconfig_flags (self , monkeypatch , toolchain , compiler_cxx ):
837+ def test_linker_so_cxx_swaps_compiler_and_keeps_sysconfig_flags (self , monkeypatch ):
936838 if sys .platform != "linux" :
937839 pytest .skip ("gnu/llvm only valid on Linux" )
938840 sysconfig_ld = sysconfig .get_config_var ("LDCXXSHARED" )
939841 if not sysconfig_ld :
940842 pytest .skip ("this Python has no LDCXXSHARED" )
843+ # Everything from the first flag on, including operands such as ``-B /path``.
941844 tokens = shlex .split (sysconfig_ld )
942- if os .path .basename (tokens [0 ]) == "env" :
943- pytest .skip ("sysconfig LDCXXSHARED has an env prefix" )
944- # Everything from the first flag on, including operands such as the
945- # path in ``-B /path``.
946845 first_flag = next ((i for i , tok in enumerate (tokens ) if tok .startswith ("-" )), len (tokens ))
947846 expected_tail = tokens [first_flag :]
948- monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , toolchain )
847+ monkeypatch .setenv ("CUDA_PYTHON_TOOLCHAIN" , "llvm" )
949848 build_hooks ._resolve_toolchain ()
950849 linker = self ._customized_compiler ().linker_so_cxx
951- assert linker [0 ] == compiler_cxx
850+ assert linker [0 ] == "clang++"
952851 assert linker [1 : 1 + len (expected_tail )] == expected_tail
953852
954853 @pytest .mark .agent_authored (model = "claude-sonnet-5.5" )
0 commit comments