# HAC running in the browser via GNAT-LLVM (WebAssembly)

**URL:** <https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536>\
**Category:** Releases\
**Tags:** ada, gnat\
**Created:** [June 30, 2026, 5:27pm UTC](https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536 "2026-06-30T17:27:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ovenpasta](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/ovenpasta/32/1061_2.png) [@ovenpasta](https://forum.ada-lang.io/u/ovenpasta)\
**Post date:** [June 30, 2026, 5:27pm UTC](https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536/1 "2026-06-30T17:27:04Z")

</div>

I’ve ported **HAC** ( [GitHub - zertovitch/hac: HAC Ada Compiler - a small, quick Ada compiler fully in Ada · GitHub](https://github.com/zertovitch/hac) ) (by Gautier de Montmollin) to the web - it runs as **WebAssembly** , live, here:

> **[HAC in WebAssembly](https://pizzahack.eu/hac_web/)**
>
> An Ada compiler and p-code VM (HAC) in your browser. Showcases the new GNAT-LLVM wasm port with native Ada exception-handling support, by Aldo Nicolas Bruno.

Type an **Ada** (subset) program, and it is **compiled and executed** on the spot, **entirely in your browser**. Nothing is sent to or run on the server; the page is just static assets.

Two compilers are involved, so to be clear about which does what:

- **GNAT-LLVM** (the GNAT front end on an LLVM back end) is what I used to build HAC itself into WebAssembly - a one-time, offline step.
- **HAC** is the compiler you actually use on the page: that wasm build of HAC, running in your browser, compiles the Ada you type to its p-code and runs it on its VM.

A couple of points likely of interest here:

- **HAC is used unmodified.** The **wasm**  **runtime** now supports **real Ada exception propagation** (implemented with native WebAssembly exception handling), so HAC builds and runs from upstream sources as-is - no wasm-specific workarounds.
- **It is exercised seriously.** HAC’s own regression suite - 133 tests, including the Advent of Code sets for 2020-2025 - passes in full (133/133) running through the wasm build.

Sources, for anyone who wants to look or build it:

- GNAT-LLVM fork: [GitHub - ovenpasta/gnat-llvm: LLVM based GNAT compiler · GitHub](https://github.com/ovenpasta/gnat-llvm)
- AdaWebPack (wasm runtimes + Web bindings): [GitHub - ovenpasta/adawebpack: Ada WASM Runtime and Bindings for Web API · GitHub](https://github.com/ovenpasta/adawebpack)
- The hac\_web demo itself lives in AdaWebPack under examples/hac\_web/.

Feedback welcome.

---

<div class="post-metadata">

**Author:** ![zertovitch](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/zertovitch/32/90_2.png) [@zertovitch](https://forum.ada-lang.io/u/zertovitch)\
**Post date:** [July 1, 2026, 5:50am UTC](https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536/2 "2026-07-01T05:50:59Z")

</div>

Wow!  
I have a noob question regarding WebAssembly: how is the text in the editor widget passed to HAC?  
Is there a local file system?

---

<div class="post-metadata">

**Author:** ![ovenpasta](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/ovenpasta/32/1061_2.png) [@ovenpasta](https://forum.ada-lang.io/u/ovenpasta)\
**Post date:** [July 1, 2026, 6:21am UTC](https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536/3 "2026-07-01T06:21:17Z")

</div>

First the javascript side passes the file as a string + the filename

> <https://github.com/ovenpasta/adawebpack/blob/d8bebeb0c5ddf2b87cd767f28ab6d0e3b5cc0424/examples/hac_web/index.html#L286>

Then wasm (Ada) side creates a string stream and passes it to Build\_Main:

> <https://github.com/ovenpasta/adawebpack/blob/d8bebeb0c5ddf2b87cd767f28ab6d0e3b5cc0424/examples/hac_web/hac_runner.adb#L40>

But to answer your filesystem question, it could, emcc supports it, and perhaps it is next step, that would enable having multiple source files

---

<div class="post-metadata">

**Author:** ![ovenpasta](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/ovenpasta/32/1061_2.png) [@ovenpasta](https://forum.ada-lang.io/u/ovenpasta)\
**Post date:** [July 1, 2026, 7:29am UTC](https://forum.ada-lang.io/t/hac-running-in-the-browser-via-gnat-llvm-webassembly/4536/4 "2026-07-01T07:29:01Z")

</div>

Just to clarify, hac on wasm emcc supports already loading from filesystem, just the hac\_web example doesn’t at the moment because it is on the browser. But hac\_cli.js (included in the hac\_web example) does.

Example:

mypack.ads

```ada
package Mypack is
   function Double (X : Integer) return Integer;
end Mypack;

```

mypack.adb

```ada
package body Mypack is
   function Double (X : Integer) return Integer is
   begin
      return X * 2;
   end Double;
end Mypack;

```

main.adb

```ada
with HAT; use HAT;
with Mypack;
procedure Main is
begin
   Put_Line ("Using a separate package Mypack:");
   Put_Line ("Double (21) =" & Integer'Image (Mypack.Double (21)));
end Main;

```

```ada
Run and output:
$ node hac_cli.js main.adb
Using a separate package Mypack:
Double (21) = 42

```
