Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

node build on arm fails during mksnapshot execution #1566

Closed
japj opened this issue Aug 21, 2011 · 20 comments
Closed

node build on arm fails during mksnapshot execution #1566

japj opened this issue Aug 21, 2011 · 20 comments

Comments

@japj
Copy link

japj commented Aug 21, 2011

I have a synology DS211j that I am trying to compile node (latest master) on.
Unfortunately this fails during the mksnapshot part of the v8 build with an "Illegal instruction".

> cat /proc/cpuinfo
Processor       : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS        : 1192.75
Features        : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant     : 0x2
CPU part        : 0x131
CPU revision    : 1

Hardware        : Feroceon-KW
Revision        : 0000
Serial          : 0000000000000000
> make
Waf: Entering directory `/volume1/sandbox/node/build'
DEST_OS: linux
DEST_CPU: arm
Parallel Jobs: 1
Product type: program
[ 5/37] libv8.a: deps/v8/SConstruct -> build/default/libv8.a
/opt/bin/python "/volume1/sandbox/node/tools/scons/scons.py" -j 1 -C "/volume1/sandbox/node/build/default/" -Y "/volume1/sandbox/node/deps/v8" visibility=default mode=release arch=arm toolchain=gcc library=static snapshot=on
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
/opt/bin/g++ -o obj/release/mksnapshot obj/release/mksnapshot.o obj/release/libraries.o obj/release/experimental-libraries.o obj/release/accessors.o obj/release/allocation.o obj/release/api.o obj/release/arm/assembler-arm.o obj/release/arm/builtins-arm.o obj/release/arm/code-stubs-arm.o obj/release/arm/codegen-arm.o obj/release/arm/constants-arm.o obj/release/arm/cpu-arm.o obj/release/arm/debug-arm.o obj/release/arm/deoptimizer-arm.o obj/release/arm/disasm-arm.o obj/release/arm/frames-arm.o obj/release/arm/full-codegen-arm.o obj/release/arm/ic-arm.o obj/release/arm/lithium-arm.o obj/release/arm/lithium-codegen-arm.o obj/release/arm/lithium-gap-resolver-arm.o obj/release/arm/macro-assembler-arm.o obj/release/arm/regexp-macro-assembler-arm.o obj/release/arm/stub-cache-arm.o obj/release/assembler.o obj/release/ast.o obj/release/atomicops_internals_x86_gcc.o obj/release/bignum-dtoa.o obj/release/bignum.o obj/release/bootstrapper.o obj/release/builtins.o obj/release/cached-powers.o obj/release/checks.o obj/release/circular-queue.o obj/release/code-stubs.o obj/release/codegen.o obj/release/compilation-cache.o obj/release/compiler.o obj/release/contexts.o obj/release/conversions.o obj/release/counters.o obj/release/cpu-profiler.o obj/release/data-flow.o obj/release/dateparser.o obj/release/debug-agent.o obj/release/debug.o obj/release/deoptimizer.o obj/release/disassembler.o obj/release/diy-fp.o obj/release/dtoa.o obj/release/elements.o obj/release/execution.o obj/release/extensions/externalize-string-extension.o obj/release/extensions/gc-extension.o obj/release/factory.o obj/release/fast-dtoa.o obj/release/fixed-dtoa.o obj/release/flags.o obj/release/frames.o obj/release/full-codegen.o obj/release/func-name-inferrer.o obj/release/gdb-jit.o obj/release/global-handles.o obj/release/handles.o obj/release/hashmap.o obj/release/heap-profiler.o obj/release/heap.o obj/release/hydrogen-instructions.o obj/release/hydrogen.o obj/release/ic.o obj/release/inspector.o obj/release/interpreter-irregexp.o obj/release/isolate.o obj/release/jsregexp.o obj/release/lithium-allocator.o obj/release/lithium.o obj/release/liveedit.o obj/release/liveobjectlist.o obj/release/log-utils.o obj/release/log.o obj/release/mark-compact.o obj/release/messages.o obj/release/objects-printer.o obj/release/objects-visiting.o obj/release/objects.o obj/release/parser.o obj/release/platform-linux.o obj/release/platform-posix.o obj/release/preparse-data.o obj/release/preparser.o obj/release/profile-generator.o obj/release/property.o obj/release/regexp-macro-assembler-irregexp.o obj/release/regexp-macro-assembler.o obj/release/regexp-stack.o obj/release/rewriter.o obj/release/runtime-profiler.o obj/release/runtime.o obj/release/safepoint-table.o obj/release/scanner-base.o obj/release/scanner.o obj/release/scopeinfo.o obj/release/scopes.o obj/release/serialize.o obj/release/snapshot-common.o obj/release/spaces.o obj/release/string-search.o obj/release/string-stream.o obj/release/strtod.o obj/release/stub-cache.o obj/release/token.o obj/release/type-info.o obj/release/unicode.o obj/release/utils.o obj/release/v8-counters.o obj/release/v8.o obj/release/v8conversions.o obj/release/v8threads.o obj/release/v8utils.o obj/release/variables.o obj/release/version.o obj/release/zone.o obj/release/snapshot-empty.o -lpthread
obj/release/mksnapshot obj/release/snapshot.cc --logfile "/volume1/sandbox/node/build/default/obj/release/snapshot.log" --log-snapshot-positions
Illegal instruction
scons: *** [obj/release/snapshot.cc] Error 132
scons: building terminated because of errors.
Waf: Leaving directory `/volume1/sandbox/node/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1
@japj
Copy link
Author

japj commented Aug 21, 2011

I submitted an upstream bug for this at http://code.google.com/p/v8/issues/detail?id=1632

@bnoordhuis
Copy link
Member

Jeroen, two things you'll want to check:

  1. Does V8's bleeding edge work? git mirror is at https://github.com/v8/v8 (bleeding_edge branch)
  2. Are you building for the right arch? You probably need to pass -march=armv5t.

There was a post on the mailing list where this was hashed out but apparently my google fu is weak today because I can't find it. The guy was building for a sheevaplug and ran into the same issue as you.

@japj
Copy link
Author

japj commented Aug 21, 2011

I'm following the instructions at http://stackoverflow.com/questions/6788768/cannot-build-node-on-sheevaplug-armv5t-with-debian-squeeze at the moment and am rebuilding as we speak.

@japj
Copy link
Author

japj commented Aug 21, 2011

mksnapshot crashes with the following stacktrace:

Program received signal SIGILL, Illegal instruction.
0x001ffb44 in v8::internal::ArmUsingHardFloatHelper ()
(gdb) bt
#0  0x001ffb44 in v8::internal::ArmUsingHardFloatHelper ()
#1  0x00201294 in v8::internal::OS::Setup ()
#2  0x00284970 in v8::internal::V8::InitializeOncePerProcess ()
#3  0x00284a04 in v8::internal::V8::Initialize ()
#4  0x00033474 in v8::Context::New ()
#5  0x0000ac60 in main ()

v8 compilation is currently using -mfloat-abi=softfp, instead of "soft" (since the device does not actually have an fpu). trying again.

@bnoordhuis
Copy link
Member

@japj: can you test the below feature detection patch?

diff --git a/deps/uv/src/ev/config_linux.h b/deps/uv/src/ev/config_linux.h
index b147b59..a13b179 100644
--- a/deps/uv/src/ev/config_linux.h
+++ b/deps/uv/src/ev/config_linux.h
@@ -2,12 +2,7 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */

 #include <linux/version.h>
-
-#define LINUX_VERSION_CODE_FOR(major, minor, patch) \
-  (((major & 255) << 16) | ((minor & 255) << 8) | (patch & 255))
-
-#define LINUX_VERSION_AT_LEAST(major, minor, patch) \
-  (LINUX_VERSION_CODE >= LINUX_VERSION_CODE_FOR(major, minor, patch))
+#include <features.h>

 /* Define to 1 if you have the `clock_gettime' function. */
 /* #undef HAVE_CLOCK_GETTIME */
@@ -18,14 +13,26 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #define HAVE_DLFCN_H 1

-/* Define to 1 if you have the `epoll_ctl' function. */
+/* epoll_ctl(2) is available if kernel >= 2.6.9 and glibc >= 2.4 */
+#if LINUX_VERSION_CODE >= 0x020609 && __GLIBC_PREREQ(2, 4)
 #define HAVE_EPOLL_CTL 1
-
-/* Define to 1 if you have the `eventfd' function. */
-#define HAVE_EVENTFD LINUX_VERSION_AT_LEAST(2, 6, 22)
-
-/* Define to 1 if you have the `inotify_init' function. */
-#define HAVE_INOTIFY_INIT LINUX_VERSION_AT_LEAST(2, 6, 13)
+#else
+#define HAVE_EPOLL_CTL 0
+#endif
+
+/* eventfd(2) is available if kernel >= 2.6.22 and glibc >= 2.8 */
+#if LINUX_VERSION_CODE >= 0x020616 && __GLIBC_PREREQ(2, 8)
+#define HAVE_EVENTFD 1
+#else
+#define HAVE_EVENTFD 0
+#endif
+
+/* inotify_init(2) is available if kernel >= 2.6.13 and glibc >= 2.4 */
+#if LINUX_VERSION_CODE >= 0x02060d && __GLIBC_PREREQ(2, 4)
+#define HAVE_INOTIFY_INIT 1
+#else
+#define HAVE_INOTIFY_INIT 0
+#endif

 /* Define to 1 if you have the <inttypes.h> header file. */
 #define HAVE_INTTYPES_H 1
