From 093fcd1629c4c0c9bfc0d6c7a538a679e9d481ef Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Fri, 5 May 2023 16:02:28 +0300 Subject: [PATCH 1/2] ocamlPackages.hacl-star-raw: use _mm_malloc on darwin --- .../ocaml-modules/hacl-star/aligned-alloc.patch | 14 ++++++++++++++ pkgs/development/ocaml-modules/hacl-star/raw.nix | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 pkgs/development/ocaml-modules/hacl-star/aligned-alloc.patch diff --git a/pkgs/development/ocaml-modules/hacl-star/aligned-alloc.patch b/pkgs/development/ocaml-modules/hacl-star/aligned-alloc.patch new file mode 100644 index 000000000000..a5c0b6720699 --- /dev/null +++ b/pkgs/development/ocaml-modules/hacl-star/aligned-alloc.patch @@ -0,0 +1,14 @@ +diff --git a/hacl-star-raw/karamel/include/krml/internal/target.h b/hacl-star-raw/karamel/include/krml/internal/target.h +index 695873a..c0aed18 100644 +--- a/hacl-star-raw/karamel/include/krml/internal/target.h ++++ b/hacl-star-raw/karamel/include/krml/internal/target.h +@@ -82,6 +82,9 @@ + # endif + # if (defined(_MSC_VER) || (defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR))) + # define KRML_ALIGNED_MALLOC(X, Y) _aligned_malloc(Y, X) ++# elif defined(__APPLE__) ++# include ++# define KRML_ALIGNED_MALLOC(X, Y) _mm_malloc(Y, X) + # else + # define KRML_ALIGNED_MALLOC(X, Y) aligned_alloc(X, Y) + # endif diff --git a/pkgs/development/ocaml-modules/hacl-star/raw.nix b/pkgs/development/ocaml-modules/hacl-star/raw.nix index 027d6fe17854..de20299cd4a1 100644 --- a/pkgs/development/ocaml-modules/hacl-star/raw.nix +++ b/pkgs/development/ocaml-modules/hacl-star/raw.nix @@ -20,6 +20,10 @@ stdenv.mkDerivation rec { stripRoot = false; }; + patches = [ + ./aligned-alloc.patch + ]; + minimalOCamlVersion = "4.08"; # strictoverflow is disabled because it breaks aarch64-darwin From b2963e311a5bafefed14b2d340a153da33c64ef4 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Fri, 5 May 2023 16:02:39 +0300 Subject: [PATCH 2/2] ligo: fix build on darwin --- pkgs/development/compilers/ligo/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/compilers/ligo/default.nix b/pkgs/development/compilers/ligo/default.nix index 7493d73787a5..1ebcbe786850 100644 --- a/pkgs/development/compilers/ligo/default.nix +++ b/pkgs/development/compilers/ligo/default.nix @@ -10,6 +10,7 @@ , mustache-go , yaml2json , tezos-rust-libs +, darwin }: ocamlPackages.buildDunePackage rec { @@ -110,6 +111,8 @@ ocamlPackages.buildDunePackage rec { pure-splitmix zarith_stubs_js simple-diff + ] ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security ]; preBuild = ''