Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- clang >= 10 or gcc >= 10
- clang-format
- libomp (if multithreading is required. Multithreading can be disabled using the compiler flag `-DMULTITHREADING 0`)
- wasm-opt (part of the [Binaryen](https://github.com/WebAssembly/binaryen) toolkit)

### Installing openMP (Linux)

Expand Down
19 changes: 10 additions & 9 deletions cpp/src/aztec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if(WASM)
# that as functions in 'env' should be implemented in JS itself.
# It turns out that just explicitly telling the wasm module which object files to include was easiest.
add_executable(
barretenberg-step1.wasm
barretenberg.wasm
$<TARGET_OBJECTS:srs_objects>
$<TARGET_OBJECTS:numeric_objects>
$<TARGET_OBJECTS:crypto_sha256_objects>
Expand All @@ -88,22 +88,23 @@ if(WASM)
# Presumably the -O3 when compiling the object files is fine as it's llvms IR optimiser.
# The backend optimiser is presumably triggered after linking.
target_link_options(
barretenberg-step1.wasm
barretenberg.wasm
PRIVATE
-nostartfiles -O2 -Wl,--no-entry -Wl,--export-dynamic -Wl,--import-memory -Wl,--allow-undefined -Wl,--stack-first -Wl,-z,stack-size=1048576
)

find_program(WASM_OPT wasm-opt)
if(NOT WASM_OPT)
message(FATAL_ERROR "wasm-opt executable not found. Please install binaryen.")
endif()

add_custom_command(
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/barretenberg.wasm
COMMAND wasm-opt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/barretenberg-step1.wasm -O2 --asyncify -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/barretenberg.wasm
DEPENDS barretenberg-step1.wasm
TARGET barretenberg.wasm
POST_BUILD
COMMAND wasm-opt "$<TARGET_FILE:barretenberg.wasm>" -O2 --asyncify -o "$<TARGET_FILE:barretenberg.wasm>"
VERBATIM
)

add_custom_target(
barretenberg.wasm
DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/barretenberg.wasm
)
Comment thread
dbanks12 marked this conversation as resolved.
# For use when compiling dependent cpp projects for WASM
message(STATUS "Compiling all-in-one barretenberg WASM archive")
add_library(
Expand Down