You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note how the old JS code implements everything in JS, while the new one just has some JS that calls into wasm: __wasmfs_chdir is a call to a wasm function implementing chdir, which is here:
That call is just a call further into the syscall implementation code inside the wasm. That is, WasmFS is implemented in wasm (in C++), and the goal of this project is to allow JS to use it, using the old JS API.
In general we want the entire old JS FS API implemented, but it is possible not all of it is needed. So one approach here could be to implement the entire API, and another is to focus on what is actually needed, as shown by what is used in the test suite. The process for going through those could look like this:
Run some wasmfs tests, say ./test/runner.py wasmfs.test_fs_* (or test_a* for all tests starting with the letter a etc.), see what fails, and investigate those. (edit: fixed the command here, and removed a mention of changes to settings.js).
Hi @Forchapeatl , it looks like there is a new PR that begins to work on one of the functions here, mount, #18856 . So I would not look at that specific one right now. But feel free to look into any of the other functions (each can be done independently) and to ask any questions you might have.
Reacted by FORCHA PEARL (Phd - University of Buea Ongoing)
However, my code editor wasn't able to find a definition for the function "__wasmfs_chdir" in library_wasmfs.js. Does the use of 2 underscores in library_wasmfs.js and 1 underscore in js_api.cpp make a difference?
According to the GSOC post, this project mainly involves JavaScript and relatively little C++. However, as I am looking through js_api.cpp, it seems that many of the functions listed in the TODOs of library_wasmfs.js are not implemented (e.g. lookup, ioctl). I am still interested, but would like to clarify the scope of the project. Would the project also involve adding to the js_api.cpp file?
I used my editor's search feature to look for uses of "FS." in the "test" folder to see which methods are currently being used. Right now, it looks like a lot of functions aren't being tested (e.g. readlink). Right now it seems that a lot of these functions are intermediate helper functions to other FS functions. Would this GitHub issue also involve writing new tests for these intermediate methods?
However, my code editor wasn't able to find a definition for the function "__wasmfs_chdir" in library_wasmfs.js. Does the use of 2 underscores in library_wasmfs.js and 1 underscore in js_api.cpp make a difference?
That could be it. An extra underscore is used to prefix calls into wasm (compiled C code) from JS. That makes the name not match for the editor, I guess, and confuse it, unfortunately...
According to the GSOC post, this project mainly involves JavaScript and relatively little C++. [..] Would the project also involve adding to the js_api.cpp file?
Yes, this project will involve some C++. I don't expect that to be complex though. For some operations it'll just be a few lines. For some, like ioctl, we might want to translate the JS into C++, so it wouldn't mean writing some new C++ from scratch. Overall I'd say prior C++ knowledge is not necessary; as long as you're open to learning some C++ as you go, we can help with any language-specific questions.
Overall the goal here is to provide a JS API for WasmFS that functions as close as possible to the old JS API for the JS filesystem. I expect most of that work to be on the JS side. As the top comment here says, It would be nice to make it similar to the API for the current FS, but it also might make sense to make some changes - there are some open questions about how best to do that, which we'll all need to figure out together, so I can't specifically say what % of the work will be in JS and what in C++ (but I do expect more JS).
Would this GitHub issue also involve writing new tests for these intermediate methods?
Much should be tested already but good point about readlink and others that don't appear to be. I'd say the main priority is to get existing tests passing, but testing the others would be good too.
@kripken
Thanks so much for answering my questions. I just have a few more follow up questions.
That makes the name not match for the editor, I guess, and confuse it, unfortunately...
Is there a specific development set up you would recommend?In addition to the underscore issue I also noticed that there are a lot of C/C++ preprocessing statements (Like #if, #endif) in the JS code that are confusing my code editor and giving me errors. I am currently using Visual Studio Code with the default settings for JavaScript and the Microsoft C/C++ extension and was wondering if there were any better ways to set up a development environment for Emscripten.
Overall the goal here is to provide a JS API for WasmFS that functions as close as possible to the old JS API for the JS filesystem. I expect most of that work to be on the JS side.
Based on my understanding of WASM, converting these functions from pure JS in the file library_fs.js to call the js_api.cpp wasm code in library_wasmfs.js would result in a performance improvement, right? So would the main motivation of the project be to improve the performance of the FS? I am asking this question to help refine my motivation/goal for a potential GSOC proposal.
Much should be tested already but good point about readlink and others that don't appear to be. I'd say the main priority is to get existing tests passing, but testing the others would be good too.
While looking through the Emscripten docs, I didn't see anything describing how to create tests. I have tried creating files such as "test_rmdir.c" in the "test/fs" folder, but have not been able to successfully run them with runner.py. Is there some documentation that I am missing? I noticed a lot of tests include a lot of different FS operations at once and was hoping to be able to write a few smaller tests to test out some of the individual functions as I work through them.
Finally, I've ran into a few errors while working through the project. I am currently trying to implement "open" in the library_wasmfs.js." After Googling, I learned that "__syscall_openat" might achieve what I wanted, but realized that js_api.cpp does not have a function for "_wasmfs_open".
After adding "_wasmfs_open", I still cannot call it from a test file. Currently, I know that _wasmfs_write_file is working, so I have tried to follow that model. I have tried the following approaches.
Directly calling "_wasmfs_open" from "library_wasmfs.js" - This approach results in a "_wasmfs_open" is not defined.
When I tried to add '_wasmfs_open' to the settings.REQUIRED_EXPORTS
Is there a specific development set up you would recommend?
Hmm, I don't have one to recommend. I think everyone uses something else around here 😄 I personally just use a simple text editor with syntax highlighting and little else.
Based on my understanding of WASM, converting these functions from pure JS in the file library_fs.js to call the js_api.cpp wasm code in library_wasmfs.js would result in a performance improvement, right? So would the main motivation of the project be to improve the performance of the FS?
It can be faster, yes. In general the WasmFS project moves as much logic from JS into wasm, which allows it to be faster and also use multithreading.
While looking through the Emscripten docs, I didn't see anything describing how to create tests. [..] Is there some documentation that I am missing?
In general to create a test it's simplest to look at a similar existing one, and do what it does. For example, if you know you want a test like test_loop then you'd find that in test/*.py, since that is where tests are defined. From that python code you can see what it does (just a few lines in that case, but others need more).
After adding "_wasmfs_open", I still cannot call it from a test file.
If you've implemented that function in C++ but it complains on not finding it, then the issue might be that the wasmfs library needs to be rebuilt. Our system for automatic rebuilding of libraries does not notice changes to individual files, so you need to manually force a rebuild. You can do that with this:
(You may only need one of the normal and the debug versions, depending on if you run a test in normal or debug mode, so you can remove the other one from that line).
I think you'll actually need to rebuild libwasmfs-mt and libwasmfs-mt-debug since the tests are multithreaded. To really make sure everything is being rebuilt, you can do ./emcc --clear-cache. (Unless embuilder has gotten smarter about this recently?)
"""Tool to manage building of system libraries and ports.
In general emcc will build them automatically on demand, so you do not
strictly need to use this tool, but it gives you more control over the
process (in particular, if emcc does this automatically, and you are
running multiple build commands in parallel, confusion can occur).
"""
There was no change from this and _wasmfs_open() was still not found.
I have been running tests with EMCC_DEBUG=1, so I initially tried to run "embuilder build libwasmfs-debug" without --force. This didn't change anything and _wasmfs_open() was still not found.
When I ran any of the embuilder commands with --force, I ended up seeing an error with "Error: Missing C define S_IRUGO! If you just added it to struct_info.json, you need to ./emcc --clear-cache". This occured with and without -debug, with and without -mt.
This is followed by the message "emcc: error: 'C:/Users/Documents/GitHub/emsdk/node/14.18.2_64bit/bin/node.exe C:\Users\Documents\GitHub\emsdk\emscripten\main\src\compiler.js C:\Users\AppData\Local\Temp\emscripten_temp\tmprfcuqfas.json --symbols-only' failed (returned 1)".
After I see this message, no embuilder commands have been able to fix the problem - I've had to reclone the emscripten repo multiple times. I have searched for uses of S_IRUGO and none of the files I have edited should involve it. The console message that I should create a bug report for this issue. I am currently unsure if this bug is related to something I tried to implement in js_api.cpp or a bug in embuilder. I'm not currently sure about what steps to take next.
Just to summarize my process is as follows -
Add _wasmfs_open to js_api.cpp. Currently I just return 0 instead of a file descriptor/syscall as a placeholder.
Add an "open" method to library_wasmfs.js
Calling "FS.open()" in my test file.
Is there a step I'm missing? Could there be a missing import? One thing I have noticed is that when I add "_wasmfs_open" to the exports in the emcc.py file, the error changes.
The error becomes "_wasmfs_open should be exported but is not found". Could this issue be related to not being able to rebuild the lib? I am currently on Windows 10, if that could be making the difference.
Could we make each function stand alone rather than being methods of FS? Ie, prefix them like FS_chdir? This way you could export only the functions you need rather than the whole lot. That was one of the flaws of the original API.
On the other hand, if they become very thin wrappers of exported WASM functions then it wouldn't matter nearly so much.
@jameshu15869, see my comment above about running ./emcc --clear-cache instead of using embuilder to clear specific libraries. After clearing the cache, Emscripten will build all the libraries it needs on-demand and pick up your new changes.
@curiousdannii that's a good idea. Ideally we would both implement the old API for compatibility and also have a newer
improved API.
@kripken
Sorry, I made a typo in my comment. The screenshot shows the macro is “S_IRUGO”, not “S_IGURO” like I accidentally typed. I’ve searched through the codebase and it seems to be some macro associated with the file system, but I don’t believe that I am calling it in any code I modified.
Ok, S_IRUGO looks valid. In that case, can you find more specifically where things break for you? What I mean is, find a compile command that works, then make some small change (like to library_wasmfs.js) and then you get that error. Finding the smallest step like that would make it easiest to understand the issue.
Separately, that error suggests there is a problem in the struct_info.json file which should be in cache/sysroot/lib/wasm32-emscripten/struct_info.json by default. That should contain that symbol. If not ./embuilder build struct_info may help, but that should not be needed (if it does help though, that might be a clue).
// ATTENTION [WIP]: Experimental feature. Please use at your own risk.
// This will eventually replace the current JS file system implementation.
// If set to 1, uses new filesystem implementation.
// [link]
// [experimental]
varWASMFS=false;
As long as I leave WASMFS=false, I can modify any of the files and .\emcc will compile them without trouble. Now, the last step is just to add _wasmfs_open to the exports section in emcc.py file right in the section shown below, and everything works fine!
in test_core.py right before running any WASMFS tests, and everything works. I have very little experience/understanding of Emscripten's build process, but I strongly suspect that setting WASMFS = true in settings.js is affecting some part of the compilation process - I found that cache/sysroot/lib/wasm32-emscripten/struct_info.json was not being generated at all when WASMFS = true, causing my S_IRUGO macro error. In the meantime I've been able to test my changes and have begun working towards making an initial pull request.
Should I open a bug report? This seems like a serious issue going forward.
@impact-maker Interesting, good find! I'm not sure why that's a problem but it does seem wrong. @sbc100 you are right that settings are not normally modified in the settings file, but I've done it often in the past without issue, so I'm curious what's wrong here. I'll investigate.
In any case, specifically for here, it might be simplest to run tests using ./tests/runner wasmfs.test_loop etc., that is, run them in the wasmfs mode. At least for the core tests that is simple to do (for other, changes might be needed in test_other.py).
Ok, I can reproduce this issue locally. The issue is that we cannot bootstrap struct_info.json using wasmfs mode atm. That mode runs with -nostdlib which means no malloc/free, which that mode requires. I opened #18916 to work around that now (we can bootstrap without WasmFS).
Ok, I can reproduce this issue locally. The issue is that we cannot bootstrap struct_info.json using wasmfs mode atm. That mode runs with -nostdlib which means no malloc/free, which that mode requires. I opened #18916 to work around that now (we can bootstrap without WasmFS).
Yes gen_struct_info depends on the defaults being a certain way. I think that is fine. If the defaults ever change we sometimes must adapt the settings used by gen_struct_info.
@kripken@tlively@sbc100
I just submitted a pull request implementing open(). The link is below. This is my first-ever pull request for an open source project, so please let me know if there is anything I need to improve.
I've completed the implementation for rmdir on my branch and I'm looking for feedback on my code. I would appreciate it if you could review my PR and provide me with feedback or suggestions.
Sorry, I'm not sure what you're asking in the first question?
A "backend" is an implementation of storage. For example, the "memory backend" stores data in memory (RAM), while a "JS backend" could store data on the JavaScript side (in a JS array). The idea is that the core FS code is abstract - it can work on any backend. For example, to copy a file, the core FS code does something like x = read(); write(x), it reads the data and then writes it to the proper place. Both of those operations will be sent to the proper backend to actually read and write the data.
@HwangTaehyun Yes, the naming convention in JS should match existing JS code, like that in the old JS API that you linked.
The goal is to implement as much as possible of the old JS filesystem API. If we run into parts that are difficult to implement, then we'll need to think about things on a case by case basis. But most APIs should just be simple calls from JS into WasmFS code, I believe.
Activity
kripken commentedon Feb 16, 2023
The old JS FS code is mainly here: https://github.com/emscripten-core/emscripten/blob/main/src/library_fs.js
WasmFS has a small amount of existing JS API code here:
emscripten/src/library_wasmfs.js
Line 24 in db35f20
The goal here is to implement the full API in the first link in the second link. For example, here is
chdirin the old JS FS:emscripten/src/library_fs.js
Lines 1315 to 1328 in db35f20
and here it is in the WasmFS JS code:
emscripten/src/library_wasmfs.js
Lines 133 to 138 in db35f20
Note how the old JS code implements everything in JS, while the new one just has some JS that calls into wasm:
__wasmfs_chdiris a call to a wasm function implementing chdir, which is here:emscripten/system/lib/wasmfs/js_api.cpp
Line 107 in db35f20
That call is just a call further into the syscall implementation code inside the wasm. That is, WasmFS is implemented in wasm (in C++), and the goal of this project is to allow JS to use it, using the old JS API.
In general we want the entire old JS FS API implemented, but it is possible not all of it is needed. So one approach here could be to implement the entire API, and another is to focus on what is actually needed, as shown by what is used in the test suite. The process for going through those could look like this:
./test/runner.py wasmfs.test_fs_*(ortest_a*for all tests starting with the letteraetc.), see what fails, and investigate those. (edit: fixed the command here, and removed a mention of changes tosettings.js).kripken commentedon Feb 16, 2023
See also the main WasmFS docs and links there for background and other useful info.
kripken commentedon Feb 16, 2023
A good starting point can be the TODOs in
library_wasmfs.js, like these:emscripten/src/library_wasmfs.js
Lines 216 to 224 in db35f20
Forchapeatl commentedon Feb 27, 2023
Hello , @kripken , please may I handle this issue ?
kripken commentedon Feb 27, 2023
Hi @Forchapeatl , it looks like there is a new PR that begins to work on one of the functions here,
mount, #18856 . So I would not look at that specific one right now. But feel free to look into any of the other functions (each can be done independently) and to ask any questions you might have.jameshu15869 commentedon Feb 28, 2023
Hi @kripken, I've been working through this issue through GSOC and have a couple questions.
In the original issue post, you referenced the code below as the place where the call to the WasmFS function is.
emscripten/src/library_wasmfs.js
Lines 133 to 138 in db35f20
According to your post, the above code should call the function below.
emscripten/system/lib/wasmfs/js_api.cpp
Line 107 in db35f20
However, my code editor wasn't able to find a definition for the function "__wasmfs_chdir" in library_wasmfs.js. Does the use of 2 underscores in library_wasmfs.js and 1 underscore in js_api.cpp make a difference?
According to the GSOC post, this project mainly involves JavaScript and relatively little C++. However, as I am looking through js_api.cpp, it seems that many of the functions listed in the TODOs of library_wasmfs.js are not implemented (e.g. lookup, ioctl). I am still interested, but would like to clarify the scope of the project. Would the project also involve adding to the js_api.cpp file?
I used my editor's search feature to look for uses of "FS." in the "test" folder to see which methods are currently being used. Right now, it looks like a lot of functions aren't being tested (e.g. readlink). Right now it seems that a lot of these functions are intermediate helper functions to other FS functions. Would this GitHub issue also involve writing new tests for these intermediate methods?
kripken commentedon Feb 28, 2023
@jameshu15869
That could be it. An extra underscore is used to prefix calls into wasm (compiled C code) from JS. That makes the name not match for the editor, I guess, and confuse it, unfortunately...
Yes, this project will involve some C++. I don't expect that to be complex though. For some operations it'll just be a few lines. For some, like
ioctl, we might want to translate the JS into C++, so it wouldn't mean writing some new C++ from scratch. Overall I'd say prior C++ knowledge is not necessary; as long as you're open to learning some C++ as you go, we can help with any language-specific questions.Overall the goal here is to provide a JS API for WasmFS that functions as close as possible to the old JS API for the JS filesystem. I expect most of that work to be on the JS side. As the top comment here says,
It would be nice to make it similar to the API for the current FS, but it also might make sense to make some changes- there are some open questions about how best to do that, which we'll all need to figure out together, so I can't specifically say what % of the work will be in JS and what in C++ (but I do expect more JS).Much should be tested already but good point about
readlinkand others that don't appear to be. I'd say the main priority is to get existing tests passing, but testing the others would be good too.jameshu15869 commentedon Feb 28, 2023
@kripken
Thanks so much for answering my questions. I just have a few more follow up questions.
Is there a specific development set up you would recommend?In addition to the underscore issue I also noticed that there are a lot of C/C++ preprocessing statements (Like #if, #endif) in the JS code that are confusing my code editor and giving me errors. I am currently using Visual Studio Code with the default settings for JavaScript and the Microsoft C/C++ extension and was wondering if there were any better ways to set up a development environment for Emscripten.
Based on my understanding of WASM, converting these functions from pure JS in the file library_fs.js to call the js_api.cpp wasm code in library_wasmfs.js would result in a performance improvement, right? So would the main motivation of the project be to improve the performance of the FS? I am asking this question to help refine my motivation/goal for a potential GSOC proposal.
While looking through the Emscripten docs, I didn't see anything describing how to create tests. I have tried creating files such as "test_rmdir.c" in the "test/fs" folder, but have not been able to successfully run them with runner.py. Is there some documentation that I am missing? I noticed a lot of tests include a lot of different FS operations at once and was hoping to be able to write a few smaller tests to test out some of the individual functions as I work through them.
Finally, I've ran into a few errors while working through the project. I am currently trying to implement "open" in the library_wasmfs.js." After Googling, I learned that "__syscall_openat" might achieve what I wanted, but realized that js_api.cpp does not have a function for "_wasmfs_open".
emscripten/system/lib/wasmfs/syscalls.cpp
Lines 565 to 573 in 8778c72
After adding "_wasmfs_open", I still cannot call it from a test file. Currently, I know that _wasmfs_write_file is working, so I have tried to follow that model. I have tried the following approaches.
emscripten/emcc.py
Lines 2305 to 2316 in 8778c72
However, this gives an error saying "symbol exported via --export not found: _wasmfs_open"
Is there something else I'm missing here to add a new exported function?
kripken commentedon Mar 1, 2023
Hmm, I don't have one to recommend. I think everyone uses something else around here 😄 I personally just use a simple text editor with syntax highlighting and little else.
It can be faster, yes. In general the WasmFS project moves as much logic from JS into wasm, which allows it to be faster and also use multithreading.
The main docs are here: https://emscripten.org/docs/getting_started/test-suite.html
In general to create a test it's simplest to look at a similar existing one, and do what it does. For example, if you know you want a test like
test_loopthen you'd find that intest/*.py, since that is where tests are defined. From that python code you can see what it does (just a few lines in that case, but others need more).If you've implemented that function in C++ but it complains on not finding it, then the issue might be that the wasmfs library needs to be rebuilt. Our system for automatic rebuilding of libraries does not notice changes to individual files, so you need to manually force a rebuild. You can do that with this:
(You may only need one of the normal and the debug versions, depending on if you run a test in normal or debug mode, so you can remove the other one from that line).
tlively commentedon Mar 1, 2023
I think you'll actually need to rebuild
libwasmfs-mtandlibwasmfs-mt-debugsince the tests are multithreaded. To really make sure everything is being rebuilt, you can do./emcc --clear-cache. (Unlessembuilderhas gotten smarter about this recently?)jameshu15869 commentedon Mar 2, 2023
@kripken
I've been stuck on getting the code to account for adding _wasmfs_open() to the js_api.cpp file. Here are a few things I've tried.
I tried running emcc on a regular file in hopes of triggering the auto build, according to this comment in embuilder.py.
emscripten/embuilder.py
Lines 7 to 13 in db51a47
There was no change from this and _wasmfs_open() was still not found.
I have been running tests with EMCC_DEBUG=1, so I initially tried to run "embuilder build libwasmfs-debug" without --force. This didn't change anything and _wasmfs_open() was still not found.
When I ran any of the embuilder commands with --force, I ended up seeing an error with "Error: Missing C define S_IRUGO! If you just added it to struct_info.json, you need to ./emcc --clear-cache". This occured with and without -debug, with and without -mt.
This is followed by the message "emcc: error: 'C:/Users/Documents/GitHub/emsdk/node/14.18.2_64bit/bin/node.exe C:\Users\Documents\GitHub\emsdk\emscripten\main\src\compiler.js C:\Users\AppData\Local\Temp\emscripten_temp\tmprfcuqfas.json --symbols-only' failed (returned 1)".
After I see this message, no embuilder commands have been able to fix the problem - I've had to reclone the emscripten repo multiple times. I have searched for uses of S_IRUGO and none of the files I have edited should involve it. The console message that I should create a bug report for this issue. I am currently unsure if this bug is related to something I tried to implement in js_api.cpp or a bug in embuilder. I'm not currently sure about what steps to take next.
Just to summarize my process is as follows -
Is there a step I'm missing? Could there be a missing import? One thing I have noticed is that when I add "_wasmfs_open" to the exports in the emcc.py file, the error changes.
emscripten/emcc.py
Lines 2305 to 2316 in db51a47
The error becomes "_wasmfs_open should be exported but is not found". Could this issue be related to not being able to rebuild the lib? I am currently on Windows 10, if that could be making the difference.
curiousdannii commentedon Mar 3, 2023
Could we make each function stand alone rather than being methods of
FS? Ie, prefix them likeFS_chdir? This way you could export only the functions you need rather than the whole lot. That was one of the flaws of the original API.On the other hand, if they become very thin wrappers of exported WASM functions then it wouldn't matter nearly so much.
tlively commentedon Mar 3, 2023
@jameshu15869, see my comment above about running
./emcc --clear-cacheinstead of usingembuilderto clear specific libraries. After clearing the cache, Emscripten will build all the libraries it needs on-demand and pick up your new changes.@curiousdannii that's a good idea. Ideally we would both implement the old API for compatibility and also have a newer
improved API.
2 remaining items
jameshu15869 commentedon Mar 6, 2023
@kripken
Sorry, I made a typo in my comment. The screenshot shows the macro is “S_IRUGO”, not “S_IGURO” like I accidentally typed. I’ve searched through the codebase and it seems to be some macro associated with the file system, but I don’t believe that I am calling it in any code I modified.
kripken commentedon Mar 6, 2023
Ok,
S_IRUGOlooks valid. In that case, can you find more specifically where things break for you? What I mean is, find a compile command that works, then make some small change (like tolibrary_wasmfs.js) and then you get that error. Finding the smallest step like that would make it easiest to understand the issue.Separately, that error suggests there is a problem in the
struct_info.jsonfile which should be incache/sysroot/lib/wasm32-emscripten/struct_info.jsonby default. That should contain that symbol. If not./embuilder build struct_infomay help, but that should not be needed (if it does help though, that might be a clue).jameshu15869 commentedon Mar 7, 2023
@kripken @tlively
I've finally identified the exact moment when the error happens and found a fix!
It happens when I set
WASMFS=trueinsettings.js. It turns out this is the cause of all the compiler errors. The exact line is shown below.emscripten/src/settings.js
Lines 1715 to 1720 in 0ec0351
As long as I leave
WASMFS=false, I can modify any of the files and.\emccwill compile them without trouble. Now, the last step is just to add_wasmfs_opento the exports section inemcc.pyfile right in the section shown below, and everything works fine!emscripten/emcc.py
Lines 2305 to 2316 in 0ec0351
To run any tests using WASMFS I just made sure to do
in test_core.py right before running any WASMFS tests, and everything works. I have very little experience/understanding of Emscripten's build process, but I strongly suspect that setting
WASMFS = truein settings.js is affecting some part of the compilation process - I found thatcache/sysroot/lib/wasm32-emscripten/struct_info.jsonwas not being generated at all whenWASMFS = true, causing my S_IRUGO macro error. In the meantime I've been able to test my changes and have begun working towards making an initial pull request.Should I open a bug report? This seems like a serious issue going forward.
sbc100 commentedon Mar 7, 2023
The settings.js is not designed to be edited like that. Settings are expected to be set via the command line.
impact-maker commentedon Mar 7, 2023
@kripken @tlively Implemented the cwd function and tested it too. Kindly review the PR #18856 and help me with the changes and the feedback. Thank you
kripken commentedon Mar 7, 2023
@impact-maker Interesting, good find! I'm not sure why that's a problem but it does seem wrong. @sbc100 you are right that settings are not normally modified in the settings file, but I've done it often in the past without issue, so I'm curious what's wrong here. I'll investigate.
In any case, specifically for here, it might be simplest to run tests using
./tests/runner wasmfs.test_loopetc., that is, run them in the wasmfs mode. At least for thecoretests that is simple to do (forother, changes might be needed intest_other.py).kripken commentedon Mar 7, 2023
Ok, I can reproduce this issue locally. The issue is that we cannot bootstrap
struct_info.jsonusing wasmfs mode atm. That mode runs with-nostdlibwhich means no malloc/free, which that mode requires. I opened #18916 to work around that now (we can bootstrap without WasmFS).sbc100 commentedon Mar 7, 2023
Yes gen_struct_info depends on the defaults being a certain way. I think that is fine. If the defaults ever change we sometimes must adapt the settings used by gen_struct_info.
jameshu15869 commentedon Mar 8, 2023
@kripken @tlively @sbc100
I just submitted a pull request implementing open(). The link is below. This is my first-ever pull request for an open source project, so please let me know if there is anything I need to improve.
Pull Request Link: #18919
kshitjj commentedon Mar 13, 2023
Hi @tlively @kripken,
I've completed the implementation for rmdir on my branch and I'm looking for feedback on my code. I would appreciate it if you could review my PR and provide me with feedback or suggestions.
Here is the link to my PR: #18952
HwangTaehyun commentedon Apr 1, 2023
@kripken @tlively @jameshu15869 Hi! It's awesome work!
I also reach out to this PR through GSOC.
I did some settings for the wasm build and run some tests related to wasm fs now.
I can't find some explanation of how to run tests.
So, at first, I just tested it using emcc.py.
./emcc.py -sFORCE_FILESYSTEM -sWASMFS test/fs/test_open_wasmfs.c -o index.htmlFinally, I found that I should run some tests like the following one using test/runner.py.
I would like to see some README or MANUAL related to testing in more detail. Are there any resources about that?
If there are no resources, then I would like to write some brief Readme for running tests for newbies like me. 😂
@kripken Sorry, you already mentioned that at first this issue. I missed it... I have tried to search test method in project README.
HwangTaehyun commentedon Apr 1, 2023
@kripken @tlively I would like to handle create WasmFS API part.
Before I started, I have some questions about that.
It would be appropriate for classifying createFile & createDirectory wasmFS API. How about this?
Would you give me some explanation about the backends concept in wasmfs? I can't fully understand the backend concept when creating files. I guess this one is https://emscripten.org/docs/api_reference/Filesystem-API.html#filesystem-api-filesystems.
emscripten/system/lib/wasmfs/syscalls.cpp
Lines 555 to 562 in 8778c72
Thank you!
kripken commentedon Apr 3, 2023
@HwangTaehyun
x = read(); write(x), it reads the data and then writes it to the proper place. Both of those operations will be sent to the proper backend to actually read and write the data.HwangTaehyun commentedon Apr 4, 2023
@kripken Thank you!
Ah, I apologize for my mistake in the previous first question. I would like to ask again.
Should I follow the naming convention in old JS filesystem API (https://github.com/emscripten-core/emscripten/blob/db35f20f37ede0f5dafb02b334f9586e19f5b0d3/src/library_fs.js), when I implement WasmFS API?
Also, I have one more question. This project will implement all old JS filesystem API in (https://github.com/emscripten-core/emscripten/blob/db35f20f37ede0f5dafb02b334f9586e19f5b0d3/src/library_fs.js)?
Thank you!
kripken commentedon Apr 4, 2023
@HwangTaehyun Yes, the naming convention in JS should match existing JS code, like that in the old JS API that you linked.
The goal is to implement as much as possible of the old JS filesystem API. If we run into parts that are difficult to implement, then we'll need to think about things on a case by case basis. But most APIs should just be simple calls from JS into WasmFS code, I believe.