Author |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Tue 13 Dec '22 17:55 Post subject: mod_wasm Available |
|
|
Download on the VS17 download page
03 July Update to 0.12.1, see below
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: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
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: 7373 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: 12
|
|
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: 3094 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: 12
|
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 |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Tue 20 Dec '22 21:00 Post subject: |
|
|
Steffen,
Just tested your build and it worked for me!
Thanks! |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
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: 692
|
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: 12
|
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 |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Mon 10 Apr '23 15:54 Post subject: mod_wasm v0.11.1 available |
|
|
Hola!
Just a heads up about recent mod_wasm v0.11.x releases: https://github.com/vmware-labs/mod_wasm/releases
v0.11.0 allows Wasm modules to return any output type via stdout, including binaries with non UTF-8 bytes sequences or \0 NULL terminators in the middle.
v0.11.1 fixes an issue where a new thread could not create a new Wasm execution context while another thread was running a Wasm module.
Cheers! |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Tue 02 May '23 11:19 Post subject: |
|
|
Hola!
We just released a mod_wasm security update (v0.11.2) to address a recent CVE (low severity). More details in the changelog.
Best,
Jesús |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Tue 30 May '23 20:59 Post subject: mod_wasm v0.12.0 |
|
|
Hola,
We just released mod_wasm v0.12.0!
This new version introduces a new directive, WasmMapCGIFileNames, providing the ability to configure CGI applications using custom guest directories, eliminating the need for both the host and the guest to use the same paths. It also normalizes SCRIPT_FILENAME to use Unix-like forward slashes. This feature is particularly helpful when setting up Windows applications, as it allows for the use of paths that may not be compatible in Windows (with backslashes and drive letters).
Looking forward to your feedback.
Cheers,
Jesús |
|
Back to top |
|
gzurl
Joined: 13 Dec 2022 Posts: 12
|
Posted: Mon 03 Jul '23 14:47 Post subject: mod_wasm v0.12.1 |
|
|
Hola!
mod_wasm v0.12.1 available!
This maintenance release bumps Wasmtime to 10.0.1, including preliminary support for WASI preview 2 among other improvements and fixes.
Best,
Jesús |
|
Back to top |
|