Unverified Commit 83537eca authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

[Backport release-25.11] cudaPackages.cuda_nvcc: wrap binary so NVCC can...

[Backport release-25.11] cudaPackages.cuda_nvcc: wrap binary so NVCC can always find compiler (#465957)
parents 0c8ca2a4 a5335c04
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
  cuda_cccl,
  lib,
  libnvvm,
  makeBinaryWrapper,
}:
buildRedist (finalAttrs: {
  redistName = "cuda";
@@ -22,6 +23,10 @@ buildRedist (finalAttrs: {
  # The nvcc and cicc binaries contain hard-coded references to /usr
  allowFHSReferences = true;

  nativeBuildInputs = [
    makeBinaryWrapper
  ];

  # Entries here will be in nativeBuildInputs when cuda_nvcc is in nativeBuildInputs
  propagatedBuildInputs = [ setupCudaHook ];

@@ -144,13 +149,19 @@ buildRedist (finalAttrs: {
        EOF
      ''
      # Add the dependency on backendStdenv.cc to the nvcc.profile.
      # NOTE: NVCC explodes in horrifying fashion if GCC is not on PATH -- it fails even before
      # reading nvcc.profile!
      + ''
        nixLog "adding backendStdenv.cc to nvcc.profile"
        nixLog "setting compiler-bindir to backendStdenv.cc in nvcc.profile"
        cat << EOF >> "''${!outputBin:?}/bin/nvcc.profile"

        # Fix a compatible backend compiler
        PATH += "${backendStdenv.cc}/bin":
        compiler-bindir = ${backendStdenv.cc}/bin
        EOF

        nixLog "wrapping nvcc to add backendStdenv.cc to its PATH"
        wrapProgramBinary \
          "''${!outputBin:?}/bin/nvcc" \
          --prefix PATH : ${lib.makeBinPath [ backendStdenv.cc ]}
      ''
    );

+0 −3
Original line number Diff line number Diff line
@@ -5,9 +5,6 @@ makeSetupHook {

  substitutions.setupCudaHook = placeholder "out";

  # Point NVCC at a compatible compiler
  substitutions.ccRoot = "${backendStdenv.cc}";

  # Required in addition to ccRoot as otherwise bin/gcc is looked up
  # when building CMakeCUDACompilerId.cu
  substitutions.ccFullPath = "${backendStdenv.cc}/bin/${backendStdenv.cc.targetPrefix}c++";
+0 −2
Original line number Diff line number Diff line
@@ -92,8 +92,6 @@ setupCUDAToolkitCompilers() {
    export CUDAHOSTCXX="@ccFullPath@"
  fi

  appendToVar NVCC_PREPEND_FLAGS "--compiler-bindir=@ccRoot@/bin"

  # NOTE: We set -Xfatbin=-compress-all, which reduces the size of the compiled
  #   binaries. If binaries grow over 2GB, they will fail to link. This is a problem for us, as
  #   the default set of CUDA capabilities we build can regularly cause this to occur (for