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

wasi-common/yanix: fix FreeBSD support #756

Merged
merged 3 commits into from
Feb 9, 2020
Merged

wasi-common/yanix: fix FreeBSD support #756

merged 3 commits into from
Feb 9, 2020

Conversation

valpackett
Copy link
Contributor

@valpackett valpackett commented Dec 30, 2019

Copy link
Member

@kubkon kubkon left a comment

Choose a reason for hiding this comment

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

Hey! Thanks for the PR! The changes look great to me, just a couple of nitpicks.

crates/wasi-common/yanix/src/file.rs Show resolved Hide resolved
crates/wasi-common/yanix/src/file.rs Outdated Show resolved Hide resolved
crates/wasi-common/yanix/src/file.rs Outdated Show resolved Hide resolved
@kubkon
Copy link
Member

kubkon commented Dec 31, 2019

Now that I look at how we use O_RSYNC in wasi-common, I think we've got a bug since regardless what is specified in yanix, i.e., whether O_RSYNC is defined or not, we always overwrite it with a substitution O_RSYNC = yanix::file::OFlag::SYNC: see sys/unix/bsd/host_impl.rs#4.

This is not directly relevant to changes introduced in this PR, but I thought it's good to point that out, and fix in a subsequent PR.

@sunfishcode
Copy link
Member

The linked comment says that defining O_RSYNC to 0 is ok because they use rangelocks. In WASI, we don't have range locks, so that assumption may not be valid.

If FreeBSD doesn't support O_RSYNC or O_DSYNC, we should consider implementing them manually -- by calling fdatasync etc. ourselves as needed. If that's infeasible or awkward, we should consider removing them from WASI altogether, so that applications don't rely on them if they aren't reliable.

@kubkon
Copy link
Member

kubkon commented Jan 2, 2020

The linked comment says that defining O_RSYNC to 0 is ok because they use rangelocks. In WASI, we don't have range locks, so that assumption may not be valid.

If FreeBSD doesn't support O_RSYNC or O_DSYNC, we should consider implementing them manually -- by calling fdatasync etc. ourselves as needed. If that's infeasible or awkward, we should consider removing them from WASI altogether, so that applications don't rely on them if they aren't reliable.

Hmm, that's a good catch! I missed the fact that the reason O_RSYNC is set to 0 is because FreeBSD uses range locks.

I reckon trying to implement them manually for our use sounds good, and if impossible, dropping it from WASI is within reason as well (as we might have to do with symlinks for instance due to the differences between *nixes and Windows).

@kubkon kubkon added the wasi:impl Issues pertaining to WASI implementation in Wasmtime label Jan 3, 2020
@valpackett
Copy link
Contributor Author

Maybe defining them to O_SYNC is a safe-and-easy option..?

@sunfishcode
Copy link
Member

Yes, defining O_DSYNC to O_SYNC on hosts that lack O_DSYNC looks like a reasonable solution.

@sunfishcode
Copy link
Member

To elaborate, while the comment here says that defining O_DSYNC to O_SYNC is wrong in intent, that relies on an assumption of what the intent is. In wasi-common, we can't make such assumptions, so we have to be conservative.

@valpackett
Copy link
Contributor Author

Updated with O_SYNC, nitpicks, fixes for the new any(target_os = "macos", target_os = "linux") stuff in the runtime, and posix_fadvise support.

test result: ok. 109 passed; 0 failed; 40 ignored; 0 measured; 0 filtered out

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@sunfishcode sunfishcode merged commit 6991096 into bytecodealliance:master Feb 9, 2020
@valpackett valpackett deleted the freebsd branch February 9, 2020 17:15
arkpar pushed a commit to paritytech/wasmtime that referenced this pull request Mar 4, 2020
* Clarify that FixedTied constraints are not Tied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi:impl Issues pertaining to WASI implementation in Wasmtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants