Author |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Tue 13 Dec '22 17:55 Post subject: mod_wasm 0.10.3 Available |
|
|
Download on the VS17 download page
10 March 2023 Update to 0.10.3
Hello Apache Lounge folks!
I’m Jesús González, and I am part of VMware’s Wasm Labs, a group focused on creating open-source tools for WebAssembly (Wasm).
We have created mod_wasm, an Apache module for running WebAssembly binaries inside httpd, and we are working with the ASF to contribute it upstream.
In our GitHub repo https://github.com/vmware-labs/mod_wasm you can find a quick demo for both Python and PHP Wasm binaries.
The hello_wasm demo is as simple as:
Code: | LoadModule wasm_module modules/mod_wasm.so
<Location /hello-wasm>
SetHandler wasm-handler
WasmModule /var/www/modules/hello_wasm.wasm
</Location>
|
We would need your help to ensure mod_wasm can also run on Windows.
Could you please point us in the right direction? We are still figuring out whether a module like mod_wasm (with a Rust dependency) can run directly on Windows (as a .so) or if it would require a special build.
Cheers! |
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7187 Location: Germany, Next to Hamburg
|
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Fri 16 Dec '22 0:54 Post subject: |
|
|
Thanks for your feedback, James!
The insight about mod_log_rotate was very useful
I managed to add the missing parts in the example and build both libraries mod_wasm.so and wasm_runtime.dll. They worked perfectly under the httpd-2.4.54-win64-VS17 provided by Apache Lounge
Compile (mod_wasm.c --> mod_wasm.obj):
Code: | "c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe" /nologo /MD /O2 /LD /W3 -DWIN32 -D_WIN32 -I%APACHE%\include -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\shared" -I"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt" -I"%WASM_RUNTIME%\include" /c /Fomod_wasm.obj mod_wasm.c
|
Link (mod_wasm.obj --> mod_wasm.so):
Code: | "c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\link.exe" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.20348.0\um\x64\kernel32.lib" "%APACHE%\lib\libhttpd.lib" "%APACHE%\lib\libapr-1.lib" "%APACHE%\lib\libaprutil-1.lib" "%WASM_RUNTIME%\target\release\wasm_runtime.dll.lib" /LIBPATH:"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\lib\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.20348.0\ucrt\x64" /nologo /subsystem:windows /dll /out:mod_wasm.so mod_wasm.obj
|
We would be extremely happy if you decide to include mod_wasm for Windows in your Download section
Thanks! |
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7187 Location: Germany, Next to Hamburg
|
|
Back to top |
|
Xing Moderator

Joined: 26 Oct 2005 Posts: 49
|
Posted: Fri 16 Dec '22 9:45 Post subject: |
|
|
How to build wasm_runtime.dll ? |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
|
Back to top |
|
Xing Moderator

Joined: 26 Oct 2005 Posts: 49
|
|
Back to top |
|
Xing Moderator

