diff --git a/barretenberg/cpp/scripts/wasmtime.sh b/barretenberg/cpp/scripts/wasmtime.sh index 3ad657d5798d..3e4032043ab8 100755 --- a/barretenberg/cpp/scripts/wasmtime.sh +++ b/barretenberg/cpp/scripts/wasmtime.sh @@ -5,6 +5,7 @@ set -eu export WASMTIME_BACKTRACE_DETAILS=1 exec wasmtime run \ -Wthreads=y \ + -Wunknown-imports-trap=y \ -Sthreads=y \ ${HARDWARE_CONCURRENCY:+--env HARDWARE_CONCURRENCY} \ --env HOME \ diff --git a/barretenberg/cpp/src/barretenberg/env/throw_or_abort_impl.cpp b/barretenberg/cpp/src/barretenberg/env/throw_or_abort_impl.cpp index 2cc76037a1f5..fdff0104f6e3 100644 --- a/barretenberg/cpp/src/barretenberg/env/throw_or_abort_impl.cpp +++ b/barretenberg/cpp/src/barretenberg/env/throw_or_abort_impl.cpp @@ -1,3 +1,14 @@ +// In WASM builds, throw_or_abort_impl is provided by the JavaScript environment +// (declared as WASM_IMPORT in throw_or_abort_impl.hpp). The JS implementation +// throws a catchable JS Error with the error message. +// +// For non-JS WASM runtimes (wasmtime), the import must also be provided. +// See barretenberg/cpp/scripts/wasmtime.sh for the wasmtime configuration. +// +// We guard out the C++ definition so the JS import is used instead of being +// shadowed by the local definition (which would call std::abort). +#ifndef __wasm__ + #include "barretenberg/common/log.hpp" #include "barretenberg/common/wasm_export.hpp" #include @@ -27,3 +38,5 @@ WASM_EXPORT void throw_or_abort_impl [[noreturn]] (const char* err) abort_with_message(err); #endif } + +#endif // !__wasm__