You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use binaryen just to emit WASM modules without optimizations, Wasm2JS and so on. Is it possible to compile somewhat minimal amount of code for that? Did not find a quick way to do it.
No, optimisations themselves did not happen. It is just the compilation which takes longer due to compiling cpp files related to optimization passes.
What I did is I added the following to my CMakeLists.txt (I use CMake):
set(BUILD_TESTS Off)
set(BUILD_STATIC_LIB On) # I need a static lib, this is expected
set(BUILD_LLVM_DWARF Off)
set(BUILD_TOOLS Off)
set(ENABLE_WERROR Off)
add_subdirectory(third_party/dependencies/binaryen)
include_directories(third_party/dependencies/binaryen/src)
where third_party/dependencies/binaryen is where a submodule of this repo resides.
Then I launched cmake and did see the following:
There are ~100 files which got compiled but seem related only to optimizations and emscripten and I did not use any of them. So I am wondering if there is a way to turn off the compilation of those files so that the whole process is faster and the output file is less in terms of file size.
Just created a PR to allow configuring this via SKIP_OPTIMIZATIONS option in CMakeLists and a C++ macro.
Changes I made led to decrease in compilation time by 3-4 minutes on my machine and in file size by ~60 MB.
Activity
kripken commentedon May 2, 2025
If you do not specify optimizations, they will not run - what optimizations did you see happen that you didn't want?
(Note that wasm2js specifically does run some passes internally, as part of compilation.)
kormanowsky commentedon May 2, 2025
@kripken
No, optimisations themselves did not happen. It is just the compilation which takes longer due to compiling cpp files related to optimization passes.
What I did is I added the following to my
CMakeLists.txt
(I use CMake):where
third_party/dependencies/binaryen
is where a submodule of this repo resides.Then I launched cmake and did see the following:
There are ~100 files which got compiled but seem related only to optimizations and emscripten and I did not use any of them. So I am wondering if there is a way to turn off the compilation of those files so that the whole process is faster and the output file is less in terms of file size.
kripken commentedon May 2, 2025
Oh, it sounds like you want to build Binaryen itself without optimizations enabled?
There isn't an option for that. You could probably hack up
src/passes/CMakeLists, pass.cpp
to remove passes you don't need, but it would be messy.kormanowsky commentedon May 4, 2025
Just created a PR to allow configuring this via
SKIP_OPTIMIZATIONS
option in CMakeLists and a C++ macro.Changes I made led to decrease in compilation time by 3-4 minutes on my machine and in file size by ~60 MB.