Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc-wrapper: Fix for prebuilt android #97387

Merged
merged 5 commits into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/systems/examples.nix
Expand Up @@ -47,15 +47,15 @@ rec {
armv7a-android-prebuilt = {
config = "armv7a-unknown-linux-androideabi";
sdkVer = "29";
ndkVer = "18b";
ndkVer = "21";
platform = platforms.armv7a-android;
useAndroidPrebuilt = true;
};

aarch64-android-prebuilt = {
config = "aarch64-unknown-linux-android";
sdkVer = "29";
ndkVer = "18b";
ndkVer = "21";
platform = platforms.aarch64-multiplatform;
useAndroidPrebuilt = true;
};
Expand Down
12 changes: 9 additions & 3 deletions pkgs/build-support/cc-wrapper/default.nix
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/androidndk-pkgs/androidndk-pkgs.nix
Expand Up @@ -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 ];
Expand Down
@@ -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"
Expand Down Expand Up @@ -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};
};

Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/mobile/androidenv/default.nix
@@ -1,12 +1,12 @@
{ 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
}:

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 {
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/mobile/androidenv/deploy-androidpackage.nix
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions 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;
Expand Down