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

error: #[ctor] is not supported on the current target when compiling for wasm32-unknown-emscripten #2517

Closed
kylebarron opened this issue Jul 19, 2022 · 6 comments

Comments

@kylebarron
Copy link
Contributor

👋 I'm trying to compile polars to wasm to work with pyodide (ref #2412 and pola-rs/polars#3672 (comment)).

After removing some dependencies, I got all of polars's dependencies to build for wasm32-unknown-emscripten using RUSTUP_TOOLCHAIN=nightly maturin build --release -o dist --target wasm32-unknown-emscripten -i python3.10, but compilation failed on polars itself with a couple hundred #[ctor] is not supported on the current target errors:

2310   │ error: #[ctor] is not supported on the current target
2311   │   --> src/lazy/dataframe.rs:95:1
2312   │    |
2313   │ 95 | #[pymethods]
2314   │    | ^^^^^^^^^^^^
2315   │    |
2316   │    = note: this error originates in the attribute macro `$crate::ctor` (in Nightly builds, run with -Z macro-backtrac
       │ e for more info)

I've seen mmastrac/rust-ctor#14 and #1434. Does this mean there's no way to use a pyo3 class in wasm32-unknown-emscripten? Did the opt-out functionality mentioned here ever get implemented?

@kylebarron kylebarron changed the title error: #[ctor] is not supported on the current target when compiling for wasm32-unknown-emscripten error: #[ctor] is not supported on the current target when compiling for wasm32-unknown-emscripten Jul 19, 2022
@messense
Copy link
Member

I wonder if it's possible to get rid of multiple pymethods usage in polars?

@kylebarron
Copy link
Contributor Author

kylebarron commented Jul 19, 2022

When compiling from this commit, this (log1.txt) is the output log from

RUSTUP_TOOLCHAIN=nightly maturin build --release -o dist --target wasm32-unknown-emscripten -i python3.10

So for example several of the errors come from here: https://github.com/kylebarron/polars/blob/3e52839c89367e8fb676c483f6c618a83f0460f9/py-polars/src/series.rs#L31-L61

2265   │ error: #[ctor] is not supported on the current target
2266   │   --> src/series.rs:53:1
2267   │    |
2268   │ 53 | init_method!(new_i8, i8);
2269   │    | ^^^^^^^^^^^^^^^^^^^^^^^^
2270   │    |
2271   │    = note: this error originates in the attribute macro `$crate::ctor` (in Nightly builds, run with -Z macro-backtrac
       │ e for more info)

I wonder if it's possible to get rid of multiple pymethods usage in polars?

I'm not sure I understand pyo3 well enough to answer this question 😅 (I also didn't write the polars python bindings; I'm just exploring compiling them to pyodide). It seems like there's a compile error every time #[pymethods] is used...?

@messense
Copy link
Member

Only multiple-pymethods feature in pyo3 requires #[ctor], see https://pyo3.rs/v0.16.4/class.html#implementation-details

@kylebarron
Copy link
Contributor Author

Oh I see! That makes sense now!

It looks like polars uses multiple pymethods to simplify their macros (they use #[pymethods] dozens of times on just the PySeries struct). I'll talk to the polars project and see what they say.

Thanks for your help!

@davidhewitt
Copy link
Member

As this is documented and not anything PyO3 can realistically change, I will close this issue.

@messense
Copy link
Member

UPDATE: inventory just got wasi and emscripten support in 0.3.16 (when using Rust nightly): https://github.com/dtolnay/inventory/releases/tag/0.3.16

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

No branches or pull requests

3 participants