atom/node-nslog

All is not well in the state of NSLog. (How do you GitHubbers even build a Mac release?)

Closed this issue · 3 comments

So after working my way to through atom/atom#3184 (open since August of last year!) to reach atom/apm#293, I breezed through https://github.com/zcbenz/base-minimal/pull/4. But this one's a doozie.

To be clear, after those fixes, it is, in fact, possible to "complete" a build of atom/atom on a Mac. But we immediately crash due to a "missing" - so to speak - symbol in nslog.node: __ZN5nslog3LogERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE.
(See below.)

So I dove in here to see if I could do something, and I must confess the whole thing seems very odd to me. With an apm install/grunt/gyp "magic" build, the module emits symbols that bear the hallmarks of -stdlib=libstdc++ in nslog_mac.o:

0000000000006197 s L_.str
                 U _NSLog
0000000000000000 T __ZN5nslog3LogERKSs
                 U ___CFConstantStringClassReference

Note that this is not the default or recommended behavior on modern Darwin, and is not ABI compatible with libc++, which is used throughout the system these days. So, when I compile the file myself, it emits:

                 U _NSLog
---------------- T __ZN5nslog3LogERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
                 U ___CFConstantStringClassReference 

Manually compiling and linking the two little files into a bundle, and dropping it in place of old one Atom.app, we get a little bit farther, as I now get a modal dialog:

Uncaught Exception:
Error: Module version mismatch. Expected 41, got 14.
    at Error (native)
    at Object.module.(anonymous function) [as .node] (/private/var/folders/m0/w2hkm_7159j4h6177k9gvb3m0000gn/T/atom-build/Atom.app/Contents/Resources/atom/common/lib/asar.js:422:20)
    at Module.load (module.js:370:32)
    at Function.Module._load (module.js:325:12)
    at Module.require (module.js:380:17)
    at require (module.js:399:17)
    at Object.<anonymous> (/private/var/folders/m0/w2hkm_7159j4h6177k9gvb3m0000gn/T/atom-build/Atom.app/Contents/Resources/app/node_modules/nslog/lib/nslog.js:5:11)
    at Object.<anonymous> (/private/var/folders/m0/w2hkm_7159j4h6177k9gvb3m0000gn/T/atom-build/Atom.app/Contents/Resources/app/node_modules/nslog/lib/nslog.js:15:4)
    at Module._compile (module.js:475:26)
    at Object.Module._extensions..js (module.js:493:10)

Well, if you say so. 😉 ?

One thing that occurs to me, is that you're coercing a C++ function taking an argument of an STL std::string container, into NSLog, which uses Objective-C NSString, and invoking this function with a pointer to a v8::String::Utf8Value. Which, for all I know, may be just perfectly fine and good (I'm not very adept at C++)... but I have some suspicions.

But this whole thing, given the trouble myself and others are having, not to mention the fact that you've recently tacked on Linux and Windows NSLog "implementations" 😆, it sorta begs the question, um, why?

I mean, why not just use syslog(3)? asl(3)? Or even just use syslog(1)?
I mean hell, these days, for you JavaScript minded folk:
osascript -l JavaScript -e '$.NSLog("Application did a cool thing in 123 seconds.");'.

I don't really care one way or another. It would just be nice to be able to build a working Atom.app myself.
One day.

So, um, yeah. Whats the skinny, @zcbenz?

To answer the question in the title, building on Mac still works using Node v0.10.x. See atom/atom#5493 for the current efforts on getting it to build using io.js v1.2.0.

Uncaught Exception:
Error: Module version mismatch. Expected 41, got 14.

This error means the modules was built with wrong headers, I suggest removing node_modules and build/node_modules and run ./script/build again.

Notice not to use npm install to install dependencies, it will build modules with Node's headers, not Atom's headers.

Got it. Thanks.