@@ -60,8 +67,12 @@
 /* Define to 1 if you have the `select' function. */
 #define HAVE_SELECT 1

-/* Define to 1 if you have the `signalfd' function. */
-#define HAVE_SIGNALFD LINUX_VERSION_AT_LEAST(2, 6, 22)
+/* signalfd(2) is available if kernel >= 2.6.22 and glibc >= 2.8 */
+#if LINUX_VERSION_CODE >= 0x020616 && __GLIBC_PREREQ(2, 8)
+#define HAVE_SIGNALFD 1
+#else
+#define HAVE_SIGNALFD 0
+#endif

 /* Define to 1 if you have the <stdint.h> header file. */
 #define HAVE_STDINT_H 1

@japj
Copy link
Author

japj commented Aug 30, 2011

@bnoordhuis if I remember correctly the above patch worked (we talked about this on IRC a while ago).

However, it does not yet solve the 'v8 mksnapshot' issue for arm.
Would it be acceptable to extend the node configure script and add "v8-*" SConstruct arguments?
like v8-armeabi=soft would pass "armeabi=soft" to the v8 SConstruct command.
This would allow people to set v8 options through the node configure script.

@bnoordhuis
Copy link
Member

waf is going away Real Soon Now but we'd probably take a gyp patch. Ping back in a couple of days when the gyp stuff (hopefully!) has landed.

@bnoordhuis
Copy link
Member

The improved feature detection patch landed in joyent/libuv@0ba44cf.

@sh1mmer
Copy link

sh1mmer commented Nov 2, 2011

any updates @japj or @bnoordhuis?

@bnoordhuis
Copy link
Member

Master on ARM builds fine for me. Cross-compiling is still troublesome but that's a toolchain issue.

@japj
Copy link
Author

japj commented Nov 3, 2011

For v8 I am currently overruling CCFLAGS with -march=armv5t and armabi:'soft' (this defaults to 'softfp').

I think if this is available through a commandline option to configure-gyp then we can close this issue.

@bnoordhuis
Copy link
Member

I think we can close this one. The great thing about gyp is that it generates plain Makefiles that respect CFLAGS and CXXFLAGS. So you run E="-march=armv5t -mfloat-abi=soft" make CFLAGS="$E" CXXFLAGS="$E" and it'll Just Work.

@blalor
Copy link

blalor commented Nov 16, 2011

@bnoordhuis, as stated, that make command doesn't work, at least with bash. Slightly better, on two lines (which may be what you intended)

E="-march=armv5t -mfloat-abi=soft"
make CFLAGS="$E" CXXFLAGS="$E"

However, this still doesn't work for me in v0.6.0. It looks like modifying deps/v8/SConstruct is going to be necessary, and even that is still not working as mksnapshot is still dying with "Illegal Instruction".

@bnoordhuis
Copy link
Member

Try it with master, we've replaced waf and scons with gyp now.

@blalor
Copy link

blalor commented Nov 16, 2011

With or without the make flags? ie. should the build system detect the correct flags, or is the override still required?

@bnoordhuis
Copy link
Member

With. The configure script doesn't yet honour the CFLAGS and CXXFLAGS environment variables and we can't add a 'does this processor support floating point?' check, it would fail when cross-compiling.

@blalor
Copy link

blalor commented Nov 16, 2011

Hm, I can't start the build. My master is cf2ee19.

https://gist.github.com/509ed97da39c52fca1fe

@bnoordhuis
Copy link
Member

Right, that's one of the TODOs, strip out the -m32 switches from the *.gypi files (probably not that blunt, I want to make it a conditional for the sake of cross-compiling).

Until that's fixed, perl -i -pe "s/'-m32'//g" $(find -name \*.gypi) should get you up and running.

@blalor
Copy link

blalor commented Nov 16, 2011

In file included from ../deps/v8/src/v8globals.h:31,
                 from ../deps/v8/src/v8.h:53,
                 from /home/blalor/nodejs/out/Release/obj/gen/libraries.cc:7:
../deps/v8/src/globals.h:113:2: error: #error Target architecture ia32 is only supported on ia32 host

https://gist.github.com/509ed97da39c52fca1fe#file_4.1_compile_output.txt

Should this be a new issue?

@bnoordhuis
Copy link
Member

Should this be a new issue?

Yes, please.

You can probably hack around it for now by updating the host_arch and target_arch variables in $REPO_ROOT/options.gypi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants