Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cudaPackages: enable cross-compilation (take two) #279952

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cbcc890
gcc: link $lib/lib -> $lib/$targetConfig correctly and consistently
Jan 20, 2024
cbde122
cudaPackages: cross-compilation attempt 2
Jan 10, 2024
c86cead
cuda-modules/setup-hooks: introduce helper function and add comments …
Jan 23, 2024
798c380
cuda-modules/generic-builders/manifest: use hostTarget autoAddCudaCom…
Jan 23, 2024
96cc899
cuda-modules/cuda/overrides: introduce helper function and add commen…
Jan 23, 2024
40aab07
cuda-modules/cuda/overrides: add TODOs for @connorbaker
Jan 23, 2024
2057e24
cuda-modules: use hostPlatform when downloading binaries
Jan 30, 2024
cd632d8
cuda-modules/setup-hooks: switch to directory structure
Mar 20, 2024
1aa56f0
cuda-modules: always get *Platform from stdenv
Mar 20, 2024
0fec676
cuda-modules/cuda/overrides: simplify callPackage then overrideAttrs …
Mar 20, 2024
ddcfff0
cudaPackages.cuda_nvcc: lib must precede static in outputs
Mar 20, 2024
112d38b
cuda-modules: add check for duplicate/misordered outputs
Mar 20, 2024
49676c7
cuda-modules: update note on use of lndir from path
Mar 20, 2024
868fa52
cudaPackages.saxpy: Jetson should be supported after CUDA 11.4
Mar 20, 2024
2b351b2
cuda-modules/cuda/overrides: remove unused callPackage arguments
Mar 20, 2024
0304c9b
cuda-modules/flags: use cudaAtLeast when possible
Mar 25, 2024
5b65222
cuda-modules/flags: ignore platforms in throwIf in isJetsonBuild
Mar 25, 2024
969ee2b
cuda-modules: fix deprecated uses of substituteInPlace replace flag
Mar 25, 2024
3b629a2
cuda-modules/cuda/overrides: backendStdenv.cc is already part of nati…
Mar 25, 2024
e55a9c2
cuda-modules/cuda/overrides: specify spliced packages for cuda_nvcc p…
Mar 25, 2024
f85d321
cuda-modules/generic-builders/manifest: wip cross-compilation
Mar 25, 2024
2b6a5a9
cuda-modules/saxpy: remove CMAKE_VERBOSE_MAKEFILE
Mar 25, 2024
77ea14b
cuda-modules/setup-hooks/setup-cuda-hook: factor out cc access
Mar 25, 2024
37d2448
cuda-modules/setup-hooks/auto-add-cuda-compat-runpath-hook: collapse …
Mar 25, 2024
de0bb6a
cuda-modules/setup-hooks: wip rewrite and set NIX_DEBUG=1
Mar 25, 2024
3297d6f
cudaPackages.cuda_nvcc: never has a lib output
Mar 26, 2024
1ac7621
cuda-modules/setup-hooks: wip
Mar 26, 2024
a026c05
cuda-modules/cuda/overrides: cuda_nvcc should not include references …
Mar 27, 2024
b340c3f
cudaPackages.nccl: remove unneeded makeFlags, specify splicing, and e…
Mar 27, 2024
0fa534c
cuda-modules/generic-builders/manifest: cleanup
Mar 27, 2024
1f077ac
cuda-modules/setup-hooks/mark-for-cudatoolkit-root-hook: rewrite
Mar 27, 2024
3fc9e9b
cudaPackages.saxpy: getDev/getLib would not always select the desired…
Mar 27, 2024
7fced11
cuda-modules/setup-hooks/setup-cuda-hook: rewrite
Mar 27, 2024
b43bf06
cudaPackages.saxpy: attempt manually setting flags for cross
Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkgs/development/compilers/gcc/common/builder.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib
, stdenv
, enableMultilib
, targetConfig
}:

let
Expand Down Expand Up @@ -196,6 +197,13 @@ originalAttrs: (stdenv.mkDerivation (finalAttrs: originalAttrs // {
mkdir -p "$out/''${targetConfig}/lib"
mkdir -p "''${!outputLib}/''${targetConfig}/lib"
'' +
# if cross-compiling, link from $lib/lib to $lib/${targetConfig}.
# since native-compiles have $lib/lib as a directory (not a
# symlink), this ensures that in every case we can assume that
# $lib/lib contains the .so files
lib.optionalString (with stdenv; targetPlatform.config != hostPlatform.config) ''
ln -Ts "''${!outputLib}/''${targetConfig}/lib" $lib/lib
'' +
# Make `lib64` symlinks to `lib`.
lib.optionalString (!enableMultilib && stdenv.hostPlatform.is64bit && !stdenv.hostPlatform.isMips64n32) ''
ln -s lib "$out/''${targetConfig}/lib64"
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/compilers/gcc/common/libgcc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ in
lib.optionalString (!langC) ''
rm -f $out/lib/libgcc_s.so*
''
+ lib.optionalString (hostPlatform != targetPlatform) ''
mkdir -p $lib/lib/
ln -s ${targetPlatformSlash}lib $lib/lib
''

# TODO(amjoseph): remove the `libgcc_s.so` symlinks below and replace them
# with a `-L${gccForLibs.libgcc}/lib` in cc-wrapper's
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/compilers/gcc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ let inherit version;
disableBootstrap = atLeast11 && !stdenv.hostPlatform.isDarwin && (atLeast12 -> !profiledCompiler);

inherit (stdenv) buildPlatform hostPlatform targetPlatform;
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;

patches = callFile ./patches {};

Expand All @@ -124,6 +125,7 @@ let inherit version;
buildPlatform
hostPlatform
targetPlatform
targetConfig
patches
crossMingw
stageNameAddon
Expand Down Expand Up @@ -329,7 +331,7 @@ lib.pipe ((callFile ./common/builder.nix {}) ({
++ optional (is7 && targetPlatform.isAarch64) "--enable-fix-cortex-a53-843419"
++ optional (is7 && targetPlatform.isNetBSD) "--disable-libcilkrts";

targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
inherit targetConfig;

buildFlags =
# we do not yet have Nix-driven profiling
Expand Down
4 changes: 1 addition & 3 deletions pkgs/development/cuda-modules/backend-stdenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
nvccCompatibilities,
cudaVersion,
pkgs,
overrideCC,
stdenv,
wrapCCWith,
stdenvAdapters,
stdenvAdapters
}:

let
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{hostPlatform, lib}:
{backendStdenv, lib}:
let
inherit (backendStdenv.hostPlatform) isx86_64 isLinux;

# Samples are built around the CUDA Toolkit, which is not available for
# aarch64. Check for both CUDA version and platform.
platformIsSupported = hostPlatform.isx86_64 && hostPlatform.isLinux;
platformIsSupported = isx86_64 && isLinux;

# Build our extension
extension =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ in
# CUTENSOR_ROOT is double escaped
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include"
--replace-fail "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include"
'';

CUTENSOR_ROOT = cutensor;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/cuda-modules/cuda-samples/extension.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
backendStdenv,
cudaVersion,
hostPlatform,
lib,
}:
let
Expand All @@ -26,7 +26,7 @@ let
# Samples are built around the CUDA Toolkit, which is not available for
# aarch64. Check for both CUDA version and platform.
cudaVersionIsSupported = cudaVersionToHash ? ${cudaVersion};
platformIsSupported = hostPlatform.isx86_64;
platformIsSupported = backendStdenv.hostPlatform.isx86_64;
isSupported = cudaVersionIsSupported && platformIsSupported;

# Build our extension
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/cuda-modules/cuda-samples/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}:
let
inherit (lib) lists strings;
inherit (backendStdenv.hostPlatform.parsed) cpu kernel;
in
backendStdenv.mkDerivation (
finalAttrs: {
Expand Down Expand Up @@ -64,7 +65,7 @@ backendStdenv.mkDerivation (
installPhase = ''
runHook preInstall

install -Dm755 -t $out/bin bin/${backendStdenv.hostPlatform.parsed.cpu.name}/${backendStdenv.hostPlatform.parsed.kernel.name}/release/*
install -Dm755 -t $out/bin bin/${cpu.name}/${kernel.name}/release/*

runHook postInstall
'';
Expand Down
Loading