Closed mhart closed 8 years ago
It's probably the -fuse-ld=gold
flag. Does this patch help?
diff --git a/common.gypi b/common.gypi
index 5b8b2c0..1ebfa7c 100644
--- a/common.gypi
+++ b/common.gypi
@@ -23,6 +23,9 @@
# Don't bake anything extra into the snapshot.
'v8_use_external_startup_data%': 0,
+ # Don't use gold linker.
+ 'linux_use_gold_flags%': 0,
+
'conditions': [
['OS == "win"', {
'os_posix': 0,
That may very well be it. Compiling now.
If so, question is β is it better to require gold linker to be installed (looks like there might be one for Alpine: https://pkgs.alpinelinux.org/package/main/x86_64/binutils-gold) β not use it at all (as your patch does) β or detect whether it's installed during the build and only use it then?
Hmmm, for some reason it's still including that flag (and failing)
After patching common.gypi
I ran make clean && ./configure --prefix=/usr && make -j4
Did I need to do something else?
Now trying with the original common.gypi
after installing binutils-gold
I wonder if linux_use_bundled_gold
and/or linux_use_bundled_binutils
are the flags to modify?
The flag is passed in deps/v8/build/toolchain.gypi
based on the value of linux_use_gold_flags
, which is set to 0 or 1 depending on whether we're on x86_64 linux. You may want to try modifying that file by hand.
Ok β so it just finished compiling successfully (using the original v5.2.0 source) after installing binutils-gold
I'm happy for that to be the solution for now (for me anyway) β another dependency in the build chain I guess!
Up to you whether you want to mark this as closed, or continue exploring options that don't require the gold linker as a dependency?
FWIW I just encountered this on CentOS 6 with the compilers provided by devtoolset-2
, which is a package used to provide a newer compiler.
@mscdex we run the same toolset at ci for centos5/6; haven't seen this error so far.
Follow up: using scl enable devtoolset-2 'bash'
to get into a bash session that has everything set up for you allowed the compile to complete successfully.
Previously I was manually setting CC
, CXX
(and later LD
). I guess I was missing another environment variable or something ...
@mhart, are you sure it was the original 5.2.0 source? I just tried to run your exact Dockerfile code and it fails with:
/usr/lib/gcc/x86_64-alpine-linux-musl/4.9.2/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: /node-v5.2.0/out/Release/mksnapshot: Not supported
collect2: error: ld returned 1 exit status
deps/v8/tools/gyp/mksnapshot.target.mk:139: recipe for target '/node-v5.2.0/out/Release/mksnapshot' failed
make[1]: *** [/node-v5.2.0/out/Release/mksnapshot] Error 1
make[1]: Leaving directory '/node-v5.2.0/out'
Makefile:45: recipe for target 'node' failed
make: *** [node] Error 2
@smebberson Yeah, I built v5.2.0 using this exact Dockerfile and pushed it up to the Docker hub.
Also built a static version successfully using this Dockerfile and pushed it up too.
@smebberson Ah, I see you have an impressively similar Dockerfile here: https://github.com/smebberson/docker-alpine/blob/master/alpine-nodejs/Dockerfile :laughing:
Try mine as is and let me know how you go
@mhart, I copied and pasted yours verbatim and it didn't work. I have no idea why though. I've even applied the patch (using my Dockerfile) and it still didn't build. The error message I posted above is what I received when running your exact Dockerfile.
Try disabling snapshots (/.configure --without-snapshot
); they might not be available on your architecture.
@jbergstroem, that worked! Thanks.
(We recently enabled this by default which is why you didn't see this earlier)
@jbergstroem. Ah okay. I see. Well, I can confirm that I can also build it with:
binutils-gold
package--without-snapshot
configure flagWe also encount this problem when we compile node.js 4.2.4.
What's the usage of --without-snapshot
? Why we didn't have this problem in 4.2.3?
I believe compiling with --without-snapshot
will make node' startup time slower because it can't take advantage of v8's snapshot feature.
so, could I infer that compile 4.2.4 with --without-snapshot
will made node.js startup time slower than 4.2.3 ? Or, 4.2.3 didn't support snapshot feature by default?
See commit 49b3c3b, released in 4.2.4. Binaries were supposed to be built with snapshots enabled, but weren't.
The snapshot/nosnapshot performance difference is negligible for most use cases; it slows startup by perhaps 50 ms on x86.
@bnoordhuis Thanks;)
I've encountered this issues as well trying to compile node
on Linuxbrew. I'll try --without-snapshot
workaround. Perhaps configure
should check whether gold
is available before trying to use it as the linker.
The --without-snapshot
workaround worked for me!
https://github.com/Homebrew/linuxbrew/commit/17d7674278df0e9dc63ec0e49bf58069c604b200
Thanks for this! apk add binutils-gold fixed it for me. (node version 4.2.6)
I guess we can close this now. The workaround is to build with --without-snapshot
or install the gold linker.
Just a follow up to this β installing binutils-gold
works fine when compiling on boot2docker on my Mac, but there seem to be certain OS/architecture/platform combinations that this still doesn't work for β Docker's Automated Build environment being one of them.
The only method I've found so far that reliably works is manually editing linux_use_gold_flags%
in deps/v8/build/toolchain.gypi
as suggested earlier by @bnoordhuis
It looks like this change might be made permanent in #6603 ...?
It also works to set the GYP_DEFINES
env variable β I had tried it with just linux_use_gold_flags=0
to no avail, but if you set it to linux_use_bundled_binutils=0 linux_use_bundled_gold=0 linux_use_gold_flags=0
, then it also works β less hacky than editing toolchain.gypi
in any case
Actually, turns out I was just being stupid and the problem before was that I wasn't exporting it. So, you can just do export GYP_DEFINES="linux_use_gold_flags=0"
instead of editing toolchain.gypi
or installing binutils-gold
β that works for the Alpine Docker case anyway.
I'm getting this error when compiling Node.js v5.2.0 on Alpine Linux 3.2. This error does not occur with any version <= v5.1.1 β including all io.js versions.
Any idea what may have changed that could cause this, or how to fix it?
You can reproduce using Docker and running
alpine:3.2
. The following packages have been installed:After fetching the v5.2.0 source, here's the configure and make output:
For comparison, here's the same output compiling v5.1.1 on the same setup: