OSX, a module, x86_64, i386, and a node compiled as a universal binary.

353 views
Skip to first unread message

Jorge

unread,
Feb 5, 2013, 6:39:46 AM2/5/13
to nod...@googlegroups.com
When someone installs node in his Mac with joyent's installer he gets a universal binary:

$ file `which node`
/usr/local/bin/node: Mach-O universal binary with 2 architectures
/usr/local/bin/node (for architecture i386): Mach-O executable i386
/usr/local/bin/node (for architecture x86_64): Mach-O 64-bit executable x86_64

If he then installs a module, for some reason (*) waf chooses to make it for i386 only:

$ npm install threads_a_gogo
...

$ file /Users/jorge/.node_libraries/threads_a_gogo.node
/Users/jorge/.node_libraries/threads_a_gogo.node: Mach-O bundle i386

Then he's got a problem if on his Mac node is run in 64bits mode by default:

$ arch -arch i386 node node_modules/threads_a_gogo/test/test00_run_once_and_destroy.js
Using 1 threads
[0] -> 0.4702872186899185
THREADS PER SECOND -> 47.6
BYE !


$ node node_modules/threads_a_gogo/test/test00_run_once_and_destroy.js

module.js:485
process.dlopen(filename, module.exports);
^
Error: dlopen(/Users/jorge/node_modules/threads_a_gogo/build/release/threads_a_gogo.node, 1): no suitable image found. Did find:
/Users/jorge/node_modules/threads_a_gogo/build/release/threads_a_gogo.node: mach-o, but wrong architecture
at Object.Module._extensions..node (module.js:485:11)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/jorge/node_modules/threads_a_gogo/test/test00_run_once_and_destroy.js:3:14)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)


How can I tell waf to make a universal binary ?

How can I override the arch waf defaults to?

(*)<https://github.com/joyent/node/blob/v0.8.18/tools/wafadmin/Tools/node_addon.py#L61-65>
--
Jorge.

Fedor Indutny

unread,
Feb 5, 2013, 6:40:59 AM2/5/13
to nod...@googlegroups.com
Just use gyp ;)

Cheers,
Fedor.


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
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?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Jorge Chamorro

unread,
Feb 5, 2013, 6:47:01 AM2/5/13
to nod...@googlegroups.com
On 05/02/2013, at 12:40, Fedor Indutny wrote:

> Just use gyp ;)

Thanks ;) but I need a fix for waf too... any ideas?

Cheers,
--
Jorge.

Fedor Indutny

unread,
Feb 5, 2013, 6:50:15 AM2/5/13
to nod...@googlegroups.com
That's how I solved it long time ago: https://github.com/indutny/node-hogan.jit/blob/master/wscript

Hopefully, it'll work for you.

Cheers,
Fedor.


--
Jorge.

Fedor Indutny

unread,
Feb 5, 2013, 6:50:50 AM2/5/13
to nod...@googlegroups.com
Sorry, its wrong file... searching another one.

Cheers,
Fedor.

Jorge Chamorro

unread,
Feb 5, 2013, 8:31:53 AM2/5/13
to nod...@googlegroups.com

On 05/02/2013, at 12:50, Fedor Indutny wrote:

> That's how I solved it long time ago: https://github.com/indutny/node-hogan.jit/blob/master/wscript
>
> Hopefully, it'll work for you.

Yes, perhaps...

Did a google search and I (guess) I'd have to do what says here <http://blog.omega-prime.co.uk/?p=102> in the "easy method", is that ~ right?

So, how can I pass multiple arch flags from my wscript ?

Cheers,
--
Jorge.

Nathan Rajlich

unread,
Feb 5, 2013, 11:54:01 AM2/5/13
to nod...@googlegroups.com
Why do you *need* a fix for waf too? It's been deprecated for 2 major releases now, and is completely removed from v0.9/v0.10.

--
Jorge.

Isaac Schlueter

unread,
Feb 5, 2013, 11:55:30 AM2/5/13
to nodejs
Whoa, why are you looking in ~/.node_modules? What version of npm are
you using, 0.2.something?

Jorge Chamorro

unread,
Feb 5, 2013, 1:06:25 PM2/5/13
to nod...@googlegroups.com
On 05/02/2013, at 17:54, Nathan Rajlich wrote:

> Why do you *need* a fix for waf too? It's been deprecated for 2 major releases now, and is completely removed from v0.9/v0.10.

Currently my module can be installed in any node from v0.5.1 all the way up to the latest (0.8.18), and I'd like it to continue to be so.

If I switch to gyp, will it still build in the older versions such as 0.5.1 ?

Jorge Chamorro

unread,
Feb 5, 2013, 1:08:47 PM2/5/13
to nod...@googlegroups.com
On 05/02/2013, at 17:55, Isaac Schlueter wrote:

> Whoa, why are you looking in ~/.node_modules? What version of npm are
> you using, 0.2.something?

$ npm -v && node -v
1.2.2
v0.8.18

Nathan Rajlich

unread,
Feb 5, 2013, 2:01:59 PM2/5/13
to nod...@googlegroups.com
If I switch to gyp, will it still build in the older versions such as 0.5.1 ?

When you switch to node-gyp the lowest supported version will be v0.6.0.

v0.5.1 is in the unstable range anyways, so I doubt it would be a problem to drop support for v0.5.x. Nobody should be using an release that old/unstable anyways.

Matt

unread,
Feb 5, 2013, 2:26:39 PM2/5/13
to nod...@googlegroups.com
On Tue, Feb 5, 2013 at 2:01 PM, Nathan Rajlich <nat...@tootallnate.net> wrote:
Nobody should be using an release that old/unstable anyways

I still have servers running 0.4 for some stuff. Though I don't add anything to them, so it's not really a fair comparison. They just sit there rock solid stable.

Nathan Rajlich

unread,
Feb 5, 2013, 2:29:10 PM2/5/13
to nod...@googlegroups.com
Well v0.4.x is an even numbered release, so it is technically stable. I'm sure some older running applications are still on those versions and that's ok, they're just probably not going to be compatible with a lot of the newer native addons.

--

Jorge

unread,
Feb 5, 2013, 3:45:02 PM2/5/13
to nod...@googlegroups.com
On 05/02/2013, at 14:31, Jorge Chamorro wrote:
>
>
> Did a google search and I (guess) I'd have to do what says here <http://blog.omega-prime.co.uk/?p=102> in the "easy method", is that ~ right?
>
> So, how can I pass multiple arch flags from my wscript ?

JFTR:

After some research the answer is: it's not possible because there's a bug in waf and another in node-waf:

1.- Waf won't pass properly -arch flags twice, which is needed to build universal binaries on a Mac, and
2.- the node_addon.py file has a bug that defaults to i386 iff the node executable is a mac universal binary.

The issue is known, there's a pull request with the patch ready to fix it, isaacs and tootallnate in particular know it, but they simply don't give a damn:

<https://github.com/joyent/node/issues/3633>
<https://github.com/joyent/node/issues/3524>
<https://github.com/joyent/node/issues/3633>

( RYAN DAHL PLEASE COME BACK SOON )

Cheers,
--
Jorge.

Nathan Rajlich

unread,
Feb 5, 2013, 4:14:27 PM2/5/13
to nod...@googlegroups.com
Oh please, any well maintained native module migrated to node-gyp months ago. If you haven't yet, you should.

I don't really get what you're complaining about...


Cheers,
--
Jorge.

Jorge Chamorro

unread,
Feb 6, 2013, 11:09:18 AM2/6/13
to nod...@googlegroups.com
On 05/02/2013, at 22:14, Nathan Rajlich wrote:

> Oh please, any well maintained native module migrated to node-gyp months ago. If you haven't yet, you should.
>
> I don't really get what you're complaining about...

*YOU* are breaking the APIs, not me. My module built and ran fine until:

- You broke the API for the umpteenth time again, and
- You began distributing node as a universal binary which made that node-waf bug in your code -that you don't want to fix- bite.

Thank you, it's always a pleasure to deal with you guys.

:-(
--
Jorge.

Jorge Chamorro

unread,
Feb 6, 2013, 11:16:56 AM2/6/13
to nod...@googlegroups.com
On 05/02/2013, at 20:29, Nathan Rajlich wrote:

> Well v0.4.x is an even numbered release, so it is technically stable. I'm sure some older running applications are still on those versions and that's ok, they're just probably not going to be compatible with a lot of the newer native addons.

My module *is* compatible with a node that old too:

"You need a node with a v8 >= 3.2.4 to run this module. Any node >= 0.5.1 comes with a v8 >= 3.2.4.

The module runs fine, though, in any node >= 0.2.0 as long as you build it with a v8 >= 3.2.4. To do that you simply have to replace /node/deps/v8 with a newer version of v8 and recompile it (node). To get any version of node goto http://nodejs.org/dist/, and for v8 goto http://github.com/v8/v8, click on "branch", select the proper tag (>= 3.2.4), and download the .zip."

<https://github.com/xk/node-threads-a-gogo#installing-the-module>

Nathan Rajlich

unread,
Feb 6, 2013, 2:31:09 PM2/6/13
to nod...@googlegroups.com
You can actually keep support for your old node versions if you keep your wscript file hanging around. Just *also* add a binding.gyp file. Older versions of node will still compile using node-waf and versions of npm that have node-gyp will compile using that.

Isaac Schlueter

unread,
Feb 8, 2013, 8:32:04 PM2/8/13
to nodejs
As far as I can tell, the node core team is unanimously opposed to
continuing to support node-waf, or wscript files in modules.

That's what it means when something is deprecated. "It might break,
and we aren't going to care when it does."

If you want to take on the burden of supporting Node 0.5 and node-waf,
then that's fine, of course. Just don't expect us to help. We have
other fish to fry, I'm afraid.
Reply all
Reply to author
Forward
0 new messages