Skip to content

Commit

Permalink
cudaPackages.cuda_nvcc: use gcc from pkgsHostTarget
Browse files Browse the repository at this point in the history
i.e. with the same offsets as nvcc itself
  • Loading branch information
SomeoneSerge committed Jan 12, 2024
1 parent 8eda4c3 commit c45e1b6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkgs/development/cuda-modules/cuda/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,20 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
);

cuda_nvcc = prev.cuda_nvcc.overrideAttrs (
oldAttrs: {
oldAttrs:
let
# This replicates the logic in backend-stdenv.nix, except the stdenv uses
# buildPackages and we use pkgsHostTarget.
ccForLibs-wrapper = final.pkgs.stdenv.cc;
gccMajorVersion = final.nvccCompatibilities.${cudaVersion}.gccMaxMajorVersion;
cc = final.pkgs.wrapCCWith {
cc = final.pkgs."gcc${gccMajorVersion}".cc;
useCcForLibs = true;
gccForLibs = ccForLibs-wrapper.cc;
};
cxxStdlibDir = ccForLibs-wrapper.cxxStdlib.solib;
in
{

outputs = oldAttrs.outputs ++ lists.optionals (!(builtins.elem "lib" oldAttrs.outputs)) [ "lib" ];

Expand Down Expand Up @@ -119,8 +132,8 @@ attrsets.filterAttrs (attr: _: (builtins.hasAttr attr prev)) {
cat << EOF >> bin/nvcc.profile
# Fix a compatible backend compiler
PATH += ${lib.getBin final.backendStdenv.cc}/bin:
LIBRARIES += "-L${lib.getLib final.backendStdenv.nixpkgsCompatibleLibstdcxx}/lib"
PATH += ${lib.getBin cc}/bin:
LIBRARIES += "-L${cxxStdlibDir}/lib"
# Expose the split-out nvvm
LIBRARIES =+ -L''${!outputBin}/nvvm/lib
Expand Down

0 comments on commit c45e1b6

Please sign in to comment.