v8cross-build

How do I cross build the latest version of V8 for Raspberry Pi?


I've been trying to cross build V8 for the Raspberry Pi like this:

sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf g++-multilib-arm-linux-gnueabihf
cd ~/
mkdir ~/build/
cd ~/build/
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=~/build/depot_tools:"$PATH"
fetch v8
cd v8
make arm.release snapshot=off arm_version=6 armfpu=vfp

However it won't compile for so many different reasons. What am I doing wrong?


Solution

  • Cross Compiling V8 for Raspberry Pi on Ubuntu 16.04 LTS x64.

    First get the cross compiler and necessary libraries:

    sudo apt-get install gcc-4.9-arm-linux-gnueabihf g++-4.9-arm-linux-gnueabihf g++-4.9-multilib-arm-linux-gnueabihf libc6-armhf-cross
    

    Then get depot tools, which will retrieve V8.

    cd ~/
    mkdir ~/build/
    cd ~/build/
    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    

    Next set the path to depot tools and retrieve the latest version of V8.

    export PATH=~/build/depot_tools:"$PATH"
    fetch v8
    

    Now lets prepare the cross build script for building.

    cd v8/tools
    nano ./cross_build_gcc.sh
    

    Add -4.9 to the end of CXX,CC,LD, and LINK. So it should look like:

    export CXX=$1g++-4.9
    export AR=$1ar
    export RANLIB=$1ranlib
    export CC=$1gcc-4.9
    export LD=$1g++-4.9
    export LINK=$1g++-4.9
    

    Save and exit.

    Now we have to create a link to asm-generic for the headers to be found while compiling.

    cd ..
    ln -s /usr/include/asm-generic /usr/include/asm
    

    Now we can start compiling.

    ./tools/cross_build_gcc.sh /usr/bin/arm-linux-gnueabihf- arm.release arm_version=6 armfpu=vfp armfloatabi=hard