-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
cc-wrapper: expose a single, consistent libcxx #282221
Changes from all commits
0226f32
cfaec16
e4aa7b8
bc45b42
c204e65
a8d6548
c940f6e
f565379
34c3989
895dbe8
9d96656
caab415
1bb69e8
8670f50
ad34020
eca13b3
0917ca9
587ee6e
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 |
---|---|---|
|
@@ -55,6 +55,26 @@ | |
, includeFortifyHeaders ? null | ||
}: | ||
|
||
let libcxx_args = libcxx; in | ||
let | ||
stdenv = stdenvNoCC; | ||
|
||
useGccForLibs = useCcForLibs | ||
&& libcxx_args == null | ||
&& !stdenv.targetPlatform.isDarwin | ||
&& !(stdenv.targetPlatform.useLLVM or false) | ||
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false) | ||
&& !(stdenv.targetPlatform.isiOS or false) | ||
&& gccForLibs != null; | ||
|
||
libcxx = | ||
if libcxx_args != null | ||
then libcxx_args | ||
else if useGccForLibs | ||
then lib.getLib gccForLibs | ||
else null; | ||
Comment on lines
+70
to
+75
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.
|
||
in | ||
|
||
with lib; | ||
|
||
assert nativeTools -> !propagateDoc && nativePrefix != ""; | ||
|
@@ -64,7 +84,6 @@ assert !(nativeLibc && noLibc); | |
assert (noLibc || nativeLibc) == (libc == null); | ||
|
||
let | ||
stdenv = stdenvNoCC; | ||
inherit (stdenv) hostPlatform targetPlatform; | ||
|
||
includeFortifyHeaders' = if includeFortifyHeaders != null | ||
|
@@ -100,17 +119,7 @@ let | |
expand-response-params = | ||
lib.optionalString ((buildPackages.stdenv.hasCC or false) && buildPackages.stdenv.cc != "/dev/null") (import ../expand-response-params { inherit (buildPackages) stdenv; }); | ||
|
||
useGccForLibs = useCcForLibs | ||
&& libcxx == null | ||
&& !stdenv.targetPlatform.isDarwin | ||
&& !(stdenv.targetPlatform.useLLVM or false) | ||
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false) | ||
&& !(stdenv.targetPlatform.isiOS or false) | ||
&& gccForLibs != null; | ||
gccForLibs_solib = getLib gccForLibs | ||
+ optionalString (targetPlatform != hostPlatform) "/${targetPlatform.config}"; | ||
|
||
# Analogously to cc_solib and gccForLibs_solib | ||
# Analogously to cc_solib | ||
libcxx_solib = "${lib.getLib libcxx}/lib"; | ||
|
||
# The following two functions, `isGccArchSupported` and | ||
|
@@ -394,7 +403,7 @@ stdenv.mkDerivation { | |
|
||
strictDeps = true; | ||
propagatedBuildInputs = [ bintools ] ++ extraTools ++ optionals cc.langD or cc.langJava or false [ zlib ]; | ||
depsTargetTargetPropagated = optional (libcxx != null) libcxx ++ extraPackages; | ||
depsTargetTargetPropagated = optional (libcxx_args != null) libcxx_args ++ extraPackages; | ||
|
||
setupHooks = [ | ||
../setup-hooks/role.bash | ||
|
@@ -437,11 +446,11 @@ stdenv.mkDerivation { | |
## | ||
+ optionalString (useGccForLibs && isClang) '' | ||
|
||
echo "-B${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-cflags | ||
echo "-B${libcxx}/lib/gcc/${targetPlatform.config}/${libcxx.version}" >> $out/nix-support/cc-cflags | ||
'' | ||
+ optionalString useGccForLibs '' | ||
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags | ||
echo "-L${gccForLibs_solib}/lib" >> $out/nix-support/cc-ldflags | ||
echo "-L${libcxx}/lib/gcc/${targetPlatform.config}/${libcxx.version}" >> $out/nix-support/cc-ldflags | ||
echo "-L${libcxx_solib}/lib" >> $out/nix-support/cc-ldflags | ||
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 needs to be the following, right?
|
||
'' | ||
|
||
# TODO We would like to connect this to `useGccForLibs`, but we cannot yet | ||
|
@@ -516,27 +525,27 @@ stdenv.mkDerivation { | |
|
||
# We have a libc++ directly, we have one via "smuggled" GCC, or we have one | ||
# bundled with the C compiler because it is GCC | ||
+ optionalString (libcxx != null || (useGccForLibs && gccForLibs.langCC or false) || (isGNU && cc.langCC or false)) '' | ||
+ optionalString (libcxx_args != null || (useGccForLibs && gccForLibs.langCC or false) || (isGNU && cc.langCC or false)) '' | ||
touch "$out/nix-support/libcxx-cxxflags" | ||
touch "$out/nix-support/libcxx-ldflags" | ||
'' | ||
# Adding -isystem flags should be done only for clang; gcc | ||
# already knows how to find its own libstdc++, and adding | ||
# additional -isystem flags will confuse gfortran (see | ||
# https://github.com/NixOS/nixpkgs/pull/209870#issuecomment-1500550903) | ||
+ optionalString (libcxx == null && isClang && (useGccForLibs && gccForLibs.langCC or false)) '' | ||
+ optionalString (libcxx_args == null && isClang && (useGccForLibs && gccForLibs.langCC or false)) '' | ||
for dir in ${gccForLibs}${lib.optionalString (hostPlatform != targetPlatform) "/${targetPlatform.config}"}/include/c++/*; do | ||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags | ||
done | ||
for dir in ${gccForLibs}${lib.optionalString (hostPlatform != targetPlatform) "/${targetPlatform.config}"}/include/c++/*/${targetPlatform.config}; do | ||
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags | ||
done | ||
'' | ||
+ optionalString (libcxx.isLLVM or false) '' | ||
echo "-isystem ${lib.getDev libcxx}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags | ||
echo "-isystem ${lib.getDev libcxx.cxxabi}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags | ||
+ optionalString (libcxx_args.isLLVM or false) '' | ||
echo "-isystem ${lib.getDev libcxx_args}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags | ||
echo "-isystem ${lib.getDev libcxx_args.cxxabi}/include/c++/v1" >> $out/nix-support/libcxx-cxxflags | ||
echo "-stdlib=libc++" >> $out/nix-support/libcxx-ldflags | ||
echo "-l${libcxx.cxxabi.libName}" >> $out/nix-support/libcxx-ldflags | ||
echo "-l${libcxx_args.cxxabi.libName}" >> $out/nix-support/libcxx-ldflags | ||
'' | ||
|
||
## | ||
|
@@ -566,7 +575,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)) '' | ||
'' + optionalString (targetPlatform.isDarwin && (libcxx_args != null) && (cc.isClang or false)) '' | ||
echo " -L${libcxx_solib}" >> $out/nix-support/cc-ldflags | ||
'' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11752,7 +11752,7 @@ with pkgs; | |
boost = boost179; | ||
libclang = llvmPackages_15.libclang; | ||
clang = | ||
if stdenv.cc.libcxx != null | ||
if stdenv.cc.isClang | ||
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.
|
||
then (overrideLibcxx llvmPackages_15.stdenv).cc | ||
else clang_15; | ||
llvm = llvm_15; | ||
|
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.
Instead of the sequence of
let
-expressions one could also add@args
after the lambda's formal parameters, and then definelibcxx = if args.libcxx != null then args.libcxx else ...
. Can't say which one is less "wacky". I've seen (and committed) both in nixpkgs