cc-wrapper: allow non-clang compilers to use gccForLibs codepath

cc-wrapper has essentially two separate codepaths: the `gccForLibs`
codepath, used only by non-gcc (i.e. clang) compilers, and the
"other" codepath.

This PR allows non-clang compilers to opt-in to the `gccForLibs`
codepath (off by default).  To allow this, a new parameter
`ccForLibs` is exposed, since it would be extremely confusing for
gcc to be able to use `gccForLibs` but not do so by default.
This commit is contained in:
Adam Joseph 2023-02-13 13:50:09 -08:00
parent 2d285b1590
commit 6b6c06e5d7

View File

@ -9,7 +9,6 @@
, lib
, stdenvNoCC
, cc ? null, libc ? null, bintools, coreutils ? null, shell ? stdenvNoCC.shell
, gccForLibs ? null
, zlib ? null
, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, propagateDoc ? cc != null && cc ? man
@ -18,6 +17,9 @@
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {}
, libcxx ? null
, gccForLibs ? if useCcForLibs then cc else null
# same as `gccForLibs`, but generalized beyond clang
, useCcForLibs ? isClang
}:
with lib;
@ -61,7 +63,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 = isClang
useGccForLibs = useCcForLibs
&& libcxx == null
&& !stdenv.targetPlatform.isDarwin
&& !(stdenv.targetPlatform.useLLVM or false)