Compiling node.js on a jailbroken iPhone? Possible?

161 views
Skip to first unread message

TooTallNate

unread,
Jun 11, 2010, 7:44:10 PM6/11/10
to nodejs
I have a jailbroken iPhone which gives me ssh access, and a whole slew
of dev packages ported over for the iPhone.

Do you think there's any way it'd be possible to compile node.js on a
jailbroken iPhone? Which kinds of dev packages would be needed?

I realize this could be impossible, but I have a static IP on mine
thanks to work and it would be cool to start hosting some services
through node on the thing. Thanks in advance!

Daniel Ly

unread,
Jun 13, 2010, 7:19:53 AM6/13/10
to nodejs
Cool idea. My iPhone uses an ARM processor but V8 supports ARM (how
fast is another question).

Let's try it out. First I got apt-get then installed the packages
iphone-python, wget, iphone-gcc and make. iphone-gcc installs only if
you this beforehand:

wget http://files.getdropbox.com/u/876743/fake-libgcc_1.0_iphoneos-arm.deb
dpkg -i fake-libgcc_1.0_iphoneos-arm.deb

because package libgc is missing. I know this part is a bit shady. I
won't try it on an iPhone which you really need for your work...
Caveat emptor!

But then ./configure complains that the dl library could not be found
(but there is one at /usr/lib/libdl.dylib). Since Node.js compiles on
Macintosh, there should be a possibility to convince ./configure to
switch to Macintosh "mode", but I don't know scons at all. Can someone
help me here?

A different (and perhaps a better) approach would be cross-compiling
Node.js: http://stackoverflow.com/questions/552509/cross-compiling-c-to-iphone-arm

-nalply

TooTallNate

unread,
Jun 14, 2010, 3:25:42 PM6/14/10
to nodejs
It's actually my iPhone, but my work has SIM cards that have
provisioned static IPs and allow incoming connections from AT&T, and I
can put one in temporarily for fun.

I actually first tried to compile Git from source on the iPhone
(figured it would at least be simpler than node), and ran into similar
errors in the ./configure step. Without me being more knowledgeable
about all these building steps and the insides of the configure
script, etc, I can't go much further.

It's too bad there's not somebody reading on this list who's
knowledgeable on the iPhone jailbreak scene/building software from
source. Perhaps I should post this same question on a more iPhone
jailbreak related mailing list? Somebody on an iPhone specific list
might at least be able to help me through the individual errors while
trying to compile.

Also, cross-compiling on a Mac to ARM, then manually transferring the
files to the phone might be the right way to do it. What would that
take for node? Probably something like modifying the configure or
Makefile files?

Please forgive my ignorance, I just think this would be awesome if we
can figure it out!

On Jun 13, 4:19 am, Daniel Ly <nal...@gmail.com> wrote:
> Cool idea. MyiPhoneuses an ARM processor but V8 supports ARM (how
> fast is another question).
>
> Let's try it out. First I got apt-get then installed the packagesiphone-python, wget,iphone-gcc and make.iphone-gcc installs only if
> you this beforehand:
>
> wgethttp://files.getdropbox.com/u/876743/fake-libgcc_1.0_iphoneos-arm.deb
> dpkg -i fake-libgcc_1.0_iphoneos-arm.deb
>
> because package libgc is missing. I know this part is a bit shady. I
> won't try it on aniPhonewhich you really need for your work...
> Caveat emptor!
>
> But then ./configure complains that the dl library could not be found
> (but there is one at /usr/lib/libdl.dylib). Since Node.js compiles on
> Macintosh, there should be a possibility to convince ./configure to
> switch to Macintosh "mode", but I don't know scons at all. Can someone
> help me here?
>
> A different (and perhaps a better) approach would be cross-compiling
> Node.js:http://stackoverflow.com/questions/552509/cross-compiling-c-to-iphone...
>
> -nalply

Raffaele Sena

unread,
Jun 14, 2010, 4:24:57 PM6/14/10
to nod...@googlegroups.com
One thing I would do first (but it may be even harder than compiling/crosscompiling node.js) is to try to port the v8 engine.

One of the problem on a non-jailbroken iPhone is that you cannot implement a JIT that writes in a data area and then tries to execute it (or you can't write in a code area). The virtual memory is configured to disable write access to code and/or execute access to data, and I don't remember if a jailbroken iphone removes these limitations (I think it does, or at least used to, but again not sure of what the current state of this is).

And, yes, probably a mailing list dedicated to cross-compilers / native compilers would be more appropriate.

-- Raffaele


>
> -nalply

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Daniel Ly

unread,
Jun 15, 2010, 4:26:03 AM6/15/10
to nodejs
> One thing I would do first (but it may be even harder than
> compiling/crosscompiling node.js) is to try to port the v8 engine.

Are you overstating the problem?

1. http://limpet.net/mbrubeck/2009/11/06/android-v8.html: V8 runs on
Android.
2. http://gizmodo.com/5521580/the-iphone-now-runs-android: iPhone runs
Android.

These reports give me important clues that it is perhaps possible to
compile V8 for iPhone directly.

Who is the first who gets Node.js running on an iPhone? Last one
there's a rotten egg!! :-)

-nalply

TooTallNate

unread,
Jun 17, 2010, 9:01:16 PM6/17/10
to nodejs
Well I perhaps made some progress. My './configure' step was failing
on the "Checking if C Compiler works" part, saying that output files
are not executable, and directing me to use the --host option for
cross compiling. But I'm not cross-compiling, this is a native build
on an iPhone!

So that made me think that the output files need to be ran through
"ldid -S filename" to pseudo-sign them, so that the iPhone actually
executes them. Without some way of augmenting gcc directly, I wrote a
little bash script that runs gcc, then ldid -S on the output filename
(by finding the -o switch).

You can try them here: http://gist.github.com/443040

It's not even close to working, but I think it's progress. The catch
is that we have to run "ldid -S" on anything that 'gcc' or 'g++' put
out. Determining the actual output filename is the part that isn't
perfect, and I believe is why it's failing now.


On Jun 15, 1:26 am, Daniel Ly <nal...@gmail.com> wrote:
> > One thing I would do first (but it may be even harder than
> > compiling/crosscompiling node.js) is to try to port the v8 engine.
>
> Are you overstating the problem?
>
> 1.http://limpet.net/mbrubeck/2009/11/06/android-v8.html:V8 runs on
> Android.
> 2.http://gizmodo.com/5521580/the-iphone-now-runs-android:iPhoneruns
> Android.
>
> These reports give me important clues that it is perhaps possible to
> compile V8 foriPhonedirectly.
>
> Who is the first who gets Node.js running on aniPhone? Last one
Reply all
Reply to author
Forward
0 new messages