Skip to content

Commit

Permalink
Add some more details based on davidhewitt's review
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jun 22, 2022
1 parent 855f085 commit 9a5b73f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions content/posts/rust-pyo3-support-in-pyodide.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,14 @@ export somehow.
Using `-sSIDE_MODULE=2` solves the `lib.rmeta` error because `--whole-archive`
is not passed to the linker. Conveniently, Rust is good at calculating which
symbols should be exported: public symbols with the `#[no_mangle]` attribute are
exported, other symbols are not. In the case of a PyO3 module, the only exported
symbol is the `PyInit__my_module` function that Python invokes when loading a
native module.

It would be great to link our other extension modules with `-sSIDE_MODULE=2` but
we first need to figure out how to export the `PyInit` function.
exported, other symbols are not. [It automatically passes this information on to
the linker.](https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/back/link.rs#L1882).
In the case of a PyO3 module, the only exported symbol is the
`PyInit__my_module` function that Python invokes when loading a native module.

[We are working on linking Python C/C++ extension modules with `-sSIDE_MODULE=2`
too](https://github.com/pyodide/pyodide/pull/2712). To do this we need to
calculate the symbols to export with the Pyodide build system.


## Misencoded object files and LLVM version conflicts
Expand Down

0 comments on commit 9a5b73f

Please sign in to comment.