[pythran] Re: Pythran to wasm too ?
- From: Serge Guelton <serge.guelton@xxxxxxxxxxxxxxxxxxx>
- To: pythran@xxxxxxxxxxxxx
- Date: Sat, 6 Apr 2019 10:48:31 +0200
On Sat, Apr 06, 2019 at 09:02:26AM +0200, Olivier Borderies wrote:
Pythran "takes a Python module annotated with a few interface description and
turns it into a native Python module with the same interface (hopefully
faster)
".
How difficult / useful / relevant would it be to target .wasm module too ?
I realize this is a broad question, outside Pythran natural scope. And I have
no idea whether it's feasible (for normal humans) to take a Pythran output and
feed it into emscripen..
However I ask because (1) I find Pythran really convenient and efficient (2)
in
my work we use the Python and web ecosystems in equal proportions I see quite
a
few use cases.
Would be keen to know your thoughts.
I don't see a reason why it wouldn't work, but I'm not a wasm expert, something
alongside
$ cat hello.py
def hello():
print("hello world")
$ pythran -e hello.py -o hello.hpp
$ cat hello.cpp
#include "hello.hpp"
auto hello() {
return __pythran_hello::hello{}();
}
$ clang++ hello.cpp -std=c++14 -Ipythran -O2 -emit-llvm --target=wasm32 -Oz -c
-o hello.bc
$ llc -asm-verbose=false -o hello.s hello.bc
(following this recipe
https://stackoverflow.com/questions/45146099/how-do-i-compile-a-c-file-to-webassembly)
should be a good start. The key is to use the `-e` flag of pythran!
Other related posts: