Skip to content

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

Closed
coolreader18 wants to merge 4 commits intoRustPython:mainfrom
coolreader18:wasm-unknown
Closed

Make rustpython-vm compatible with non-js wasm32-unknown & add tests#4211
coolreader18 wants to merge 4 commits intoRustPython:mainfrom
coolreader18:wasm-unknown

Conversation

@coolreader18
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@coolreader18
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

cc @lastmjs

Copy link
Copy Markdown
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


#[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
Copy Markdown

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

error(&s);
panic!("{}; exception backtrace above", msg)
}
#[cfg(all(target_arch = "wasm32", not(feature = "js"), not(target_os = "wasi")))]
Copy link
Copy Markdown

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
Copy Markdown
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