r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.
https://docs.r-wasm.org/webr/latest/
Other
805 stars 54 forks source link

Consider allowing multiple cores to be used in `make` to speed up compilation from scratch #405

Open coatless opened 2 months ago

coatless commented 2 months ago

I think only the tools/ llvm part of the compilation is allowing jobs/commands to run simultaneously. As a result, the build times from scratch are a bit time-intensive. Would it be possible to add -j$(NPROC) after $(MAKE) to allow using as many cores as possible?


Note, that there are some parallelized portions already in use. Specifically, in the llvm part due to the use of ninja.

cmake -G Ninja -S /Users/ronin/Documents/GitHub/oss/webr/tools/flang/llvm-project/llvm -B /Users/ronin/Documents/GitHub/oss/webr/tools/flang/build \
      -DCMAKE_INSTALL_PREFIX=/Users/ronin/Documents/GitHub/oss/webr/host \
      -DCMAKE_BUILD_TYPE=MinSizeRel \
      -DLLVM_DEFAULT_TARGET_TRIPLE="wasm32-unknown-emscripten" \
      -DLLVM_TARGETS_TO_BUILD="WebAssembly" \
      -DLLVM_ENABLE_PROJECTS="clang;flang;mlir" \

Also, in a separate file related to dragonegg that doesn't seem to be called, we have the desired $(MAKE) command using -j$(NPROC):

https://github.com/r-wasm/webr/blob/2f3b4673bded2aa62249249efe6636bfa3d8348c/tools/dragonegg/Makefile#L40