diff options
author | Someone <sergei.kozlukov@aalto.fi> | 2024-01-13 09:36:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-13 09:36:02 +0000 |
commit | bc5ed95a042cf6131f04aba0314b51ff6ba58f73 (patch) | |
tree | 80eda3cccf3ad4d7f3d80b5bac4777d10dacf6d9 /pkgs/build-support | |
parent | 9b19f5e77dd906cb52dade0b7bd280339d2a1f3d (diff) | |
parent | ff1232cf6302a9f7c488946b90997b9c108bc41e (diff) | |
download | nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar.gz nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar.bz2 nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar.lz nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar.xz nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.tar.zst nixlib-bc5ed95a042cf6131f04aba0314b51ff6ba58f73.zip |
Merge pull request #275947 from SomeoneSerge/fix/cuda-cc-wrapper
cudaPackages.backendStdenv.cc: gccForLibs
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/cc-wrapper/default.nix | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 56075a032971..0b25d70b14a2 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -110,6 +110,9 @@ let gccForLibs_solib = getLib gccForLibs + optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; + # Analogously to cc_solib and gccForLibs_solib + libcxx_solib = "${lib.getLib libcxx}/lib"; + # The following two functions, `isGccArchSupported` and # `isGccTuneSupported`, only handle those situations where a flag # (`-march` or `-mtune`) is accepted by one compiler but rejected @@ -261,6 +264,25 @@ stdenv.mkDerivation { inherit bintools; inherit cc libc libcxx nativeTools nativeLibc nativePrefix isGNU isClang; + # Expose the C++ standard library we're using. See the comments on "General + # libc++ support". This is also relevant when using older gcc than the + # stdenv's, as may be required e.g. by CUDAToolkit's nvcc. + cxxStdlib = + let + givenLibcxx = libcxx.isLLVM or false; + givenGccForLibs = useGccForLibs && gccForLibs.langCC or false; + in + if (!givenLibcxx) && givenGccForLibs then + { kind = "libstdc++"; package = gccForLibs; solib = gccForLibs_solib; } + else if givenLibcxx then + { kind = "libc++"; package = libcxx; solib = libcxx_solib;} + else + # We're probably using the `libstdc++` that came with our `gcc`. + # TODO: this is maybe not always correct? + # TODO: what happens when `nativeTools = true`? + { kind = "libstdc++"; package = cc; solib = cc_solib; } + ; + emacsBufferSetup = pkgs: '' ; We should handle propagation here too (mapc @@ -440,6 +462,13 @@ stdenv.mkDerivation { echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags echo "-L${gccForLibs_solib}/lib" >> $out/nix-support/cc-ldflags '' + # The above "fix" may be incorrect; gcc.cc.lib doesn't contain a + # `target-triple` dir but the correct fix may be to just remove the above? + # + # For clang it's not necessary (see `--gcc-toolchain` below) and for other + # situations adding in the above will bring in lots of other gcc libraries + # (i.e. sanitizer libraries, `libatomic`, `libquadmath`) besides just + # `libstdc++`; this may actually break clang. # TODO We would like to connect this to `useGccForLibs`, but we cannot yet # because `libcxxStdenv` on linux still needs this. Maybe someday we'll @@ -564,7 +593,7 @@ stdenv.mkDerivation { echo "$ccLDFlags" >> $out/nix-support/cc-ldflags echo "$ccCFlags" >> $out/nix-support/cc-cflags '' + optionalString (targetPlatform.isDarwin && (libcxx != null) && (cc.isClang or false)) '' - echo " -L${lib.getLib libcxx}/lib" >> $out/nix-support/cc-ldflags + echo " -L${libcxx_solib}" >> $out/nix-support/cc-ldflags '' ## |