hyperscan
hyperscan copied to clipboard
Port to web assembly
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:
- 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.
- 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 .
- Build hscheck
emmake make -j<jobs> hscheck
- Run hscheck
node --experimental-wasm-simd --experimental-wasm-eh ./<build-dir>/bin/hscheck.js
@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?
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