Skip to content

Commit 3d2484c

Browse files
committed
kimchi-bindings/js: back on nightly and use 2023-09-18
nightly has been initially removed as it seemed to make vendoring all the dependencies more complicated (which seems to not be the case though). However, removing nightly introduces issues like "DataCloneError", see o1-labs/o1js#1989, which makes the reliance on nightly inevitable. It seems that --offline works out of the box. Another note is that cargo vendor has been introduced to provide a consistent build environment for all platforms and all users, including the CI. The lockfile Cargo.lock is meant to provide a locked environment with all the dependencies, including the transitive ones. However, it is only used by binaries. In our build process, we do build a static library (libwires_15_stubs.a), not a binary. And Rust doesn't use the lockfile in this case. Another solution than `cargo vendor` would have been to strictly enforce the version in the top-level Cargo.toml, but it implies to add all the transitive dependencies (as otherwise, when a new transitive dependency is released, cargo will fetch it, making the environment inconsistent). This solution is not viable as the purpose of Cargo.toml is to enforce versions on direct dependencies only, and leave the cargo solver doing its job for the transitive dependencies. For these reasons, the solution of vendoring the dependencies to build the static library has been selected.
1 parent f2c4046 commit 3d2484c

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

src/lib/crypto/kimchi_bindings/js/node_js/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ set -euo pipefail
33

44
if [[ -z "${PLONK_WASM_NODEJS-}" ]]; then
55
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
6-
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
7-
rustup run 1.72 wasm-pack build --target nodejs --out-dir ../js/node_js ../../wasm -- --features nodejs --offline
6+
wasm-pack build --target nodejs --out-dir ../js/node_js ../../wasm -- -Zbuild-std=std,panic_abort --features nodejs --offline
87
else
98
cp "$PLONK_WASM_NODEJS"/* -R .
109
fi

src/lib/crypto/kimchi_bindings/js/node_js/dune

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
;; Required as we use Cargo workspace, and the build requires the Cargo.toml
3232
;; and sources for each members
3333
../../wasm/Cargo.toml
34+
;; Enforcing the rust version used for the build
35+
../../wasm/rust-toolchain.toml
3436
(source_tree ../../wasm/src))
3537
(locks /cargo-lock) ; lock for rustup
3638
(action

src/lib/crypto/kimchi_bindings/js/web/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ set -euo pipefail
33

44
if [[ -z "${PLONK_WASM_WEB-}" ]]; then
55
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
6-
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
7-
rustup run 1.72 wasm-pack build --target web --out-dir ../js/web ../../wasm -- --offline
6+
wasm-pack build --target web --out-dir ../js/web ../../wasm -- --offline -Zbuild-std=std,panic_abort
87
else
98
cp "$PLONK_WASM_WEB"/* -R .
109
fi

src/lib/crypto/kimchi_bindings/js/web/dune

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
;; Required as we use Cargo workspace, and the build requires the Cargo.toml
3232
;; and sources for each members
3333
../../wasm/Cargo.toml
34+
;; Enforcing the rust version used for the build
35+
../../wasm/rust-toolchain.toml
3436
(source_tree ../../wasm/src))
3537
(locks /cargo-lock) ; lock for rustup
3638
(action
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Used to build stanzas in ../js/node_js and ../js/web.
2+
#
3+
# 2023-09-18 is used because serde 1.0.217 uses the feature Saturating not
4+
# working for versions before 2023-09-18
5+
# For more information regarding the usage of nightly, see
6+
# https://github.com/o1-labs/o1js/issues/1989
17
[toolchain]
2-
# This should stay in line with the versions in
3-
# - kimchi_bindings/js/node_js/build.sh
4-
# - kimchi_bindings/js/web/build.sh
5-
channel = "1.72"
8+
channel = "nightly-2023-09-18"

0 commit comments

Comments
 (0)