Open EricSivilog opened 4 years ago
At a quick glance, it looks like the only thing in libcxx that needs <sys/statvfs.h>
is the space
functions, which you don't need for create_directory
or indeed most of the filesystem library.
It would probably be straightforward to get the filesystem library to build if you disabled use of <sys/statvfs.h>
and the space
functions. If someone wanted to write up a patch that introduced a new CMake variable like LIBCXX_ENABLE_FILESYSTEM_SPACE
or so that did that, we may be able to help land that in upstream LLVM and use it in wasi-sdk to allow us to enable the rest of LIBCXX_ENABLE_FILESYSTEM
.
We could also talk about adding functionality to WASI to support a subset of <sys/statvfs.h> sufficient to implement the
space` function, though that would be more involved.
Dan,
I've done what you suggested but I then have other issues with functions referenced in "filesystem_common.h" or "operations.cpp" which are not available in WASI such as:
I'll follow the same idea as for statvfs and see where i get.
Thanks for your help. :-)
For fchmod/chmod the underlying functions were added to WASI ephemeral here: https://github.com/WebAssembly/WASI/pull/170/files. I imagine that once we make next snapshot and this migrates into wasi-sdk we can them implement fchmod and chmod.
For chdir/getcwd we don't currently implement them in wasi-libc, but I don't see why we couldn't implement this purely in userspace.
realpath looks a bit more tricky. We already support readlink (via __wasi_path_readlink) which might be enough get a useful implementation.
Hi there!
I have just recompiled wasi-sdk v10 for a project I am working on and I thought I'd try to enable LIBCXX_ENABLE_FILESYSTEM for libcxx in order to have access to std::filesystem from my WASM code - the custom environment I am using is WASI-capable and works fine with C file I/O and C++ streams, but I hit a problem when trying to use std::filesystem::create_directory (or std::__fs::filesystem::create_directory as it seems to be named here).
My problem is that enabling the flag leads to an include error with a missing <sys/statvfs.h> included in "filesystem_common.h": does anyone know if it is at all possible to get std::filesystem to compile in libcxx for use in WASM?
For a bit of context, I am compiling under Ubuntu 18.04 (through WSL in Windows 10), cloned the wasi-sdk repo and used make. Everything works as expected without the flag.
Thanks a lot for your hard work!!!