Skip to content
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

Merged
merged 13 commits into from
Feb 14, 2022
Merged

[WasmFS] Support utime() #16262

merged 13 commits into from
Feb 14, 2022

Conversation

kripken
Copy link
Member

@kripken kripken commented Feb 11, 2022

This implements the __syscall_utimensat syscall and everything necessary
for 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 is
necessary 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)

@@ -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.
Copy link
Collaborator

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:

  1. Have libwasmfs inherit from MuslInternalLibrary.
  2. Use the new customize_build_cmd to use different cflags for utime.c.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

# implements the syscall.
libc_files = files_in_path(
path='system/lib/libc/musl/src/time',
filenames=['utime.c'])
Copy link
Collaborator

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).

Copy link
Member Author

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',
Copy link
Collaborator

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'],
Copy link
Collaborator

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).

@kripken kripken enabled auto-merge (squash) February 14, 2022 19:36
@kripken kripken merged commit e001023 into main Feb 14, 2022
@kripken kripken deleted the wftime branch February 14, 2022 21:08
@kripken kripken mentioned this pull request Feb 14, 2022
kripken added a commit that referenced this pull request Feb 14, 2022
@kripken kripken mentioned this pull request Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants