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

Make rustpython-vm compatible with non-js wasm32-unknown & add tests #4211

Closed
wants to merge 4 commits into from

Conversation

coolreader18
Copy link
Member

Ideally the test crate shouldn't take long to compile, since it's the same target with only a few crates configured differently.

@coolreader18
Copy link
Member Author

Hmm, is there a reason we need to have wasm32-unknown-unknown checked in exotic_targets when we have the wasm job? Is that a holdover from before we had the wasm job?

@coolreader18 coolreader18 force-pushed the wasm-unknown branch 2 times, most recently from cd74d27 to e00c1f2 Compare October 14, 2022 22:31
@youknowone
Copy link
Member

I recently added it there without specific reason. Do you think it belongs to wasm job? That makes sense.

@@ -0,0 1 @@
A test crate to ensure that `rustpython-vm` compiles on `wasm32-unknown-unknown` without a JS host.
Copy link
Member

Choose a reason for hiding this comment

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

👍

@coolreader18
Copy link
Member Author

As far as I can tell compilation for the target is already tested fully on the wasm job, so it's redundant in exotic_targets.

@youknowone
Copy link
Member

I added the build to prevent the target's build error.

wasm build job was not fully covering the top-most crate rustpython build
See #3634

@coolreader18
Copy link
Member Author

Oh, I see. But that's not supported anyway, right? You can't compile a cli application to wasm w/ js-interop, there's no syscalls or argv or anything.

@youknowone
Copy link
Member

there was wasm32-unknown use case without js interop.
the top crate is now more useful than vm because user must manually construct interpreter using vm and stdlib since we seprated stdlib crate. rustpython crate suggests a convenient way to construct one without knowing the details.

@youknowone
Copy link
Member

cc @lastmjs

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

not sure if skipping cargo check --target wasm32-unknown-unknown --no-default-features is safe.
other parts looks great

@@ -102,6 102,11 @@ mod time {
Ok(Date::now() / 1000.0)
}

#[cfg(all(target_arch = "wasm32", not(feature = "js"), not(target_os = "wasi")))]
fn _time(vm: &VirtualMachine) -> PyResult<f64> {
Err(vm.new_not_implemented_error("time.time".to_owned()))
Copy link

Choose a reason for hiding this comment

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

I will need a way to implement time, I have the APIs in my environment, but I will need a way to override this

@@ -53,6 53,11 @@ impl VirtualMachine {
error(&s);
panic!("{}; exception backtrace above", msg)
}
#[cfg(all(target_arch = "wasm32", not(feature = "js"), not(target_os = "wasi")))]
Copy link

Choose a reason for hiding this comment

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

Wouldn't it be useful to still see information from the exception? Can't you do something like:

let err_string: String = exc.to_pyobject(vm).repr(vm).unwrap().to_string();

Or does the msg have everything we need?

Copy link
Member

Choose a reason for hiding this comment

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

It will be useful

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