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

View file

@ -61,6 +61,12 @@ let
then import ../expand-response-params { inherit (buildPackages) stdenv; } then import ../expand-response-params { inherit (buildPackages) stdenv; }
else ""; 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 # older compilers (for example bootstrap's GCC 5) fail with -march=too-modern-cpu
isGccArchSupported = arch: isGccArchSupported = arch:
if isGNU then if isGNU then
@ -272,7 +278,7 @@ stdenv.mkDerivation {
## ##
## GCC libs for non-GCC support ## 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 "-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 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 # We have a libc++ directly, we have one via "smuggled" GCC, or we have one
# bundled with the C compiler because it is GCC # 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-cxxflags"
touch "$out/nix-support/libcxx-ldflags" 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 for dir in ${gccForLibs}/include/c++/*; do
echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags echo "-isystem $dir" >> $out/nix-support/libcxx-cxxflags
done done

View file

@ -53,7 +53,9 @@ in
rec { rec {
# Misc tools # 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 isClang = true; # clang based cc, but bintools ld
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = [ androidndk ]; 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" { toolsVersion ? "25.2.5"
, platformToolsVersion ? "29.0.6" , platformToolsVersion ? "29.0.6"
@ -144,7 +144,7 @@ rec {
) cmakeVersions; ) cmakeVersions;
ndk-bundle = import ./ndk-bundle { 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}; 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"; } , pkgs_i686 ? import <nixpkgs> { system = "i686-linux"; }
, licenseAccepted ? config.android_sdk.accept_license or false , licenseAccepted ? config.android_sdk.accept_license or false
}: }:
@ -6,7 +6,7 @@
rec { rec {
composeAndroidPackages = import ./compose-android-packages.nix { composeAndroidPackages = import ./compose-android-packages.nix {
inherit (pkgs) requireFile autoPatchelfHook; inherit (pkgs) requireFile autoPatchelfHook;
inherit pkgs pkgs_i686 licenseAccepted; inherit pkgs pkgsHostHost pkgs_i686 licenseAccepted;
}; };
buildApp = import ./build-app.nix { buildApp = import ./build-app.nix {

View file

@ -5,7 +5,8 @@ let
extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ]; extraParams = removeAttrs args [ "package" "os" "buildInputs" "patchInstructions" ];
in in
stdenv.mkDerivation ({ 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; src = if os != null && builtins.hasAttr os package.archives then package.archives.${os} else package.archives.all;
buildInputs = [ unzip ] ++ buildInputs; buildInputs = [ unzip ] ++ buildInputs;
preferLocalBuild = true; 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 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 in
deployAndroidPackage { deployAndroidPackage {
inherit package os; inherit package os;