logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Third-party Modules View previous topic :: View next topic
Reply to topic   Topic: mod_wasm Available Page 1, 2  Next
Author
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Tue 13 Dec '22 17:55    Post subject: mod_wasm Available Reply with quote

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

PostPosted: Wed 14 Dec '22 10:12    Post subject: Reply with quote

Hello Jesús,
since it is a single C file you may take a look at how mod_log_rotate is compiled against the binaries from ApacheLounge https://github.com/JBlond/mod_log_rotate/blob/master/build.md

if there is still a question please ask again.
Back to top
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Fri 16 Dec '22 0:54    Post subject: Reply with quote

Thanks for your feedback, James!
The insight about mod_log_rotate was very useful Very Happy

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 Cool

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 Mr. Green

Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Fri 16 Dec '22 9:19    Post subject: Reply with quote

it would be nice if you could add the windows compiling steps to https://github.com/vmware-labs/mod_wasm/tree/main/mod_wasm
Back to top
Xing
Moderator


Joined: 26 Oct 2005
Posts: 49

PostPosted: Fri 16 Dec '22 9:45    Post subject: Reply with quote

How to build wasm_runtime.dll ?
Back to top
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Fri 16 Dec '22 13:23    Post subject: Reply with quote

Hi,

@James, nice feedback. Windows build instructions are now included at https://github.com/vmware-labs/mod_wasm/tree/main/mod_wasm

@Xing, Rust will automatically target the host platform. You can find detailed instructions here: https://github.com/vmware-labs/mod_wasm/tree/main/wasm_runtime

Hope this helps!
Back to top
Xing
Moderator


Joined: 26 Oct 2005
Posts: 49

PostPosted: Sat 17 Dec '22 11:37    Post subject: Reply with quote

Followed the steps at https://github.com/vmware-labs/mod_wasm/tree/main/wasm_runtime

All fine with cargo install cbindgen.

Changed to the wasm_runtime folder.

Then what to do ? make all not recognized as command.
Back to top
Xing
Moderator


Joined: 26 Oct 2005
Posts: 49

PostPosted: Sat 17 Dec '22 12:20    Post subject: Reply with quote

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

PostPosted: Sat 17 Dec '22 15:11    Post subject: Reply with quote

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

PostPosted: Sat 17 Dec '22 23:24    Post subject: Reply with quote

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

PostPosted: Tue 20 Dec '22 21:00    Post subject: Reply with quote

Steffen,

Just tested your build and it worked for me! Mr. Green


Thanks!
Back to top
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Thu 22 Dec '22 13:21    Post subject: Reply with quote

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

PostPosted: Mon 16 Jan '23 19:14    Post subject: Reply with quote

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

PostPosted: Mon 16 Jan '23 19:25    Post subject: Reply with quote

The VS17 version is compatible with VS16.
Back to top
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Thu 09 Mar '23 17:36    Post subject: mod_wasm v0.10.3 Reply with quote

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

PostPosted: Mon 10 Apr '23 15:54    Post subject: mod_wasm v0.11.1 available Reply with quote

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

PostPosted: Tue 02 May '23 11:19    Post subject: Reply with quote

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

PostPosted: Mon 08 May '23 14:32    Post subject: mod_wasm v0.11.3 fixes Reply with quote

Hi,

Just released v0.11.3 to downgrade a dependency that introduced a regression issue on Windows.

https://github.com/vmware-labs/mod_wasm/releases/tag/v0.11.3

Cheers,
Jesús
Back to top
gzurl



Joined: 13 Dec 2022
Posts: 12

PostPosted: Tue 30 May '23 20:59    Post subject: mod_wasm v0.12.0 Reply with quote

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

PostPosted: Mon 03 Jul '23 14:47    Post subject: mod_wasm v0.12.1 Reply with quote

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


Reply to topic   Topic: mod_wasm Available View previous topic :: View next topic
Post new topic   Forum Index -> Third-party Modules Page 1, 2  Next