Joined: 26 Oct 2005 Posts: 49
|
Posted: Sat 17 Dec '22 12:20 Post subject: |
|
|
Ah builds the .dll
In x64 command prompt (vcvarsall.bat).
Changed to the wasm_runtime folder.
did only: cargo build --release
And surprise there is a wasm_runtime.dll in folder wasm_runtime\target\release |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 2992 Location: Hilversum, NL, EU
|
Posted: Sat 17 Dec '22 15:11 Post subject: |
|
|
Thanks! Xing for the pointers.
Jesus, is cargo build --release the good way to get the .dll ?
Was able to build.
Using Visual Studio 2022 Professional, in the compile/link above you are using community.
Tested with Hello Wasm ( https://github.com/vmware-labs/mod_wasm/tree/main/examples )
LoadModule wasm_module modules/mod_wasm.so
<Location /hello-wasm>
SetHandler wasm-handler
WasmModule C:\Apache24\modules/hello_wasm.wasm
</Location>
And get in de Browser : Hello, Wasm! @stdout
and in the Apache error.log : Hello, Wasm! @stderr
Have not yet figured out how to test with PHP ? |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Sat 17 Dec '22 23:24 Post subject: |
|
|
Yes, as @Xing pointed out, running `cargo build --release` will generate the `wasm_runtime.dll` dependency needed to run mod_wasm.
The `make all` command (assuming Make is present), will in addition generate the C bindings from Rust using the cbindgen package. We are providing those bindings in the mod_wasm repo (`wasm_runtime.h`) so that is why executing just `cargo build --release` is enough.
@Steffen, I do believe both Visual Studio 2022 Professional and Community can be used. The key is to ensure dependencies are met (i.e.: MSVC C++ x64/x86 build tools and Windows SDK).
Regarding the examples you tried, `hello_wasm` worked as expected. For PHP, I identified an unexpected behavior and we are looking into it. It seems more related to the PHP Wasm build rather than mod_wasm itself. We'll keep you updated.
In the meantime, I'd suggest trying the Python examples instead with the following Apache configuration and this Python Wasm build: https://github.com/tiran/cpython-wasm-test/releases/download/v3.11.0/Python-3.11.0-wasm32-wasi-16.zip
Code: | <Location /http-request-viewer>
SetHandler wasm-handler
WasmModule C:\mod_wasm-main\examples\wasm_modules\Python-3.11.0-wasm32-wasi-16\python.wasm
WasmMapDir / C:\mod_wasm-main\examples\wasm_modules\Python-3.11.0-wasm32-wasi-16
WasmMapDir /opt C:/mod_wasm-main/examples/wasm_modules
WasmEnv PYTHONHOME /opt/Python-3.11.0-wasm32-wasi-16/lib/python3.11
WasmEnv PYTHONPATH /opt/Python-3.11.0-wasm32-wasi-16/lib/python3.11
WasmArg /opt/python-scripts/http_request_viewer.py
WasmEnableCGI On
</Location>
|
Of course, you can modify all those directories at your convenience. Just make sure that both `PYTHONHOME` and `PYTHONPATH` point to the Python 3.11 libraries, and `WasmArg` contains the Python script to be run whose directory is contained in a `WasmMapDir` directive. I did try several Python scripts with mod_wasm in Windows successfully.
Looking forward to your feedback! |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 2992 Location: Hilversum, NL, EU
|
Posted: Sun 18 Dec '22 15:27 Post subject: |
|
|
When others want to test/use :
On the VS17 Download page.
Please comment !
Last edited by Steffen on Thu 22 Dec '22 10:52; edited 1 time in total |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Tue 20 Dec '22 21:00 Post subject: |
|
|
Steffen,
Just tested your build and it worked for me!
Thanks! |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 2992 Location: Hilversum, NL, EU
|
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Thu 22 Dec '22 13:21 Post subject: |
|
|
These are great news! Thanks!
@Steffen, how do you want us to notify Apache Lounge for new mod_wasm releases? New topic in the forum with the new features/fixes? |
|
Back to top |
|
Beltran
Joined: 27 Jun 2013 Posts: 3 Location: Spain
|
Posted: Mon 16 Jan '23 19:14 Post subject: |
|
|
Hi @Steffen, would be possible to have the mod_wasm extension for VS16? Thanks |
|
Back to top |
|
admin Site Admin

Joined: 15 Oct 2005 Posts: 656
|
Posted: Mon 16 Jan '23 19:25 Post subject: |
|
|
The VS17 version is compatible with VS16. |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 7
|
Posted: Thu 09 Mar '23 17:36 Post subject: mod_wasm v0.10.3 |
|
|
Hola!
We just released a mod_wasm security update (v0.10.3) to address two recently disclosed CVEs (one critical) of Wasmtime, the WebAssembly runtime mod_wasm uses.
Further details can be found in this article and in the mod_wasm changelog.
Let us know if you find any issues.
Cheers!
Jesús |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 2992 Location: Hilversum, NL, EU
|
Posted: Fri 10 Mar '23 12:12 Post subject: |
|
|
Version 0.10.3 available on the VS17 download page. |
|
Back to top |
|