| 7 | | |
| | 7 | Creating 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 | |
| | 12 | 1. Download and unpack the last stable version of buildroot. Example: |
| | 13 | {{{ |
| | 14 | wget https://buildroot.org/downloads/buildroot-2017.11.2.tar.bz2 |
| | 15 | tar xfa buildroot-2017.11.2.tar.bz2 |
| | 16 | cd buildroot-2017.11.2 |
| | 17 | }}} |
| | 18 | |
| | 19 | 2. 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 | {{{ |
| | 25 | support/kconfig/merge_config.sh configs/raspberrypi3_64_defconfig /tmp/webkit_jsc_buildbot_extraconfig |
| | 26 | }}} |
| | 27 | |
| | 28 | |
| | 29 | 3. 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 |
| | 44 | BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2" |
| | 45 | }}} |
| | 46 | |
| | 47 | Save the value of this variable for later. |
| | 48 | |
| | 49 | |
| | 50 | 4. 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 | |
| | 61 | 1. export this environment variables |
| | 62 | {{{ |
| | 63 | export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2" |
| | 64 | export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")" |
| | 65 | export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}" |
| | 66 | export CC="${CROSS_COMPILE}gcc" |
| | 67 | export CXX="${CROSS_COMPILE}g++" |
| | 68 | }}} |
| | 69 | |
| | 70 | 2. Check that the CROSS_COMPILE one evaluates to the cross-compiler name without the compiler suffix. Example: |
| | 71 | {{{ |
| | 72 | |
| | 73 | $ echo ${CROSS_COMPILE} |
| | 74 | aarch64-buildroot-linux-gnu- |
| | 75 | |
| | 76 | $ echo ${CROSS_COMPILE}gcc |
| | 77 | aarch64-buildroot-linux-gnu-gcc |
| | 78 | }}} |
| | 79 | |
| | 80 | 3. 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 | {{{ |
| | 82 | export BUILD_JSC_ARGS="--cmakeargs=-DCMAKE_TOOLCHAIN_FILE=${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake" |
| | 83 | }}} |
| | 84 | |
| | 85 | === Enabling ccache (optional, but recommended) === |
| | 86 | |
| | 87 | If you wish to enable ccache, you can do this: |
| | 88 | |
| | 89 | 1. First install ccache (the native from the host, via apt-get or similar) |
| | 90 | |
| | 91 | 2. Create a ccache dir inside ```${BR2_HOST_DIR}``` and cd into it |
| | 92 | {{{ |
| | 93 | mkdir "${BR2_HOST_DIR}/usr/ccache" |
| | 94 | cd "${BR2_HOST_DIR}/usr/ccache" |
| | 95 | }}} |
| | 96 | |
| | 97 | 3. Create symlinks to ccache with the name of the CC and CXX compilers |
| | 98 | {{{ |
| | 99 | # Define CC and CXX like above |
| | 100 | ln -s "$(which ccache)" "${CXX}" |
| | 101 | ln -s "$(which ccache)" "${CC}" |
| | 102 | }}} |
| | 103 | |
| | 104 | 4. 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 | {{{ |
| | 106 | sed -i '/set(CMAKE_C/s,/bin/,/ccache/,' ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake |
| | 107 | }}} |
| | 108 | |
| | 109 | 5. Now, '''each''' time you build, set your path with the ccache directory first |
| | 110 | {{{ |
| | 111 | export 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 | |
| | 116 | The 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. |
| | 117 | This 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. |
| | 118 | To make use of this follow the instructions below: |
| | 119 | |
| | 120 | === Setup cross-ldd script === |
| | 121 | |
| | 122 | For 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 | |
| | 124 | To fix that we use the attached cross-ldd. |
| | 125 | So 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 | |
| | 134 | Check 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. |
| | 141 | export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2" |
| | 142 | export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")" |
| | 143 | export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}" |
| | 144 | export CC="${CROSS_COMPILE}gcc" |
| | 145 | export 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 | |
| | 165 | Note: Replace the above IP with the one from your board. |
| | 166 | |
| | 167 | === Configure the SSH access to the board === |
| | 168 | |
| | 169 | 1. 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 | {{{ |
| | 177 | ssh-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 | |
| | 182 | 2. 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 | {{{ |
| | 185 | dev-machine $ ssh root@jsc-rpi3-64.board.local |
| | 186 | |
| | 187 | board-rpi64 # mkdir /root/jsc-temp |
| | 188 | board-rpi64 # echo '{"tempPath": "/root/jsc-temp"}' > /root/.bencher |
| | 189 | }}} |
| | 190 | |
| | 191 | 3. 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 | |
| | 198 | 4. Finally, execute run-javascriptcore-tests as follows: |
| | 199 | {{{ |
| | 200 | # NOTE: The cross-ldd script needs the environment variables below set to work properly. |
| | 201 | export BR2_HOST_DIR="/home/buildbot/toolchains/aarch64/buildroot_2017.11.2" |
| | 202 | export CROSS_COMPILE="$(basename $(cat ${BR2_HOST_DIR}/usr/share/buildroot/toolchainfile.cmake|grep CMAKE_CXX_COMPILER|awk -F'"' '{print $2}')|sed "s/g++$//g")" |
| | 203 | export PATH="${BR2_HOST_DIR}/usr/bin:${PATH}" |
| | 204 | export CC="${CROSS_COMPILE}gcc" |
| | 205 | export CXX="${CROSS_COMPILE}g++" |
| | 206 | |
| | 207 | Tools/Scripts/run-javascriptcore-tests --jsc-only --release --no-build --no-fail-fast --memory-limited --remote-config-file ${pathtothefileabove}/remote-jsc-tests-config.json |
| | 208 | }}} |