GNAT-LLVM in Alire and improved WASM support

Dear committee,

I would like to propose a project to encourage GNAT-LLVM to be upstreamed to Alire, and update AdaWebPack (RTS for WASM). I am not willing to take upon this task.

What is GNAT-LLVM and AdaWebPack?

GNAT-LLVM is a newish Ada compiler based on the LLVM infrastructure. It uses the same sources as GNAT while additionally bringing CCG (C Code Generator), which is able to translate most of Ada into C. One large advantage of GNAT-LLVM over GCC-GNAT is that LLVM uses a single binary to target any architecture (if it was compiled to support it). This means that with a single compiler a user could target x86, ARM, RISC-V, AMD, NVPTX, WASM… LLVM is also favoured in the *BSD world in comparison to GCC. Making the new compiler easily available in Alire for the Ada community and other projects will increase its adoption and usage; as it is currently quite difficult to get it installed properly.

Additionally, GNAT-LLVM is used as the compiler for WASM (Web Assembly). The only RTS support for WASM is GitHub - godunko/adawebpack: Ada WASM Runtime and Bindings for Web API · GitHub which has not seen much support in the last years while the rest of the WASM ecosystem has kept on evolving. For example, WASM 3.0 Wasm 3.0 Completed - WebAssembly was released recently and it brings a substantial amount of improvements while the underlying main compiler for WASM https://emscripten.org/ has also seen a lot improvements and low level additions that could be leveraged by the RTS. It would be very nice it AdaWebPack could also be updated alongside GNAT-LLVM.

Why should this idea be considered?

GNAT-LLVM is a very competitive open source compiler (even if it mostly just GNAT) and it comes with CCG. It is the only compiler with support for some architectures (WASM) and it is seeing a lot of improvements and work done by major companies such as Intel, NVIDIA, AMD, ARM, etc. LLVM also bring in some cool features that GCC may be lacking and those could be interesting too.

WASM (AdaWebPack) is a rapidly growing target that allows for very efficient computations in the browser or as standalone portable binaries. It is now even presented for server applications. If Ada/SPARK can be compiled to WASM, we could even have formally verified binaries for the web. I believe no other language has managed to do that.

The tasks

  • Add the latest GNAT-LLVM (LLVM v21) to Alire. There have already been attempts on this but they have not been upstreadmed.
  • Update and add AdaWebPack to Alire.

Disclaimer

I am part of the committee and I will not vote on this topic.

Best regards,
Fer

EDIT: I was made aware of https://wgpu.rs/ If Ada in WASM has good support, bindings for WGPU library could be created. It would then enable GPU accelerated graphics, in a platform independent manner, to be created directly from WASM in Ada. That would be pretty nice!

9 Likes

NB: in the GNAT FSF builds repo, we plan on building and publishing a build of GNAT LLVM around the same time as the GCC 16 release a bit later this year.

Work is already ongoing to publish binary releases of various AdaCore tools like GNATformat, GNATdoc, GNATtest and GNATcov.

12 Likes

Hi,

I did some work to make gnat llvm work on gcc 15 and then on 16 pre release. I’ve also made adawebpack work with it, and added more packages to the runtime, and support for emscriptem. I’ve also added support for multiple runtimes in the same installation. Was mostly an experiment, I hope to see all of this upstream. Thank you

5 Likes

I know only the basics about compilers, but isn’t C being treated as an all-round intermediary problematic ? Isn’t it much less rich than a dedicated bytecode ?
And if LLVM already uses a bytecode (if I remember well), why bother passing by C?

I think there is a misunderstanding, gnat-llvm is not using C as intermediary. It is just another output target.