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

Update CI test for wasm32-unknown-unknown to enable wasmbind feature #746

Merged
merged 2 commits into from Jul 28, 2022

Conversation

esheppa
Copy link
Collaborator

@esheppa esheppa commented Jul 28, 2022

Testing whether this triggers the CI

src/lib.rs Outdated Show resolved Hide resolved
@@ -6,6 +6,7 @@ on:
pull_request:
branches: [main]
paths:
- ".ci/**"
Copy link
Contributor

Choose a reason for hiding this comment

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

Hah, good call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm thinking of removing branches: [main] as well, that way PR's to PR's will also run CI which would be great

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! In a separate commit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep - just squashing them

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant, would be good to have the test.yml changes in a separate commit from the Cargo.toml changes since they're conceptually independent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, will push up two separate commits

@esheppa esheppa force-pushed the wasm32-target-features branch 2 times, most recently from 6e2a859 to 40519df Compare July 28, 2022 10:36
@djc
Copy link
Contributor

djc commented Jul 28, 2022

Also I think we'll no longer need @AmateurECE's original commit as part of this PR, right?

@esheppa esheppa force-pushed the wasm32-target-features branch 2 times, most recently from 8da3baf to d20c344 Compare July 28, 2022 11:02
no longer require wasmbind feature to get js-sys on wasm32-unknown-unknown target

fix comment and remove wasmbind feature from tests

add wasi test

add wasi test
@esheppa
Copy link
Collaborator Author

esheppa commented Jul 28, 2022

I initially thought we still needed, but then I saw the inconsistency between the #[cfg flags in the Cargo.toml and in the code, so I just used #[cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))] and its negation everywhere which avoids breaking emscripten while still removing use of the wasmbind feature. This should be safe as using rustup target list there are only three wasm targets, wasm32-unknown-unknown, wasm32-unknown-emscripten and wasm32-wasi, so there shouldn't be any other wasm targets getting unexpected wasm-bindgen or js-sys

@morenol
Copy link

morenol commented Aug 10, 2022

Hey, now that the wasm-bindgen is in the dependency tree and it is not possible to remove that from wasm targets, it adds a bunch of wasm_bindgen imports that runtimes like wasmtime and wasmer don't provide. Is it ok if I create a PR adding a feature_flag that is off by default that we can use to disable wasm_bingen from being installed?

RIght now I am having difficulties in using chrono crate with wasmtime. In chrono = 0.4.19 I didnt have that issue

@esheppa
Copy link
Collaborator Author

esheppa commented Aug 11, 2022

@morenol - this PR was to fix #740 where there is essentially a discoverability problem, however it is not ideal that we have broken your use case. If I'm understanding you correctly, you are proposing to have a feature which disables wasm-bindgen, but this might break the additive nature of features. Instead, it may be possible to make those two dependencies optional and add wasmbind to the default features (and include wasm-bindgen and js-sys in wasmbind feature)?

Also to note, because the features would be additive, if any of your dependencies used the wasmbind feature, then you would get those crates in your tree as well. Is this preventing you from using chrono with wasmtime, eg compile error or runtime error - or is this more of an efficiency concern?

@morenol
Copy link

morenol commented Aug 11, 2022

This is preventing me from using chrono with wasmtime. The solution that you propose would also work, the thing that I need is to disable wasm-bindgen from the dependency tree.

The issue that I am having is that when wasm-bindgen is in the dependency tree, it injects some imports that are intended for JavaScripts hosts.

Just as a reference, this is the specific line in wasmtime that is returing an error:

https://github.com/bytecodealliance/wasmtime/blob/c3e31c99461f7f109637528d805dbaa349cf4a22/crates/wasmtime/src/instance.rs#L830

@djc
Copy link
Contributor

djc commented Aug 11, 2022

Instead, it may be possible to make those two dependencies optional and add wasmbind to the default features (and include wasm-bindgen and js-sys in wasmbind feature)?

This sounds good to me.

@esheppa
Copy link
Collaborator Author

esheppa commented Aug 11, 2022

@morenol - are you using the target wasm32-wasi or wasm32-unknown-unknown?

@morenol
Copy link

morenol commented Aug 11, 2022

wasm32-unknown-unknown, I am able to compile without issues, the problem arises when trying to instanciate the module in wasmtime

@esheppa
Copy link
Collaborator Author

esheppa commented Aug 11, 2022

I've set up #771 allow this. Do you mind checking whether it works for you? I might need to make a few more changes. We can continue the conversation over there

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.

None yet

3 participants