From f4de66977749f733b9a13d5f03550960ff800b0b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 11 May 2018 18:30:38 -0400 Subject: [PATCH 1/3] lib/systems/inspect: Fix after assertions Function are never equal in Nix, so we need to filter out this attribute in ABIs. --- lib/systems/inspect.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 9960954e464..c0c283469fe 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -3,6 +3,9 @@ with import ./parse.nix { inherit lib; }; with lib.attrsets; with lib.lists; +let abis_ = abis; in +let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in + rec { patterns = rec { isi686 = { cpu = cpuTypes.i686; }; From 28bacc2093a43c21f34a192397d2b2561a9fd29d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 11 May 2018 17:35:56 -0400 Subject: [PATCH 2/3] lib/systems: Add assertion to "android" ABI This is analogous to the GNU assertion. --- lib/systems/parse.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 02ca3a6b361..3dba5ad4698 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -199,8 +199,16 @@ rec { msvc = {}; eabi = {}; - androideabi = {}; - android = {}; + androideabi = { float = "hard"; }; + android = { + assertions = [ + { assertion = platform: !platform.isAarch32; + message = '' + The "android" ABI is not for 32-bit ARM. Use "androideabi" instead. + ''; + } + ]; + }; gnueabi = { float = "soft"; }; gnueabihf = { float = "hard"; }; From 827ef0914089e1a2bba140b49e1311eff28cc156 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 27 Feb 2018 18:36:48 -0500 Subject: [PATCH 3/3] prebuilt android cc: Edit wrapper to pass the right -m flags for armv7a --- lib/systems/examples.nix | 3 ++ .../mobile/androidenv/androidndk-pkgs.nix | 33 ++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 897ba448b95..9c43d9b1bbc 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -31,18 +31,21 @@ rec { armv5te-android-prebuilt = rec { config = "armv5tel-unknown-linux-androideabi"; + sdkVer = "21"; platform = platforms.armv5te-android; useAndroidPrebuilt = true; }; armv7a-android-prebuilt = rec { config = "armv7a-unknown-linux-androideabi"; + sdkVer = "21"; platform = platforms.armv7a-android; useAndroidPrebuilt = true; }; aarch64-android-prebuilt = rec { config = "aarch64-unknown-linux-android"; + sdkVer = "21"; platform = platforms.aarch64-multiplatform; useAndroidPrebuilt = true; }; diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 19fc0dc812d..f0557390988 100644 --- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix +++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix @@ -15,7 +15,12 @@ let "x86_64-unknown-linux-gnu" = { double = "linux-x86_64"; }; - "arm-unknown-linux-androideabi" = { + "armv5tel-unknown-linux-androideabi" = { + arch = "arm"; + triple = "arm-linux-androideabi"; + gccVer = "4.8"; + }; + "armv7a-unknown-linux-androideabi" = { arch = "arm"; triple = "arm-linux-androideabi"; gccVer = "4.8"; @@ -59,9 +64,29 @@ rec { cc = binaries; bintools = binutils; libc = targetAndroidndkPkgs.libraries; - extraBuildCommands = + extraBuildCommands = lib.optionalString targetPlatform.isAarch32 (let + p = targetPlatform.platform.gcc or {}; + float = p.float or (targetPlatform.parsed.abi.float or null); + flags = lib.concatLists [ + (lib.optional (p ? arch) "-march=${p.arch}") + (lib.optional (p ? cpu) "-mcpu=${p.cpu}") + (lib.optional (p ? abi) "-mabi=${p.abi}") + (lib.optional (p ? fpu) "-mfpu=${p.fpu}") + (lib.optional (float != null) "-mfloat=${float}") + (lib.optional (p ? float-abi) "-mfloat-abi=${p.float-abi}") + (lib.optional (p ? mode) "-mmode=${p.mode}") + ]; + in '' + sed -E -i \ + $out/bin/${targetPlatform.config}-cc \ + $out/bin/${targetPlatform.config}-c++ \ + $out/bin/${targetPlatform.config}-gcc \ + $out/bin/${targetPlatform.config}-g++ \ + -e '130i extraBefore+=(-Wl,--fix-cortex-a8)' \ + -e 's|^(extraBefore=)\(\)$|\1(${builtins.toString flags})|' + '') # GCC 4.9 is the first relase with "-fstack-protector" - lib.optionalString (lib.versionOlder targetInfo.gccVer "4.9") '' + + lib.optionalString (lib.versionOlder targetInfo.gccVer "4.9") '' sed -E \ -i $out/nix-support/add-hardening.sh \ -e 's|(-fstack-protector)-strong|\1|g' @@ -76,7 +101,7 @@ rec { libraries = { name = "bionic-prebuilt"; type = "derivation"; - outPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-21/arch-${hostInfo.arch}/usr/"; + outPath = "${buildAndroidndk}/libexec/${buildAndroidndk.name}/platforms/android-${hostPlatform.sdkVer}/arch-${hostInfo.arch}/usr/"; drvPath = throw "fake derivation, build ${buildAndroidndk} to use"; }; }