diff --git a/pkgs/development/compilers/gcc/all.nix b/pkgs/development/compilers/gcc/all.nix index 70b4b75369a7dc9..618e2a6f24a9c75 100644 --- a/pkgs/development/compilers/gcc/all.nix +++ b/pkgs/development/compilers/gcc/all.nix @@ -11,6 +11,7 @@ , cloog_0_18_0, cloog , lowPrio , wrapCC +, __splicedPackages }@args: let @@ -27,7 +28,7 @@ let libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then args.libcCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor majorMinorVersion else { }; isl = if stdenv.isDarwin then null - else if atLeast "9" then isl_0_20 + else if atLeast "9" then __splicedPackages.isl_0_20 else if atLeast "7" then isl_0_17 else if atLeast "6" then (if stdenv.targetPlatform.isRedox then isl_0_17 else isl_0_14) else if atLeast "4.9" then isl_0_11 diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index cbe38f1127f3820..a066b9eeeb0b0a3 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -1,5 +1,5 @@ { lib, stdenv -, targetPackages +, targetPackages_bintools , withoutTargetLibc, libcCross , threadsCross @@ -56,8 +56,8 @@ let crossConfigureFlags = # Ensure that -print-prog-name is able to find the correct programs. [ - "--with-as=${if targetPackages.stdenv.cc.bintools.isLLVM then binutils else targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" - "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-as=${if targetPackages_bintools.isLLVM then binutils else targetPackages_bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages_bintools}/bin/${targetPlatform.config}-ld" ] ++ (if withoutTargetLibc then [ "--disable-libssp" diff --git a/pkgs/development/compilers/gcc/common/dependencies.nix b/pkgs/development/compilers/gcc/common/dependencies.nix index a38cdcb9e20f5f6..99a50305fe4aac7 100644 --- a/pkgs/development/compilers/gcc/common/dependencies.nix +++ b/pkgs/development/compilers/gcc/common/dependencies.nix @@ -2,7 +2,6 @@ , stdenv , version , buildPackages -, targetPackages , texinfo , which , gettext @@ -12,6 +11,7 @@ , gmp , mpfr , libmpc +, targetPackages_bintools , libucontext ? null , libxcrypt ? null , cloog ? null @@ -62,7 +62,7 @@ in depsBuildTarget = ( if hostPlatform == buildPlatform then [ - targetPackages.stdenv.cc.bintools # newly-built gcc will be used + targetPackages_bintools # newly-built gcc will be used ] else assert targetPlatform == hostPlatform; [ # build != host == target stdenv.cc @@ -77,7 +77,7 @@ in ] ++ optionals (lib.versionAtLeast version "10") [ libxcrypt ] ++ [ - targetPackages.stdenv.cc.bintools # For linking code at run-time + targetPackages_bintools # For linking code at run-time ] ++ optionals (lib.versionOlder version "5" && cloog != null) [ cloog ] ++ optionals (isl != null) [ isl ] diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 01f1725130803a9..a6c8a5fec5efee4 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +{ lib, stdenv, fetchurl, fetchpatch, noSysDirs , langC ? true, langCC ? true, langFortran ? false , langAda ? false , langObjC ? stdenv.targetPlatform.isDarwin @@ -14,6 +14,7 @@ , texinfo ? null , perl ? null # optional, for texi2pod (then pod2man) , gmp, mpfr, libmpc, gettext, which, patchelf, binutils +, targetPackages_bintools , isl ? null # optional, for the Graphite optimization framework. , zlib ? null , libucontext ? null @@ -173,7 +174,7 @@ let inherit version; reproducibleBuild staticCompiler stdenv - targetPackages + targetPackages_bintools texinfo threadsCross which diff --git a/pkgs/development/libraries/cracklib/default.nix b/pkgs/development/libraries/cracklib/default.nix index 4c0badf3df7cefd..16db40bdf9cfa6d 100644 --- a/pkgs/development/libraries/cracklib/default.nix +++ b/pkgs/development/libraries/cracklib/default.nix @@ -1,5 +1,6 @@ let version = "2.9.11"; in { stdenv, lib, buildPackages, fetchurl, zlib, gettext +, cracklib , lists ? [ (fetchurl { url = "https://github.com/cracklib/cracklib/releases/download/v${version}/cracklib-words-${version}.gz"; hash = "sha256-popxGjE1c517Z+nzYLM/DU7M+b1/rE0XwNXkVqkcUXo="; @@ -15,7 +16,7 @@ stdenv.mkDerivation rec { hash = "sha256-yosEmjwtOyIloejRXWE3mOvHSOOVA4jtomlN5Qe6YCA="; }; - nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) buildPackages.cracklib; + nativeBuildInputs = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) cracklib; buildInputs = [ zlib gettext ]; postPatch = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 63d02c8f085704d..bbc9ed5c8afd7ae 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -1,3 +1,67 @@ +let + + # + # This is a list of pnames of packages that have failed to splice. + # Every one of these is an unfixed bug. Please fix them instead + # of taking shameful behavior, you scoundrel! + # + list-of-shame = + builtins.listToAttrs + (builtins.map + (name: { inherit name; value = true; }) + [ + # shame on you, python + "pypa-build-hook.sh" + "pypa-install-hook" + "pytest-check-hook" + "python-catch-conflicts-hook" + "python-imports-check-hook.sh" + "python-namespaces-hook.sh" + "python-output-dist-hook" + "python-remove-bin-bytecode-hook" + "python-remove-tests-dir-hook" + "python-remove-tests-dir-hook" + "python3-3.11.5-env" + "setuptools-check-hook" + "setuptools-setup-hook" + "unittest-check-hook" + "wrap-python-hook" + "wrap-python-hook" + "wrap-python-hook" + + # shame on you, llvm! + "llvm" + "compiler-rt" + "libcxx" + "libcxxabi" + "libunwind" + + # shame on you, embedded ARM! + "arm-none-eabi-stage-final-gcc-wrapper" + "arm-none-eabi-binutils-wrapper" + + # wasm doesn't care about shamefulness, so I won't bother... + "rustc-wasm32" + + # windows + # has overrides which discard splicing + # improvement: convert makeScope to makeScopeWithSplicing' + # may not fix it but it'll improve the set + # https://github.com/NixOS/nixpkgs/blob/53aa767c849b159cdb8c59dce4a5a44f167fc31b/pkgs/os-specific/windows/default.nix#L20 + "mcfgthreads" + "i686-w64-mingw32-stage-final-gcc-wrapper" + "x86_64-w64-mingw32-stage-final-gcc-wrapper" + + # other shameful derivations + "git-minimal" + "busybox" + "avr-stage-final-gcc-wrapper" + "boost-build" + "cmake-boot" + "perl" # only for libxcrypt; we should fix this + ]); +in + { lib, config }: stdenv: @@ -283,32 +347,89 @@ else let references = nativeBuildInputs ++ buildInputs ++ propagatedNativeBuildInputs ++ propagatedBuildInputs; + getSpliced = type: dep: + dep.__spliced or + (let approximate-pname = dep.pname or dep.name; in + assert + (dep?stdenv && + dep.stdenv.buildPlatform != dep.stdenv.targetPlatform && + + # I can't test on Darwin, so let's just ignore it for now. + !dep.stdenv.buildPlatform.isDarwin && + !dep.stdenv.hostPlatform.isDarwin && + !dep.stdenv.targetPlatform.isDarwin && + + !(list-of-shame ? ${approximate-pname}) + ) + + # Hi there! If you're reading this, it's probably + # because the line below caused your PR to fail CI. + # Don't panic! Most likely, what happened is that you + # used one of the following as a dependency: + # + # - `buildPackages.something` + # - `targetPackages.something` + # - `pkgs{Build,Host,Target}{Build,Host,Target}.something` + # + # You can't use those as dependencies (i.e. in a + # `buildInputs`, `nativeBuildInputs`, or + # `deps{Build,Host,Target}{Build,Host,Target}` + # attribute). The reason is a bit obscure, but the fix + # is easy: just use `something` instead! The explicit + # packagesets (the three bullet points above) are mainly + # for when you need to reference a package with string + # interpolation (e.g. "cat blah | ${buildPackages.jq}"). + # For dependencies, you control which packageset is used + # by *which attribute you put the dependency in* -- if + # you put it in `depsBuildHost`, it will get pulled from + # `pkgsBuildHost`. + # + # Please take a moment to try to fix your PR. If you + # can't get it fixed, ping @amjoseph-nixpkgs who can + # help you fix it. If this is a crisis situation and + # the future of humanity depends on your PR passing CI + # pronto, you can mute the warning by adding your + # package's `pname` to the `list-of-shame` at the top of + # this file. But please don't do that. + # + -> lib.warn + ''derivation ${attrs.pname or "!!no pname!!"}: + unspliced ${type} dependency ${approximate-pname} + build=${dep.stdenv.buildPlatform.config} + host=${dep.stdenv.hostPlatform.config} + target=${dep.stdenv.targetPlatform.config} + For advice on fixing this, read the comment above the lib.warn that produced this message. + '' true; + {}); + dependencies = map (map chooseDevOutputs) [ [ - (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) - (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs')) - (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) + (map (drv: (getSpliced "build-build" drv).buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) + (map (drv: (getSpliced "build-host" drv).buildHost or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs')) + (map (drv: (getSpliced "build-target" drv).buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) ] [ - (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) + (map (drv: (getSpliced "host-host" drv).hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) + #(map (drv: (getSpliced "host-target" drv).hostTarget or drv) (checkDependencyList "buildInputs" buildInputs')) ] [ - (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) + (map (drv: (getSpliced "target-target" drv).targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) ] ]; propagatedDependencies = map (map chooseDevOutputs) [ [ - (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuildPropagated" depsBuildBuildPropagated)) - (map (drv: drv.__spliced.buildHost or drv) (checkDependencyList "propagatedNativeBuildInputs" propagatedNativeBuildInputs)) - (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTargetPropagated" depsBuildTargetPropagated)) + (map (drv: (getSpliced "build-build propagated" drv).buildBuild or drv) (checkDependencyList "depsBuildBuildPropagated" depsBuildBuildPropagated)) + (map (drv: (getSpliced "build-host propagated" drv).buildHost or drv) (checkDependencyList "propagatedNativeBuildInputs" propagatedNativeBuildInputs)) + (map (drv: (getSpliced "build-target propagated" drv).buildTarget or drv) (checkDependencyList "depsBuildTargetPropagated" depsBuildTargetPropagated)) ] [ - (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) + (map (drv: (getSpliced "host-host propagated" drv).hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) (map (drv: drv.__spliced.hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) + #(map (drv: (getSpliced "host-target propagated" drv).hostTarget or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) ] [ - (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) + (map (drv: (getSpliced "target-target propagated" drv).targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) ] ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3712806cf012a60..dfe24a7ab9b6996 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15948,6 +15948,10 @@ with pkgs; then overrideCC stdenv buildPackages.llvmPackages.clangNoLibc else gccCrossLibcStdenv; + # This needs to have a top-level entry here in all-packages.nix in + # order to be spliced. + targetPackages_bintools = targetPackages.stdenv.cc.bintools; + # The GCC used to build libc for the target platform. Normal gccs will be # built with, and use, that cross-compiled libc. gccWithoutTargetLibc = assert stdenv.targetPlatform != stdenv.hostPlatform; let @@ -15961,12 +15965,12 @@ with pkgs; reproducibleBuild = true; profiledCompiler = false; - isl = if !stdenv.isDarwin then isl_0_20 else null; + isl = if !stdenv.isDarwin then __splicedPackages.isl_0_20 else null; withoutTargetLibc = true; langCC = false; libcCross = libcCross1; - targetPackages.stdenv.cc.bintools = binutilsNoLibc; + targetPackages_bintools = __splicedPackages.binutilsNoLibc; enableShared = stdenv.targetPlatform.hasSharedLibraries @@ -16963,6 +16967,7 @@ with pkgs; }; }; }).overrideAttrs (old: { + pname = "rustc-wasm32"; configureFlags = old.configureFlags ++ ["--set=build.docs=false"]; }); @@ -18630,7 +18635,10 @@ with pkgs; enableGold = false; }; }); - binutilsNoLibc = wrapBintoolsWith { + binutilsNoLibc = + # this `if..then null else` is an ugly hack to prevent infinite recursion + if stdenv.hostPlatform == stdenv.targetPlatform then null else + wrapBintoolsWith { bintools = binutils-unwrapped; libc = preLibcCrossHeaders; };