Merge pull request #97387 from Ericson2314/fix-android-prebuilt

cc-wrapper: Fix for prebuilt android
This commit is contained in:
John Ericson 2020-09-08 20:24:50 -04:00 committed by GitHub
commit 5fd27509cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 13 deletions

View File

@ -47,7 +47,7 @@ rec {
armv7a-android-prebuilt = {
config = "armv7a-unknown-linux-androideabi";
sdkVer = "29";
ndkVer = "18b";
ndkVer = "21";
platform = platforms.armv7a-android;
useAndroidPrebuilt = true;
};
@ -55,7 +55,7 @@ rec {
aarch64-android-prebuilt = {
config = "aarch64-unknown-linux-android";
sdkVer = "29";
ndkVer = "18b";
ndkVer = "21";
platform = platforms.aarch64-multiplatform;
useAndroidPrebuilt = true;
};

View File

@ -61,6 +61,12 @@ let
then import ../expand-response-params { inherit (buildPackages) stdenv; }
else "";
useGccForLibs = isClang
&& libcxx == null
&& !(stdenv.targetPlatform.useLLVM or false)
&& !(stdenv.targetPlatform.useAndroidPrebuilt or false)
&& gccForLibs != null;
# older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
isGccArchSupported = arch:
if isGNU then
@ -272,7 +278,7 @@ stdenv.mkDerivation {
##
## GCC libs for non-GCC support
##
+ optionalString (isClang && libcxx == null && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs != null) ''
+ optionalString useGccForLibs ''
echo "-B${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-cflags
echo "-L${gccForLibs}/lib/gcc/${targetPlatform.config}/${gccForLibs.version}" >> $out/nix-support/cc-ldflags
@ -316,11 +322,11 @@ stdenv.mkDerivation {
# We have a libc++ directly, we have one via "smuggled" GCC, or we have one
# bundled with the C compiler because it is GCC
+ optionalString (libcxx != null || (isClang && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs.langCC or false) || (isGNU && cc.langCC or false)) ''
+ optionalString (libcxx != null || (useGccForLibs && gccForLibs.langCC or false) || (isGNU && cc.langCC or false)) ''
touch "$out/nix-support/libcxx-cxxflags"
touch "$out/nix-support/libcxx-ldflags"
''
+ optionalString (libcxx == null && (isClang && !(stdenv.targetPlatform.useLLVM or false) && gccForLibs.langCC or false)) ''
+ optionalString (libcxx == null && (useGccForLibs && gccForLibs.langCC or false)) ''
for dir in ${gccForLibs}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done

View File

@ -53,7 +53,9 @@ in
rec {
# Misc tools
binaries = runCommand "ndk-gcc-binutils" {
binaries = runCommand "ndk-toolchain-binutils" {
pname = "ndk-toolchain-binutils";
inherit (androidndk) version;
isClang = true; # clang based cc, but bintools ld
nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = [ androidndk ];

View File

@ -1,4 +1,4 @@
{requireFile, autoPatchelfHook, pkgs, pkgs_i686, licenseAccepted ? false}:
{requireFile, autoPatchelfHook, pkgs, pkgsHostHost, pkgs_i686, licenseAccepted ? false}:
{ toolsVersion ? "25.2.5"
, platformToolsVersion ? "29.0.6"
@ -144,7 +144,7 @@ rec {
) cmakeVersions;
ndk-bundle = import ./ndk-bundle {
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs lib platform-tools;
inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgsHostHost lib platform-tools;
package = packages.ndk-bundle.${ndkVersion};
};

View File

@ -1,4 +1,4 @@
{ config, pkgs ? import <nixpkgs> {}
{ config, pkgs ? import <nixpkgs> {}, pkgsHostHost ? pkgs.pkgsHostHost
, pkgs_i686 ? import <nixpkgs> { system = "i686-linux"; }
, licenseAccepted ? config.android_sdk.accept_license or false
}:
@ -6,7 +6,7 @@
rec {
composeAndroidPackages = import ./compose-android-packages.nix {
inherit (pkgs) requireFile autoPatchelfHook;
inherit pkgs pkgs_i686 licenseAccepted;
inherit pkgs pkgsHostHost pkgs_i686 licenseAccepted;
};
buildApp = import ./build-app.nix {

View File

@ -5,7 +5,8 @@ let
extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ];
in
stdenv.mkDerivation ({
name = package.name + "-" + package.revision;
pname = package.name;
version = package.revision;
src = if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all;
buildInputs = [ unzip ] ++ buildInputs;
preferLocalBuild = true;

View File

@ -1,7 +1,11 @@
{deployAndroidPackage, lib, package, os, autoPatchelfHook, makeWrapper, pkgs, platform-tools}:
{ lib, pkgs, pkgsHostHost, makeWrapper, autoPatchelfHook
, deployAndroidPackage, package, os, platform-tools
}:
let
runtime_paths = lib.makeBinPath [ pkgs.coreutils pkgs.file pkgs.findutils pkgs.gawk pkgs.gnugrep pkgs.gnused pkgs.jdk pkgs.python3 pkgs.which ] + ":${platform-tools}/platform-tools";
runtime_paths = lib.makeBinPath (with pkgsHostHost; [
coreutils file findutils gawk gnugrep gnused jdk python3 which
]) + ":${platform-tools}/platform-tools";
in
deployAndroidPackage {
inherit package os;