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

pkgsStatic.coreutils: error targetPackages.darwin.LibsystemCross x86_64-apple-darwin #270375

Closed
avdv opened this issue Nov 27, 2023 · 4 comments
Closed
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: static 6.topic: stdenv Standard environment

Comments

@avdv
Copy link
Member

avdv commented Nov 27, 2023

Describe the bug

Trying to use the pkgsStatic.coreutils package on x86_64 Darwin fails when using nixos-unstable:

error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin`

(it works on aarch64-darwin)

Steps To Reproduce

Steps to reproduce the behavior:

  1. nix-shell --argstr localSystem x86_64-darwin -I nixpkgs=./. --show-trace -p pkgsStatic.coreutils
error:
       … while evaluating the attribute 'buildInputs' of the derivation 'shell'

       at /Users/claudio/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:348:7:

          347|     // (optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          348|       name =
             |       ^
          349|         let

       … while evaluating the attribute 'NIX_CFLAGS_LINK' of the derivation 'coreutils-static-x86_64-apple-darwin-9.3'

       at /Users/claudio/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:348:7:

          347|     // (optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          348|       name =
             |       ^
          349|         let

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/stdenv/adapters.nix:146:11:

          145|       NIX_CFLAGS_LINK = toString (finalAttrs.NIX_CFLAGS_LINK or "")
          146|         + lib.optionalString (stdenv.cc.isGNU or false) " -static-libgcc";
             |           ^
          147|       nativeBuildInputs = (finalAttrs.nativeBuildInputs or [])

       … while calling 'optionalString'

       at /Users/claudio/nixpkgs/lib/strings.nix:257:5:

          256|     # String to return if condition is true
          257|     string: if cond then string else "";
             |     ^
          258|

       … while evaluating the attribute 'cc.isGNU'

       at /Users/claudio/nixpkgs/pkgs/stdenv/generic/default.nix:165:14:

          164|
          165|       inherit cc hasCC;
             |              ^
          166|

       … while evaluating the attribute 'llvmPackages.libcxxClang'

       at /Users/claudio/nixpkgs/pkgs/development/compilers/llvm/16/default.nix:132:5:

          131|
          132|     libcxxClang = wrapCCWith rec {
             |     ^
          133|       cc = tools.clang-unwrapped;

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/development/compilers/llvm/16/default.nix:132:19:

          131|
          132|     libcxxClang = wrapCCWith rec {
             |                   ^
          133|       cc = tools.clang-unwrapped;

       … while calling 'wrapCCWith'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17387:5:

        17386|   wrapCCWith =
        17387|     { cc
             |     ^
        17388|     , # This should be the only bintools runtime dep with this sort of logic. The

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17406:7:

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

       … while calling 'callPackageWith'

       at /Users/claudio/nixpkgs/lib/customisation.nix:141:35:

          140|   */
          141|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          142|     let

       … while evaluating call site

       at /Users/claudio/nixpkgs/lib/customisation.nix:192:34:

          191|
          192|     in if missingArgs == [] then makeOverridable f allArgs else abort error;
             |                                  ^
          193|

       … while calling anonymous lambda

       at /Users/claudio/nixpkgs/lib/customisation.nix:84:17:

           83|     in
           84|     mirrorArgs (origArgs:
             |                 ^
           85|     let

       … while evaluating call site

       at /Users/claudio/nixpkgs/lib/customisation.nix:86:16:

           85|     let
           86|       result = f origArgs;
             |                ^
           87|

       … while calling anonymous lambda

       at /Users/claudio/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1:

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

       … while evaluating the attribute 'libc'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17415:12:

        17414|
        17415|     inherit cc bintools libc libcxx extraPackages nixSupport zlib;
             |            ^
        17416|   } // extraArgs; in self);

       … while evaluating the attribute 'bintools'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:18669:3:

        18668|   };
        18669|   bintools = wrapBintoolsWith {
             |   ^
        18670|     bintools = bintools-unwrapped;

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:18669:14:

        18668|   };
        18669|   bintools = wrapBintoolsWith {
             |              ^
        18670|     bintools = bintools-unwrapped;

       … while calling 'wrapBintoolsWith'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17423:5:

        17422|   wrapBintoolsWith =
        17423|     { bintools
             |     ^
        17424|     , libc ? if stdenv.targetPlatform != stdenv.hostPlatform then libcCross else stdenv.cc.libc

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17427:7:

        17426|     } @ extraArgs:
        17427|       callPackage ../build-support/bintools-wrapper (let self = {
             |       ^
        17428|     nativeTools = stdenv.targetPlatform == stdenv.hostPlatform && stdenv.cc.nativeTools or false;

       … while calling 'callPackageWith'

       at /Users/claudio/nixpkgs/lib/customisation.nix:141:35:

          140|   */
          141|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          142|     let

       … while evaluating call site

       at /Users/claudio/nixpkgs/lib/customisation.nix:192:34:

          191|
          192|     in if missingArgs == [] then makeOverridable f allArgs else abort error;
             |                                  ^
          193|

       … while calling anonymous lambda

       at /Users/claudio/nixpkgs/lib/customisation.nix:84:17:

           83|     in
           84|     mirrorArgs (origArgs:
             |                 ^
           85|     let

       … while evaluating call site

       at /Users/claudio/nixpkgs/lib/customisation.nix:86:16:

           85|     let
           86|       result = f origArgs;
             |                ^
           87|

       … while calling anonymous lambda

       at /Users/claudio/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix:8:1:

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

       … while evaluating the attribute 'libc'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:17434:12:

        17433|
        17434|     inherit bintools libc;
             |            ^
        17435|     inherit (darwin) postLinkSignHook signingUtils;

       … while evaluating call site

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:21644:69:

        21643|
        21644|   libcCross = assert stdenv.targetPlatform != stdenv.buildPlatform; libcCrossChooser stdenv.targetPlatform.libc;
             |                                                                     ^
        21645|

       … while calling 'libcCrossChooser'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:21618:22:

        21617|   # We can choose:
        21618|   libcCrossChooser = name:
             |                      ^
        21619|     # libc is hackily often used from the previous stage. This `or`

       … while evaluating the attribute 'darwin.LibsystemCross'

       at /Users/claudio/nixpkgs/pkgs/top-level/all-packages.nix:27768:3:

        27767|   # `.override` clobbered. C.F. `llvmPackages` which does the same.
        27768|   darwin = recurseIntoAttrs (callPackage ./darwin-packages.nix { });
             |   ^
        27769|

       error: don't yet have a `targetPackages.darwin.LibsystemCross for x86_64-apple-darwin`

Expected behavior

We should be able to use pkgsStatic.coreutils on x86_64-darwin.

Additional context

I git bisected the problem to commit 42b5817 which actually introduced support for non-linux host platforms in the first place. This would probably mean that before this change package x and pkgsStatic.x would be exactly the same on Darwin?

We used the pkgsStatic.coreutils package from nixos-22.11 before, but ran into this problem after upgrading to nixos-unstable, see tweag/rules_nixpkgs#424

Notify maintainers

cc @uri-canva

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"

 - system: `"aarch64-darwin"`
 - host os: `Darwin 21.6.0, macOS 12.7`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Priorities

Add a 👍 reaction to issues you find important.

@uri-canva
Copy link
Contributor

Yes, correct, before that commit x and pkgsStatic.x would be exactly the same. After that commit it's now attempting to build packages statically. Unfortunately since that combination of packages and stdenv weren't being built before, most of them didn't build. We've got pkgsStatic.nix building, although that was on aarch64. x86_64 doesn't work, the exact reason why is beyond my understanding of how stdenvs are wired together, but #180771 has more context, and #256590 has a potential fix (it's for cross compilation, but it also changes how things are passed through stdenv, so it affects pkgsStatic which is implemented as cross compilation).

I think it's fine to keep this issue open to track pkgsStatic.coreutils specifically, but do note that in general pkgsStatic / cross compiled packages aren't checked so they break a lot. I suggest setting up your own nix ci to verify whether upstream nixpkgs bumps will break these packages if you care about them so you can open issues immediately after they get broken.

In the meantime can you verify that the PR fixes your issue?

@chewblacka chewblacka added the 6.topic: darwin Running or building packages on Darwin label Nov 27, 2023
@avdv
Copy link
Member Author

avdv commented Nov 28, 2023

In the meantime can you verify that the PR fixes your issue?

Yes, it fixes the issue at hand and it is building pkgsStatic.coreutils again, but it seems the package is not really static:

$ otool -L /nix/store/fbzhv146kg8b8mp90q8ncrqj7l2fj4wy-coreutils-9.3/bin/coreutils
/nix/store/fbzhv146kg8b8mp90q8ncrqj7l2fj4wy-coreutils-9.3/bin/coreutils:
	/nix/store/7flhczqiibyhadll32xx83awsg1bcmbi-gmp-with-cxx-6.3.0/lib/libgmp.10.dylib (compatibility version 16.0.0, current version 16.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)

Like before, coreutils and pkgsStatic.coreutils seem to be the same:

$ nix-shell --argstr localSystem x86_64-darwin -I nixpkgs=./. --pure -p which pkgsStatic.coreutils --run 'which coreutils'
/nix/store/fbzhv146kg8b8mp90q8ncrqj7l2fj4wy-coreutils-9.3/bin/coreutils
$ nix-shell --argstr localSystem x86_64-darwin -I nixpkgs=./. --pure -p which coreutils --run 'which coreutils'
/nix/store/fbzhv146kg8b8mp90q8ncrqj7l2fj4wy-coreutils-9.3/bin/coreutils

@reckenrode
Copy link
Contributor

This should be fixed by #346043.

@aviallon
Copy link
Contributor

Closed by #346043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 6.topic: darwin Running or building packages on Darwin 6.topic: static 6.topic: stdenv Standard environment
Projects
None yet
Development

No branches or pull requests

6 participants