Skip to content

moriaam/cib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clang In Browser (cib)

Try it at https://tbfleming.github.io/cib/

I'm trying to see how far wasm can go. Is it possible to compile clang to wasm and have it generate code within the browser?

Current status:

  • Works in Firefox 57 and Chrome 63
  • clang-format: working
  • clang: working for simple cases
  • Running generated wasm: working for simple cases

Currently missing:

  • Global constructors and destructors
  • Standard library globals (e.g. cin, cout)
  • RTTI, exception handling

VM for building clang

  • Create a fresh VM to build with. The build will probably fail if you already have emscripten or clang installed.
  • Consider using a high thread-count VM; e.g. an EC2 c5.9xlarge.
  • I put the repo in a dedicated volume while building; this aids using spot instances. 100 GB.

Ubuntu 16.04:

sudo apt update
sudo apt upgrade
sudo apt install build-essential cmake ninja-build python nodejs-legacy libncurses-dev

Building WASM binaries

./build.py -a

This script:

  • Clones needed repos
  • Builds an llvm toolchain for targeting WASM
  • Builds emscripten
  • Invokes emscripten to:
    • set up environment
    • build emscripten's dependances
  • Uses emscripten to build llvm libraries
  • Builds the apps

About

clang running in browser (wasm)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 40.0%
  • Python 22.0%
  • C++ 19.4%
  • HTML 15.4%
  • CMake 3.2%