From 6f40d18d4432858199e14d2323b4f8503ee47a7e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 27 Feb 2018 18:36:48 -0500 Subject: prebuilt android cc: Edit wrapper to pass the right -m flags for armv7a (cherry picked from commit 827ef0914089e1a2bba140b49e1311eff28cc156) --- .../mobile/androidenv/androidndk-pkgs.nix | 33 +++++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'pkgs/development/mobile') diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 19fc0dc812d8..1413e35e904a 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"; }; } -- cgit 1.4.1 From f2004e62870aa6b21dd52612295da973194c7c73 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 12 May 2018 15:07:31 -0400 Subject: lib: Fix float handling for Aarch32 Forgot to adjust default so abi with explicit float attr would be used. --- lib/systems/parse.nix | 29 +++++++++++++--------- lib/systems/platforms.nix | 1 - .../compilers/gcc/common/platform-flags.nix | 6 ++--- .../mobile/androidenv/androidndk-pkgs.nix | 6 ++--- 4 files changed, 23 insertions(+), 19 deletions(-) (limited to 'pkgs/development/mobile') diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 33daf0791641..856ab297d5be 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -68,17 +68,17 @@ rec { cpuTypes = with significantBytes; setTypes types.openCpuType { arm = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv6l = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv7a = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv7r = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv7m = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv7l = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv8a = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; }; - armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; }; - aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; }; + armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; version = "5"; }; + armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; }; + armv6l = { bits = 32; significantByte = littleEndian; family = "arm"; version = "6"; }; + armv7a = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; }; + armv7r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; }; + armv7m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; }; + armv7l = { bits = 32; significantByte = littleEndian; family = "arm"; version = "7"; }; + armv8a = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; }; + armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; }; + armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; version = "8"; }; + aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; version = "8"; }; i686 = { bits = 32; significantByte = littleEndian; family = "x86"; }; x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; }; @@ -271,7 +271,12 @@ rec { kernel = getKernel args.kernel; abi = /**/ if args ? abi then getAbi args.abi - else if isLinux parsed then abis.gnu + else if isLinux parsed then + if isAarch32 parsed then + if lib.versionAtLeast (parsed.cpu.version or "0") "6" + then abis.gnueabihf + else abis.gnueabi + else abis.gnu else if isWindows parsed then abis.gnu else abis.unknown; }; diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 5becaf581a45..32f055b6b1c5 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -245,7 +245,6 @@ rec { gcc = { arch = "armv6"; fpu = "vfp"; - float = "hard"; # TODO(@Ericson2314) what is this and is it a good idea? It was # used in some cross compilation examples but not others. # diff --git a/pkgs/development/compilers/gcc/common/platform-flags.nix b/pkgs/development/compilers/gcc/common/platform-flags.nix index e261f54f582d..9a6d3f8f6203 100644 --- a/pkgs/development/compilers/gcc/common/platform-flags.nix +++ b/pkgs/development/compilers/gcc/common/platform-flags.nix @@ -1,13 +1,13 @@ { lib, targetPlatform }: let - p = targetPlatform.platform.gcc or {}; - float = p.float or (targetPlatform.parsed.abi.float or null); + p = targetPlatform.platform.gcc or {} + // targetPlatform.parsed.abi; in lib.concatLists [ (lib.optional (p ? arch) "--with-arch=${p.arch}") (lib.optional (p ? cpu) "--with-cpu=${p.cpu}") (lib.optional (p ? abi) "--with-abi=${p.abi}") (lib.optional (p ? fpu) "--with-fpu=${p.fpu}") - (lib.optional (float != null) "--with-float=${float}") + (lib.optional (p ? float) "--with-float=${p.float}") (lib.optional (p ? mode) "--with-mode=${p.mode}") ] diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 1413e35e904a..663a1f1ee8f4 100644 --- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix +++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix @@ -65,14 +65,14 @@ rec { bintools = binutils; libc = targetAndroidndkPkgs.libraries; extraBuildCommands = lib.optionalString targetPlatform.isAarch32 (let - p = targetPlatform.platform.gcc or {}; - float = p.float or (targetPlatform.parsed.abi.float or null); + p = targetPlatform.platform.gcc or {} + // targetPlatform.parsed.abi; 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) "-mfloat=${p.float}") (lib.optional (p ? float-abi) "-mfloat-abi=${p.float-abi}") (lib.optional (p ? mode) "-mmode=${p.mode}") ]; -- cgit 1.4.1