Describe the bug
The context, copied pretty much as is from matrix: cudaPackages.cuda_nvcc builds cuda programs, and behind the scenes it uses gcc for that. This is controlled by the CMAKE_CUDA_HOST_COMPILER variable.
If we just set CMAKE_CUDA_HOST_COMPILER to cudaPackages.cudatoolkit.cc (which currently equals wrapCCWith { cc = gcc11Stdenv.cc.cc; libcxx = gcc12Stdenv.cc.cc.lib; }), the build ends up still linking gcc11's libstdc++, which is explicitly not what we're trying to do, and results in broken builds
If we make a customStdenv = overrideCC stdenv (wrapCCWith ( ... }) (currently, cudaPackages.backendStdenv, to be renamed into cudaStdenv) and use its mkDerivation to build the cuda program, it correctly links gcc12's libstdc++.
This is unexpected, because the actual host compiler (e.g. used for .cc and .cpp files) in the derivation is still gcc12. Gcc11 is only visible to the build through the aforementioned CMAKE_CUDA_HOST_COMPILER and it is wrapped anyway
Steps To Reproduce
- Unsuccessful usage of
wrapCCWith ...
- Successful usage of
overrideCC (wrapCCWith ...)
Another version of the same example: https://gist.github.com/SomeoneSerge/cc47a75885f8b9ea267456675e115cfe#file-vanilla-log-L59
Expected behavior
Both builds link gcc12's libstdc++ and succeed
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
wrapCCWith practically just adds the chosen libstdc++ into propagatedBuildInput, and we maybe abuse the function
Notify maintainers
@NixOS/cuda-maintainers
Describe the bug
The context, copied pretty much as is from matrix:
cudaPackages.cuda_nvccbuilds cuda programs, and behind the scenes it uses gcc for that. This is controlled by theCMAKE_CUDA_HOST_COMPILERvariable.If we just set
CMAKE_CUDA_HOST_COMPILERtocudaPackages.cudatoolkit.cc(which currently equalswrapCCWith { cc = gcc11Stdenv.cc.cc; libcxx = gcc12Stdenv.cc.cc.lib; }), the build ends up still linking gcc11's libstdc++, which is explicitly not what we're trying to do, and results in broken buildsIf we make a
customStdenv = overrideCC stdenv (wrapCCWith ( ... })(currently,cudaPackages.backendStdenv, to be renamed intocudaStdenv) and use itsmkDerivationto build the cuda program, it correctly links gcc12's libstdc++.This is unexpected, because the actual host compiler (e.g. used for .cc and .cpp files) in the derivation is still gcc12. Gcc11 is only visible to the build through the aforementioned
CMAKE_CUDA_HOST_COMPILERand it is wrapped anywaySteps To Reproduce
wrapCCWith ...cppzmqfromtarget_link_librariesand observing the output oflddin the logs)stdenv = pkgs.stdenv)overrideCC (wrapCCWith ...)stdenv = overrideCC (wrapCCWith ...))Another version of the same example: https://gist.github.com/SomeoneSerge/cc47a75885f8b9ea267456675e115cfe#file-vanilla-log-L59
Expected behavior
Both builds link gcc12's libstdc++ and succeed
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
wrapCCWithpractically just adds the chosen libstdc++ intopropagatedBuildInput, and we maybe abuse the functionNotify maintainers
@NixOS/cuda-maintainers