This repository has been archived by the owner. It is now read-only.

"Exec format error" when cross-compiling for ARM (workaround provided) #1541

Closed
jampy opened this Issue Aug 16, 2011 · 7 comments

Comments

Projects
None yet
4 participants
@jampy

jampy commented Aug 16, 2011

(This was first reported as a side-note in issue 1131 but I thought it would be better to open a separate issue)

With Node versions 0.4.8 and 0.4.10 I get a Exec format error in the configure script:

export PATH=/opt/sdg/angstrom2007.12/sdk/bin:$PATH
export CC=arm-angstrom-linux-gnueabi-gcc
export STRIP=arm-angstrom-linux-gnueabi-strip
export LD=arm-angstrom-linux-gnueabi-ld
export GCC=arm-angstrom-linux-gnueabi-gcc
export CXX=arm-angstrom-linux-gnueabi-g++
export CPP=arm-angstrom-linux-gnueabi-g++
export CCFLAGS=-march=armv5t
mkdir -p _stage
./configure --prefix=$PWD/_stage --destdir=$PWD/_stage --without-ssl

Checking for program g++ or c++          : arm-angstrom-linux-gnueabi-g++
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for program gcc or cc           : arm-angstrom-linux-gnueabi-gcc
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for gcc                         : ok
Checking for library dl                  : yes
Checking for library util                : yes
Checking for library rt                  : yes
--- libeio ---
Checking for library pthread             : yes
Checking for function pthread_create     : yes
Checking for function pthread_atfork     : yes
Checking for futimes(2)                  : yes
Checking for readahead(2)                : yes
Checking for fdatasync(2)                : yes
Checking for pread(2) and pwrite(2)      : yes
Checking for sendfile(2)                 : yes
Checking for sync_file_range(2)          : no
--- libev ---
Checking for header sys/inotify.h        : yes
Checking for function inotify_init       : yes
Checking for header sys/epoll.h          : yes
Checking for function epoll_ctl          : yes
Checking for header port.h               : not found
Checking for header poll.h               : yes
Checking for function poll               : yes
Checking for header ['sys/types.h', 'sys/event.h'] : not found
Checking for header sys/queue.h                    : yes
Checking for function kqueue                       : not found
Checking for header sys/select.h                   : yes
Checking for function select                       : yes
Checking for header sys/eventfd.h                  : not found
Checking for SYS_clock_gettime                     : Traceback (most recent call last):
  File "/home/udo/Nomad/node-v0.4.10/tools/waf-light", line 158, in <module>
    Scripting.prepare(t, cwd, VERSION, wafdir)
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Scripting.py", line 145, in prepare
    prepare_impl(t, cwd, ver, wafdir)
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Scripting.py", line 135, in prepare_impl
    main()
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Scripting.py", line 188, in main
    fun(ctx)
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Scripting.py", line 241, in configure
    conf.sub_config([''])
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Configure.py", line 221, in sub_config
    self.recurse(k, name='configure')
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Utils.py", line 634, in recurse
    f(self)
  File "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/wscript", line 421, in configure
    conf.sub_config('deps/libev')
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Configure.py", line 221, in sub_config
    self.recurse(k, name='configure')
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Utils.py", line 634, in recurse
    f(self)
  File "/mnt/bigdrive/home/udo/Nomad/node-v0.4.10/deps/libev/wscript", line 67, in configure
    msg="Checking for SYS_clock_gettime")
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Tools/config_c.py", line 572, in check_cc
    return self.check(*k, **kw)
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Tools/config_c.py", line 444, in check
    ret = self.run_c_code(*k, **kw)
  File "/home/udo/Nomad/node-v0.4.10/tools/wafadmin/Tools/config_c.py", line 549, in run_c_code
    proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)
  File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 8] Exec format error

Adding conf.define('HAVE_CLOCK_SYSCALL', 1) to /deps/libev/wscript makes ./configure succeed.

Version 0.5.4 does not have this problem. However, since the stable version is still 0.4 I opened this issue.

@Zahreddin

This comment has been minimized.

Show comment Hide comment
@Zahreddin

Zahreddin Sep 12, 2011

I've the same issue with ubuntu 11.04 and node.js version v0.4.11

I've the same issue with ubuntu 11.04 and node.js version v0.4.11

@aurels

This comment has been minimized.

Show comment Hide comment
@aurels

aurels Sep 14, 2011

Idem.

aurels commented Sep 14, 2011

Idem.

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Sep 14, 2011

Member

Can one of you test if the below patch fixes the issue?

