From 204dc3a88b69e64a4882852c4cf69405f7f6bc21 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 7 Sep 2020 15:08:11 -0400 Subject: [PATCH 1/5] cc-wrapper: Fix for prebuilt android We don't want to use Nix-built GCC's libs with prebuilt clang in this case. --- pkgs/build-support/cc-wrapper/default.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index bfb15f2f7836..0e4e76d72843 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -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 From 4c489b5f5dda57883dad634bb5a6455b66c1fd36 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Sep 2020 09:31:18 -0400 Subject: [PATCH 2/5] deployAndroidPackage: Use `pname` and `version` --- pkgs/development/mobile/androidenv/deploy-androidpackage.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/mobile/androidenv/deploy-androidpackage.nix b/pkgs/development/mobile/androidenv/deploy-androidpackage.nix index 839a14f7033c..4f9db98c0062 100644 --- a/pkgs/development/mobile/androidenv/deploy-androidpackage.nix +++ b/pkgs/development/mobile/androidenv/deploy-androidpackage.nix @@ -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; From 7cac79b3adc20cbf4e94bec35d7f8f9e6535de96 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Sep 2020 09:32:06 -0400 Subject: [PATCH 3/5] androidndkPkgs: Take version from underlying package We can now do this, so let's. --- pkgs/development/androidndk-pkgs/androidndk-pkgs.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix index 04420370ff1c..995789b8c1ba 100644 --- a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix +++ b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix @@ -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 ]; From e2bef8fbdc998c07c146db1d047a1e331e4f0517 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Sep 2020 09:33:09 -0400 Subject: [PATCH 4/5] lib.systems.examples: Bump android SDK to 21 074bc78cc8749faa31729096b65f2ef51b10abeb evidently meant to do this, but forgot. --- lib/systems/examples.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 40e2b8fcefbc..5403f73405c2 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -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; }; From 452854a13cd7f3a4f687096423652040da56e289 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Sep 2020 09:49:39 -0400 Subject: [PATCH 5/5] androidndk: Avoid depending on target-sensative openjdk We just need jdk for this script that helps set up toolchains. The script might need to know about the target platform, but the interpreter that runs it (or part of it) doesn't. --- .../mobile/androidenv/compose-android-packages.nix | 4 ++-- pkgs/development/mobile/androidenv/default.nix | 4 ++-- pkgs/development/mobile/androidenv/ndk-bundle/default.nix | 8 ++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkgs/development/mobile/androidenv/compose-android-packages.nix b/pkgs/development/mobile/androidenv/compose-android-packages.nix index 1786aebae830..794de2276645 100644 --- a/pkgs/development/mobile/androidenv/compose-android-packages.nix +++ b/pkgs/development/mobile/androidenv/compose-android-packages.nix @@ -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}; }; diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 0228cd839242..a13b98cf945c 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs ? import {} +{ config, pkgs ? import {}, pkgsHostHost ? pkgs.pkgsHostHost , pkgs_i686 ? import { 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 { diff --git a/pkgs/development/mobile/androidenv/ndk-bundle/default.nix b/pkgs/development/mobile/androidenv/ndk-bundle/default.nix index 6bdb71815909..ca305e0398d5 100644 --- a/pkgs/development/mobile/androidenv/ndk-bundle/default.nix +++ b/pkgs/development/mobile/androidenv/ndk-bundle/default.nix @@ -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;