From 1fe467640a12c1aa3c2380f90976aa085d06285c Mon Sep 17 00:00:00 2001 From: martyall Date: Fri, 13 Dec 2024 13:43:46 -0800 Subject: [PATCH] review in progress --- flake.nix | 3 +- nix/rust.nix | 59 +++++++++---------- .../kimchi_bindings/js/node_js/build.sh | 1 + .../crypto/kimchi_bindings/js/web/build.sh | 1 + 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/flake.nix b/flake.nix index b942ec517a4..c15c3b87951 100644 --- a/flake.nix +++ b/flake.nix @@ -305,7 +305,7 @@ # Packages for the development environment that are not needed to build mina-dev. # For instance dependencies for tests. - devShellPackages = with pkgs; [ rosetta-cli wasm-pack wasm-bindgen-cli nodejs binaryen ]; + devShellPackages = with pkgs; [ rosetta-cli wasm-pack nodejs binaryen ]; in { inherit ocamlPackages; @@ -388,7 +388,6 @@ nativeBuildInputs = oa.nativeBuildInputs ++ [ pkgs.rustup pkgs.libiconv # needed on macOS for one of the rust dep - pkgs.wasm-pack ]; }); diff --git a/nix/rust.nix b/nix/rust.nix index 04f6e8cc40e..3e5af8e77e1 100644 --- a/nix/rust.nix +++ b/nix/rust.nix @@ -62,7 +62,6 @@ let allRefs = true; }).narHash; }) package; - in { kimchi_bindings_stubs = let toolchain = rustChannelFromToolchainFileOf @@ -124,33 +123,6 @@ in { doCheck = false; }; - - wasm-bindgen-cli = final.rustPlatform.buildRustPackage rec { - pname = "wasm-bindgen-cli"; - version = "0.2.87"; - src = final.fetchCrate { - inherit pname version; - sha256 = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0="; - }; - - cargoSha256 = "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko="; - - nativeBuildInputs = [ final.pkg-config ]; - - buildInputs = with final; - [ openssl ] ++ lib.optionals stdenv.isDarwin [ - curl - darwin.apple_sdk.frameworks.Security - libiconv - ]; - - checkInputs = [ final.nodejs ]; - - # other tests, like --test=wasm-bindgen, require it to be ran in the - # wasm-bindgen monorepo - cargoTestFlags = [ "--test=reference" ]; - }; - plonk_wasm = let lock = ../src/lib/crypto/proof-systems/Cargo.lock; @@ -161,6 +133,30 @@ in { rustPlatform = rustPlatformFor final.kimchi-rust-wasm; + wasm-bindgen-cli = final.rustPlatform.buildRustPackage rec { + pname = "wasm-bindgen-cli"; + version = "0.2.87"; + src = final.fetchCrate { + inherit pname version; + sha256 = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0="; + }; + + cargoSha256 = "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko="; + nativeBuildInputs = [ final.pkg-config ]; + + buildInputs = with final; + [ openssl ] ++ lib.optionals stdenv.isDarwin [ + curl + darwin.apple_sdk.frameworks.Security + libiconv + ]; + + checkInputs = [ final.nodejs ]; + + # other tests, like --test=wasm-bindgen, require it to be ran in the + # wasm-bindgen monorepo + cargoTestFlags = [ "--test=reference" ]; + }; in rustPlatform.buildRustPackage { pname = "plonk_wasm"; version = "0.1.0"; @@ -169,7 +165,7 @@ in { ]; buildAndTestSubdir = "plonk-wasm"; sourceRoot = "source/lib/crypto/proof-systems"; - nativeBuildInputs = [ final.wasm-pack final.wasm-bindgen-cli ]; + nativeBuildInputs = [ final.wasm-pack wasm-bindgen-cli ]; buildInputs = with final; lib.optional stdenv.isDarwin libiconv; cargoLock.lockFile = lock; cargoLock.outputHashes = narHashesFromCargoLock lock; @@ -194,10 +190,9 @@ in { runHook preBuild ( set -x - ls export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296" - wasm-pack build ./plonk-wasm --mode no-install --target nodejs --out-dir $out/nodejs -- --features nodejs - wasm-pack build ./plonk-wasm --mode no-install --target web --out-dir $out/web + wasm-pack build --mode no-install --target nodejs --out-dir $out/nodejs ./plonk-wasm -- --features nodejs + wasm-pack build --mode no-install --target web --out-dir $out/web ./plonk-wasm ) runHook postBuild ''; diff --git a/src/lib/crypto/kimchi_bindings/js/node_js/build.sh b/src/lib/crypto/kimchi_bindings/js/node_js/build.sh index 3b98883d7ca..c835d8556d2 100755 --- a/src/lib/crypto/kimchi_bindings/js/node_js/build.sh +++ b/src/lib/crypto/kimchi_bindings/js/node_js/build.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +# When using nix this is already cached if [[ -z "${PLONK_WASM_NODEJS-}" ]]; then export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296" # The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml diff --git a/src/lib/crypto/kimchi_bindings/js/web/build.sh b/src/lib/crypto/kimchi_bindings/js/web/build.sh index 18d0c02e270..0fbd1c7afb6 100755 --- a/src/lib/crypto/kimchi_bindings/js/web/build.sh +++ b/src/lib/crypto/kimchi_bindings/js/web/build.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +# When using nix this is already cached if [[ -z "${PLONK_WASM_WEB-}" ]]; then export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296" # The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml