Skip to content
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

Cross-compiling Nix to aarch64-darwin fails with infinite recursion #126829

Closed
domenkozar opened this issue Jun 14, 2021 · 14 comments · Fixed by #126844 or #348827
Closed

Cross-compiling Nix to aarch64-darwin fails with infinite recursion #126829

domenkozar opened this issue Jun 14, 2021 · 14 comments · Fixed by #126844 or #348827
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin

Comments

@domenkozar
Copy link
Member

Using Nix from master for better traceback:

$ NIX_PATH=~/dev ~/dev/nix/result/bin/nix-build '<nixpkgs>' -A pkgsCross.aarch64-darwin.nix --show-trace
error: infinite recursion encountered

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:17505:3:

        17504|
        17505|   openssl = openssl_1_1;
             |   ^
        17506|

       … while evaluating the attribute 'openssl'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:17505:3:

        17504|
        17505|   openssl = openssl_1_1;
             |   ^
        17506|

       … while evaluating 'optionalAttrs'

       at /home/ielectric/dev/nixpkgs/lib/attrsets.nix:353:25:

          352|   */
          353|   optionalAttrs = cond: as: if cond then as else {};
             |                         ^
          354|

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:65:24:

           64|           inherit (builtins.tryEval value0) success value;
           65|         in getOutputs (lib.optionalAttrs success value);
             |                        ^
           66|         getOutputs = value: lib.genAttrs

       … while evaluating 'genAttrs'

       at /home/ielectric/dev/nixpkgs/lib/attrsets.nix:313:21:

          312|   */
          313|   genAttrs = names: f:
             |                     ^
          314|     listToAttrs (map (n: nameValuePair n (f n)) names);

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:66:29:

           65|         in getOutputs (lib.optionalAttrs success value);
           66|         getOutputs = value: lib.genAttrs
             |                             ^
           67|           (value.outputs or (lib.optional (value ? out) "out"))

       … while evaluating 'getOutputs'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:66:22:

           65|         in getOutputs (lib.optionalAttrs success value);
           66|         getOutputs = value: lib.genAttrs
             |                      ^
           67|           (value.outputs or (lib.optional (value ? out) "out"))

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:65:12:

           64|           inherit (builtins.tryEval value0) success value;
           65|         in getOutputs (lib.optionalAttrs success value);
             |            ^
           66|         getOutputs = value: lib.genAttrs

       … while evaluating 'tryGetOutputs'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:63:25:

           62|         # on {}
           63|         tryGetOutputs = value0: let
             |                         ^
           64|           inherit (builtins.tryEval value0) success value;

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:78:30:

           77|           pkgsHostTarget = getOutputs valueHostTarget;
           78|           pkgsTargetTarget = tryGetOutputs valueTargetTarget;
             |                              ^
           79|         # Just recur on plain attrsets

       … while evaluating 'spliceReal'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:28:16:

           27|
           28|   spliceReal = { pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget
             |                ^
           29|                , pkgsHostHost, pkgsHostTarget

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:72:65:

           71|         # on to splice them together.
           72|         if lib.isDerivation defaultValue then augmentedValue // spliceReal {
             |                                                                 ^
           73|           pkgsBuildBuild = tryGetOutputs valueBuildBuild;

       … while evaluating anonymous lambda

       at /home/ielectric/dev/nixpkgs/pkgs/development/interpreters/python/cpython/default.nix:105:25:

          104|
          105|   buildInputs = filter (p: p != null) ([
             |                         ^
          106|     zlib bzip2 expat xz libffi gdbm sqlite readline ncurses openssl ]

       … from call site

       … while evaluating the attribute 'CPPFLAGS' of the derivation 'python3-3.8.9'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating the attribute 'buildInputs' of the derivation 'libxml2-2.9.12'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating the attribute 'buildInputs' of the derivation 'xar-1.6.1'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating the attribute 'buildInputs' of the derivation 'pbzx-1.0.2'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating the attribute 'nativeBuildInputs' of the derivation 'MacOSX-SDK-11.0.0'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating the attribute 'installPhase' of the derivation 'libSystem-11.0.0'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

       … while evaluating anonymous lambda

       at /home/ielectric/dev/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1:

            7|
            8| { name ? ""
             | ^
            9| , lib

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:69:16:

           68|     let
           69|       result = f origArgs;
             |                ^
           70|

       … while evaluating 'makeOverridable'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:67:24:

           66|   */
           67|   makeOverridable = f: origArgs:
             |                        ^
           68|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:121:8:

          120|       auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
          121|     in makeOverridable f (auto // args);
             |        ^
          122|

       … while evaluating 'callPackageWith'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:117:35:

          116|   */
          117|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          118|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:12091:7:

        12090|     } @ extraArgs:
        12091|       callPackage ../build-support/cc-wrapper (let self = {
             |       ^
        12092|     nativeTools = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeTools or false;

       … while evaluating 'wrapCCWith'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:12077:5:

        12076|   wrapCCWith =
        12077|     { cc
             |     ^
        12078|     , # This should be the only bintools runtime dep with this sort of logic. The

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:109:22:

          108|
          109|     libstdcxxClang = wrapCCWith rec {
             |                      ^
          110|       cc = tools.clang-unwrapped;

       … while evaluating the attribute 'libstdcxxClang'

       at /home/ielectric/dev/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:109:5:

          108|
          109|     libstdcxxClang = wrapCCWith rec {
             |     ^
          110|       cc = tools.clang-unwrapped;

       … while evaluating the attribute 'llvmPackages.clang'

       at /home/ielectric/dev/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:107:5:

          106|
          107|     clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
             |     ^
          108|

       … while evaluating the attribute 'cc.isGNU'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/default.nix:166:14:

          165|
          166|       inherit cc hasCC;
             |              ^
          167|     }

       … while evaluating 'optional'

       at /home/ielectric/dev/nixpkgs/lib/lists.nix:254:20:

          253|   */
          254|   optional = cond: elem: if cond then [elem] else [];
             |                    ^
          255|

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:105:29:

          104|       separateDebugInfo' = separateDebugInfo && stdenv.hostPlatform.isLinux && !(stdenv.hostPlatform.useLLVM or false);
          105|       outputs' = outputs ++ lib.optional separateDebugInfo' "debug";
             |                             ^
          106|

       … while evaluating anonymous lambda

       at //builtin/derivation.nix:5:1:
       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:407:10:

          406|          passthru)
          407|         (derivation derivationArg);
             |          ^
          408|

       … while evaluating 'extendDerivation'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:144:43:

          143|      the derivation itself and check a given condition when evaluating. */
          144|   extendDerivation = condition: passthru: drv:
             |                                           ^
          145|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:371:7:

          370|
          371|       lib.extendDerivation
             |       ^
          372|         validity.handled

       … while evaluating 'mkDerivation'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:22:5:

           21|   mkDerivation =
           22|     {
             |     ^
           23|

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/development/libraries/openssl/default.nix:26:4:

           25|   common = { version, sha256, patches ? [], withDocs ? false, extraMeta ? {} }:
           26|    stdenv.mkDerivation rec {
             |    ^
           27|     pname = "openssl";

       … while evaluating 'common'

       at /home/ielectric/dev/nixpkgs/pkgs/development/libraries/openssl/default.nix:25:12:

           24| let
           25|   common = { version, sha256, patches ? [], withDocs ? false, extraMeta ? {} }:
             |            ^
           26|    stdenv.mkDerivation rec {

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/development/libraries/openssl/default.nix:187:17:

          186|
          187|   openssl_1_1 = common {
             |                 ^
          188|     version = "1.1.1k";

       … while evaluating the attribute 'openssl_1_1'

       at /home/ielectric/dev/nixpkgs/pkgs/development/libraries/openssl/default.nix:187:3:

          186|
          187|   openssl_1_1 = common {
             |   ^
          188|     version = "1.1.1k";

       … while evaluating anonymous lambda

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:133:53:

          132|       pkgs = f origArgs;
          133|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                                     ^
          134|     in

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:69:16:

           68|     let
           69|       result = f origArgs;
             |                ^
           70|

       … while evaluating 'makeOverridable'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:67:24:

           66|   */
           67|   makeOverridable = f: origArgs:
             |                        ^
           68|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:133:36:

          132|       pkgs = f origArgs;
          133|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                    ^
          134|     in

       … while evaluating 'mkAttrOverridable'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:133:33:

          132|       pkgs = f origArgs;
          133|       mkAttrOverridable = name: _: makeOverridable (newArgs: (f newArgs).${name}) origArgs;
             |                                 ^
          134|     in

       … from call site

       … while evaluating the attribute 'openssl_1_1'

       … while evaluating the attribute 'openssl'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:17505:3:

        17504|
        17505|   openssl = openssl_1_1;
             |   ^
        17506|

       … while evaluating 'isDerivation'

       at /home/ielectric/dev/nixpkgs/lib/attrsets.nix:327:18:

          326|   */
          327|   isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
             |                  ^
          328|

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:72:12:

           71|         # on to splice them together.
           72|         if lib.isDerivation defaultValue then augmentedValue // spliceReal {
             |            ^
           73|           pkgsBuildBuild = tryGetOutputs valueBuildBuild;

       … while evaluating anonymous lambda

       at /home/ielectric/dev/nixpkgs/pkgs/tools/networking/curl/default.nix:1:1:

            1| { stdenv, lib, fetchurl, pkg-config, perl
             | ^
            2| , http2Support ? true, nghttp2

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:69:16:

           68|     let
           69|       result = f origArgs;
             |                ^
           70|

       … while evaluating 'makeOverridable'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:67:24:

           66|   */
           67|   makeOverridable = f: origArgs:
             |                        ^
           68|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:121:8:

          120|       auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
          121|     in makeOverridable f (auto // args);
             |        ^
          122|

       … while evaluating 'callPackageWith'

       at /home/ielectric/dev/nixpkgs/lib/customisation.nix:117:35:

          116|   */
          117|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          118|     let

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:3933:17:

         3932|
         3933|   curlMinimal = callPackage ../tools/networking/curl { };
             |                 ^
         3934|

       … while evaluating the attribute 'curl'

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/all-packages.nix:3927:3:

         3926|
         3927|   curl = curlMinimal.override {
             |   ^
         3928|     idnSupport = true;

       … while evaluating 'isDerivation'

       at /home/ielectric/dev/nixpkgs/lib/attrsets.nix:327:18:

          326|   */
          327|   isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
             |                  ^
          328|

       … from call site

       at /home/ielectric/dev/nixpkgs/pkgs/top-level/splice.nix:72:12:

           71|         # on to splice them together.
           72|         if lib.isDerivation defaultValue then augmentedValue // spliceReal {
             |            ^
           73|           pkgsBuildBuild = tryGetOutputs valueBuildBuild;

       … while evaluating anonymous lambda

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:152:17:

          151|           (map (drv: drv.__spliced.hostHost or drv) depsHostHost)
          152|           (map (drv: drv.crossDrv or drv) buildInputs)
             |                 ^
          153|         ]

       … from call site

       … while evaluating 'getOutput'

       at /home/ielectric/dev/nixpkgs/lib/attrsets.nix:486:23:

          485|   */
          486|   getOutput = output: pkg:
             |                       ^
          487|     if pkg.outputUnspecified or false

       … from call site

       … while evaluating the attribute 'buildInputs' of the derivation 'nix-aarch64-apple-darwin-2.3.12'

       at /home/ielectric/dev/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:

          200|         // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          201|           name =
             |           ^
          202|             let

@domenkozar domenkozar added the 0.kind: bug Something is broken label Jun 14, 2021
@domenkozar
Copy link
Member Author

Seems to be related to stdenv.cc.isGNU in openssl expression.

@domenkozar domenkozar added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jun 14, 2021
@sternenseemann
Copy link
Member

sternenseemann commented Jun 14, 2021

Minimal reproducer for this seems to be pkgsCross.aarch64-darwin.buildPackages.llvmPackages_11.clang or even pkgsCross.aarch64-darwin.buildPackages.llvmPackages_11.libstdcxxClang pkgsCross.aarch64-darwin.buildPackages.pbzx or rather pkgsCross.aarch64-darwin.buildPackages.python3.

@sternenseemann
Copy link
Member

My current theory is that pkgsCross.aarch64-darwin.buildPackages.python3 for some reason pulls in pkgsCross.aarch64-darwin.buildPackages.targetPackages.openssl instead of pkgsCross.aarch64-darwin.buildPackages.openssl as part of its buildInputs, but I can't quite figure out why.

@domenkozar
Copy link
Member Author

I wonder if it's somehow related to #49526 (although I imagine python3 uses callPackage).

@sternenseemann
Copy link
Member

It does seem like the usage of callPackage is what triggers the problem, i. e. this is a even more focused reproducer:

pkgsCross.aarch64-darwin.buildPackages.callPackage ({ openssl }: openssl) { }

@domenkozar
Copy link
Member Author

cc @thefloweringash as this once must have worked due to how bootstrap files were generated.

@sternenseemann
Copy link
Member

My current theory as to why this happens is the following (read with pkgsCross.aarch64-darwin):

  • buildPackages.python gets openssl via callPackage, so all our splicing stuff happens
  • Splicing involves getting a list of all outputs for multiple pkgsFooBar sets including pkgsTargetTarget
    tryGetOutputs = value0: let
    inherit (builtins.tryEval value0) success value;
    in getOutputs (lib.optionalAttrs success value);
    getOutputs = value: lib.genAttrs
    (value.outputs or (lib.optional (value ? out) "out"))
    (output: value.${output});
  • Evaluating the output lists requires knowing the output list for any given derivation for all the package sets this aspects whenever we evaluate this
  • openssl has an output list whose length depends on stdenv.cc.isGNU
  • stdenv.cc depends on buildPackages.openssl due to Libsystem / MacOSX-SDK's nativeBuildInputs (pbzx-> xar -> openssl / libxml2 -> python -> openssl)
  • When receiving openssl via callPackage, the splicing logic happens
  • All mentioned uses of openssl need a python which is equivalent to buildPackages.openssl; however due to splicing also the output list of (roughly) buildPackages.targetPackages.openssl needs to be evaluated
  • This output list however depends on buildPackages.targetPackages.stdenv.cc which completes the circle and causes the infinite recursion

If you set separateDebugInfo = false statically in openssl, the issue described here does not happen. This supports my hypothesis, so I'm fairly sure about this, but I'd love for someone more knowledgeable about splicing to comment on this — ccing @Ericson2314.

Note that if this is indeed how this happens, we have to rethink stuff like dynamically deciding separateDebugInfo in general because it is just asking for bootstrapping eval issues to happen unless these packages are unlikely to ever be used in relation to anything in buildPackages.

alyssais added a commit to alyssais/nixpkgs that referenced this issue Jun 14, 2021
stdenv depends on openssl, and isGNU depends on stdenv.

Thanks-to: sternenseemann <[email protected]>
Fixes: NixOS#126829
github-actions bot pushed a commit that referenced this issue Jun 14, 2021
stdenv depends on openssl, and isGNU depends on stdenv.

Thanks-to: sternenseemann <[email protected]>
Fixes: #126829
(cherry picked from commit 502de3c)
@domenkozar domenkozar reopened this Jun 15, 2021
@sternenseemann
Copy link
Member

When evaluating pkgsCross.aarch64-darwin.hello on x86_64-linux, we now have the following new, but related problem:

$ nix-instantiate -A pkgsCross.aarch64-darwin.hello --show-trace
error: while evaluating the attribute 'stdenv' of the derivation 'hello-aarch64-apple-darwin-2.10' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'defaultBuildInputs' of the derivation 'stdenv-linux' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/default.nix:93:14:
while evaluating the attribute 'disallowedRequisites' of the derivation 'apple-framework-CoreFoundation-11.0.0' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'MacOSX-SDK-11.0.0' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'buildInputs' of the derivation 'pbzx-1.0.2' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'buildInputs' of the derivation 'xar-1.6.1' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'buildInputs' of the derivation 'libxml2-2.9.12' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'postPatch' of the derivation 'python3-3.8.9' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating 'spliceReal' at /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:28:16, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:72:65:
while evaluating 'tryGetOutputs' at /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:63:25, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:78:30:
while evaluating 'getOutputs' at /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:66:22, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:65:12:
while evaluating 'genAttrs' at /home/lukas/src/nix/nixpkgs/lib/attrsets.nix:313:21, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:66:29:
while evaluating 'optionalAttrs' at /home/lukas/src/nix/nixpkgs/lib/attrsets.nix:353:25, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/splice.nix:65:24:
while evaluating the attribute 'bash' at /home/lukas/src/nix/nixpkgs/pkgs/top-level/all-packages.nix:10248:3:
while evaluating 'addMetaAttrs' at /home/lukas/src/nix/nixpkgs/lib/meta.nix:15:28, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/all-packages.nix:10248:10:
while evaluating 'callPackageWith' at /home/lukas/src/nix/nixpkgs/lib/customisation.nix:117:35, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/all-packages.nix:10248:19:
while evaluating 'makeOverridable' at /home/lukas/src/nix/nixpkgs/lib/customisation.nix:67:24, called from /home/lukas/src/nix/nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /home/lukas/src/nix/nixpkgs/pkgs/shells/bash/4.4.nix:1:1, called from /home/lukas/src/nix/nixpkgs/lib/customisation.nix:69:16:
while evaluating the attribute 'cc.bintools' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/default.nix:166:14:
while evaluating the attribute 'llvmPackages.clang' at /home/lukas/src/nix/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:107:5:
while evaluating the attribute 'libstdcxxClang' at /home/lukas/src/nix/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:109:5:
while evaluating 'wrapCCWith' at /home/lukas/src/nix/nixpkgs/pkgs/top-level/all-packages.nix:12091:5, called from /home/lukas/src/nix/nixpkgs/pkgs/development/compilers/llvm/11/default.nix:109:22:
while evaluating 'callPackageWith' at /home/lukas/src/nix/nixpkgs/lib/customisation.nix:117:35, called from /home/lukas/src/nix/nixpkgs/pkgs/top-level/all-packages.nix:12105:7:
while evaluating 'makeOverridable' at /home/lukas/src/nix/nixpkgs/lib/customisation.nix:67:24, called from /home/lukas/src/nix/nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /home/lukas/src/nix/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1, called from /home/lukas/src/nix/nixpkgs/lib/customisation.nix:69:16:
while evaluating the attribute 'installPhase' of the derivation 'libSystem-11.0.0' at /home/lukas/src/nix/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
infinite recursion encountered, at undefined position

Not sure how big the impact of this is in practice, but I fear this points at a fundamental risk to evaluation of cross package sets posed by the openssl derivation in its current form.

@domenkozar
Copy link
Member Author

Refs #66851

@stale
Copy link

stale bot commented May 2, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 2, 2022
@sternenseemann sternenseemann removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 2, 2022
@pwaller
Copy link
Contributor

pwaller commented Aug 12, 2022

Ping @Ericson2314, pkgsCross.aarch64-darwin remains broken and would be nice to have, in case the route to solution is obvious to you.

$ nix build --dry-run nixpkgs#pkgsCross.aarch64-darwin.stdenv.cc
error: infinite recursion encountered

       at /nix/store/d5c6h5p16jg2rna7db5y4s3y19dmwvx6-source/pkgs/top-level/all-packages.nix:12102:16:

        12101|   bash = lowPrio (callPackage ../shells/bash/5.1.nix {
        12102|     binutils = stdenv.cc.bintools;
             |                ^
        12103|   });
(use '--show-trace' to show detailed location information)

@sternenseemann
Copy link
Member

@pwaller There is no real solution afaik, since cross wouldn't work from x86_64-linux, only x86_64-darwin (which does) due to some impure stuff it needs.

This issue is mostly about a nice to have cleanup of the darwin stdenv bootstrapping.

@sternenseemann
Copy link
Member

Should be resolved by #346043 / #348827.

@sternenseemann sternenseemann linked a pull request Oct 17, 2024 that will close this issue
2 tasks
@Frontear
Copy link
Member

Frontear commented Oct 30, 2024

#346043 only fixes the infinite recursion aspect, there are still many packages which cannot compile, which means this issue isn't really fully resolved as proper cross-compiling support from * to *-darwin isn't fully here yet.

While I agree it's a tough problem to solve, projects like https://github.com/tpoechtrager/osxcross prove that it is possible, and I think it'd be awesome for Nixpkgs to have support too. It'd be pretty much all wins and no losses, of course with the exception of the initial hurdle to overcome.

EDIT

An example to see what I mean (pinned to current staging-next):

$ nix build --impure --expr '(import (builtins.getFlake "github:NixOS/nixpkgs?rev=6968567d601da88ff67834173c9384f7a7be3d3d") { localSystem = "x86_64-linux"; crossSystem = "x86_64-darwin"; }).hello'
       error: Package ‘x86_64-apple-darwin-cctools-1010.6’ in /nix/store/j04fgl16av0c30xz5sw0nipi6m16xxjb-source/pkgs/by-name/cc/cctools/package.nix:167 is not available on the requested hostPlatform:
         hostPlatform.config = "x86_64-unknown-linux-gnu"
         package.meta.platforms = [
           "x86_64-darwin"
           "i686-darwin"
           "aarch64-darwin"
           "armv7a-darwin"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: darwin Running or building packages on Darwin
Projects
None yet
5 participants