[Nix-dev] getting node.js to work on darwin
shea at shealevy.com
shea at shealevy.com
Thu Mar 14 14:10:50 CET 2013
Hi Sander,
On 2013-03-14 07:22, Sander van der Burg - EWI wrote:
> Hello everybody,
>
> Today I was (again) struggling a bit with getting nodejs to work on
> Darwin. One of the things that make it so hard/annoying is the fact
> that V8 (the JavaScript engine) uses some kind of weird/stupid
> meta-build system called gyp (http://code.google.com/p/gyp) developed
> by Google. No idea, why they think we need yet another solution, but
> that's a different discussion....
>
> On Darwin, gyp assumes that you want to generate an Xcode project
> and use xcodebuild to build it. I've dived a bit into the source code
> of gyp and I couldn't find a (simple) way to instruct gyp to just
> create Makefiles. In fact, it's not surprising to me if there is no
> way to do it all.
>
> I have tried various things to solve it. One solution was to use
> xcodeenv.xcodewrapper -- a wrapper component that exposes the host
> system's xcodebuild utility (if installed) inside a Nix expression.
> Unfortunately, the v8 xcodebuild script calls g++ with a parameter:
> -arch, that does not seem to work with the gcc version in Nixpkgs
> used
> on Darwin.
>
> I've also tried replacing gcc by clang on darwin, since that's what
> Apple is using for recent Xcode releases. Clang seems to accept the
> -arch parameter and to be able to compile most of the source code.
> However, when all object files are linked, it stops and reports some
> weird error showing all kinds of unresolved symbols.
>
This is because darwin's libraries and binaries are all multilib
"universal" binaries, so the linker is looking for 64-bit and 32-bit
symbols, but our libstdc++ (which is used by clang too, though we could
switch to libc++ on darwin I think) is not multilib.
>
> The third solution was to just expose the host's g++ (which is fact
> clang) to the nodejs expression that's included with xcode. This
> option seems to compile nodejs on darwin, although it's impure.
>
> I know that the last solution is not elegant, but it's (as far as I
> know) the only way to get it working on Mac. Do you mind submitting
> my
> nodejs expression? On Linux, it should still ignore these impurities.
>
I don't mind personally. I have a project that I touch now and then to
get a stdenv that's as close as possible to the native darwin tools
(multilib, using Apple's patches, etc.), but it's slow going and boring
work so I don't expect it to be done any time soon.
Cheers,
Shea
More information about the nix-dev
mailing list