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

Add WASI support to C API #856

Merged
merged 20 commits into from
Oct 29, 2019
Merged

Add WASI support to C API #856

merged 20 commits into from
Oct 29, 2019

Conversation

MarkMcCaskey
Copy link
Contributor

@MarkMcCaskey MarkMcCaskey commented Oct 1, 2019

This is an additive change (with one unrelated clean up of *mut ptr -> *const ptr). It exposes the functions to get a WASI import object. It also implements a function on import object to get an import with namespace and name.

These changes should be okay to ship now, we can follow up to finish adding methods to ImportObject on the C API side and start migrating away from *imports.

Review

  • Add a short description of the the change to the CHANGELOG.md file

@MarkMcCaskey MarkMcCaskey added the 📦 lib-c-api About wasmer-c-api label Oct 1, 2019
@Hywan Hywan self-requested a review October 2, 2019 12:19
lib/runtime-c-api/src/import.rs Outdated Show resolved Hide resolved
lib/runtime-c-api/src/import.rs Outdated Show resolved Hide resolved
lib/runtime-c-api/src/import.rs Outdated Show resolved Hide resolved
@MarkMcCaskey MarkMcCaskey force-pushed the feature/wasi-in-c-api branch from 2390096 to b45b1c1 Compare October 2, 2019 19:09
sletz pushed a commit to sletz/wasmer that referenced this pull request Oct 3, 2019
808: Bump rand from 0.7.0 to 0.7.2 r=MarkMcCaskey a=dependabot-preview[bot]

Bumps [rand](https://github.com/rust-random/rand) from 0.7.0 to 0.7.2.
<details>
<summary>Changelog</summary>

*Sourced from [rand's changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md).*

> ## [0.7.2] - 2019-09-16
> ### Fixes
> - Fix dependency on `rand_core` 0.5.1 ([wasmerio#890](https://github-redirect.dependabot.com/rust-random/rand/issues/890))
> 
> ### Additions
> - Unit tests for value stability of distributions added ([wasmerio#888](https://github-redirect.dependabot.com/rust-random/rand/issues/888))
> 
> ## [0.7.1] - 2019-09-13
> ### Fixes
> - Fix `no_std` behaviour, appropriately enable c2-chacha's `std` feature ([wasmerio#844](https://github-redirect.dependabot.com/rust-random/rand/issues/844))
> - `alloc` feature in `no_std` is available since Rust 1.36 ([wasmerio#856](https://github-redirect.dependabot.com/rust-random/rand/issues/856))
> - Fix or squelch issues from Clippy lints ([wasmerio#840](https://github-redirect.dependabot.com/rust-random/rand/issues/840))
> 
> ### Additions
> - Add a `no_std` target to CI to continously evaluate `no_std` status ([wasmerio#844](https://github-redirect.dependabot.com/rust-random/rand/issues/844))
> - `WeightedIndex`: allow adjusting a sub-set of weights ([wasmerio#866](https://github-redirect.dependabot.com/rust-random/rand/issues/866))
</details>
<details>
<summary>Commits</summary>

- [`249ebfc`](rust-random/rand@249ebfc) Merge pull request [wasmerio#888](https://github-redirect.dependabot.com/rust-random/rand/issues/888) from dhardy/master
- [`5ac4cbd`](rust-random/rand@5ac4cbd) Prepare rand 0.7.2
- [`f39915a`](rust-random/rand@f39915a) rand_distr: work around tan func issue
- [`802ba8f`](rust-random/rand@802ba8f) rand_distr: add missing value_stability tests
- [`a43d7f1`](rust-random/rand@a43d7f1) Fix tests
- [`2ef2e66`](rust-random/rand@2ef2e66) Add value_stability tests for uniform
- [`096a5dd`](rust-random/rand@096a5dd) UniformSampler: add doc on usage of sample_single
- [`f78781a`](rust-random/rand@f78781a) Uniform: replace inner field with struct tuple
- [`856fdfb`](rust-random/rand@856fdfb) Distribution: add doc of portability
- [`72af6f8`](rust-random/rand@72af6f8) Add value_stability tests for bernoulli, int, float and other distrs
- Additional commits viewable in [compare view](rust-random/rand@0.7.0...0.7.2)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=rand&package-manager=cargo&previous-version=0.7.0&new-version=0.7.2)](https://dependabot.com/compatibility-score.html?dependency-name=rand&package-manager=cargo&previous-version=0.7.0&new-version=0.7.2)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in your Dependabot [dashboard](https://app.dependabot.com):
- Update frequency (including time of day and day of week)
- Pull request limits (per update run and/or open at any time)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
@Hywan
Copy link
Contributor

Hywan commented Oct 7, 2019

What is left to do? Can I help?

@MarkMcCaskey
Copy link
Contributor Author

@Hywan I think it's done, we just wanted to get it tested (I made an example in the C API example repo and I'm working on implementing it in Go). I think I know enough to say with reasonable confidence that we can ship this before finishing the implementation in Go because it just returns an import object but 🤷‍♂ .

One thing this code doesn't do is expose the errors properly. I'd like to hear your thoughts on that.

@MarkMcCaskey MarkMcCaskey marked this pull request as ready for review October 10, 2019 18:22
@MarkMcCaskey MarkMcCaskey requested a review from bjfish as a code owner October 10, 2019 18:22
Copy link
Contributor

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Overall, the PR looks good. I would love to see some tests though. How hard would it be? I believe high-level WASI tests are really mandatory since WASI is ship as a default feature.

};
if import.is_null() || import_export_value.is_null() {
update_last_error(CApiError {
msg: "pointer to import and import_export_value must not be null".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

- pointer
+ pointers

lib/runtime-c-api/src/import.rs Outdated Show resolved Hide resolved
@Hywan Hywan self-assigned this Oct 11, 2019
@Hywan Hywan added 🎉 enhancement New feature! 📚 documentation Do you like to read? labels Oct 11, 2019
@Hywan
Copy link
Contributor

Hywan commented Oct 11, 2019

@MarkMcCaskey I've created #873 to fix some of my feedbacks in this PR. Feel free to include them if you think they are relevant.

MarkMcCaskey and others added 2 commits October 22, 2019 12:14
add headers too
@MarkMcCaskey MarkMcCaskey force-pushed the feature/wasi-in-c-api branch from 02fa331 to 80cfeb5 Compare October 24, 2019 18:51
MarkMcCaskey and others added 2 commits October 25, 2019 14:38
@MarkMcCaskey MarkMcCaskey force-pushed the feature/wasi-in-c-api branch from 38a9597 to aa82df7 Compare October 25, 2019 21:52
@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Oct 25, 2019
@bors
Copy link
Contributor

bors bot commented Oct 25, 2019

try

Build failed

  • wasmerio.wasmer

@MarkMcCaskey
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Oct 28, 2019
@bors
Copy link
Contributor

bors bot commented Oct 28, 2019

try

Build succeeded

  • wasmerio.wasmer

lib/runtime-c-api/src/import/mod.rs Show resolved Hide resolved
lib/runtime-c-api/src/import/mod.rs Show resolved Hide resolved
lib/runtime-c-api/src/import/mod.rs Outdated Show resolved Hide resolved
lib/runtime-c-api/src/import/mod.rs Show resolved Hide resolved
@Hywan
Copy link
Contributor

Hywan commented Oct 28, 2019

Minor comments. The PR looks good. Nice work! Thanks.

Mark McCaskey and others added 3 commits October 29, 2019 14:55
PRId64 is defined to the right printf format string to print a int64_t on the current system.
@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 29, 2019
856: Add WASI support to C API r=MarkMcCaskey a=MarkMcCaskey

This is an additive change (with one unrelated clean up of `*mut ptr -> *const ptr`).  It exposes the functions to get a WASI import object.  It also implements a function on import object to get an `import` with namespace and name.

These changes should be okay to ship now, we can follow up to finish adding methods to ImportObject on the C API side and start migrating away from  `*imports`.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <[email protected]>
Co-authored-by: Ivan Enderlin <[email protected]>
Co-authored-by: Mark McCaskey <[email protected]>
Though both orders work, this is customary.
@MarkMcCaskey
Copy link
Contributor Author

bors r-

@bors
Copy link
Contributor

bors bot commented Oct 29, 2019

Canceled

@MarkMcCaskey
Copy link
Contributor Author

bors r+

bors bot added a commit that referenced this pull request Oct 29, 2019
856: Add WASI support to C API r=MarkMcCaskey a=MarkMcCaskey

This is an additive change (with one unrelated clean up of `*mut ptr -> *const ptr`).  It exposes the functions to get a WASI import object.  It also implements a function on import object to get an `import` with namespace and name.

These changes should be okay to ship now, we can follow up to finish adding methods to ImportObject on the C API side and start migrating away from  `*imports`.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Mark McCaskey <[email protected]>
Co-authored-by: Ivan Enderlin <[email protected]>
Co-authored-by: Mark McCaskey <[email protected]>
Co-authored-by: nlewycky <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 29, 2019

Build succeeded

  • wasmerio.wasmer

@bors bors bot merged commit d87e81c into master Oct 29, 2019
@bors bors bot deleted the feature/wasi-in-c-api branch October 29, 2019 23:15
@MarkMcCaskey MarkMcCaskey mentioned this pull request Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation Do you like to read? 🎉 enhancement New feature! 📦 lib-c-api About wasmer-c-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants