I cannot build


#1

I’m trying to build Atom from source (commit de2bce4) and I’m getting the following error when it tries to compile runas:

Node: v0.12.0
npm: v2.13.3
Installing build modules...
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/runas.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/mbolin/src/atom/build/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/Users/mbolin/src/atom/build/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mbolin/src/atom/build/node_modules/runas
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
ld: library not found for -lgcc_s.10.5
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/dump_syms] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/mbolin/src/atom/build/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/Users/mbolin/src/atom/build/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/mbolin/src/atom/build/node_modules/minidump
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/Users/mbolin/src/atom/build/node_modules/.bin/npm" "--userconfig=/Users/mbolin/src/atom/build/.npmrc" "install" "--loglevel" "error"
npm ERR! node v0.12.0
npm ERR! npm  v2.13.3
npm ERR! code ELIFECYCLE

npm ERR! runas@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the runas@2.0.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the runas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls runas
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mbolin/src/atom/build/npm-debug.log

I suspect that this is the important line:

ld: library not found for -lgcc_s.10.5

Xcode tried updating its command line tools recently for the new Xcode/iOS, so that may be part of the problem. I’m trying to just to npm install runas@2 in a temp directory, but that’s failing and since it fails, it doesn’t even create the directory.

Now I’m trying:

git clone git@github.com:atom/node-runas.git
cd node-runas
npm install

And I get basically the same error, but at least it spits out build/Makefile, so I have something I can look at. I’m trying to figure out where to stick the -v so I can actually see what clang is trying to do.

Has anyone else hit/solved this?


#2

I changed the line in the Makefile to:

LDFLAGS.target ?= $(LDFLAGS) -v

re-ran, and then I could see the command:

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -bundle -macosx_version_min 10.5.0 -undefined dynamic_lookup -undefined dynamic_lookup -o Release/runas.node -lbundle1.o -L./Release -search_paths_first Release/obj.target/runas/src/main.o Release/obj.target/runas/src/runas_darwin.o Release/obj.target/runas/src/fork.o -framework Security -lstdc++ -lSystem -lgcc_s.10.5 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib/darwin/libclang_rt.osx.a

As expected, it failed.

However, if I dropped the flag -lgcc_s.10.5, then it succeeded.

Now I need to figure out how to appease the Makefile so that it keeps that out.


#3

In the end, I had to do two things to solve this problem:

  1. I had to upgrade to Xcode 7 (from Xcode 6.4). One might think this has nothing to do with Atom, but that’s how I was able to get the latest version of the Command line tools for Xcode, which includes clang and friends. After I did this, I was able to do npm install runas@2 whereas I could not before.
  2. After this, I was able to build Atom, but it would not start up. I got the following error:
Module version mismatch. Expected 44, got 43.
Error: Module version mismatch. Expected 44, got 43.
    at Error (native)
    at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:137:20)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:148:18)
    at Module.load (module.js:353:32)
    at Function.Module._load (module.js:308:12)
    at Module.require (module.js:363:17)
    at require (module.js:382:17)
    at Object.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/nslog/lib/nslog.js:5:11)
    at Object.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/nslog/lib/nslog.js:15:4)
    at Module._compile (module.js:428:26)

Despite running ./script/clean many, many times, I was left with an ./electron directory that was apparently the source of the issue. Just for kicks, I ran git clean -nxfd to see if I had failed to clean anything else, which is what alerted me to the ./electron directory. Once I deleted that, I was able to build Atom 1.0.12 (or later) such that it started up.