summary refs log tree commit diff
path: root/pkgs/os-specific/linux/kernel-headers
diff options
context:
space:
mode:
authors1341 <s1341@github.com>2021-05-06 07:15:34 +0300
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-05-11 15:39:08 +0000
commit1e1d29c2af646b21c04f7a27614317a19ee01bc5 (patch)
treec9aae224cdc64de857abe26dcba02ecf1456af1c /pkgs/os-specific/linux/kernel-headers
parent680b33fe37d4b6fd0bd8fe596ed438c88bfb3637 (diff)
downloadnixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar.gz
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar.bz2
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar.lz
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar.xz
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.tar.zst
nixpkgs-1e1d29c2af646b21c04f7a27614317a19ee01bc5.zip
treewide: Support aarch64-android using minimal prebuilt components
This PR adds a new aarch64 android toolchain, which leverages the
existing crossSystem infrastructure and LLVM builders to generate a
working toolchain with minimal prebuilt components.

The only thing that is prebuilt is the bionic libc. This is because it
is practically impossible to compile bionic outside of an AOSP tree. I
tried and failed, braver souls may prevail. For now I just grab the
relevant binaries from https://android.googlesource.com/.

I also grab the msm kernel sources from there to generate headers. I've
included a minor patch to the existing kernel-headers derivation in
order to expose an internal function.

Everything else, from binutils up, is using stock code. Many thanks to
@Ericson2314 for his help on this, and for building such a powerful
system in the first place!

One motivation for this is to be able to build a toolchain which will
work on an aarch64 linux machine. To my knowledge, there is no existing
toolchain for an aarch64-linux builder and an aarch64-android target.
Diffstat (limited to 'pkgs/os-specific/linux/kernel-headers')
-rw-r--r--pkgs/os-specific/linux/kernel-headers/default.nix22
1 files changed, 18 insertions, 4 deletions
diff --git a/pkgs/os-specific/linux/kernel-headers/default.nix b/pkgs/os-specific/linux/kernel-headers/default.nix
index 34e80ac8222..d9dac5e53a5 100644
--- a/pkgs/os-specific/linux/kernel-headers/default.nix
+++ b/pkgs/os-specific/linux/kernel-headers/default.nix
@@ -1,4 +1,9 @@
-{ stdenvNoCC, lib, buildPackages, fetchurl, perl, elf-header }:
+{ stdenvNoCC, lib, buildPackages, fetchurl, perl, elf-header
+, bison ? null, flex ? null, python ? null, rsync ? null
+}:
+
+assert stdenvNoCC.hostPlatform.isAndroid ->
+  (flex != null && bison != null && python != null && rsync != null);
 
 let
   makeLinuxHeaders = { src, version, patches ? [] }: stdenvNoCC.mkDerivation {
@@ -13,7 +18,11 @@ let
     # We do this so we have a build->build, not build->host, C compiler.
     depsBuildBuild = [ buildPackages.stdenv.cc ];
     # `elf-header` is null when libc provides `elf.h`.
-    nativeBuildInputs = [ perl elf-header ];
+    nativeBuildInputs = [
+      perl elf-header
+    ] ++ lib.optionals stdenvNoCC.hostPlatform.isAndroid [
+      flex bison python rsync
+    ];
 
     extraIncludeDirs = lib.optional stdenvNoCC.hostPlatform.isPowerPC ["ppc"];
 
@@ -21,6 +30,8 @@ let
 
     hardeningDisable = lib.optional stdenvNoCC.buildPlatform.isDarwin "format";
 
+    sourceRoot = lib.optionalString stdenvNoCC.hostPlatform.isAndroid ".";
+
     makeFlags = [
       "SHELL=bash"
       # Avoid use of runtime build->host compilers for checks. These
@@ -36,9 +47,12 @@ let
     # Skip clean on darwin, case-sensitivity issues.
     buildPhase = lib.optionalString (!stdenvNoCC.buildPlatform.isDarwin) ''
       make mrproper $makeFlags
-    '' + ''
+    '' + (if stdenvNoCC.hostPlatform.isAndroid then ''
+      make defconfig
+      make headers_install
+    '' else ''
       make headers $makeFlags
-    '';
+    '');
 
     checkPhase = ''
       make headers_check $makeFlags