-
Notifications
You must be signed in to change notification settings - Fork 190
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
libcxx's <fstream>
no longer works as of wasi-sdk
21
#373
Comments
Probably best to modify libc++ upstream to not depend on |
@sbc100 it's ugly, but it works: dicej/llvm-project@4fe4740 Note that it wasn't just Does that seem appropriate to submit as an upstream PR? |
Signed-off-by: Joel Dice <[email protected]>
I just had an idea: I expect WASI will be adding Does that sound reasonable? |
Per WebAssembly/wasi-sdk#373, LLVM's libc++ no longer allows us to enable `<fstream>` and `<filesystem>` separately -- it's both or neither. Consequently, we either need to patch libc++ to not use `statvfs`, `chmod`, etc. or add stub functions for those features to `wasi-libc`. Since we're planning to eventually support those features with WASI Preview 2 and beyond, it makes sense to do the latter. Note that since libc++ uses `DT_SOCK`, I've added a definition for it -- even though WASI Preview 1 does not define it. No Preview 1 file will ever have that type, so code that handles that type will never be reached, but defining it allows us to avoid WASI-specific patches to libc++. Related to `DT_SOCK`, I had to change the `S_IFIFO` value so it does not conflict with `S_IFSOCK`, thereby avoiding ambiguity in `__wasilibc_iftodt`. Signed-off-by: Joel Dice <[email protected]>
Per WebAssembly/wasi-sdk#373, LLVM's libc++ no longer allows us to enable `<fstream>` and `<filesystem>` separately -- it's both or neither. Consequently, we either need to patch libc++ to not use `statvfs`, `chmod`, etc. or add stub functions for those features to `wasi-libc`. Since we're planning to eventually support those features with WASI Preview 2 and beyond, it makes sense to do the latter. Note that since libc++ uses `DT_SOCK`, I've added a definition for it -- even though WASI Preview 1 does not define it. No Preview 1 file will ever have that type, so code that handles that type will never be reached, but defining it allows us to avoid WASI-specific patches to libc++. Related to `DT_SOCK`, I had to change the `S_IFIFO` value so it does not conflict with `S_IFSOCK`, thereby avoiding ambiguity in `__wasilibc_iftodt`. Signed-off-by: Joel Dice <[email protected]>
This is fixed by WebAssembly/wasi-libc#463 -- just need to update the |
Fixes WebAssembly#373 Signed-off-by: Joel Dice <[email protected]>
As of LLVM 17, which includes https://reviews.llvm.org/D152168, libcxx has combined the old `_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY` and `_LIBCPP_HAS_NO_FSTREAM` preprocessor symbols into a single `_LIBCPP_HAS_NO_FILESYSTEM` symbol, which means there's no longer any way to enable `<fstream>` without enabling `<filesystem>`. The solution is to set `-DLIBCXX_ENABLE_FILESYSTEM:BOOL=ON` and update `wasi-libc`, which includes stubs for the functions required by libcxx's `<filesystem>` implementation. Fixes WebAssembly#373 Signed-off-by: Joel Dice <[email protected]>
As of LLVM 17, which includes https://reviews.llvm.org/D152168, libcxx has combined the old `_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY` and `_LIBCPP_HAS_NO_FSTREAM` preprocessor symbols into a single `_LIBCPP_HAS_NO_FILESYSTEM` symbol, which means there's no longer any way to enable `<fstream>` without enabling `<filesystem>`. The solution is to set `-DLIBCXX_ENABLE_FILESYSTEM:BOOL=ON` and update `wasi-libc`, which includes stubs for the functions required by libcxx's `<filesystem>` implementation. Fixes #373 Signed-off-by: Joel Dice <[email protected]>
As of LLVM 17, which includes https://reviews.llvm.org/D152168, libcxx has combined the old
_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY
and_LIBCPP_HAS_NO_FSTREAM
preprocessor symbols into a single_LIBCPP_HAS_NO_FILESYSTEM
symbol, which means there's no longer any way to enable<fstream>
without enabling<filesystem>
. Consequently,wasi-sdk
21 no longer supports e.g.std::ifstream
etc.The solution may involve setting
-DLIBCXX_ENABLE_FILESYSTEM:BOOL=ON
and then fixing the breakage. I just tried that and hitfatal error: 'sys/statvfs.h' file not found
. I'm going to try creating that file and adding stubs to it to see how far I get. Meanwhile, I'm open to alternative approaches.The text was updated successfully, but these errors were encountered: