From b6e813b8cdd7bbf4f447ec4c259c85155a5cf06f Mon Sep 17 00:00:00 2001 From: Artturin Date: Thu, 25 Jul 2024 18:53:17 +0300 Subject: [PATCH] treewide: Rename android `sdkVer` and `ndkVer` `sdkVer` conflicts with the old `sdkVer`(now `darwinSdkVersion` but that still uses `sdkVer` if set) used by darwin This shouldn't be an issue but due to `pkgs/development/interpreters/python/cpython/default.nix` running `lib.filterAttrs (n: v: ! lib.isDerivation v && n != "passthruFun")` on it's inputs (2 of them are darwin only) the `throw "Unsupported sdk...` in `pkgs/top-level/darwin-packages.nix` will be triggered. After this change `pkgsCross.armv7a-android-prebuilt.python3.pythonOnBuildForHost` won't fail with `error: Unsupported sdk: 33` Issue was bisected to 3cb23cec239d4f73bb1b51f26ac7599384fdadd6 (cherry picked from commit 1144d46f9510b8c31d0195e8049caa0df3eb3fec) --- lib/systems/examples.nix | 10 ++++------ .../androidndk-pkgs/androidndk-pkgs.nix | 16 ++++++++-------- pkgs/stdenv/cross/default.nix | 2 +- pkgs/top-level/all-packages.nix | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 79ec4461e419..0fc37fa715a6 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -60,23 +60,21 @@ rec { armv7a-android-prebuilt = { config = "armv7a-unknown-linux-androideabi"; rustc.config = "armv7-linux-androideabi"; - sdkVer = "28"; - ndkVer = "24"; useAndroidPrebuilt = true; } // platforms.armv7a-android; aarch64-android-prebuilt = { config = "aarch64-unknown-linux-android"; rustc.config = "aarch64-linux-android"; - sdkVer = "28"; - ndkVer = "24"; + androidSdkVersion = "28"; + androidNdkVersion = "24"; useAndroidPrebuilt = true; }; aarch64-android = { config = "aarch64-unknown-linux-android"; - sdkVer = "30"; - ndkVer = "24"; + androidSdkVersion = "30"; + androidNdkVersion = "24"; libc = "bionic"; useAndroidPrebuilt = false; useLLVM = true; diff --git a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix index a8b172f4eb5d..561bae2a9b92 100644 --- a/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix +++ b/pkgs/development/androidndk-pkgs/androidndk-pkgs.nix @@ -44,7 +44,7 @@ let buildInfo = ndkBuildInfoFun stdenv.buildPlatform; targetInfo = ndkTargetInfoFun stdenv.targetPlatform; - inherit (stdenv.targetPlatform) sdkVer; + androidSdkVersion = if (stdenv.targetPlatform ? androidSdkVersion && stdenv.targetPlatform.androidSdkVersion != null) then stdenv.targetPlatform.androidSdkVersion else (throw "`androidSdkVersion` is not set during the importing of nixpkgs"); suffixSalt = lib.replaceStrings ["-" "."] ["_" "_"] stdenv.targetPlatform.config; # targetInfo.triple is what Google thinks the toolchain should be, this is a little @@ -76,8 +76,8 @@ rec { cp -r ${androidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double} $out/toolchain find $out/toolchain -type d -exec chmod 777 {} \; - if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} ]; then - echo "NDK does not contain libraries for SDK version ${sdkVer}"; + if [ ! -d $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion} ]; then + echo "NDK does not contain libraries for SDK version ${androidSdkVersion}"; exit 1 fi @@ -85,8 +85,8 @@ rec { ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.so $out/lib/ ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/*.a $out/lib/ chmod +w $out/lib/* - ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer}/*.so $out/lib/ - ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${sdkVer}/*.o $out/lib/ + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.so $out/lib/ + ln -s $out/toolchain/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion}/*.o $out/lib/ echo "INPUT(-lc++_static)" > $out/lib/libc++.a @@ -129,7 +129,7 @@ rec { bintools = binutils; libc = targetAndroidndkPkgs.libraries; extraBuildCommands = '' - echo "-D__ANDROID_API__=${stdenv.targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags + echo "-D__ANDROID_API__=${stdenv.targetPlatform.androidSdkVersion}" >> $out/nix-support/cc-cflags # Android needs executables linked with -pie since version 5.0 # Use -fPIC for compilation, and link with -pie if no -shared flag used in ldflags echo "-target ${targetInfo.triple} -fPIC" >> $out/nix-support/cc-cflags @@ -150,9 +150,9 @@ rec { # cross-compiling packages to wrap incorrectly wrap binaries we don't include # anyways. libraries = runCommand "bionic-prebuilt" {} '' - lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${sdkVer} + lpath=${buildAndroidndk}/libexec/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/${buildInfo.double}/sysroot/usr/lib/${targetInfo.triple}/${androidSdkVersion} if [ ! -d $lpath ]; then - echo "NDK does not contain libraries for SDK version ${sdkVer} <$lpath>" + echo "NDK does not contain libraries for SDK version ${androidSdkVersion} <$lpath>" exit 1 fi mkdir -p $out/lib diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index 1cbbfeb6d202..8aa83b8aa858 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -64,7 +64,7 @@ in lib.init bootStages ++ [ cc = if crossSystem.useiOSPrebuilt or false then buildPackages.darwin.iosSdkPkgs.clang else if crossSystem.useAndroidPrebuilt or false - then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang + then buildPackages."androidndkPkgs_${crossSystem.androidNdkVersion}".clang else if targetPlatform.isGhcjs # Need to use `throw` so tryEval for splicing works, ugh. Using # `null` or skipping the attribute would cause an eval failure diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f54fce79166d..ded2b23ca8a4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20099,7 +20099,7 @@ with pkgs; # TODO(@Ericson2314): Build bionic libc from source bionic = if stdenv.hostPlatform.useAndroidPrebuilt - then pkgs."androidndkPkgs_${stdenv.hostPlatform.ndkVer}".libraries + then pkgs."androidndkPkgs_${stdenv.hostPlatform.androidNdkVer}".libraries else callPackage ../os-specific/linux/bionic-prebuilt { }; boolstuff = callPackage ../development/libraries/boolstuff { };