Changes between Version 1 and Version 2 of JSCOnly/CrossBuildAndRemoteTestJSCLinux

Feb 5, 2018 4:05:58 PM (4 years ago)



  • JSCOnly/CrossBuildAndRemoteTestJSCLinux

    v1 v2  
    55This document explains how to cross-build the [[JSCOnly]] port for a target board (like a RaspberryPi) and run the JSC tests suite on the board remotely.[[BR]]
    66To achieve that we build both an image for the board and a cross-toolchain with buildroot.
     7Creating a helper script that exports the required variables documented below is a good idea.
     9== Instructions for building the image and the toolchain with buildroot ==
     121. Download and unpack the last stable version of buildroot. Example:
     13  {{{
     15tar xfa buildroot-2017.11.2.tar.bz2
     16cd buildroot-2017.11.2
     17  }}}
     192. pre-configure buildroot with your target board plus this config fragment:
     21  2.1. download webkit_jsc_buildroot_extraconfig and save it as /tmp/webkit_jsc_buildroot_extraconfig
     23  2.2. guess the name of your board defconfig (check the files in config/) and merge the default config for it with the attached one. For example, for configuring for using the RPi3 in ARM64 (Aarch64) mode we will do:
     24    {{{
     25support/kconfig/ configs/raspberrypi3_64_defconfig /tmp/webkit_jsc_buildbot_extraconfig
     26    }}}
     293. run "make menuconfig" and review your systems details, pay special attention the following sections:
     31   3.1 Target options: review that the selected options are ok:
     33     3.1.1 For example, if the  board is ```ARM32``` (```ARMv7```) is not the same to enable ```Thumb2``` instructions than not. Also the type of ```FPU``` selected is relevant.
     35   3.2 Check that ```ICU``` will be built for the target:  (check the value ```BR2_PACKAGE_ICU=y``` )
     37   3.3 Check that the compiler has C++ support enabled (```Toolchain -> Enable C++ support```)
     39   3.4 Check also on ```Filesystem images``` the size of the image to be generated: Set it to at least to a 2GB size so it has enough free space for storing all the subproducts of the JSC tests.
     41   3.5 Set the builroot hostdir (```Build options -> Host dir```) to the path where the toolchain should be installed. Example:
     42    {{{
     43$ cat .config|grep BR2_HOST_DIR
     45    }}}
     47    Save the value of this variable for later.
     504. Build the buildroot toolchain and the board image.
     51  {{{
     52$ make -j $(nproc)
     53  }}}
     54  When it has finished you should have available in the path you defined for ```${BR2_HOST_DIR}``` the cross-toolchain. And you should have available in the subdir output/target of buildroot the image or rootfs that should be flashed on the board.
     57==  Instructions for cross-compiling JSC  with the buildroot toolchain ==
     59=== Defining the environment variables for the cross-compiler ===
     611. export this environment variables
     62  {{{
     63export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2"
     64export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")"
     65export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}"
     66export CC="${CROSS_COMPILE}gcc"
     67export CXX="${CROSS_COMPILE}g++"
     68  }}}
     702. Check that the CROSS_COMPILE one evaluates to the cross-compiler name without the compiler suffix. Example:
     71  {{{
     73$ echo ${CROSS_COMPILE}
     76$ echo ${CROSS_COMPILE}gcc
     78  }}}
     803. Pass the flag ```-DCMAKE_TOOLCHAIN_FILE``` to cmake to the path of the toolchainfile.cmake that buildroot generates. If you use the WebKit internal tooling for building (script Tools/Scripts/build-jsc) you can do that  by simply exporting this environment variable:
     81  {{{
     82export BUILD_JSC_ARGS="--cmakeargs=-DCMAKE_TOOLCHAIN_FILE=${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake"
     83  }}}
     85=== Enabling ccache (optional, but recommended) ===
     87If you wish to enable ccache, you can do this:
     891. First install ccache (the native from the host, via apt-get or similar)
     912. Create a ccache dir inside ```${BR2_HOST_DIR}``` and cd into it
     92  {{{
     93mkdir "${BR2_HOST_DIR}/usr/ccache"
     94cd "${BR2_HOST_DIR}/usr/ccache"
     95  }}}
     973. Create symlinks to ccache with the name of the CC and CXX compilers
     98  {{{
     99# Define CC and CXX like above
     100ln -s "$(which ccache)" "${CXX}"
     101ln -s "$(which ccache)" "${CC}"
     102  }}}
     1044. Replace on the ```${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake``` file the paths to the C and CXX compilers, so they point to ```${RELOCATED_HOST_DIR}/ccache``` instead of to ```${RELOCATED_HOST_DIR}/bin```
     105  {{{
     106sed -i '/set(CMAKE_C/s,/bin/,/ccache/,' ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake
     107  }}}
     1095. Now, '''each''' time you build, set your path with the ccache directory first
     110  {{{
     111export PATH="${BR2_HOST_DIR}/usr/ccache:${BR2_HOST_DIR}/usr/bin:${PATH}"
     112  }}}
     114== Instructions for running the tests remotely on the board ==
     116The script [ run-javascriptcore-tests] allows to run the jsc tests remotely on the board.
     117This script will generate a tarball bundled with the built jsc and all the libraries linking to it, plus all what is needed for run the tests.
     118To make use of this follow the instructions below:
     120=== Setup cross-ldd script ===
     122For identifying which libraries link to the jsc binary, [ run-javascriptcore-tests] executes the script ldd, but this tool (ldd) won't work out of the box on a cross-build environment.
     124To fix that we use the attached cross-ldd.
     125So we need to put this script renamed to ldd on the binary path of the cross-toolchain (```${BR2_HOST_DIR}/bin```)
     128# Save attached cross-ldd as /tmp/cross-ldd
     129$ cp /tmp/cross-ldd ${BR2_HOST_DIR}/usr/bin/ldd
     130# Important! make it executable:
     131$ chmod +x ${BR2_HOST_DIR}/usr/bin/ldd
     134Check that it worked:
     137$ which ldd
     140# We need to export this environment variables every-time we want to use this.
     141export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2"
     142export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")"
     143export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}"
     144export CC="${CROSS_COMPILE}gcc"
     145export CXX="${CROSS_COMPILE}g++"
     147$ cd WebKit
     148$ ldd WebKitBuild/Release/bin/jsc
     149 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     150 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     151 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     152 => /home/buildbot/jsconly/jsconly-linux-aarch64-release/build/WebKitBuild/Release/lib/ (0x00000000deadc0de)
     153 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/ (0x00000000deadbeef)
     154 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/ (0x00000000deadbeef)
     155 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/ (0x00000000deadbeef)
     156 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     157 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     158 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/ (0x00000000deadbeef)
     159 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     160 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ (0x00000000deadbeef)
     165Note: Replace the above IP with the one from your board.
     167=== Configure the SSH access to the board ===
     1691. First copy your ssh key to the board so you can login passwordless
     170   {{{
     171$ ssh-keygen
     172# default root password is "jsc"
     173$ ssh-copy-id root@jsc-rpi3-64.board.local
     174   }}}
     175   Now double-check that you can ssh on the board without password:
     176   {{{
     177ssh-copy-id root@jsc-rpi3-64.board.local
     178   }}}
     180   Also accept any ssh key so next time it don't answers any question and the webkit tooling later can ssh automatically.
     1822. Then configure the bencher config file on the board.
     183  ssh on the board and create in the home directory a file named '.bencher' with the path where to copy the jsc products and tests for running.
     184  {{{
     185dev-machine $ ssh root@jsc-rpi3-64.board.local
     187board-rpi64 # mkdir /root/jsc-temp
     188board-rpi64 # echo '{"tempPath": "/root/jsc-temp"}' > /root/.bencher
     189 }}}
     1913. Now configure the remote config file
     192  The Script Tools/Scripts/run-javascriptcore-tests also expects some config parameters with the IP of the board. You can pass that parameters by creating a file with this contents
     193  {{{
     194$ cat remote-jsc-tests-config.json
     195{"remote": "root@"}
     196  }}}
     1984. Finally, execute run-javascriptcore-tests as follows:
     199  {{{
     200# NOTE: The cross-ldd script needs the  environment variables below set to work properly.
     201export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2"
     202export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")"
     203export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}"
     204export CC="${CROSS_COMPILE}gcc"
     205export CXX="${CROSS_COMPILE}g++"
     207Tools/Scripts/run-javascriptcore-tests --jsc-only --release --no-build --no-fail-fast --memory-limited  --remote-config-file ${pathtothefileabove}/remote-jsc-tests-config.json
     208  }}}