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
C++ compilers: Be sane with standard libraries #85189
Conversation
Seeing that this is such a massive rebuild, on I am all ears on how we can do more nix and less bash to make the inevitable follow-up work easier. Maybe we could purely concat lists for all those |
25260c6
to
881d8cc
Compare
@@ -8181,14 +8180,6 @@ in | |||
stripped = false; | |||
})); | |||
|
|||
libstdcxxHook = makeSetupHook |
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.
We may need a migration or warning for this.
It may not be actively used though
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.
aliases.nix should be enough.
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 am not sure what should be aliased?
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.
Not aliased but we need a throw
statement in aliases.nix
that generates a warning stating that this file has been removed.
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.
Ah! sounds good.
@@ -115,7 +109,7 @@ stdenv.mkDerivation { | |||
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an | |||
# unused middle-ground name that evokes both. | |||
inherit bintools; | |||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile; |
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.
This may be used outside by wrappers outside of nixpkgs. might be worth keeping, but just as meta-information.
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.
It might be, but I think that's bad :)
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.
There's no good way to use libraries that want these c flags without some meta-info like this. For instance bindgen in rust or anything that uses libclang. If we're going to be removing it, we should at least have a replacement.
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.
see #26474 for why this was exported
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.
Right I would rather have a more general way to get flags and just this one in particular. The default part (i.e. miy get overriden) is no good too.
@@ -178,9 +178,9 @@ stdenv.mkDerivation ({ | |||
|
|||
BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-cflags) \ |
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.
Maybe we should just expose all of these flags in the cc-wrapper ? Something like stdenv.cc.cflags_compile
and stdenv.cc.ld_flags
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.
that is the pre-substituted values since we don't know the actual values at evaluation
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.
It would be nice to uses more Nix so we did know the values. (e.g. have a nix boolean and then assert at run-time it was correct.)
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 think that requires Nix-level setup-hooks to work correctly. I think that might be too ambitious for now.
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'm thinking something like /nix-support/get-cflags.sh
which does all of this for you.
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.
Well getting all the -I flags for other packaged requires that, but not just the std library stuff I think.
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.
Right these should just need the basic c/c++ headers and library paths.
9427d9c
to
de07048
Compare
I think we can also remove some of the old hacks like in https://github.com/NixOS/nixpkgs/pull/26709/files too |
Does that change here? I would expect this to still only include it for clang++. Come to think of it, wouldn't |
@@ -115,7 +109,7 @@ stdenv.mkDerivation { | |||
# Binutils, and Apple's "cctools"; "bintools" as an attempt to find an | |||
# unused middle-ground name that evokes both. | |||
inherit bintools; | |||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang default_cxx_stdlib_compile; | |||
inherit libc nativeTools nativeLibc nativePrefix isGNU isClang; |
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.
Would it make sense to expose the libc++ of the compiler, similar to libc?
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.
Yeah, though null
for libstdc++
is rather unfortunate. Oh well, all the more reason to get on splitting up the GCC derivation.
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.
Perhaps for now cc.libcxx = gcc
would make sense? Maybe that could also solve cc ? gcc
.
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'm on the fence about this---I do want to get rid of cc.gcc
but it's a bit disingenous unless we can somehow filter the other libraries out. Maybe we can leave that for a follow-up PR?
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.
#91293 got rid of cc.gcc
here.
Yeah, you're right - I was forgetting what the issue was there. We still need CXX to be used. |
a7808ca
to
995989a
Compare
995989a
to
604b60d
Compare
OK with the last push I have both |
We also have some tools that consume the c/c++ standard includes: cquery, clang-tools and ccls |
604b60d
to
a385085
Compare
eba5f1f
to
9e62a88
Compare
9e62a88
to
f3f7612
Compare
As it turns out those are not affected by this change. I removed cquery last week. Clangd and CCLS only take the libcxx include path as input. I remember to use |
OK, it evals! I don't think we need any more back-compat stuff ATM, but happy to add things in requested. |
NIX_CXXSTDLIB_COMPILE has been removed in NixOS#85189 and NixOS#85189 (comment) remommends using the files in ${clang}/nix-support to find the correct flags to pass to libclang.
Motivation for this change
This is long overdue, @LnL7 Time for you to say "I told you so!" :).
CC @matthewbauer @TravisWhitaker
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)