Giter Club home page Giter Club logo

adawebpack's Introduction

Build binaries

AdaWebPack

AdaWebPack includes GNAT-LLVM compiler for WebAssembly target, GNAT Run Time Library and AdaWebPack bindings for Web API.

How to install

Prebuild packages are available on Release page.

You will also need wasm-ld, the Web asssembly linker. You will find this:

  • on Fedora Linux through the lld package;
  • on Ubuntu through the lld-15 package;
  • on other Linux systems look for a similarly-named package.

How to build

  • Setup GNAT using Alire or GNAT Community 2021.

  • Clone GNAT-LLVM. Latest known good revision of GNAT-LLVM compatible with GNAT FSF is e000ea613704acc27238ec17ce020251427f9e1d.

    git clone https://github.com/AdaCore/gnat-llvm
    git -C gnat-llvm checkout e000ea613704acc27238ec17ce020251427f9e1d
    
  • Clone bb-runtimes. Use gnat-fsf-12 branch.

    git clone -b gnat-fsf-12 https://github.com/Fabien-Chouteau/bb-runtimes gnat-llvm/llvm-interface/bb-runtimes
    
  • Clone GCC sources. Use, for instance, e000ea613704acc27238ec17ce020251427f9e1d commit.

    git clone --single-branch --shallow-since=13-11-2022 https://github.com/gcc-mirror/gcc gnat-llvm/llvm-interface/gcc
    git -C gnat-llvm/llvm-interface/gcc checkout e000ea613704acc27238ec17ce020251427f9e1d
    
  • Setup GNAT-LLVM development environment, see details in GNAT-LLVM README. Note, you need to use externally build LLVM with enabled 'lld' project and 'WebAssembly' target, so, if you build it your-self, cmake command line should contain among other switches:

    cmake ... -DLLVM_ENABLE_PROJECTS='...;clang;lld' -DLLVM_TARGETS_TO_BUILD="...;WebAssembly"
    

    On Ubuntu it is possible to install prebuild LLVM/CLang packages (use LLVM/CLang 15). However, alternatives need to be updated using the provided script:

    sudo utilities/update-alternatives-clang.sh 15 100
    

    Or install a LLVM 15 binary release (llvm-15, lld-15 and clang-15 are required).

  • Checkout AdaWebPack repository into gnat-llvm/llvm-interface as adawebpack_src and create link for Makefile.target.

    cd gnat-llvm/llvm-interface
    git clone https://github.com/godunko/adawebpack.git adawebpack_src
    ln -s adawebpack_src/source/rtl/Makefile.target
    cd -
    
  • Create a link to RTS source code

    cd gnat-llvm/llvm-interface
    ln -s bb-runtimes/gnat_rts_sources/include/rts-sources/
    cd -
    
  • Create a link to GNAT source code (or copy it)

    cd gnat-llvm/llvm-interface
    ln -s gcc/gcc/ada gnat_src
    cd -
    
  • Apply patch to GNAT-LLVM repository

    cd gnat-llvm
    patch -p0 < llvm-interface/adawebpack_src/patches/gnat-llvm.patch
    cd -
    
  • Use make wasm to build compiler and Run Time Library

    cd gnat-llvm/llvm-interface
    make wasm
    cd -
    
  • When make finishes, you will find toolchain in gnat-llvm/llvm-interface/bin.

    cd gnat-llvm/llvm-interface
    export PATH=$PWD/bin:$PATH
    cd -
    
  • Now you can build examples:

    cd gnat-llvm/llvm-interface/adawebpack_src
    make build_examples
    cd -
    

    You will most likely need to run the examples through an HTTP server; otherwise, the browser will report a security error and/or refuse to load the page. An easy way to obtain an HTTP server is by via Python 3 with python3 -m http.server.

Usage with Docker

It could be handy to use docker.

  • Find latest build on our Fedora COPR repository.
  • Build a container image (make sure to replace curl argument with latest RPM URL)
    docker build --tag wgprbuild - <<EOF
    FROM registry.fedoraproject.org/fedora-minimal:36
    RUN microdnf --assumeyes install \
      make \
      rpmdevtools \
      libstdc++-static \
      libgnat \
      clang \
      llvm-devel \
      lld \
      gprbuild \
      gdb \
      git \
      openssh-server \
      tar \
      gzip \
      chrpath \
      ca-certificates && \
    curl -O \
    https://download.copr.fedorainfracloud.org/results/reznik/adawebpack/fedora-36-x86_64/05068491-adawebpack/adawebpack-22.1.0-git.fc36.x86_64.rpm && \
    rpm -i adawebpack*.rpm && \
    rm -f adawebpack*.rpm && \
    microdnf clean all
    EOF
    
  • Write a bash wrapper script to replace gprbuild like this:
    #!/bin/bash
    exec docker run --rm --tmpfs /tmp/ --user $UID --volume $HOME:$HOME --workdir $PWD wgprbuild gprbuild "$@"

Unsupported features

  • nested subprograms are not supported

  • exceptions support is limited to local exceptions propagation and last chance handler

  • tasks and protected objects are not supported

License

Web API bindings is licensed under BSD3 license.

GNAT Runtime Library is licensed under GPL3 license with GCC Runtime Library Exception.

adawebpack's People

Contributors

godunko avatar johnperry-math avatar reznikmm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

adawebpack's Issues

Compile GHDL to WASM?

Hello,

I wanted to ask for help and seeing how feasible it would be to compile GHDL to WASM using this tool? My ultimate goal is to be able to run GHDL in a web browser (or just universally) similar to YoWASP for Yosys.

I've tried using the adawebpack binaries (extracting them from the rpm) but it doesn't provide an llvm-config (which is required by GHDL for compilation). I've also tried compiling adawebpack and gnat-llvm from source but that turned into a mess fairly quickly. Any advice or help would be appreciated. Thank you.

Documentation requests: GNAT, wasm-ld, and an http server

It works! Some suggestions on improving the documentation:

Update "How to install" with...

Tell users they need

  • a recent version of GNAT, in order to have access to gprbuild
  • wasm-ld, which can be obtained:
    • on Fedora Linux through the lld package,
    • on Ubuntu through the lld-13 package (I think),
    • on other systems through...
      (GNAT might be obvious, but wasm-ld won't be obvious until it fails.)

Update "Now you can build examples" with...

Tell users they probably need to run the examples through an HTTP server; they cannot just load them them as HTML files. An http server is easily obtained by running python3 -m http.server (if one has Python3 installed) or ...

This second item has dogged me from time to time. I do web development very rarely, so I forget that modern web browsers don't allow one to load a script from a local filesystem unless one goes through a web server.

Perhaps include images of expected output.

I watched @reznikmm 's presentation at FOSDEM and he showed a rotating cube that one could manipulate. It was great! but... the WebGL demo included here was a bit of a disappointment after that.

Actually, am I seeing the right thing? All I see is a white box on a black background. I could inspect the Ada code, but perhaps it would be nice to include a screenshot in the documentation, so that new users know what to expect?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.