diff --git a/deps/libev/wscript b/deps/libev/wscript
index aaa57e1..b29ddf7 100644
--- a/deps/libev/wscript
+++ b/deps/libev/wscript
@@ -63,7 +63,7 @@ def configure(conf):
           return 0;
       }
   """
-  conf.check_cc(fragment=code, define_name="HAVE_CLOCK_SYSCALL", execute=True,
+  conf.check_cc(fragment=code, define_name="HAVE_CLOCK_SYSCALL",
                 msg="Checking for SYS_clock_gettime")

   have_librt = conf.check(lib='rt', uselib_store='RT')
Member

bnoordhuis commented Sep 14, 2011

Can one of you test if the below patch fixes the issue?

diff --git a/deps/libev/wscript b/deps/libev/wscript
index aaa57e1..b29ddf7 100644
--- a/deps/libev/wscript
+++ b/deps/libev/wscript
@@ -63,7 +63,7 @@ def configure(conf):
           return 0;
       }
   """
-  conf.check_cc(fragment=code, define_name="HAVE_CLOCK_SYSCALL", execute=True,
+  conf.check_cc(fragment=code, define_name="HAVE_CLOCK_SYSCALL",
                 msg="Checking for SYS_clock_gettime")

   have_librt = conf.check(lib='rt', uselib_store='RT')
@jampy

This comment has been minimized.

Show comment Hide comment
@jampy

jampy Sep 16, 2011

Yes, removing "execute=True" solves the problem for me! (Node 0.4.12)

jampy commented Sep 16, 2011

Yes, removing "execute=True" solves the problem for me! (Node 0.4.12)

@jampy

This comment has been minimized.

Show comment Hide comment
@jampy

jampy Sep 16, 2011

Not sure if this is related but the build now fails with another exec error:

DEST_OS: linux
DEST_CPU: arm
Parallel Jobs: 1
Product type: program
[51/74] libv8.a: deps/v8/SConstruct -> build/default/libv8.a
/usr/bin/python "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/tools/scons/scons.py" -j 1 -C "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build/default/" -Y "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/deps/v8" visibility=default mode=release arch=arm toolchain=gcc library=static snapshot=on
scons: Reading SConscript files ...

scons: warning: Ignoring missing SConscript 'obj/test/release/SConscript'
File "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/deps/v8/SConstruct", line 1201, in BuildSpecific
scons: done reading SConscript files.
scons: Building targets ...
obj/release/mksnapshot obj/release/snapshot.cc --logfile "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build/default/obj/release/snapshot.log" --log-snapshot-positions
/bin/bash: obj/release/mksnapshot: cannot execute binary file
scons: *** [obj/release/snapshot.cc] Error 126
scons: building terminated because of errors.
Waf: Leaving directory `/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1

jampy commented Sep 16, 2011

Not sure if this is related but the build now fails with another exec error:

DEST_OS: linux
DEST_CPU: arm
Parallel Jobs: 1
Product type: program
[51/74] libv8.a: deps/v8/SConstruct -> build/default/libv8.a
/usr/bin/python "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/tools/scons/scons.py" -j 1 -C "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build/default/" -Y "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/deps/v8" visibility=default mode=release arch=arm toolchain=gcc library=static snapshot=on
scons: Reading SConscript files ...

scons: warning: Ignoring missing SConscript 'obj/test/release/SConscript'
File "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/deps/v8/SConstruct", line 1201, in BuildSpecific
scons: done reading SConscript files.
scons: Building targets ...
obj/release/mksnapshot obj/release/snapshot.cc --logfile "/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build/default/obj/release/snapshot.log" --log-snapshot-positions
/bin/bash: obj/release/mksnapshot: cannot execute binary file
scons: *** [obj/release/snapshot.cc] Error 126
scons: building terminated because of errors.
Waf: Leaving directory `/mnt/bigdrive/home/udo/Nomad/node-v0.4.12/build'
Build failed:  -> task failed (err #2):
        {task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1
@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Sep 16, 2011

Member

Fixed in ed44098.

@jampy: Run the configure script with --without-snapshot. V8 by default tries to build a pre-compiled image of the JS runtime but that fails when you cross-compile.

Member

bnoordhuis commented Sep 16, 2011

Fixed in ed44098.

@jampy: Run the configure script with --without-snapshot. V8 by default tries to build a pre-compiled image of the JS runtime but that fails when you cross-compile.

@jampy

This comment has been minimized.

Show comment Hide comment
@jampy

jampy Sep 17, 2011

@bnoordhuis: You are of course right. I forgot to add that switch. It now builds fine, thanks.

jampy commented Sep 17, 2011

@bnoordhuis: You are of course right. I forgot to add that switch. It now builds fine, thanks.

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