NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.05k stars 14.1k forks source link

Cross Compiling linux_latest fails with 'crossDrv' missing. #24388

Closed TomSmeets closed 6 years ago

TomSmeets commented 7 years ago

Issue description

I want to cross-compile the linux kernel for my raspberry-pi 3 But it fails with the error: attribute ‘crossDrv’ missing.

Steps to reproduce

> nix-build -A linux_latest cross-aarch64.nix
error: attribute ‘crossDrv’ missing, at /etc/nixos/nixpkgs-rpi/pkgs/os-specific/linux/kernel/generic.nix:74:18
(use ‘--show-trace’ to show detailed location information)

cross-aarch64.nix

let
  aarch64-multiplatform = {
    name = "aarch64-multiplatform";
    kernelMajor = "2.6"; # Using "2.6" enables 2.6 kernel syscalls in glibc.
    kernelHeadersBaseConfig = "defconfig";
    kernelBaseConfig = "defconfig";
    kernelArch = "arm64";
    kernelDTB = true;
    kernelAutoModules = true;
    kernelPreferBuiltin = true;
    kernelExtraConfig = ''
      # Raspberry Pi 3 stuff. Not needed for kernels >= 4.10.
      ARCH_BCM2835 y
      BCM2835_MBOX y
      BCM2835_WDT y
      RASPBERRYPI_FIRMWARE y
      RASPBERRYPI_POWER y
      SERIAL_8250_BCM2835AUX y
      SERIAL_8250_EXTENDED y
      SERIAL_8250_SHARE_IRQ y
      # Cavium ThunderX stuff.
      PCI_HOST_THUNDER_ECAM y
    '';
    uboot = null;
    kernelTarget = "Image";
    gcc = {
      arch = "armv8-a";
    };
  };
in import ./default.nix {
  crossSystem = rec {
    config = "aarch64-linux";
    bigEndian = false;
    arch = "aarch64";
    withTLS = true;
    libc = "glibc";
    platform = aarch64-multiplatform;

    float = "hard";
    fpu = "vfp";
    openssl.system = "linux-generic32";
    gcc = {
      arch = "aarch64";
      fpu = "vfp";
      float = "softfp";
      abi = "aapcs-linux";
    };
  };
}

Technical details

globin commented 7 years ago

cc @Ericson2314 who was working on cross compiling stuff and should know "everything" ;)

Ericson2314 commented 7 years ago

Try just removing .crossDrv from that line. CrossDrv is now the default.

TomSmeets commented 7 years ago

@Ericson2314 What line do you mean?

copumpkin commented 7 years ago

@TomSmeets probably means changing this line (from your original error message) from

inherit (kernel.crossDrv) src patches preUnpack;

to

inherit (kernel) src patches preUnpack;
TomSmeets commented 7 years ago

Yes, it started compiling.

There were also some errors in my cryssSystem definition. I changed my crossSystem.gcc to:

    gcc = {
      arch = "armv8-a;
      abi = "lp64";
    };

Thanks for your help. :+1:

Ericson2314 commented 7 years ago

Can somebody make a PR for this?

Ericson2314 commented 7 years ago

Reopening until somebody confirms this is fixed on master.

TomSmeets commented 7 years ago

I just want to say that I never managed to finish the compilation. It fails with this error message:

unpacking source archive /nix/store/kj202br6bkh4xhd1i42p9rmlmbs5frhd-kmod-24.tar.xz
/nix/store/fylfd4fpibv5s2c01sq7m777qn8r7jz9-stdenv/setup: line 533: /nix/store/396q89s7wp2mhi94hfxyzll5y6ly4rx7-xz-5.2.2-aarch64-linux-gnu-bin/bin/xz: cannot execute binary file: Exec format error
Ericson2314 commented 7 years ago

https://github.com/NixOS/nixpkgs/pull/26805 will take non-runnable binaries off the path, which should fix that. https://github.com/obsidiansystems/nixpkgs/tree/linux-cross-overhaul is a WIP branch to fix other linux stuff.

Ericson2314 commented 6 years ago

@shlevy I think we can build linux now? :grinning:

shlevy commented 6 years ago

I already built Linux fine on staging...

Ericson2314 commented 6 years ago

(I didn't forget, just being tongue in cheek :). Great work, again!)