Cross-compiling V8 for ARM and uclibc - such a world of pain

879 views
Skip to first unread message

Yoann

unread,
Aug 5, 2010, 11:17:36 AM8/5/10
to v8-users
Hello,

I'm trying to cross-compile V8 for an ARM 920T board (armv4) with a
toolchain generated by buildroot (based on the uclibc), 4.3.4 version.
I'm working with ubuntu 10.04.

I definitly need some help...

After a "svn checkout http://v8.googlecode.com/svn/trunk/ v8" I've
tried the following scons command with some exports :

export GCC_VERSION=43

export CC="$BUILDROOT_PATH/output/staging/usr/bin/arm-linux-gcc -I
$BUILDROOT_PATH/output/staging/usr/include -I$BUILDROOT_PATH/output/
staging/include --sysroot=$BUILDROOT_PATH
export CXX="$BUILDROOT_PATH/output/staging/usr/bin/arm-linux-g++"
export CXXFLAGS="-I. -march=armv4t --sysroot=$BUILDROOT_PATH/output/
staging/ -isysroot $BUILDROOT_PATH/output/staging"
export CFLAGS="-I. -march=armv4t"
export LDFLAGS="--sysroot $BUILDROOT_PATH/output/staging/"

scons mode=debug arch=arm library=shared prof=off os=linux

(I know some of these scons options are optional, but I wanted to be
sure to get what I need)

Then, i get this error :

src/platform-linux.cc:48:56: error: execinfo.h: No such file or
directory
src/platform-linux.cc: In static member function 'static int
v8::internal::OS::StackWalk(v8::internal::Vector<v8::internal::OS::StackFrame>)':
src/platform-linux.cc:405: error: 'backtrace' was not declared in this
scope
src/platform-linux.cc:407: error: 'backtrace_symbols' was not declared
in this scope
src/platform-linux.cc: In function 'void
v8::internal::ProfilerSignalHandler(int, siginfo_t*, void*)':
src/platform-linux.cc:773: error: 'struct sigcontext' has no member
named 'gregs'
src/platform-linux.cc:774: error: 'struct sigcontext' has no member
named 'gregs'
src/platform-linux.cc:775: error: 'struct sigcontext' has no member
named 'gregs'
scons: *** [obj/debug/platform-linux.os] Error 1
scons: building terminated because of errors.


I've read backtrace() was a glibc-specific function and because I'm
not interested in backtrace in my project I've created an execinfo.h
file with redefined functions. I've put it at the project root in my
case.

#ifndef _EXECINFO_H_
#define _EXECINFO_H_ 1

#include <sys/cdefs.h>

__BEGIN_DECLS

int backtrace(void**,int){ return 0; }
char** backtrace_symbols(void* const*,int){return NULL; }
void backtrace_symbols_fd(void* const*,int,int){}

__END_DECLS

#endif /* !_EXECINFO_H_ */

I know, it's sooo nasty ! I'm trying every kind of way to get V8 cross-
compiled ...

Now, the backtrace error is gone, I deal whith the
ProfilerSignalHandler one by uncommenting the all function content.
Then it ends up getting this :

/home/yoann/workspace/karotz/buildroot/buildroot-2010.05/output/
staging/usr/bin/arm-linux-g++ -o obj/debug/platform-linux.os -c -I. -
march=armv4t --sysroot=/home/yoann/workspace/karotz/buildroot/
buildroot-2010.05/output/staging/ -isysroot /home/yoann/workspace/
karotz/buildroot/buildroot-2010.05/output/staging -Wall -Werror -W -
Wno-unused-parameter -Wnon-virtual-dtor -pedantic -g -O0 -ansi -fno-
rtti -fno-exceptions -fvisibility=hidden -Wall -Werror -W -Wno-unused-
parameter -Wnon-virtual-dtor -pedantic -g -O0 -ansi -fPIC -
DV8_TARGET_ARCH_ARM -DENABLE_DISASSEMBLER -DDEBUG -DV8_SHARED -
DENABLE_VMSTATE_TRACKING -DENABLE_LOGGING_AND_PROFILING -
DV8_ENABLE_CHECKS -DENABLE_DEBUGGER_SUPPORT -Isrc src/platform-
linux.cc
/tmp/ccSp2ze3.s: Assembler messages:
/tmp/ccSp2ze3.s:414: Error: bad instruction `int $3'
scons: *** [obj/debug/platform-linux.os] Error 1
scons: building terminated because of errors.

I've tried several branches of V8 (trunk, bleeding_edge and 2.2) but i
get the same result.

I think this is a flag problem. I'm missing something ...
I fear that with the armv4t + uclibc combination I'm entering in a
world of pain.

If someone has any idea to deal with my problem. I would so pleased to
hear anything that would help me.

Thanks in advance !!

Erik Corry

unread,
Aug 6, 2010, 4:45:14 AM8/6/10
to v8-u...@googlegroups.com
Den 5. aug. 2010 17.17 skrev Yoann <yoann...@gmail.com>:
Hello,

I'm trying to cross-compile V8 for an ARM 920T board (armv4) with a
toolchain generated by buildroot (based on the uclibc), 4.3.4 version.
I'm working with ubuntu 10.04.

I wonder how much memory your 920T board has.  I would guess it doesn't have enough to run Chromium.  Perhaps that is not your aim.
 

I definitly need some help...

After a "svn checkout http://v8.googlecode.com/svn/trunk/ v8" I've
tried the following scons command with some exports :

export GCC_VERSION=43

export CC="$BUILDROOT_PATH/output/staging/usr/bin/arm-linux-gcc -I
$BUILDROOT_PATH/output/staging/usr/include -I$BUILDROOT_PATH/output/
staging/include --sysroot=$BUILDROOT_PATH
export CXX="$BUILDROOT_PATH/output/staging/usr/bin/arm-linux-g++"
export CXXFLAGS="-I. -march=armv4t --sysroot=$BUILDROOT_PATH/output/
staging/ -isysroot $BUILDROOT_PATH/output/staging"
export CFLAGS="-I. -march=armv4t"
export LDFLAGS="--sysroot $BUILDROOT_PATH/output/staging/"

scons mode=debug arch=arm library=shared prof=off os=linux

(I know some of these scons options are optional, but I wanted to be
sure to get what I need)

Then, i get this error :

src/platform-linux.cc:48:56: error: execinfo.h: No such file or

This stuff isn't very important for V8.  It's only used by the profiler.  Just remove this include.

All the uses of backtrace etc. are inside an #ifdef __GLIBC__.  I guess with uclibc that macro should be undefined?  So I'm not sure why you get these errors.
int3 is an x86 instruction.  I can't work out how you are getting this.  Could it be that your include paths are wrong so you are including system libraries from the host rather than the target?  That would also explain the ifdef not working, perhaps?
 
scons: *** [obj/debug/platform-linux.os] Error 1
scons: building terminated because of errors.

I've tried several branches of V8 (trunk, bleeding_edge and 2.2) but i
get the same result.

I think this is a flag problem. I'm missing something ...
I fear that with the armv4t + uclibc combination I'm entering in a
world of pain.

If someone has any idea to deal with my problem. I would so pleased to
hear anything that would help me.

Thanks in advance !!



--
Erik Corry, Software Engineer
Google Denmark ApS.  CVR nr. 28 86 69 84
c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 Copenhagen K, Denmark.

Yoann

unread,
Aug 6, 2010, 10:25:37 AM8/6/10
to v8-users
Thank you Erik.

I've managed to cross-compile V8 !!

I've inspected every functions of platform-linux.cc and found the
guilty one, DebugBreak()

void OS::DebugBreak() {
// TODO(lrn): Introduce processor define for runtime system (!=
V8_ARCH_x,
// which is the architecture of generated code).
#if (defined(__arm__) || defined(__thumb__)) && \
defined(CAN_USE_ARMV5_INSTRUCTIONS)
asm("bkpt 0");
#elif defined(__mips__)
asm("break");
#else
asm("int $3");
#endif
}

Now it's quite logical ... I'm on armv4 architecture, then I had a
beautifull asm error. (according to the preprocessor tests)
I'have commented all the content of the function, and It builds and
works fine on my board ! It's maybe not very clean, but it works !
Great !

To answer to your questions, I'm actually interested in V8 engine
only, to develop a SDK.
I have 64 Mb of memory. Now I'm headed to bench this on my board. I
hope these 64 Mb will be enough to wrap it with my system.

Thank you !
Have a nice day
Yoann

On 6 août, 10:45, Erik Corry <erik.co...@gmail.com> wrote:
> Den 5. aug. 2010 17.17 skrev Yoann <yoann.sc...@gmail.com>:
>
> > Hello,
>
> > I'm trying to cross-compile V8 for an ARM 920T board (armv4) with a
> > toolchain generated by buildroot (based on the uclibc), 4.3.4 version.
> > I'm working with ubuntu 10.04.
>
> I wonder how much memory your 920T board has.  I would guess it doesn't have
> enough to run Chromium.  Perhaps that is not your aim.
>
>
>
>
>
> > I definitly need some help...
>
> > After a "svn checkouthttp://v8.googlecode.com/svn/trunk/v8" I've

Yoann

unread,
Aug 12, 2010, 8:50:00 AM8/12/10
to v8-users
Hello Erik,

I've just seen your new patch http://codereview.chromium.org/3161009/diff/1/2
Thank you !

Yoann

Erik Corry

unread,
Aug 13, 2010, 6:20:21 AM8/13/10
to v8-u...@googlegroups.com
Now committed. Thanks for pointing this out. We don't get much
testing for ARMv4. :-)
Reply all
Reply to author
Forward
0 new messages