Native windows stuff

137 views
Skip to first unread message

Bert Belder

unread,
Aug 13, 2010, 10:53:30 AM8/13/10
to nodejs
It's no secret that I'd like to have a native windows version of node.

The good news is that we don't have to 'big bang' switch from cygwin
to using windows apis as cygwin makes it possible to mix posix and
windows api calls. It for example provides a function that converts an
FD to a windows handle and vice versa.

The first thing I'd like to try to convert is child_process.spawn().
Its performance is pretty bad currently, presumably because cygwin
doesn't do vfork() - it just does fork()s instead. Windows has the
CreateProcess function that makes it possible to connect the spawned
process' stdin/out/err to existing pipes, so we wouldn't need fork at
all.

The question is: where do I put this platform-specific stuff?
Off course I can just use '#ifdef __CYGWIN__' which would probably
work for spawn but may not be very maintainable in the long run. For
example, if we want to port asynchronous io, it's gonna be a major
problem because porting libeio is a no-go I think, so we would end up
writing #ifdefs all the time.

- Bert

r...@tinyclouds.org

unread,
Aug 13, 2010, 11:04:36 AM8/13/10
to nod...@googlegroups.com
On Fri, Aug 13, 2010 at 7:53 AM, Bert Belder <bertb...@gmail.com> wrote:
> It's no secret that I'd like to have a native windows version of node.
>
> The good news is that we don't have to 'big bang' switch from cygwin
> to using windows apis as cygwin makes it possible to mix posix and
> windows api calls. It for example provides a function that converts an
> FD to a windows handle and vice versa.

Excellent! Yes, let's work slowly toward a MinGW build. There are
probably a dozen big things that need to be reimplemented.

> The first thing I'd like to try to convert is child_process.spawn().
> Its performance is pretty bad currently, presumably because cygwin
> doesn't do vfork() - it just does fork()s instead. Windows has the
> CreateProcess function that makes it possible to connect the spawned
> process' stdin/out/err to existing pipes, so we wouldn't need fork at
> all.

Good idea.

> The question is: where do I put this platform-specific stuff?
> Off course I can just use '#ifdef __CYGWIN__' which would probably
> work for spawn but may not be very maintainable in the long run. For
> example, if we want to port asynchronous io, it's gonna be a major
> problem because porting libeio is a no-go I think, so we would end up
> writing #ifdefs all the time.

Ideally we could work these into the platform files? But perhaps
windows just needs its own files. Just do a
node_child_process_windows.cc file for now.

Bert Belder

unread,
Aug 13, 2010, 12:51:04 PM8/13/10
to nodejs
BTW, it seems that the V8 team is interested in supporting additional
windows toolchains as well; they're talking about MinGW mostly.

I've told them about the patch Raff has made for node so maybe they
want to support cyg as well.

More info here: http://code.google.com/p/v8/issues/detail?id=64

- Bert

On Aug 13, 5:04 pm, r...@tinyclouds.org wrote:

Olly

unread,
Aug 13, 2010, 3:36:49 PM8/13/10
to nodejs
If V8 supports MinGW why are you trying to force through a Cygwin
patch? Would it not be better to just port Node.JS to MinGW which is
already supported by V8?

Surely MinGW is faster then Cygwin too?

Elijah Insua

unread,
Aug 13, 2010, 3:44:01 PM8/13/10
to nod...@googlegroups.com
Getting node running on MingGW is quite a ways off due to libeio / libev, and the failure of windows in general.

-- Elijah

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


Bert Belder

unread,
Aug 13, 2010, 4:00:42 PM8/13/10
to nodejs
On Aug 13, 9:36 pm, Olly <oliver.mor...@kohark.com> wrote:
> If V8 supports MinGW why are you trying to force through a Cygwin
> patch?

Because node currently runs on only cygwin. V8 works with cygwin
without much effort, but as long as the v8 team itself is not aware of
that the cygwin build will break every now and then, like the latest
version (v2.3.7).

> Would it not be better to just port Node.JS to MinGW which is
> already supported by V8?

Well, that's the goal - eventually.
But we need to move a few mountains before node can run on MingW.

Bert Belder

unread,
Aug 13, 2010, 4:00:54 PM8/13/10
to nodejs
On Aug 13, 9:36 pm, Olly <oliver.mor...@kohark.com> wrote:
> If V8 supports MinGW why are you trying to force through a Cygwin
> patch?

Because node currently runs on only cygwin. V8 works with cygwin
without much effort, but as long as the v8 team itself is not aware of
that the cygwin build will break every now and then, like the latest
version (v2.3.7).

> Would it not be better to just port Node.JS to MinGW which is
> already supported by V8?

Olly

unread,
Aug 14, 2010, 12:41:48 PM8/14/10
to nodejs
Why doesn't someone who knows what they're doing, write down a list of
things that needs to be done in order to have a MinGW version of node,
and people who are competent can work through different items if they
can?

Olly

unread,
Aug 15, 2010, 12:08:46 PM8/15/10
to nodejs
Further to this, has anyone given some thought as to making node
compile on MSVC? I believe V8 is natively designed to compile on
windows MSVC. Using native windows constructs would be faster then
MinGW i would of thought?

Alan Gutierrez

unread,
Aug 15, 2010, 12:29:13 PM8/15/10
to nod...@googlegroups.com
Olly wrote:

> Why doesn't someone who knows what they're doing, write down a list of
> things that needs to be done in order to have a MinGW version of node,
> and people who are competent can work through different items if they
> can?

Because everyone who knows what they are doing is busy doing something
else. Therefore, someone who has no idea what they are doing, such as
myself, is probably going to have to create a Wiki page:

http://wiki.github.com/ry/node/windows-port-mingw

The road map was extracted from the Windows port discussions from the
mailing list found at the top of the page.

The bottom of the page has a list of suspected Windows sympathizers
based on mailing list discussions, created with the intent of fostering
a Windows hacker community. If you are mortified to find your name on
this list, please remove it. If you are crushed that your name is not on
the list, please add it.

--
Alan Gutierrez - al...@blogometer.com - http://twitter.com/bigeasy

Olly

unread,
Aug 15, 2010, 12:37:48 PM8/15/10
to nodejs
The trouble is, those who know what they're doing, don't use windows.
> Alan Gutierrez - a...@blogometer.com -http://twitter.com/bigeasy

Alan Gutierrez

unread,
Aug 16, 2010, 12:29:01 AM8/16/10
to nod...@googlegroups.com
Olly wrote:
> On Aug 15, 5:29 pm, Alan Gutierrez <a...@blogometer.com> wrote:
>> Olly wrote:
>>> Why doesn't someone who knows what they're doing, write down a list of
>>> things that needs to be done in order to have a MinGW version of node,
>>> and people who are competent can work through different items if they
>>> can?
>> Because everyone who knows what they are doing is busy doing something
>> else. Therefore, someone who has no idea what they are doing, such as
>> myself, is probably going to have to create a Wiki page:
>>
>> http://wiki.github.com/ry/node/windows-port-mingw
>>
>> The road map was extracted from the Windows port discussions from the
>> mailing list found at the top of the page.
>>
>> The bottom of the page has a list of suspected Windows sympathizers
>> based on mailing list discussions, created with the intent of fostering
>> a Windows hacker community. If you are mortified to find your name on
>> this list, please remove it. If you are crushed that your name is not on
>> the list, please add it.

> The trouble is, those who know what they're doing, don't use windows.

True dat, but, hey. Looks like Ryan Dahl and Elijah Insua have spoken
with Marc Lehmann, and I'm beginning to understand that...

Node.js depends on libev and libeio for Great Justice. Porting those two
libraries to Windows would port Node.js to Windows. libev already works
on Windows, with issues related to a lack of asynchronous I/O on pipes.
libeio does not work on Windows except via cygwin.

There is historic discussion about schmorp's libraries and Windows to be
found on his website.

http://www.google.com/search?q=site%3Alists.schmorp.de+windows

Does it help to read through the Cygwin code? If Node.js works on
Cygwin, is it a matter of pulling the Cygwin tricks out of Cygwin and
into eio.c? Here's Cygwin's pipe() implementation, with notes on how to
create a selectable pipe.

http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/pipe.cc?rev=1.125&content-type=text/x-cvsweb-markup&cvsroot=src

Or is that too optimistic on my part?

Reply all
Reply to author
Forward
0 new messages