Changes between Version 1 and Version 2 of JSCOnly/CrossBuildAndRemoteTestJSCLinux


Ignore:
Timestamp:
Feb 5, 2018 4:05:58 PM (6 years ago)
Author:
clopez@igalia.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 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.
    7 
     7Creating a helper script that exports the required variables documented below is a good idea.
     8
     9== Instructions for building the image and the toolchain with buildroot ==
     10
     11
     121. Download and unpack the last stable version of buildroot. Example:
     13  {{{
     14wget https://buildroot.org/downloads/buildroot-2017.11.2.tar.bz2
     15tar xfa buildroot-2017.11.2.tar.bz2
     16cd buildroot-2017.11.2
     17  }}}
     18
     192. pre-configure buildroot with your target board plus this config fragment:
     20
     21  2.1. download webkit_jsc_buildroot_extraconfig and save it as /tmp/webkit_jsc_buildroot_extraconfig
     22
     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/merge_config.sh configs/raspberrypi3_64_defconfig /tmp/webkit_jsc_buildbot_extraconfig
     26    }}}
     27
     28
     293. run "make menuconfig" and review your systems details, pay special attention the following sections:
     30
     31   3.1 Target options: review that the selected options are ok:
     32
     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.
     34
     35   3.2 Check that ```ICU``` will be built for the target:  (check the value ```BR2_PACKAGE_ICU=y``` )
     36
     37   3.3 Check that the compiler has C++ support enabled (```Toolchain -> Enable C++ support```)
     38
     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.
     40
     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
     44BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2"
     45    }}}
     46
     47    Save the value of this variable for later.
     48
     49
     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.
     55
     56
     57==  Instructions for cross-compiling JSC  with the buildroot toolchain ==
     58
     59=== Defining the environment variables for the cross-compiler ===
     60
     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  }}}
     69
     702. Check that the CROSS_COMPILE one evaluates to the cross-compiler name without the compiler suffix. Example:
     71  {{{
     72
     73$ echo ${CROSS_COMPILE}
     74aarch64-buildroot-linux-gnu-
     75
     76$ echo ${CROSS_COMPILE}gcc
     77aarch64-buildroot-linux-gnu-gcc
     78  }}}
     79
     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  }}}
     84
     85=== Enabling ccache (optional, but recommended) ===
     86
     87If you wish to enable ccache, you can do this:
     88
     891. First install ccache (the native from the host, via apt-get or similar)
     90
     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  }}}
     96
     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  }}}
     103
     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  }}}
     108
     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  }}}
     113 
     114== Instructions for running the tests remotely on the board ==
     115
     116The script [https://trac.webkit.org/browser/trunk/Tools/Scripts/run-javascriptcore-tests 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:
     119
     120=== Setup cross-ldd script ===
     121
     122For identifying which libraries link to the jsc binary, [https://trac.webkit.org/browser/trunk/Tools/Scripts/run-javascriptcore-tests run-javascriptcore-tests] executes the script ldd, but this tool (ldd) won't work out of the box on a cross-build environment.
     123
     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```)
     126
     127{{{
     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
     132}}}
     133
     134Check that it worked:
     135
     136{{{
     137$ which ldd
     138/home/buildbot/toolchains/aarch64/buildroot_2017.11.2/usr/bin/ldd
     139
     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++"
     146
     147$ cd WebKit
     148$ ldd WebKitBuild/Release/bin/jsc
     149        libdl.so.2 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libdl.so.2 (0x00000000deadbeef)
     150        libc.so.6 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libc.so.6 (0x00000000deadbeef)
     151        ld-linux-aarch64.so.1 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/ld-linux-aarch64.so.1 (0x00000000deadbeef)
     152        libJavaScriptCore.so.1 => /home/buildbot/jsconly/jsconly-linux-aarch64-release/build/WebKitBuild/Release/lib/libJavaScriptCore.so.1 (0x00000000deadc0de)
     153        libicui18n.so.59 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libicui18n.so.59 (0x00000000deadbeef)
     154        libicuuc.so.59 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libicuuc.so.59 (0x00000000deadbeef)
     155        libicudata.so.59 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libicudata.so.59 (0x00000000deadbeef)
     156        libpthread.so.0 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libpthread.so.0 (0x00000000deadbeef)
     157        libatomic.so.1 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libatomic.so.1 (0x00000000deadbeef)
     158        libstdc++.so.6 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/usr/lib/libstdc++.so.6 (0x00000000deadbeef)
     159        libm.so.6 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libm.so.6 (0x00000000deadbeef)
     160        libgcc_s.so.1 => /home/buildbot/toolchains/aarch64/buildroot_2017.11.2/aarch64-buildroot-linux-gnu/sysroot/lib/libgcc_s.so.1 (0x00000000deadbeef)
     161
     162}}}
     163
     164
     165Note: Replace the above IP with the one from your board.
     166
     167=== Configure the SSH access to the board ===
     168
     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   }}}
     179
     180   Also accept any ssh key so next time it don't answers any question and the webkit tooling later can ssh automatically.
     181
     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
     186
     187board-rpi64 # mkdir /root/jsc-temp
     188board-rpi64 # echo '{"tempPath": "/root/jsc-temp"}' > /root/.bencher
     189 }}}
     190
     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@192.168.10.173:22"}
     196  }}}
     197
     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++"
     206
     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  }}}