Skip to content

libcap fails to cross-compile from gnu64 to aarch64-multiplatform on unstable #169010

@elizagamedev

Description

@elizagamedev

Describe the bug

When attempting to build an aarch64 sdcard image with the below configuration, libcap fails to build with the following error:

error: builder for '/nix/store/wi4g5zqg5y1m29z0g9ryg6jkmb9nsl98-libcap-aarch64-unknown-linux-gnu-2.63.drv' failed with exit code 2;
       last 10 log lines:
       > make libcap.so
       > make[2]: Entering directory '/build/libcap-2.63/libcap'
       > aarch64-unknown-linux-gnu-gcc -O2  -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -Wunreachable-code -fPIC -Dlinux -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/build/libcap-2.63/libcap/../libcap/include/uapi -I/build/libcap-2.63/libcap/../libcap/include   empty.c   -o empty
       > objcopy --dump-section .interp=loader.txt empty /dev/null
       > objcopy: Unable to recognise the format of the input file `empty'
       > make[2]: *** [Makefile:112: loader.txt] Error 1
       > make[2]: Leaving directory '/build/libcap-2.63/libcap'
       > make[1]: *** [Makefile:41: all] Error 2
       > make[1]: Leaving directory '/build/libcap-2.63/libcap'
       > make: *** [Makefile:12: all] Error 2
       For full logs, run 'nix log /nix/store/wi4g5zqg5y1m29z0g9ryg6jkmb9nsl98-libcap-aarch64-unknown-linux-gnu-2.63.drv'.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create flake.nix.
{
  description = "Base aarch64 system";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs }: rec {
    nixosConfigurations.system = nixpkgs.lib.nixosSystem {
      system = "aarch64-linux";
      modules = [
        "${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
        {
          nixpkgs = {
            config.allowUnfree = true;
            crossSystem = nixpkgs.lib.systems.examples.aarch64-multiplatform;
            localSystem = nixpkgs.lib.systems.examples.gnu64;
          };
        }
      ];
    };

    images.sdcard = nixosConfigurations.system.config.system.build.sdImage;
  };
}
  1. Run nix build '.#images.sdcard'
  2. Build eventually fails with the above error.

Expected behavior

Working build.

Screenshots

N/A

Additional context

I'm not 100% confident that I'm doing this cross compilation correctly. I've been working on this problem all evening and the above flake code is more or less the sum of my knowledge on the subject so far.

Notify maintainers

Nobody was in meta.maintainers, so I added some folks from git blame. I apologize if I @'d anyone who is not relevant. I would tag someone experienced with cross compilation but I'm not sure how to find one of the owners of such a feature.

@Ericson2314
@siraben
@orivej
@zowoq

Metadata

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

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.32, NixOS, 22.05 (Quokka), 22.05.20220406.b6966d9`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.7.0`
 - channels(root): `"nixos"`
 - channels(eliza): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions