-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[WasmFS] Support utime() #16262
[WasmFS] Support utime() #16262
Conversation
tools/system_libs.py
Outdated
@@ -1431,6 +1431,21 @@ def can_use(self): | |||
return settings.WASMFS | |||
|
|||
|
|||
# Libc components of WasmFS, which uses more libc code than the JS filesystem. | |||
# This must be a separate library than libwasmfs because the build commands | |||
# are different for libc code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this isn't necessary.
There are a couple of ways we can get the correct build flags:
- Have libwasmfs inherit from MuslInternalLibrary.
- Use the new
customize_build_cmd
to use different cflags for utime.c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 can't work as c++17 and c can't be used in the same library (the cflags conflict and clang errors out). But 2 sounds possible, thanks, I'll look into that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, switched to a single library and picking the build flags in customize_build_cmd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
tools/system_libs.py
Outdated
# implements the syscall. | ||
libc_files = files_in_path( | ||
path='system/lib/libc/musl/src/time', | ||
filenames=['utime.c']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we can't just switch to including this file across the board? (I can take a look as a followup if you like).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good point... in fact we can, it turns out. The old FS implements that syscall too - I forgot, but it has to. So it works to just use musl here. I switched to that now.
@@ -908,6 +908,7 @@ def get_files(self): | |||
'nanosleep.c', | |||
'clock_nanosleep.c', | |||
'ctime_r.c', | |||
'utime.c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way better!
} | ||
return setFileTime(path, time); | ||
}, | ||
|
||
utimes__deps: ['$setFileTime'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this can be removed too (perhaps as a followup).
This implements the
__syscall_utimensat
syscall and everything necessaryfor that to get a basic test of
utime
passing.getParsedPath()
now receives an optional FD, which if given is the "base"relative to which the path is parsed. That is what all the at* syscalls will
use.
This also switches us to use
utime.c
from musl instead of from JS. This isnecessary for WasmFS since the JS version only supported the JS FS. But
it works ok in the JS FS as well, as it also implements the relevant syscall,
so this is better anyhow.
(last paragaph was edited, after removing the new stdlib and using utime.c
in all modes)