If you open an issue on wasi-sdk we can find out.
Ah, I should add this patch to my PR. Thanks for investigating!
If you open an issue on wasi-sdk we can find out.
Ah, I should add this patch to my PR. Thanks for investigating!
Shouldnāt that be gated by thread usage instead of being wasm or not?
Iāve gated it by thread usage.
Iāve changed the build so that it compiles everything into the single LLVM driver binary (the llvm driver). This produces a complete toolchain less than 23 MB in size! Unfortunately, for some reason clang built this way doesnāt seem to run cc1 in-process, or perhaps it just doesnāt show it this way with -###; I havenāt investigated closely.
The configure time cost for the API checks is unfortunate, but not cost prohibitive right?
The piecemeal adoption of the APIs as originally proposed (i.e. HAVE_? checks) could improve the codebase for portability. While some of the semantics cannot be provided on all platforms, it might make it easier to provide equivalences across platforms for subsets with different ways to write the necessary operation. It could even possibly help smoothen some of the windows/Unix differences (e.g. LLVM_ON_UNIX) which often is confusing with MinGW and cygwin in the mix.
I am just speculating here, but maybe the wasi driver ends up generating more than one action? We artificially limit cc1 to one running action in-process, because clang leaks its memory on exit (see -disable-free). It was judged that several actions would require more testing, and I never got around to land that. However the in-process branch Iāve mentioned above can run any number of actions in-process by disabling -disable-free for all in-process actions. You can maybe try doing that for wasi specifically?
One other point if you do that: LLD doesnāt have a -disable-free flag, it always leaks its memory and thereās no flag to disable that behavior. But it could be added easily (early in lld.cpp). But maybe tail actions can keep -disable-free active.
Iām quite late to this party (and Iāve only skimmed the discussion) but just BTW/FYI Iāve been building mlir+llvm->wasi nightlies for about a month (with releases being published here; ctrl+f mlir_wasm). I donāt have much to add, since as I said I havenāt caught up yet on the prior discussion, but also itās clear youāve solved more blockers than I did.
One interesting/surprising thing (for me, personally) was how much smaller the resulting binaries (e.g., mlir-opt) ended up being (~26MB), which turned out to be the case because wasm doesnāt (by default) named symbols for functions (instead using an index into a function array).
Anyway I guess just here to say I think this is great and Iāll be watching/reading.
Thereās a significant difference between the two builds: mine is pure-Wasm, while yours as far as I can tell is Emscripten with embind. Both have their advantages; my intended application doesnāt make it feasible to use Emscripten, which is why Iām going for a pure-Wasm/WASI build.
Thereās a significant difference between the two builds
Yea it wasnāt clear what the exact differences were but it was clear there were significant differences. I didnāt mean to imply that I had solved many of the problems youāve solved.
Emscripten with embind
I do have -lembind there but Iām not currently using any of the embind facilities
(Iām actually not using that distrbution at all but when I do, I donāt plan to use embind, so thatās just a stray flag).
Any updates on this RFC/the corresponding PR?
I could also help with implementation / replying to review if that would help getting this merged ![]()
We are waiting for a resolution on this wasi-libc PR.
The wasi-libc PR has been merged, so the door is now open for LLVM to be tested on nightly wasi-sdk. Iām not sure if Iāll have time for it this year. Also, the LLVM changes probably canāt be merged until there is a new wasi-sdk release.
LLVM was apparently already tested with the PR, and now another PR, this time for libc++ integration in wasi-libc, is the one this effort is blocked on.
Any updates on this? It would be really cool if we could use LLVM from WebAssembly!
Iāve filed Using libc++ with the "emulated pthreads" mode Ā· Issue #546 Ā· WebAssembly/wasi-sdk Ā· GitHub which should hopefully be the last piece of the puzzle required to enable upstream LLVM be built with WASI SDK. Once it is resolved (hopefully in the next WASI SDK release) it will be possible, at last, to have an upstream port of Clang to WASI.
Iāve submitted PRs to enable libc++ to be built with concurrency primitives for THREAD_MODEL=single:
These are considered release blockers for wasi-sdk-26 and wasi-sdk-27, so the support should be available shortly.
I saw that both PRs got merged, and the latest SDK release ( Release wasi-sdk-26 Ā· WebAssembly/wasi-sdk Ā· GitHub ) includes the PRs. In Enable pthreads in libc++ for `THREAD_MODEL=single` by whitequark Ā· Pull Request #548 Ā· WebAssembly/wasi-sdk Ā· GitHub you mentioned that you successfully built Clang, amazing, well done!
Could you please share a few instructions on how to reproduce this? Iād love to get a build and replace the outdated hack I have in w2c2. What version of Clang did you build, and how?
Right now Iām too sick to run the entire build end to end it, but GitHub - YoWASP/clang at npm should contain a (very work-in-progress, and falling short of the quality of stuff I usually release) script for building Clang. It should either work (itās based on stuff that I used to verify wasi-sdk changes) or be very close to working. Let me know if you hit any issues.
Thank you for sharing the instructions, much appreciated! Hope you feel better soon!