Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/deshrike/c-wasm
Compile C to WebAssembly Experiment
https://github.com/deshrike/c-wasm
c linux llvm mandelbrot wabt wasm webassembly
Last synced: about 4 hours ago
JSON representation
Compile C to WebAssembly Experiment
- Host: GitHub
- URL: https://github.com/deshrike/c-wasm
- Owner: DeShrike
- Created: 2023-07-29T19:25:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-30T20:17:33.000Z (over 1 year ago)
- Last Synced: 2023-07-30T21:25:24.404Z (over 1 year ago)
- Topics: c, linux, llvm, mandelbrot, wabt, wasm, webassembly
- Language: JavaScript
- Homepage:
- Size: 478 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compile C to WebAssembly Experiment
## Dependencies
- LLVM - at least version 8
- WABT
- cmake - to build WABT, at least version 3.16## Getting started
Tested on _Ubuntu 18.04.1 LTS_
Install dependencies, see below.
Clone this repo and build:
```console
$ git clone https://github.com/DeShrike/c-wasm.git
$ cd c-wasm
$ ./build.sh
```### Browser
Start a local webserver:
```console
$ python3 -m http.server 8000
```Point your browser to http://localhost:8000/index.html
![Screenshot](c_wasm_screenshot.png)
### NodeJS
Tested with _v16.20.1_
```console
$ node node-app.js
```## Install LLVM
```console
$ sudo apt-get install llvm-8 clang-8 lld-8
```## Build cmake
```console
$ mkdir ~/temp
$ cd ~/temp
$ wget https://cmake.org/files/v3.16/cmake-3.16.0.tar.gz
$ tar -xzvf cmake-3.16.0.tar.gz
$ cd cmake-3.16.0/
$ ./bootstrap
$ make -j$(nproc)
$ sudo make install
$ cmake --version
```## Clone and build WABT
```console
$ git clone --recursive https://github.com/WebAssembly/wabt
$ cd wabt
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build
$ sudo make install
```## Usefull commands
```console
$ wasm-objdump -x main.o
``````console
$ wasm2wat main.wasm
```