From 1e1d29c2af646b21c04f7a27614317a19ee01bc5 Mon Sep 17 00:00:00 2001 From: s1341 Date: Thu, 6 May 2021 07:15:34 +0300 Subject: 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. --- pkgs/os-specific/linux/kernel-headers/default.nix | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'pkgs/os-specific/linux/kernel-headers') 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 -- cgit 1.4.1