Coder Social home page Coder Social logo

christianmurphy / compile-to-web Goto Github PK

View Code? Open in Web Editor NEW
175.0 17.0 9.0 105 KB

Discover what languages can be compiled to Web Assembly

License: MIT License

C++ 0.60% C 0.35% Crystal 0.12% Java 0.80% Rust 0.27% Swift 0.13% Go 0.46% Julia 0.14% Python 0.13% Haskell 0.18% Ruby 51.48% Shell 40.26% C# 0.65% F# 0.67% Nim 2.23% Kotlin 0.38% TypeScript 0.17% Scala 0.59% D 0.39%
language web-assembly c-plus-plus c crystal go haskell java julia python

compile-to-web's Introduction

Compile to Web

Discover what languages can be compiled into Web Assembly (WASM)

Languages

Language Compiles to LLVM Compiles to WASM
C ☑️ ☑️
C# ☑️ ☑️
C++ ☑️ ☑️
Crystal ☑️
D ☑️ ☑️
F# ☑️ ☑️
Go ☑️ ☑️
Haskell
Java ☑️ ☑️
Julia ☑️
Kotlin ☑️ ☑️
Nim ☑️ ☑️
Python
Rust ☑️ ☑️
Scala ☑️
Swift ☑️
TypeScript

Key

Icon Meaning
☑️ Success
Broken
Unknown

Installation

  1. Install Vagrant
  2. Install VirtualBox
  3. For a desired language cd into the folder, then run
vagrant up
vagrant ssh
sudo su -
install
build

Contributing

Interested in seeing a new language? Found a bug in the examples? Check out the Contributing Guide for how to get involved!

FAQ

Question: Why is "Compile to LLVM" listed?

Answer: LLVM was an influence for WebAssembly technology and was the first compiler infastructure with official WASM support.

compile-to-web's People

Contributors

ar4s avatar christianmurphy 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

compile-to-web's Issues

Python Support

Python support may be possible using the Pyston debugger.
./pyston_dbg -S -n -v -v t.py

Vagrant errors

trying to run with arch as the host machine:

already having run with vagrant up:

~/projects/compile-to-web/C++ master
❯ vagrant ssh
Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-98-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


Last login: Tue Nov 21 04:24:00 2017 from 10.0.2.2
ubuntu@ubuntu-xenial:~$ install
Reading package lists... Done
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package nodejs
--2017-11-21 04:24:10--  https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz
Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.216.80.163
Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.216.80.163|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 36333 (35K) [application/x-tar]
Saving to: ‘emsdk-portable.tar.gz.6’

emsdk-portable.tar.gz.6    100%[======================================>]  35.48K  56.3KB/s    in 0.6s    

2017-11-21 04:24:11 (56.3 KB/s) - ‘emsdk-portable.tar.gz.6’ saved [36333/36333]

emsdk-portable/
emsdk-portable/emsdk
emsdk-portable/emcmdprompt.bat
emsdk-portable/emsdk.bat
emsdk-portable/emsdk_manifest.json
emsdk-portable/emsdk_env.bat
emsdk-portable/README.md
emsdk-portable/binaryen-tags.txt
emsdk-portable/emscripten-tags.txt
emsdk-portable/emsdk_env.sh
Downloading: /home/ubuntu/emsdk-portable/zips/emsdk_unix_update.tar.gz from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emsdk_unix_update.tar.gz, 36333 Bytes
 Unpacking '/home/ubuntu/emsdk-portable/zips/emsdk_unix_update.tar.gz' to '/home/ubuntu/emsdk-portable'
emsdk-portable/emsdk
emsdk-portable/emcmdprompt.bat
emsdk-portable/emsdk.bat
emsdk-portable/emsdk_manifest.json
emsdk-portable/emsdk_env.bat
emsdk-portable/README.md
emsdk-portable/binaryen-tags.txt
emsdk-portable/emscripten-tags.txt
emsdk-portable/emsdk_env.sh
Fetching all tags from Emscripten Github repository...
Done. 109 tagged releases available, latest is 1.37.22.
Fetching all tags from Binaryen Github repository...
Done. 36 tagged Binaryen releases available, latest is 1.37.22.
Fetching all precompiled Nightly versions..
Downloading: /home/ubuntu/emsdk-portable/llvm-nightlies-32bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/nightly/linux_32bit/index.txt
Downloading: /home/ubuntu/emsdk-portable/llvm-nightlies-64bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/nightly/linux_64bit/index.txt, 24146 Bytes
 Downloading: /home/ubuntu/emsdk-portable/emscripten-nightlies.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/emscripten/nightly/linux/index.txt, 25081 Bytes
 Fetching all precompiled tagged releases..
Downloading: /home/ubuntu/emsdk-portable/llvm-tags-32bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/linux_32bit/index.txt
Downloading: /home/ubuntu/emsdk-portable/llvm-tags-64bit.txt from https://s3.amazonaws.com/mozilla-games/emscripten/packages/llvm/tag/linux_64bit/index.txt, 789 Bytes
 Installing SDK 'sdk-incoming-64bit'..
Installing tool 'clang-incoming-64bit'..
Repository 'https://github.com/kripken/emscripten-fastcomp.git' already cloned to directory '/home/ubuntu/emsdk-portable/clang/fastcomp/src', skipping.
Fetching latest changes to the branch 'incoming' for '/home/ubuntu/emsdk-portable/clang/fastcomp/src'...
Already up-to-date.
Successfully updated and checked out branch 'incoming' on repository '/home/ubuntu/emsdk-portable/clang/fastcomp/src'
Current repository version: "Fri, 10 Nov 2017 22:56:20 +0200 4c26a4f8d498ef5b06ef8594d0e5d8d0cf0e8c60"
Repository 'https://github.com/kripken/emscripten-fastcomp-clang.git' already cloned to directory '/home/ubuntu/emsdk-portable/clang/fastcomp/src/tools/clang', skipping.
Fetching latest changes to the branch 'incoming' for '/home/ubuntu/emsdk-portable/clang/fastcomp/src/tools/clang'...
Already up-to-date.
Successfully updated and checked out branch 'incoming' on repository '/home/ubuntu/emsdk-portable/clang/fastcomp/src/tools/clang'
Current repository version: "Sat, 7 Oct 2017 22:07:42 -0700 3659f873b523e5fc89ffa16baab8901fbd084251"
Running CMake: ['cmake', '-G', 'Unix Makefiles', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DPYTHON_EXECUTABLE=/usr/bin/python', '-DLLVM_TARGETS_TO_BUILD=X86;JSBackend', '-DLLVM_INCLUDE_EXAMPLES=OFF', '-DCLANG_INCLUDE_EXAMPLES=OFF', '-DLLVM_INCLUDE_TESTS=OFF', '-DCLANG_INCLUDE_TESTS=OFF', '-DLLVM_ENABLE_ASSERTIONS=ON', '/home/ubuntu/emsdk-portable/clang/fastcomp/src']
[Errno 2] No such file or directory
Could not run CMake, perhaps it has not been installed?
Installing this package requires CMake. Get it via your system package manager (e.g. sudo apt-get install cmake), or from http://www.cmake.org/
Installation failed!
Writing .emscripten configuration file to user home directory /home/ubuntu/
The SDK/tool 'clang-incoming-64bit' cannot be activated since it is not installed! Skipping this tool...
The SDK/tool 'node-4.1.1-64bit' cannot be activated since it is not installed! Skipping this tool...
The SDK/tool 'emscripten-incoming-64bit' cannot be activated since it is not installed! Skipping this tool...
The SDK/tool 'sdk-incoming-64bit' cannot be activated since it is not installed! Skipping this tool...
The Emscripten configuration file /home/ubuntu/.emscripten has been rewritten with the following contents:

import os
SPIDERMONKEY_ENGINE = ''
NODE_JS = 'node'
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

To conveniently access the selected set of tools from the command line, consider adding the following directories to PATH, or call 'source emsdk-portable/emsdk_env.sh' to do this for you.

   /home/ubuntu/emsdk-portable
ubuntu@ubuntu-xenial:~$ build
The program 'emcc' is currently not installed. You can install it by typing:
sudo apt install emscripten

Scala?

Please add Scala to your list.

swift updates - watch this space

emscripten-core/emscripten#2427

to quote @MaxDesiatov
"LLVM 7.0 was released yesterday with a lot of progress for WebAssembly target support. While the backend is still marked as experimental, not as much patching of upstream LLVM repositories should be needed. I've pulled 7.0 updates into Apple swift's fork repositories and rebased the changes in the main swift repository by @patcheng, while also fixing a few compilation issues.

Now the whole fresh toolchain with patches from above comments compiles for me, although I haven't checked yet if the actual WebAssembly support has improved. Going to look into that soon. I'm doing the work in these forks and branches:"

https://github.com/maxdesiatov/swift/tree/swift-to-wasm
https://github.com/maxdesiatov/swift-compiler-rt/tree/wasm
https://github.com/maxdesiatov/swift-llvm/tree/wasm
https://github.com/maxdesiatov/swift-clang/tree/wasm

Compilation error while running Nim ->wasm

Trying to run Nim code in wasm
When I run nim c -d:useRealtimeGC -d:release -d:emscripten --out=index.html hello.nim
I gives me error

Hint: system [Processing]
Hint: hello [Processing]
CC: hello
CC: system
Error: execution of an external compiler program 'emcc -c -w -s WASM=1 -s 'BINARYEN_METHOD="native-wasm"' -Iemscripten -O3  -I/usr/lib/nim -o /vagrant/nimcache/hello.o/vagrant/nimcache/hello.c' failed with exit code: 32512

/bin/sh: 1: emcc: not found
emcc -v
INFO:root:generating system asset: is_vanilla.txt... (this will be cached in "/home/achala/.emscripten_cache/is_vanilla.txt" for subsequent builds)
INFO:root: - ok
INFO:root:(Emscripten: Running sanity checks)
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.16
clang version 6.0.1  (emscripten 1.38.16 : 1.38.16)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/achala/emsdk/clang/e1.38.16_64bit
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
INFO:root:(Emscripten: Running sanity checks)
 nim -v
Nim Compiler Version 0.19.0 [Linux: amd64]
Compiled at 2018-09-26
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: f6c5c636bb1a1f4e1301ae0ba5a8afecef439132
active boot switches: -d:release

How to solve this issue?TIA

Try Nim

Nim compiles down to C code. So it in theory can compile to webasm.

Note: The GC can be a issue.

Dockerize Tests

Create a Docker script for each language build.
So compilation can be tested in a cross platform and easy to reproduce way.

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.