hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

Port to web assembly

Open krczapla opened this issue 2 years ago • 2 comments

I added HYPERSCAN_WASM32 cmake option. If enabled, it sets appropriate headers and compile definitions that enables WASM compilation;

I conditionaly replace some of the codeblocks that are not compilable into WASM. This blocks fetch cpu information in order to enable some extra features (that how I understand it). In the WASM conext there is no "CPU" hence no CPU info;

In order to build wasm hyperscan you need to do following:

  1. Prepare environment

Install and activate emscripten sdk. Follow steps in this instruction: https://emscripten.org/docs/getting_started/downloads.html. Use version that supports wasm exceptions proposal e.g. 3.1.16. Install nodejs version that supports wasm exceptions e.g. v16.16.0.

  1. Configure Hyperscan
cd <where-you-want-to-build-hyperscan>
mkdir <build-dir>
cd <build-dir>
emcmake cmake -DFAT_RUNTIME=FALSE -DBUILD_EXAMPLES=OFF -DHYPERSCAN_WASM32=ON -DHYPERSCAN_EMSCRIPTEN_BOOST=ON -S ../ -B .
  1. Build hscheck
emmake make -j<jobs> hscheck
  1. Run hscheck
node --experimental-wasm-simd --experimental-wasm-eh ./<build-dir>/bin/hscheck.js

krczapla avatar Sep 16 '22 13:09 krczapla

@krczapla thanks for your job,I build it successfully,but the hscheck.wasm size up to 90M,is there any way to reduce its size?

Litch1-v avatar Jan 05 '23 12:01 Litch1-v

Did you have to do anything special to get emcmake to find boost? Im getting errors that i need to specify boost_root but the normal hyperscan build instructions work just fine

strawgate avatar May 20 '23 00:05 strawgate