wasi-libc icon indicating copy to clipboard operation
wasi-libc copied to clipboard

Building wasi-sysroot on Windows?

Open DragonOsman opened this issue 6 years ago • 7 comments

I have Windows 10. I installed GNU make for Windows and tried to run the make WASM_CC="C:/Program Files (x86)/LLVM/bin/clang" command but got this error from make`:

File not found - *.c
File not found - *.c
File not found - *.c
File not found - *.c
File not found - *.d
File not found - *.c
File not found - *.c
File not found - *.c
Makefile:248: /dev/null: No such file or directory
make: *** No rule to make target '/dev/null'.  Stop.

I tried specifying the correct location to my clang lib folder in the Makefile, but that didn't work either.

DragonOsman avatar May 06 '19 15:05 DragonOsman

This requires a bit more than GNU make. I'd suggest trying under WSL or MSYS2.

Also, path names with spaces in them (C:/Program Files (x86)) may not be well supported currently.

jedisct1 avatar May 06 '19 16:05 jedisct1

Update:

wasi-sysroot can be compiled under MSYS. The default LLVM/Clang packages are version 8.

You simply need to install the following packages:

make
mingw-w64-x86_64-llvm
mingw-w64-x86_64-clang
mingw-w64-x86_64-clang-tools-extra
patchutils

And type make.

Setting the WASM_* variables is not even required.

jedisct1 avatar May 06 '19 16:05 jedisct1

Note that you may have to store the source code in a folder with a very short path, or you will hit the maximum command line length when the linker is invoked :)

jedisct1 avatar May 06 '19 16:05 jedisct1

So I have to use WSL (I don't know much about using MSYS2 but I have WSL)? Would I still be able to build WebAssembly apps where I need WASI without WSL as well? And I installed version 9 of LLVM to use the Wasm Backend with Emscripten.

As for the file path for the source code: don't worry, I have wasi_sysroot cloned directly into my C drive.

If wasi_sysroot is for the C standard library, what about the C++ standard library? What do we do about that?

DragonOsman avatar May 09 '19 21:05 DragonOsman

Once compiled, Webassembly apps can run anywhere.

All you need is a runtime. Wasmtime is such a runtime, and it works natively on Windows, so you can use it to run Webassembly code without WSL.

If you have LLVM 8 or 9, you are all set! You don't need Emscripten to use WASI.

But C++ is not supported yet.

jedisct1 avatar May 09 '19 22:05 jedisct1

@DragonOsman now I see the context for your post on llvm-dev :) MingGW with the right set of packages should be sufficient for Windows builds. As for C++, this is libc, which means that you need another layer of libraries to get to C++ support. @sunfishcode and @sbc100 do you have more context on building libcxx?

penzn avatar Jun 07 '19 18:06 penzn

We have libc++ and libc++abi are easy enough to build on top of wasi-libc. I don't think they have any requirements that clang and wasi-libc don't already have:

See https://github.com/CraneStation/wasi-sdk/blob/master/Makefile

sbc100 avatar Jun 07 '19 18:06 sbc100