binji / wasm-clang

Running Clang/LLD in WebAssembly Demo
https://binji.github.io/wasm-clang
Apache License 2.0
259 stars 27 forks source link

Measure of incompleteness and general overview #3

Open jeff-hykin opened 4 years ago

jeff-hykin commented 4 years ago

This project is awesome! I'm interested in how broken/practical it is.

I found this in the test.js, I thought it was a pretty good gauge

  // #include <algorithm>  // FAIL
  // #include <any> // ok
  #include <array> // FAIL
  // #include <bitset> // FAIL
  // #include <chrono> // ok
  // #include <complex> // FAIL
  // #include <filesystem> // ok
  // #include <fstream> // ok
  // #include <functional> // FAIL
  // #include <initializer_list> // ok
  // #include <iomanip> // FAIL
  // #include <iosfwd> // ok
  // #include <ios> // ok
  // #include <iostream> // FAIL
  // #include <istream> // FAIL
  // #include <iterator> // ok
  // #include <limits> // ok
  // #include <list> // FAIL
  // #include <locale> // FAIL
  // #include <map> // FAIL
  // #include <memory> // ok
  // #include <new> // ok
  // #include <numeric> // FAIL
  // #include <optional> // FAIL
  // #include <ostream> // FAIL
  // #include <random> // FAIL
  // #include <regex> // ok
  // #include <set> // FAIL
  // #include <span> // FAIL
  // #include <sstream> // FAIL
  // #include <stack> // FAIL
  // #include <streambuf> // ok
  // #include <string> // FAIL
  // #include <string_view> // FAIL
  // #include <tuple> // ok
  // #include <typeindex> // ok
  // #include <typeinfo> // ok
  // #include <type_traits> // ok
  // #include <unordered_map> // FAIL
  // #include <unordered_set> // FAIL
  // #include <valarray> // FAIL
  // #include <variant> // FAIL
  // #include <vector> // FAIL
  // #include <version> // ok

Do you have any advice in terms of major roadblocks causing some of these to fail?

I don't need anything crazy like multithreading or sockets, and even the canvas is overkill for my purposes. Security, keeping up with LLVM master, and performance are also completely irrelevant to me. I have an extensive background in C++, JS web-dev, and Node.js, but absolutely 0 experience with LLVM itself.

binji commented 4 years ago

Thanks for your interest! I'm not sure why these headers would fail in particular, other than that I built on top of a relatively new toolchain (wasi-sdk from about a year ago), which also may have had missing pieces. I also implemented features as I needed them for the demo, so there are likely to be holes there too.

To really productionize this code, I think it would be necessary to take some of the hacks to LLVM I did here and figure out the best way to upstream them. This may be tricky to do, since the WASI platform is still unstable. This is important for keeping up with LLVM master (which you state as a non-goal), but also increases the likelihood that things work.

The next step would be to use a better WASI polyfill for the web; as mentioned above, the one I implemented works, but uses an older version of the WASI API, and is incomplete.

jeff-hykin commented 4 years ago

Thanks @binji that helps a lot, I'll take a look at those hacks and building it with the lastest wasi sdk. What I'll be doing will probably be pretty hacky/incomplete for my purposes as well, but hopefully it'll build on what is already here.

HappyCerberus commented 3 years ago

Considering that this ended up in the state it was presented on CppCon, do you know about any projects that are taking this further? I'm interested in this type of setup exactly for educational purposes, since the initial setup is the main barrier for teaching C++ (and offline work on a mobile device, tablet or a chromebook is near impossible).

binji commented 3 years ago

Yeah, I'm sorry I haven't had more time to put into this. It really would be great if someone could take this further! I'd be happy to help with code reviews or suggestions.