From 73e2f608377a81b7ad3ff94c3e5586bded36ac71 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 22 Jun 2018 21:49:41 -0400 Subject: [PATCH 1/7] libiconv: add "enableShared" option When false, shared libraries will be disabled. also adds patch to *really* disable shared libiconv. --- pkgs/development/libraries/libiconv/default.nix | 9 +++++++-- .../apple-source-releases/libiconv/default.nix | 14 +++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkgs/development/libraries/libiconv/default.nix b/pkgs/development/libraries/libiconv/default.nix index 169a4d38bb5..0e900ca9db6 100644 --- a/pkgs/development/libraries/libiconv/default.nix +++ b/pkgs/development/libraries/libiconv/default.nix @@ -1,6 +1,7 @@ { fetchurl, stdenv, lib , buildPlatform, hostPlatform , enableStatic ? stdenv.hostPlatform.useAndroidPrebuilt +, enableShared ? !stdenv.hostPlatform.useAndroidPrebuilt }: # assert !stdenv.isLinux || hostPlatform != buildPlatform; # TODO: improve on cross @@ -23,10 +24,14 @@ stdenv.mkDerivation rec { lib.optionalString ((hostPlatform != buildPlatform && hostPlatform.libc == "msvcrt") || stdenv.cc.nativeLibc) '' sed '/^_GL_WARN_ON_USE (gets/d' -i srclib/stdio.in.h - ''; + '' + + lib.optionalString (!enableShared) '' + sed -i -e '/preload/d' Makefile.in + ''; configureFlags = lib.optional stdenv.isFreeBSD "--with-pic" - ++ lib.optional enableStatic "--enable-static"; + ++ lib.optional enableStatic "--enable-static" + ++ lib.optional (!enableShared) "--disable-shared"; meta = { description = "An iconv(3) implementation"; diff --git a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix index bb9e4fa755d..369556fd5a1 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libiconv/default.nix @@ -1,15 +1,19 @@ -{ stdenv, appleDerivation, autoreconfHook, targetPlatform, enableStatic ? targetPlatform.isiOS }: +{ stdenv, appleDerivation, lib, autoreconfHook, targetPlatform +, enableStatic ? targetPlatform.isiOS +, enableShared ? !targetPlatform.isiOS +}: appleDerivation { postUnpack = "sourceRoot=$sourceRoot/libiconv"; - preConfigure = stdenv.lib.optionalString stdenv.hostPlatform.isiOS '' + preConfigure = lib.optionalString stdenv.hostPlatform.isiOS '' sed -i 's/darwin\*/ios\*/g' configure libcharset/configure ''; - configureFlags = stdenv.lib.optionals enableStatic [ "--enable-static" "--disable-shared" ]; + configureFlags = lib.optional enableStatic "--enable-static" + ++ lib.optional (!enableShared) "--disable-shared"; - postInstall = stdenv.lib.optionalString (!enableStatic) '' + postInstall = lib.optionalString (!enableStatic) '' mv $out/lib/libiconv.dylib $out/lib/libiconv-nocharset.dylib ${stdenv.cc.bintools.targetPrefix}install_name_tool -id $out/lib/libiconv-nocharset.dylib $out/lib/libiconv-nocharset.dylib @@ -26,6 +30,6 @@ appleDerivation { ]; meta = { - platforms = stdenv.lib.platforms.darwin; + platforms = lib.platforms.darwin; }; } From 7652b2ef16375ed1e38056c69da4125b0c25c3f2 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 24 Jun 2018 16:33:20 -0400 Subject: [PATCH 2/7] android: add --build-id to ldflags the gcc in android does not have this on by default. Doing this will fix some of the errors in cross-trunk: https://hydra.nixos.org/build/76354538/nixlog/11 This is related to how separate debug info is handled in Nixpkgs. --- pkgs/development/mobile/androidenv/androidndk-pkgs.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 5c42f7bc328..011b8eb0099 100644 --- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix +++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix @@ -58,6 +58,9 @@ rec { binutils = wrapBintoolsWith { bintools = binaries; libc = targetAndroidndkPkgs.libraries; + extraBuildCommands = '' + echo "--build-id" >> $out/nix-support/libc-ldflags + ''; }; gcc = wrapCCWith { From d9155904b347679163c6fe6702f8ec6384bd8c40 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 24 Jun 2018 16:42:10 -0400 Subject: [PATCH 3/7] androidndk: add fullNDK option Setting this to true will disable removing some of the unused parts of the NDK toolchain that is unused in Nixpkgs but may be used by others. /cc @bkchr --- pkgs/development/mobile/androidenv/androidndk.nix | 6 ++++++ pkgs/development/mobile/androidenv/androidndk_r8e.nix | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/pkgs/development/mobile/androidenv/androidndk.nix b/pkgs/development/mobile/androidenv/androidndk.nix index 150d8d75869..1e8ea65c73d 100644 --- a/pkgs/development/mobile/androidenv/androidndk.nix +++ b/pkgs/development/mobile/androidenv/androidndk.nix @@ -1,6 +1,9 @@ { stdenv, fetchurl, zlib, ncurses5, unzip, lib, makeWrapper , coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which , platformTools, python3, libcxx, version, sha256 +, fullNDK ? false # set to true if you want other parts of the NDK + # that is not used by Nixpkgs like sources, + # examples, docs, or LLVM toolchains }: stdenv.mkDerivation rec { @@ -55,11 +58,14 @@ stdenv.mkDerivation rec { } cd ${pkg_path} + '' + lib.optionalString (!fullNDK) '' # Steps to reduce output size rm -rf docs sources tests # We only support cross compiling with gcc for now rm -rf toolchains/*-clang* toolchains/llvm* + '' + + '' find ${pkg_path}/toolchains \( \ \( -type f -a -name "*.so*" \) -o \ \( -type f -a -perm -0100 \) \ diff --git a/pkgs/development/mobile/androidenv/androidndk_r8e.nix b/pkgs/development/mobile/androidenv/androidndk_r8e.nix index 44fa961b992..3c12e16277d 100644 --- a/pkgs/development/mobile/androidenv/androidndk_r8e.nix +++ b/pkgs/development/mobile/androidenv/androidndk_r8e.nix @@ -1,6 +1,9 @@ { stdenv, fetchurl, zlib, ncurses, lib, makeWrapper , coreutils, file, findutils, gawk, gnugrep, gnused, jdk, which , platformTools +, fullNDK ? false # set to true if you want other parts of the NDK + # that is not used by Nixpkgs like sources, + # examples, docs, or LLVM toolchains }: stdenv.mkDerivation rec { @@ -49,11 +52,13 @@ stdenv.mkDerivation rec { -d $out/libexec/${name} < ${ ./make-standalone-toolchain_r8e.patch } cd ${pkg_path} + '' + lib.optionalString (!fullNDK) '' # Steps to reduce output size rm -rf docs sources tests # We only support cross compiling with gcc for now rm -rf toolchains/*-clang* toolchains/llvm-* + '' + '' find ${pkg_path}/toolchains \( \ \( -type f -a -name "*.so*" \) -o \ \( -type f -a -perm -0100 \) \ From 2c2169c8810a5be2456ed2340efb8a8064e1db2b Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 24 Jun 2018 16:48:03 -0400 Subject: [PATCH 4/7] ghc: build shared on android We run into issues otherwise --- pkgs/development/compilers/ghc/8.4.3.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/8.4.3.nix b/pkgs/development/compilers/ghc/8.4.3.nix index 10035af90a8..702bf1cf9b9 100644 --- a/pkgs/development/compilers/ghc/8.4.3.nix +++ b/pkgs/development/compilers/ghc/8.4.3.nix @@ -22,7 +22,7 @@ , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. - enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt && !targetPlatform.useiOSPrebuilt + enableShared ? !targetPlatform.isWindows && !targetPlatform.useiOSPrebuilt , # Whetherto build terminfo. enableTerminfo ? !targetPlatform.isWindows From 5000cc555eb35292e3819f73ee497957d1311ab0 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 24 Jun 2018 19:15:36 -0400 Subject: [PATCH 5/7] android: define __ANDROID_API__ in cflags This is needed for targeting older apis. --- pkgs/development/mobile/androidenv/androidndk-pkgs.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix index 011b8eb0099..0f43705c0d4 100644 --- a/pkgs/development/mobile/androidenv/androidndk-pkgs.nix +++ b/pkgs/development/mobile/androidenv/androidndk-pkgs.nix @@ -67,7 +67,10 @@ rec { cc = binaries; bintools = binutils; libc = targetAndroidndkPkgs.libraries; - extraBuildCommands = lib.optionalString targetPlatform.isAarch32 (let + extraBuildCommands = '' + echo "-D__ANDROID_API__=${targetPlatform.sdkVer}" >> $out/nix-support/cc-cflags + '' + + lib.optionalString targetPlatform.isAarch32 (let p = targetPlatform.platform.gcc or {} // targetPlatform.parsed.abi; flags = lib.concatLists [ From 31eac6fd0088710c193efebb632f1c97ef3045a6 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 24 Jun 2018 23:15:09 -0400 Subject: [PATCH 6/7] impure.nix: fix handling of localSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we passed a localSystem in, we don’t want the current system to override it. Now we check for localSystem first to avoid getting "mixed" localSystem values from commands like this: nix-build --arg localSystem '{config="x86_64-unknown-linux-musl";}' -A hello Which would eventually evaluate localSystem to this: { config = "x86_64-unknown-linux-musl"; system = "x86_64-darwin"; } & Nix would not be able to run it correctly. Fixes #41599 /cc @Ericson2314 --- pkgs/top-level/impure.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index df462665dd1..dafa351c4e4 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -83,5 +83,6 @@ import ./. (builtins.removeAttrs args [ "system" "platform" ] // { inherit config overlays crossSystem; # Fallback: Assume we are building packages on the current (build, in GNU # Autotools parlance) system. - localSystem = { system = builtins.currentSystem; } // localSystem; + localSystem = (if args ? localSystem then {} + else { system = builtins.currentSystem; }) // localSystem; }) From 69cad91b5c34b9ff474e973d39dd114cd91e6e82 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Mon, 25 Jun 2018 09:38:16 -0400 Subject: [PATCH 7/7] =?UTF-8?q?ghc843:=20don=E2=80=99t=20apply=20stripping?= =?UTF-8?q?=20in=20android?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This breaks some library symbols apparently. ARM symbols must be incorrectly stripped. Also some very weird issues with patchelf. --- pkgs/development/compilers/ghc/8.4.3.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.4.3.nix b/pkgs/development/compilers/ghc/8.4.3.nix index 702bf1cf9b9..0f5a43d57ed 100644 --- a/pkgs/development/compilers/ghc/8.4.3.nix +++ b/pkgs/development/compilers/ghc/8.4.3.nix @@ -75,7 +75,7 @@ let targetCC = builtins.head toolsForTarget; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (rec { version = "8.4.3"; name = "${targetPrefix}ghc-${version}"; @@ -209,4 +209,8 @@ stdenv.mkDerivation rec { inherit (ghc.meta) license platforms; }; -} +} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt { + dontStrip = true; + dontPatchELF = true; + noAuditTmpdir = true; +})