From d198d6a8db1ccb72d2db04826ad3803c3d148d36 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 21 Dec 2023 09:57:43 +0000 Subject: [PATCH] core: build iOS library with ghc 9.6.3 with iPhone7 etc. support (#3577) * bump haskell.nix * bump flake.lock * Try openssl fix * CFLAGS. not CCFLAGS * Fix iOS build issues and improve static library handling --------- Co-authored-by: Moritz Angermann --- flake.lock | 36 +++++++++++++++++++++++++++--------- flake.nix | 13 ++++++++++++- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index e5f8d531c..a11e01683 100644 --- a/flake.lock +++ b/flake.lock @@ -119,12 +119,15 @@ } }, "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -190,11 +193,11 @@ "hackage": { "flake": false, "locked": { - "lastModified": 1702340598, - "narHash": "sha256-CC0HI+6iKPtH+8r/ZfcpW5v/OYvL7zMwpr0xfkXV1zU=", + "lastModified": 1702513363, + "narHash": "sha256-kloro9uEe8aYhPMoMjVNq2rfrXNgMOZhOPwVH5DH2K0=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "24617c569995e38bf3b83b48eec6628a50fdb4fb", + "rev": "a9d931d0398da67846fa257922a924829233cb91", "type": "github" }, "original": { @@ -240,11 +243,11 @@ "stackage": "stackage" }, "locked": { - "lastModified": 1700119633, - "narHash": "sha256-nZY2eIo8TkRbXgJXEWMm9zor330GuUtcNzvUN9tN64U=", + "lastModified": 1701163700, + "narHash": "sha256-sOrewUS3LnzV09nGr7+3R6Q6zsgU4smJc61QsHq+4DE=", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "1fe47a3d52e1ecd6247c8ab83811a21de2e2f074", + "rev": "2808bfe3e62e9eb4ee8974cd623a00e1611f302b", "type": "github" }, "original": { @@ -673,6 +676,21 @@ "repo": "stackage.nix", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 999f097c2..6fabe7d65 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,9 @@ }); in let iosPostInstall = bundleName: '' ${pkgs.tree}/bin/tree $out + mkdir tmp + find ./dist -name "libHS*-ghc*.a" -exec cp {} tmp \; + (cd tmp; ${pkgs.tree}/bin/tree .; ar x libHS*.a; for o in *.o; do if /usr/bin/otool -xv $o|grep ldadd ; then echo $o; fi; done; cd ..; rm -fR tmp) mkdir -p $out/_pkg # copy over includes, we might want those, but maybe not. # cp -r $out/lib/*/*/include $out/_pkg/ @@ -82,6 +85,13 @@ ${mac2ios.packages.${system}.mac2ios}/bin/mac2ios $pkg chmod -w $pkg done + + mkdir tmp + find $out/_pkg -name "libHS*-ghc*.a" -exec cp {} tmp \; + (cd tmp; ${pkgs.tree}/bin/tree .; ar x libHS*.a; for o in *.o; do if /usr/bin/otool -xv $o|grep ldadd ; then echo $o; fi; done; cd ..; rm -fR tmp) + + sha256sum $out/_pkg/*.a + (cd $out/_pkg; ${pkgs.zip}/bin/zip -r -9 $out/${bundleName}.zip *) rm -fR $out/_pkg mkdir -p $out/nix-support @@ -536,7 +546,8 @@ packages.direct-sqlcipher.flags.commoncrypto = true; packages.entropy.flags.DoNotGetEntropy = true; packages.simplexmq.components.library.libs = pkgs.lib.mkForce [ - (pkgs.openssl.override { static = true; }) + # TODO: have a cross override for iOS, that sets this. + ((pkgs.openssl.override { static = true; }).overrideDerivation (old: { CFLAGS = "-mcpu=apple-a7 -march=armv8-a+norcpc" ;})) ]; }]; }).simplex-chat.components.library.override (