-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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.backendStdenv.cc: gccForLibs #275947
Changes from all commits
223283c
290ea23
210ce38
8eda4c3
c45e1b6
e6e2799
497f611
ff1232c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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`? | ||
Comment on lines
+281
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any further notes or comments on the two TODOs? If they're still TODO, would you mind adding a bit more description to them or making an issue to follow up on them so they're not lost? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CC @rrbutani |
||
{ 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. | ||
Comment on lines
+465
to
+471
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which above fix is this referring to? The other edit you made in the file is almost 200 lines earlier. If it's referring to that, can we move the comment there? This block seems out of place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were left after cherry picking
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rrbutani why did you find it necessary to comment out dc6a8f9#diff-ad7b67d4a92a2db43281c9c45aa74c32341a554fbca0b6b25be593f4648abb5eR330? I kept things as they were after @danielfullmer's PR |
||
|
||
# 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 | ||
'' | ||
|
||
## | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,6 +237,30 @@ rec { | |
}); | ||
}); | ||
|
||
useLibsFrom = modelStdenv: targetStdenv: | ||
let | ||
ccForLibs = modelStdenv.cc.cc; | ||
cc = pkgs.wrapCCWith { | ||
/* NOTE: cc.cc is the unwrapped compiler. Should we respect the old | ||
* wrapper instead? */ | ||
cc = targetStdenv.cc.cc; | ||
Comment on lines
+244
to
+246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the part I was asking about in https://matrix.to/#/%23stdenv%3Anixos.org/%24jhoyDDs4_NDkhlkmBihy57cv9OSaRkg8zO17cTbr5-0?via=someonex.net&via=matrix.org&via=kde.org&via=matrix.mit.edu |
||
|
||
/* NOTE(originally by rrbutani): | ||
* Normally the `useCcForLibs`/`gccForLibs` mechanism is used to get a | ||
* clang based `cc` to use `libstdc++` (from gcc). | ||
* | ||
* Here we (ab)use it to use a `libstdc++` from a different `gcc` than our | ||
* `cc`. | ||
* | ||
* Note that this does not inhibit our `cc`'s lib dir from being added to | ||
* cflags/ldflags (see `cc_solib` in `cc-wrapper`) but this is okay: our | ||
* `gccForLibs`'s paths should take precedence. */ | ||
useCcForLibs = true; | ||
gccForLibs = ccForLibs; | ||
}; | ||
in | ||
overrideCC targetStdenv cc; | ||
|
||
useMoldLinker = stdenv: let | ||
bintools = stdenv.cc.bintools.override { | ||
extraBuildCommands = '' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected to see this
Why do we (or do we not) nest when cross-compiling (beside the pain it causes our tooling, apparently #279952 (comment)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bc it was that way for darwin and i kept it, just moved to a variable