Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable whole_program compilation for SnarkyJS #11166

Merged
merged 7 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/build-snarkyjs-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ pushd "$SNARKY_JS_PATH"
[ -d node_modules ] || npm i
popd

export DUNE_USE_DEFAULT_LINKER="y"

dune b src/lib/crypto/kimchi_bindings/js/node_js \
&& dune b src/lib/snarky_js_bindings/snarky_js_node.bc.js src/lib/snarky_js_bindings/snarkyjs/src/snarky/gen/js-layout.ts || exit 1
&& dune b src/lib/snarky_js_bindings/snarky_js_node.bc.js \
&& dune b src/lib/snarky_js_bindings/snarkyjs/src/snarky/gen/js-layout.ts || exit 1

BINDINGS_PATH="$SNARKY_JS_PATH"/dist/server/node_bindings/
mkdir -p "$BINDINGS_PATH"
Expand Down
5 changes: 4 additions & 1 deletion src/dune.linker.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@

(rule
(target dune-linker)
(enabled_if (= %{bin-available:lld} false))
(enabled_if
(or
(= %{bin-available:lld} false)
(= %{env:DUNE_USE_DEFAULT_LINKER=n} n)))
(action (with-stdout-to dune-linker (echo " "))))
2 changes: 0 additions & 2 deletions src/lib/crypto/kimchi_bindings/dune

This file was deleted.

3 changes: 2 additions & 1 deletion src/lib/crypto/kimchi_bindings/js/chrome/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
flags.sexp
snippets/)
(deps
(source_tree ../../wasm)
../../wasm/Cargo.toml
(source_tree ../../wasm/src)
(source_tree ../../wasm/.cargo/config)
(source_tree ../../../../../external/wasm-bindgen-rayon)
(source_tree ../../../proof-systems) )
Expand Down
3 changes: 2 additions & 1 deletion src/lib/crypto/kimchi_bindings/js/node_js/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
plonk_wasm.js
flags.sexp)
(deps
(source_tree ../../wasm)
../../wasm/Cargo.toml
(source_tree ../../wasm/src)
(source_tree ../../wasm/.cargo/config)
(source_tree ../../../../../external/wasm-bindgen-rayon)
(source_tree ../../../proof-systems) )
Expand Down
2 changes: 1 addition & 1 deletion src/lib/crypto/kimchi_bindings/stubs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[lib]
name = "wires_15_stubs"
crate-type = ["lib", "staticlib"]
crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
array-init = "2.0.0"
Expand Down
5 changes: 3 additions & 2 deletions src/lib/crypto/kimchi_bindings/stubs/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

(rule
(enabled_if (= %{env:MARLIN_PLONK_STUBS=n} n))
(targets libwires_15_stubs.a)
(targets libwires_15_stubs.a dllwires_15_stubs.so)
(deps
Cargo.toml
(source_tree src)
Expand All @@ -27,7 +27,8 @@
RUSTFLAGS
"-C target-feature=+bmi2,+adx"
(run cargo build --release))
(run cp %{read:cargo-target-path}/release/libwires_15_stubs.a .))))
(run cp %{read:cargo-target-path}/release/libwires_15_stubs.a .)
(run cp %{read:cargo-target-path}/release/libwires_15_stubs.so dllwires_15_stubs.so))))

;; copy from $MARLIN_PLONK_STUBS if this exists
(copy_files
Expand Down
3 changes: 3 additions & 0 deletions src/lib/crypto/kimchi_bindings/wasm/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(data_only_dirs src)

(dirs :standard \ target)
1 change: 1 addition & 0 deletions src/lib/dummy_values/gen_values/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(executable
(name gen_values)
(link_flags (-linkall))
(libraries
;; opam libraries
async_unix
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pickles/plonk_checks/gen_scalars/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(executable
(name gen_scalars)
(modes native)
(link_flags (-linkall))
(libraries
;; opam libraries
core_kernel
Expand Down
6 changes: 6 additions & 0 deletions src/lib/snarky_js_bindings/dune
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
(env
(_ (js_of_ocaml (compilation_mode whole_program))))

(executable
(name snarky_js_node)
(modules snarky_js_node)
(modes js)
(link_flags (-noautolink))
(js_of_ocaml
(flags +toplevel.js +dynlink.js))
(libraries snarky_js_bindings_lib node_backend)
Expand All @@ -18,6 +22,7 @@
(name snarky_js_chrome)
(modules snarky_js_chrome)
(modes js)
(link_flags (-noautolink))
(js_of_ocaml
(flags +toplevel.js +dynlink.js))
(libraries snarky_js_bindings_lib chrome_backend)
Expand All @@ -33,6 +38,7 @@
(executable
(name snarky_js_types)
(modules snarky_js_types)
(link_flags (-linkall))
(modes native)
(libraries mina_base fields_derivers_zkapps yojson)
(instrumentation
Expand Down