Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does the demo use compiler explorer? #6

Open
EdHeller opened this issue Jun 21, 2024 · 1 comment
Open

Why does the demo use compiler explorer? #6

EdHeller opened this issue Jun 21, 2024 · 1 comment

Comments

@EdHeller
Copy link

Wouldn't it be better to compile to a wasm target and run that output in the browser? Similar to binji/wasm-clang just with nice syntax highlighting for Monaco.

@guyutongxue
Copy link
Owner

There are lots of more things to do to run the compiled executable in browser. We are now using Emscripten for compiling llvm but those C++ code will be compiled to wasm32-wasi. So we also needs a browser-based WASI implementation. As a result, we will ship clangd/clang/lld in Emscripten-packaged environment (and filesystems), and also a WASI environment (and filesystem). This is too complicate (in my opinion).

There might be a solution to this, that is, just use WASI to compile and run everything, including LLVM and user-compiled programs. But I'd tried that LLVM on WASI cannot run inside browser (may be due to memory size limit?). And also, clangd -- a multi-threaded program -- is not available under wasi-preview2.

That's why I decided to use Compiler Explorer API for compiling stuff. If you have a better solution, you are welcomed to give a PR 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants