-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
RFC: emscripten: Got something to compile and link. #1561
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
Conversation
Wow, cool! Please keep us posted as to progress. You may want to use minimal/ instead of unix/ since it has less to go wrong. |
I updated my branch to create an emscripten port, based off a copy of the minimal port. At least now, it can build by just typing make. It's still not running for me, so will need further investigation... |
This adds an emscripten port, which originated from the minimal port. You should now be able to just use make from within the emscripten directory. It still doesn't run for me. I was building under Ubuntu 14.04 using emscripten 1.35.4
9167980
to
1cc81ed
Compare
py/obj.h changes were finally applied in 2bddfd4 . The rest is indeed better to maintain in a branch. |
Why didn't work? Did it gave an error or something? |
I didn't get a REPL and didn't have time to investigate. If I were going to approach this again, I would probably start with something other than MicroPython and just try to get basic input and output working (i.e. basic needs of the REPL). I'd then figure out how to create the heap, and then how to get setjmp/longjmp working. Those 3 things are the fundamental things that MicroPython needs to function. Once you've got those things working, I suspect it's not much more difficult to bring up minimal MicroPython to a REPL. |
I would try to exec a simple script that prints to the console, and later El 10/8/2016 21:15, "Dave Hylands" notifications@github.com escribió:
|
On approach to the GC would be to disable it altogether and rely on the underlying JavaScript memory manager. |
Here is how PyPy.js handled the REPL thing, via A simpler version can be found here: https://github.com/pypyjs/pypyjs-examples/blob/gh-pages/minimal_console.html |
Ideas about overcoming the setjmp/longjmp issue on Javascript: The "suspensions" pull request of Skulpt |
It would be nice to further abstract the nlr behaviour (push/pop/raise) so it can be optionally replaced (at compile time) with samething like try/throw (eg to compile and work with native C++ exceptions). Maybe this could also be used when converting to JS, to use JS exceptions. |
I've managed to get a small example running on micropython on top of emscripten this evening (only prints 'hello, world'). I tried running the minimal example on OS X before I got it running with emscripten, which may explain the issue @dhylands was having before. I'll put some code up on GitHub this evening to show it working. cc: @jaustin |
I've put the code up here: matthewelse/micropython - you should be able to run it by following the instructions in the README, though there may be additional dependencies I've forgotten. |
Wiii!!! ^^ When we get this working publish it to npm too!!! :-D El 10/11/2016 21:33, "Matthew Else" notifications@github.com escribió:
|
@piranna - sounds like a good idea! It's probably not going to be that easy to get the REPL working with the readline code in micropython, but it can quite easily be used to provide a javascript API to allow a JavaScript process to call Python code. |
What problems has the REPL? |
The problem I've had at the moment is an issue with the way that Emscripten deals with STDIN, though it's straight forward enough to use the REPL package in node to produce a REPL. |
Then the output of emscripten could be used as a library and just add a Javascript cli using that library for the REPL :-) |
@piranna that's what I've done here :) https://github.com/matthewelse/micropython/blob/emscripten/emscripten/main.js |
Then expand it a bit, add a |
Matt this is amazing! Please excuse brevity and typos, this was sent from a phone
|
Thanks for this initial work, but I'm going to close this PR in favour of #3575. |
I used the following command line from within the unix tree:
make CC=emcc CPP='gcc -E' CFLAGS_EXTRA=-DMICROPY_NLR_SETJMP MICROPY_PY_FFI=0 STRIP=echo SIZE=echo V=1
I was building under Ubuntu 14.04 using emscripten 1.35.4
emcc doesn't recignize .S files at all, so my commit needs work (I just removed all of the nlrXXX.o files which originate from source).
In obj.h, I changed some mp_int_t to mp_uint_t because left shifting an int is apparently undefined. I tested a bunch of different values using the modified macro and it seems to produce the same results.
The resulting micropython file doesn't run under node, so I still need to figure out why not. But I figured I'd post what I've done up until now as a PR as a form of documentation.