mhart / alpine-node

Minimal Node.js Docker Images built on Alpine Linux
MIT License
2.45k stars 303 forks source link

Rebuild fails: collect2: error: ld returned 1 exit status #31

Closed vortec closed 8 years ago

vortec commented 8 years ago

Hi, I was trying to rebuild the image, but getting the following error:

g++ -pthread -rdynamic -m64  -o /node-v5.10.1/out/Release/openssl-cli -Wl,--start-group /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/app_rand.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/apps.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/asn1pars.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ca.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ciphers.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/cms.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/crl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/crl2p7.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dgst.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dh.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dhparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/dsaparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ec.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ecparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/enc.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/engine.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/errstr.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/gendh.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/gendsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/genpkey.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/genrsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/nseq.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ocsp.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/openssl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/passwd.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs12.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs7.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkcs8.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkey.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkeyparam.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/pkeyutl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/prime.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rand.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/req.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rsa.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/rsautl.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_cb.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_client.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_server.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_socket.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/s_time.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/sess_id.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/smime.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/speed.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/spkac.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/srp.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/ts.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/verify.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/version.o /node-v5.10.1/out/Release/obj.target/openssl-cli/deps/openssl/openssl/apps/x509.o /node-v5.10.1/out/Release/obj.target/deps/openssl/libopenssl.a -Wl,--end-group -static -ldl
g++ -pthread -rdynamic -m64 -fuse-ld=gold -B/node-v5.10.1/third_party/binutils/Linux_x64/Release/bin -m64  -o /node-v5.10.1/out/Release/mksnapshot -Wl,--start-group /node-v5.10.1/out/Release/obj.target/mksnapshot/deps/v8/src/snapshot/mksnapshot.o /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_libplatform.a /node-v5.10.1/out/Release/obj.target/deps/v8/tools/gyp/libv8_libbase.a -Wl,--end-group -static -ldl -lrt

/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: /node-v5.10.1/out/Release/mksnapshot: Not supported
collect2: error: ld returned 1 exit status
make[1]: *** [/node-v5.10.1/out/Release/mksnapshot] Error 1
deps/v8/tools/gyp/mksnapshot.target.mk:140: recipe for target '/node-v5.10.1/out/Release/mksnapshot' failed
make[1]: Leaving directory '/node-v5.10.1/out'
make: *** [node] Error 2
Makefile:63: recipe for target 'node' failed

The command '/bin/sh -c apk add --no-cache curl make gcc g++ binutils-gold python linux-headers paxctl libgcc libstdc++ gnupg &&   gpg --keyserver pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B &&   gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 &&   gpg --keyserver pool.sks-keyservers.net --recv-keys 0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 &&   gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E &&   gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 &&   gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273792F7D83545D &&   gpg --keyserver pool.sks-keyservers.net --recv-keys C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 &&   gpg --keyserver pool.sks-keyservers.net --recv-keys B9AE9905FFD7803F25714661B63B535A4C206CA9 &&   curl -o node-${VERSION}.tar.gz -sSL https://nodejs.org/dist/${VERSION}/node-${VERSION}.tar.gz &&   curl -o SHASUMS256.txt.asc -sSL https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc &&   gpg --verify SHASUMS256.txt.asc &&   grep node-${VERSION}.tar.gz SHASUMS256.txt.asc | sha256sum -c - &&   tar -zxf node-${VERSION}.tar.gz &&   cd /node-${VERSION} &&   ./configure --prefix=/usr ${CONFIG_FLAGS} &&   make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) &&   make install &&   paxctl -cm /usr/bin/node &&   cd / &&   if [ -x /usr/bin/npm ]; then     npm install -g npm@${NPM_VERSION} &&     find /usr/lib/node_modules/npm -name test -o -name .bin -type d | xargs rm -rf;   fi &&   apk del curl make gcc g++ binutils-gold python linux-headers paxctl gnupg ${DEL_PKGS} &&   rm -rf /etc/ssl /node-${VERSION}.tar.gz /SHASUMS256.txt.asc /node-${VERSION} ${RM_DIRS}     /usr/share/man /tmp/* /var/cache/apk/* /root/.npm /root/.node-gyp /root/.gnupg     /usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/html' returned a non-zero code: 2`
mhart commented 8 years ago

What architecture/system are you building on? You might need to build the snapshot separately and then mark it with paxctl before continuing – you can do a search for how apk does this with their node.js package.

vortec commented 8 years ago

I'm running Debian Linux and Docker version 1.10.3, build 20f81dd, does that help?

I will read into what paxctl is.

mhart commented 8 years ago

Apparently that issue can occur when using a Grsecurity/PaX kernel – which I never have, so I haven't run into it.

Try adding a couple of steps before the make step:

...
make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) -C out mksnapshot BUILDTYPE=Release && \
paxctl -cm out/Release/mksnapshot && \
make -j$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
make install && \
...
vortec commented 8 years ago

Unfortunately the same error.

mhart commented 8 years ago

Try passing --without-snapshot to the make command as well

vortec commented 8 years ago

@mhart thanks for your effort! I passed --without-snapshot to the ./configure command (as the make command didn't accept it). Unfortunately I'm getting the same error still. 😕

mhart commented 8 years ago

I recently ran into this with Docker Automated Builds – I found the only way I could reliably solve it was to do this: https://github.com/mhart/alpine-node/commit/c0f3a406568524340bc1bab34d390cff7172ee6d – I hope this solves it for you too. (if not, feel free to reopen)

vortec commented 8 years ago

That worked! Thanks a lot!

mhart commented 8 years ago

Actually discovered a simpler way too: https://github.com/mhart/alpine-node/commit/9814b1dd3e419aca3a11f95b4791d1d26010984e