prebuilt android cc: Edit wrapper to pass the right -m flags for armv7a

This commit is contained in:
John Ericson 2018-02-27 18:36:48 -05:00
parent 28bacc2093
commit 827ef09140
2 changed files with 32 additions and 4 deletions

View File

@ -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;
};

View File

@ -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";
};
}