Skip to content

cudaPackages.cuda_nvcc: wrap binary so NVCC can always find compiler#465329

Merged
SomeoneSerge merged 1 commit intoNixOS:masterfrom
ConnorBaker:fix/wrap-cuda-nvcc
Nov 28, 2025
Merged

cudaPackages.cuda_nvcc: wrap binary so NVCC can always find compiler#465329
SomeoneSerge merged 1 commit intoNixOS:masterfrom
ConnorBaker:fix/wrap-cuda-nvcc

Conversation

@ConnorBaker
Copy link
Contributor

@ConnorBaker ConnorBaker commented Nov 26, 2025

  • Wrap NVCC so it can always find a compatible compiler on the path.
  • Set compiler-bindir in nvcc.profile instead of in setupCudaHook so it is always set, even when NVCC is run in ad-hoc fashion in installed environments rather than inside mkDerivation.

These changes needed to be made to allow the tests for pycuda (#465047) to work.

I was able to build python3Packages.onnxruntime and firefox with:

{pkgs}: {
  allowUnfreePredicate = pkgs._cuda.lib.allowUnfreeCudaPredicate;
  cudaCapabilities = [ "8.9" ];
  cudaForwardCompat = false;
  cudaSupport = true;
}

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@ConnorBaker ConnorBaker self-assigned this Nov 26, 2025
@ConnorBaker ConnorBaker added the 6.topic: cuda Parallel computing platform and API label Nov 26, 2025
@ConnorBaker ConnorBaker marked this pull request as ready for review November 26, 2025 18:56
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. labels Nov 26, 2025
Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
@SomeoneSerge SomeoneSerge added this pull request to the merge queue Nov 26, 2025
@@ -92,8 +92,6 @@ setupCUDAToolkitCompilers() {
export CUDAHOSTCXX="@ccFullPath@"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to break up the hook's dependency on the cc too 🤔 Because now we have 3 references all from different places

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Nov 26, 2025
@SomeoneSerge SomeoneSerge removed this pull request from the merge queue due to a manual request Nov 26, 2025

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah damn this is off by 1 again: nvcc here is hostTarget, and cc - buildHost

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH, we never made cross actually work, might as well postpone the larping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc is unspliced but backendStdenv is spliced and from pkgsHostTarget (the default package set drawn from by callPackage) so I would hope cc is also from hostTarget.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nooo that's the thing about stdenvs, they're always offset by -1:

$ nix eval -f "<nixpkgs>" --argstr crossSystem aarch64-linux stdenv.cc.name
"aarch64-unknown-linux-gnu-gcc-wrapper-14.3.0"

But maybe we should merge regardless and fix whenever

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah screw it

@SomeoneSerge SomeoneSerge added this pull request to the merge queue Nov 28, 2025
Merged via the queue into NixOS:master with commit b39ee51 Nov 28, 2025
36 of 38 checks passed
@SomeoneSerge SomeoneSerge deleted the fix/wrap-cuda-nvcc branch November 28, 2025 10:47
@github-project-automation github-project-automation bot moved this from New to ✅ Done in CUDA Team Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cuda Parallel computing platform and API 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants