-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add WASI support #583
Merged
Merged
Add WASI support #583
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
0ba3dfc
feat: WASI support
GregoryConrad 4d065c9
Merge branch 'cberner:master' into master
GregoryConrad 2d5b1b9
docs: change feature comment to be consistent with others
GregoryConrad 85f0ce0
Merge branch 'cberner:master' into master
GregoryConrad abd5764
fix: improved WASI compilation warnings/errors
GregoryConrad f5f2f7e
fix: allow compiling tests for WASI
GregoryConrad 58837ee
docs: clarify what some deps are for
GregoryConrad 3891da5
test: fix some test failures due to tempfile
GregoryConrad 1448cfc
revert: "test: fix some test failures due to tempfile"
GregoryConrad 5388a42
test: update tests to use CWD as tmpdir
GregoryConrad fbfed53
test: fix remaining WASI tests
GregoryConrad 420b1db
test: re-enable unused import warning
GregoryConrad b9adeda
ci: enable WASI testing in CI
GregoryConrad b776ed1
refactor: remove need for wasi feature
GregoryConrad 3547ff1
refactor: wasi target clean ups
GregoryConrad 509749b
ci: switch WASI test runner to macos
GregoryConrad c4271a3
Merge branch 'master' into master
GregoryConrad 918f850
ci: manually specify wasi as target
GregoryConrad 6698d99
test: fix up remaining tests for WASI
GregoryConrad c489ef5
ci: hopefully fix missing nightly toolchain
GregoryConrad d042b2b
style: fix some lints from nightly clippy
GregoryConrad 8b6c296
test: remove unused import on wasi
GregoryConrad d32cefb
test: switch tests to use create_tempfile function
GregoryConrad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
// TODO once Rust's libc has flock implemented for WASI, this file needs to be revisited. | ||
// What needs to be changed is commented below. | ||
// See also: https://github.com/WebAssembly/wasi-filesystem/issues/2 | ||
|
||
// Remove this line once wasi-libc has flock | ||
#![cfg_attr(feature = "wasi", allow(unused_imports))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This silences some unused import warnings that will go away once wasi-libc has flock |
||
|
||
use crate::{Error, Result}; | ||
use std::fs::File; | ||
use std::io; | ||
use std::os::unix::fs::FileExt; | ||
use std::os::unix::io::AsRawFd; | ||
|
||
#[cfg(unix)] | ||
use std::os::unix::{fs::FileExt, io::AsRawFd}; | ||
|
||
#[cfg(target_os = "wasi")] | ||
use std::os::wasi::{fs::FileExt, io::AsRawFd}; | ||
|
||
pub(crate) struct LockedFile { | ||
file: File, | ||
} | ||
|
||
impl LockedFile { | ||
// This is a no-op until we get flock in wasi-libc. | ||
// Delete this function when we get flock. | ||
#[cfg(target_os = "wasi")] | ||
pub(crate) fn new(file: File) -> Result<Self> { | ||
Ok(Self { file }) | ||
} | ||
|
||
#[cfg(unix)] // remove this line when wasi-libc gets flock | ||
pub(crate) fn new(file: File) -> Result<Self> { | ||
let fd = file.as_raw_fd(); | ||
let result = unsafe { libc::flock(fd, libc::LOCK_EX | libc::LOCK_NB) }; | ||
|
@@ -41,6 +60,7 @@ impl LockedFile { | |
} | ||
} | ||
|
||
#[cfg(unix)] // remove this line when wasi-libc gets flock | ||
impl Drop for LockedFile { | ||
fn drop(&mut self) { | ||
unsafe { libc::flock(self.file.as_raw_fd(), libc::LOCK_UN) }; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 really hate this, but I don't think there is any other way to do benchmark specific dependencies (and you can't create a
benching
feature either because you can't have optional dev dependencies). If you have any ideas though, I am all ears.(This divides test specific deps and benchmark specific deps, since essentially none of the benchmark deps compile to WASI)