Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to web assembly #367

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

krczapla
Copy link

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

xiangwang1 and others added 13 commits April 21, 2022 13:27
Throw std::bad_alloc instead of returning nullptr from
ue2::AlignedAllocator. Allocators for STL containers are expected never
to return with an invalid pointer, and instead must throw on failure.
Violating this expectation can lead to invalid pointer dereferences.

Co-authored-by: johanngan <johanngan.us@gmail.com>

fixes github issue intel#317 (PR intel#320)
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.

2. 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 .
```

3. Build hscheck

```
emmake make -j<jobs> hscheck
```

4. Run hscheck

```
node --experimental-wasm-simd --experimental-wasm-eh ./<build-dir>/bin/hscheck.js
```
@Litch1-v
Copy link

Litch1-v commented Jan 5, 2023

@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?

@strawgate
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants