Merge pull request #40387 from obsidiansystems/android-32

android cross: Support 32-bit too
This commit is contained in:
John Ericson 2018-05-11 19:35:53 -04:00 committed by GitHub
commit 3fb09ac1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 6 deletions

View File

@ -31,18 +31,21 @@ rec {
armv5te-android-prebuilt = rec { armv5te-android-prebuilt = rec {
config = "armv5tel-unknown-linux-androideabi"; config = "armv5tel-unknown-linux-androideabi";
sdkVer = "21";
platform = platforms.armv5te-android; platform = platforms.armv5te-android;
useAndroidPrebuilt = true; useAndroidPrebuilt = true;
}; };
armv7a-android-prebuilt = rec { armv7a-android-prebuilt = rec {
config = "armv7a-unknown-linux-androideabi"; config = "armv7a-unknown-linux-androideabi";
sdkVer = "21";
platform = platforms.armv7a-android; platform = platforms.armv7a-android;
useAndroidPrebuilt = true; useAndroidPrebuilt = true;
}; };
aarch64-android-prebuilt = rec { aarch64-android-prebuilt = rec {
config = "aarch64-unknown-linux-android"; config = "aarch64-unknown-linux-android";
sdkVer = "21";
platform = platforms.aarch64-multiplatform; platform = platforms.aarch64-multiplatform;
useAndroidPrebuilt = true; useAndroidPrebuilt = true;
}; };

View File

@ -3,6 +3,9 @@ with import ./parse.nix { inherit lib; };
with lib.attrsets; with lib.attrsets;
with lib.lists; with lib.lists;
let abis_ = abis; in
let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in
rec { rec {
patterns = rec { patterns = rec {
isi686 = { cpu = cpuTypes.i686; }; isi686 = { cpu = cpuTypes.i686; };

View File

@ -199,8 +199,16 @@ rec {
msvc = {}; msvc = {};
eabi = {}; eabi = {};
androideabi = {}; androideabi = { float = "hard"; };
android = {}; android = {
assertions = [
{ assertion = platform: !platform.isAarch32;
message = ''
The "android" ABI is not for 32-bit ARM. Use "androideabi" instead.
'';
}
];
};
gnueabi = { float = "soft"; }; gnueabi = { float = "soft"; };
gnueabihf = { float = "hard"; }; gnueabihf = { float = "hard"; };

View File

@ -15,7 +15,12 @@ let
"x86_64-unknown-linux-gnu" = { "x86_64-unknown-linux-gnu" = {
double = "linux-x86_64"; 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"; arch = "arm";
triple = "arm-linux-androideabi"; triple = "arm-linux-androideabi";
gccVer = "4.8"; gccVer = "4.8";
@ -59,9 +64,29 @@ rec {
cc = binaries; cc = binaries;
bintools = binutils; bintools = binutils;
libc = targetAndroidndkPkgs.libraries; 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" # 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 \ sed -E \
-i $out/nix-support/add-hardening.sh \ -i $out/nix-support/add-hardening.sh \
-e 's|(-fstack-protector)-strong|\1|g' -e 's|(-fstack-protector)-strong|\1|g'
@ -76,7 +101,7 @@ rec {
libraries = { libraries = {
name = "bionic-prebuilt"; name = "bionic-prebuilt";
type = "derivation"; 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"; drvPath = throw "fake derivation, build ${buildAndroidndk} to use";
}; };
} }