Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

dhylands
Copy link
Contributor

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.

@dpgeorge
Copy link
Member

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.

@dhylands
Copy link
Contributor Author

dhylands commented Nov 2, 2015

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
@pfalcon pfalcon force-pushed the master branch 6 times, most recently from 9167980 to 1cc81ed Compare April 10, 2016 22:16
@pfalcon
Copy link
Contributor

pfalcon commented Apr 26, 2016

py/obj.h changes were finally applied in 2bddfd4 . The rest is indeed better to maintain in a branch.

@alanjds alanjds mentioned this pull request Aug 10, 2016
@piranna
Copy link

piranna commented Aug 10, 2016

Why didn't work? Did it gave an error or something?

@dhylands
Copy link
Contributor Author

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.

@piranna
Copy link

piranna commented Aug 10, 2016

I would try to exec a simple script that prints to the console, and later
go into details why the REPL doesn't work.

El 10/8/2016 21:15, "Dave Hylands" notifications@github.com escribió:

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.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1561 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAgfvlpqFEzK4rCg83eWyZ9rTCx-rDu0ks5qeiM-gaJpZM4GZUOU
.

@dpgeorge
Copy link
Member

On approach to the GC would be to disable it altogether and rely on the underlying JavaScript memory manager.

@alanjds
Copy link

alanjds commented Aug 11, 2016

Here is how PyPy.js handled the REPL thing, via jq-console.

A simpler version can be found here: https://github.com/pypyjs/pypyjs-examples/blob/gh-pages/minimal_console.html

@alanjds
Copy link

alanjds commented Aug 11, 2016

Ideas about overcoming the setjmp/longjmp issue on Javascript: The "suspensions" pull request of Skulpt

@dpgeorge
Copy link
Member

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.

@matthewelse
Copy link

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

@matthewelse
Copy link

matthewelse commented Nov 10, 2016

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.

@piranna
Copy link

piranna commented Nov 10, 2016

Wiii!!! ^^ When we get this working publish it to npm too!!! :-D

El 10/11/2016 21:33, "Matthew Else" notifications@github.com escribió:

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.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1561 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAgfvkyx-40_yhO4knbxQANd5PgAo8bUks5q83-lgaJpZM4GZUOU
.

@matthewelse
Copy link

matthewelse commented Nov 10, 2016

@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.

@piranna
Copy link

piranna commented Nov 10, 2016

What problems has the REPL?

@matthewelse
Copy link

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.

@piranna
Copy link

piranna commented Nov 10, 2016

Then the output of emscripten could be used as a library and just add a Javascript cli using that library for the REPL :-)

@matthewelse
Copy link

@matthewelse
Copy link

screen shot 2016-11-10 at 22 20 45

@piranna
Copy link

piranna commented Nov 10, 2016

Then expand it a bit, add a package.json file and you are go :-)

@jaustin
Copy link

jaustin commented Nov 10, 2016

Matt this is amazing!

Please excuse brevity and typos, this was sent from a phone

On 10 Nov 2016, at 22:21, Matthew Else notifications@github.com wrote:


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@matthewelse matthewelse mentioned this pull request Nov 10, 2016
1 task
@pfalcon pfalcon added the ports Relates to multiple ports, or a new/proposed port label Apr 29, 2017
@dpgeorge
Copy link
Member

dpgeorge commented May 2, 2018

Thanks for this initial work, but I'm going to close this PR in favour of #3575.

@dpgeorge dpgeorge closed this May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ports Relates to multiple ports, or a new/proposed port
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants