|
LinuxChromiumArm
Building Chromium for ARM
Note this currently contains various recipes:
Recipe1: Building for an ARM CrOS deviceBecause this recipe uses NinjaBuild it's can be faster than the make-based builds in the other recipes. It also replaces the need to install a cross-compiler with the need for a CrOS chroot, which any CrOS ARM developer will already have set up. Baseline: ebuildThe most commonly-used way ARM binaries of chromium get built is using a CrOS chroot and its ebuild system; for details follow the chromium-os developer guide and eventually build binaries from ToT using emerge-<BOARD> chromeos-chrome or build from chromium local-source using CHROME_ORIGIN=LOCAL_SOURCE as described in building-chromium-browser. Fasterfy: ninjaThe ebuild way above has the advantage of being smooth (because of its popularity) but the disadvantage of being very slow (an incremental rebuild of chrome after changing a single file can take minutes). A faster alternative is to build the chrome binary directly in the chroot's view of chromium's src/ tree using the cross-compiler installed in the chroot by the process described above. Example settings to use:
export BOARD=<BOARD>
export BUILD_OUT=out_${BOARD}
export builddir_name=out_${BOARD}
export CHROME_ORIGIN=LOCAL_SOURCE
export GYP_GENERATOR_FLAGS="output_dir=out_${BOARD} config=Debug"
export GYP_GENERATORS="ninja"
export GYP_DEFINES="$GYP_DEFINES chromeos=1 target_arch=arm armv7=1 arm_neon=0"
export GYP_DEFINES="$GYP_DEFINES disable_nacl=1 enable_svg=0"
export GYP_DEFINES="$GYP_DEFINES proprietary_codecs=1 ffmpeg_branding=Chrome"
export GYP_DEFINES="$GYP_DEFINES linux_use_tcmalloc=0 arm_fpu=vfpv3-d16"
export GYP_DEFINES="$GYP_DEFINES python_ver=2.6 swig_defines=-DOS_CHROMEOS linux_sandbox_path=/opt/google/chrome/chrome-sandbox"
export GYP_DEFINES="$GYP_DEFINES remove_webcore_debug_symbols=1"
export EXTRA_BUILD_ARGS="$GYP_DEFINES"
export SYSROOT=/build/${BOARD}/
export ARMV7BASE="armv7a-cros-linux-gnueabi"
export GOLDIFY="-B/usr/x86_64-pc-linux-gnu/armv7a-cros-linux-gnueabi/binutils-bin/2.21-gold/" #
export SYSROOTFLAG="--sysroot=$SYSROOT"
export ARMIFY="-march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp"
export BACKTRACE="-funwind-tables -rdynamic"
export GYP_GENERATORS=ninja
export AR_target=$ARMV7BASE-ar
export CC_target="$ARMV7BASE-gcc $SYSROOTFLAG $BACKTRACE $ARMIFY"
export CXX_target="$ARMV7BASE-g++ $SYSROOTFLAG $GOLDIFY $BACKTRACE $ARMIFY"Running the new binaryThe vanilla way to run a chrome on CrOS is to install it into the system image and re-install the image; this is both extremely slow and extremely frustrating if you introduce a bug that makes the image unusable. A much quicker turn-around way is to run the new binary alongside the system binary. The quickest way to do this is to mount the build output directory from the build host (usually a linux desktop) onto the CrOS device using sshfs, after which the new binary can be run directly. A sample workflow looks like this: alias crosdevice="ssh -o StrictHostKeyChecking=no -o CheckHostIP=no -i ~/trunk/src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa root@<CROS-IP>"
function initcrosdevice() {
cd ~/chrome_root/src
crosdevice 'bash -x -c "echo \"core.%p\" > /proc/sys/kernel/core_pattern && \
mkdir -p ~chronos/chrome && chown chronos ~chronos/chrome && \
sudo modprobe fuse && \
sudo -u chronos /bin/bash -c \"cd ~chronos/chrome && mkdir -p Release Debug\""' && \
echo "Now log into crosdevice and run:"
echo "ulimit -c unlimited && cd ~chronos/chrome && sudo -u chronos bash"
echo "sshfs <BUILDHOSTUSER>@<BUILDHOST>:/home/<BUILDHOSTUSER>/src/chromium/src/out_<BOARD>/Debug Debug && sshfs <BUILDHOSTUSER>@<BUILDHOST>:/home/<BUILDHOSTUSER>/src/chromium/src/out_<BOARD>/Release Release"
crosdevice
}Customize to match your CrOS device's IP address, build host name or IP address, and username on the build host (as well as directory paths if your build output directory lives elsewhere). Then run the initcrosdevice function from inside the cros chroot to get an ssh session to the cros device, and follow the instructions printed. Finally, a sample command line to run in that ssh session is: rm -rf x1 core.[0-9]* && USER=c DISPLAY=:0 XAUTHORITY=/home/chronos/.Xauthority ./Debug/chrome --aura-host-window-use-fullscreen --use-gl=egl --user-data-dir=x1 --no-first-run (the USER=c part is a workaround for http://crosbug.com/23507 and the rest should be self-explanatory) Recipe2: Explicit Cross compilingDue to the lack of ARM hardware with the grunt to build Chromium native, cross compiling is currently the recommended method of building for ARM. Building a toolchainPre-builtCodeSourcery has prebuilt cross-compilers available for download here: http://www.codesourcery.com/sgpp/lite/arm/portal/release1039 Chromium developers have tested using 2009q3. Older versions are known to cause errors when building Chromium. Build your owncrosstool-ng is a set of scripts capable of building a cross-toolchain from source.
$ mkdir toolchain-build $ cd toolchain-build $ ct-ng arm-none-linux-gnueabi $ ct-ng build.6 This will build a toolchain and place it in ~/x-tools/arm-unknown-linux-gnueabi/. The toolchain-build directory can be safely removed after the build has completed. Building a rootfsThe easiest way to build a rootfs for linking against is to copy the directories /lib and /usr/lib from the ARM system to a rootfs directory on the build machine. You must take care to ensure any copied symlinks are relative to the copied directory, not to the build machine's root. If you do not have a pre-existing rootfs, Ubuntu's rootstock tool can be used to create a working ARM system. It is available in Ubuntu 9.10 (Karmic) and newer. The following example builds an Ubuntu Karmic system. The list of packages to install come from LinuxBuildInstructionsPrerequisites#Ubuntu_Setup, and as such may be out dated. An alternate list may be found in $lib_list from build/install-build-deps.sh. $ sudo apt-get install rootstock $ sudo rootstock --fqdn beagleboard --login ubuntu --password temppwd \ --imagesize 2G --seed xfce4,gdm,pkg-config,python,perl,g++,bison,flex,\ gperf,libnss3-dev,libgtk2.0-dev,libnspr4-0d,libasound2-dev,libnspr4-dev,\ libgconf2-dev,libcairo2-dev,libdbus-1-dev,libstdc++6-4.4-dev,libexpat1-dev,\ libxslt1-dev,libxml2-dev,libbz2-dev --dist karmic Compiling
{
'variables': {
'target_arch': 'arm',
'sysroot': '/path/to/rootfs',
'disable_nacl': 1, # NaCL does not build for ARM.
'linux_use_tcmalloc': 0, # tcmalloc does not build for ARM.
'armv7': 1, # Optional, for targeting ARMv7.
'arm_thumb': 1, # Optional, for targetting thumb. Combine with armv7 to target thumb2.
'arm_neon': 0, # Optional, to disable NEON. 1 is the default, and most people want to keep it that way.
'arm_fpu': 'vfpv3-d16', # Optional, to select which version of vfp to use if NEON is off. Default is vfpv3.
}
}
export GYP_DEFINES="target_arch=arm sysroot=/path/to/rootfs disable_nacl=1 linux_use_tcmalloc=0 armv7=1 arm_thumb=1" Note: as of 26-aug-2011 you must also set chromeos=1 as well due to problems in libvpx.
export CROSSTOOL=~/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi export CXX=$CROSSTOOL-g++ export CC=$CROSSTOOL-gcc export AR=$CROSSTOOL-ar export AS=$CROSSTOOL-as export RANLIB=$CROSSTOOL-ranlib make -r -j6 BUILDTYPE=Release chrome Using goldWhether you use the prebuilt toolchain or a custom built one, link times are very high (from 15 minutes in Release to 2+h hours in Debug) Although still experimental, gold on arm got to the point where it can link chrome, and the resulting binary runs fine. gold on arm is only available currently on the top-of-trunk binutils. $ mkdir binutils $ cd binutils $ cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login (only needed the first time; enter "anoncvs" as the password) $ cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils $ cd src $ ./configure --enable-gold --target=arm-none-linux-gnueabi $ make -i $ cd .. $ ln -s src/gold/ld-new ld Then modify the CC and CXX lines above adding -B /path/to/binutils to indicate the path to the ld symlink that was created above (that is, /path/to/binutils/ld should be the gold binary), e.g. $ export CC="$CROSSTOOL-gcc -B /path/to/binutils" $ export CXX="$CROSSTOOL-g++ -B /path/to/binutils" Then, rebuild chrome as usual. For the arm buildbot, run configure with --prefix=/usr/local/tot-binutils. This will install gold into /usr/local/tot-binutils/arm-none-linux-gnueabi/bin/ld. Then to make the bot find the correct binutils, edit /b/scripts/slave/compile.py, and look for the stanza that sets 'CC' and 'CC'. It should look like: os.environ['CC'] = crosstool + '-gcc'. os.environ['CXX'] = crosstool + '-g++'. Change it so that it says: os.environ['CC'] = crosstool + '-gcc -B/usr/local/tot-binutils/arm-none-linux-gnueabi/bin'. os.environ['CXX'] = crosstool + '-g++ -B/usr/local/tot-binutils/arm-none-linux-gnueabi/bin'. TestingIf you don't have a real ARM machine, you can test with QEMU. For instance, there are some prebuilt QEMU Debian images here: http://people.debian.org/~aurel32/qemu/. Another option is to use the rootfs generated by rootstock, as mentioned above. Here's a minimal xorg.conf if needed: Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection
Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
EndSection
Section "Device"
Identifier "Configured Video Device"
Driver "fbdev"
Option "UseFBDev" "true"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 8
SubSection "Display"
Depth 8
Modes "1024x768" "800x600" "640x480"
EndSubSection
EndSectionNotes
Recipe3: Packaged/Automated Cross compilingThis recipe describes how to cross compile chrome on an x86 ubuntu system to an arm ubuntu system (natty, and up). This worked as of version 114696 Note: for simplicity the recipe steps have been move into a script, chrome-setup.sh , which can be found here: http://codereview.chromium.org/8967004/ The script should be run from inside the src/ directory in a chrome client Step 1: Install basic cross tool componentsThis needs to be run only once per machine. chrome-setup.sh install-cross-toolchain-base Step 2: Install additional cross tool jailThis jail is pre-built and can be installed like so: chrome-setup.sh install-cross-toolchain-jail This step needs to be run only once per client and could be modified to be necessary only once per machine. Step 3: Configure Chrome Buildchrome-setup.sh configure-chrome Step 4: Build Chromechrome-setup.sh make-chrome You maybe want to change the parallelism (currently: -j 16) Step 5: Package Chromechrome-setup.sh package-chrome This creates a tarball for shipping to/testing on the target system. |
What should be the linker environment variable for arm-unknown-linux-gnueabi-ld?
I'm getting below error while compiling for arm using the above mentioned tools:
/home/sashinde/chromiumos/chromiumos.git/chroot/usr/lib/crt1.o: file not recognized: File format not recognized collect2: ld returned 1 exit status make: out/Debug/xdisplaycheck? Error 1
And if I set "export LINK=$CROSSTOOL-ld" then I get below error:
/home/sashinde/tools/arm-2009q3/bin/arm-none-linux-gnueabi-ld: unrecognized option '-Wl,-z,noexecstack' /home/sashinde/tools/arm-2009q3/bin/arm-none-linux-gnueabi-ld: use the --help option for usage information make: out/Debug/xdisplaycheck? Error 1
In build your own toolchain section, the command must be "$ ct-ng arm-unknown-linux-gnueabi" instead of "ct-ng arm-none-linux-gnueabi".
I cross built chromium for ARM see: https://wiki.linaro.org/DeveloperDocs/CrossBuildingChromiumBrowser Build runs on Marvell's Dove board
is it possible to compile for ARM from inside the qemu user-emulation chroot..? I tried and it core dumped..
When i install the CC from http://www.codesourcery.com/sgpp/lite/arm/portal/release1039, the bins extracted is arm-none-linux-gnueabi instead of arm-unknown-linux-gnueabi. Any reason?
How do i specify cflags (include path) in gyp? I have a sysroot and would like to add the include path (sysroot/usr/include)
Seems current Chromium ARM build requires "EGL" and "GLESv2", which are not required by x86 build? I encountered the errors like "cannot find -lEGL" and "cannot find -lGLESv2" at the final linkage stage.
gclient went wild if I use the 'target_arch': 'arm', among the other variables in ~/.gyp/include.gypi file. the error is:
KeyError?: 'src/third_party/libvpx/libvpx.gyp:libvpx#target while trying to load target src/remoting/remoting.gyp:remoting_base#target' Error: /usr/bin/python src/build/gyp_chromium in /home/concept/francesco/work/chromium/home/chrome-svn/tarball/chromium returned 1
The script input.py raises an exception while building the dependecy list. Did someone face, and above all solved, this problem? I've got lost in the gyp syntax without any result.
Thanks a lot in advance
I found the cause by logging a bit in the input.py script. Basicall there isn't any target named libvpx (in libvpx.gyp) which is listed as dependency in remoting_base target sitting in remoting.gyp. This happens to be used when target_arch is 'arm'. Now one question comes to my mind: do they provide stuff without try it up first? Wha.
I have built success, it's a long jounery, but one question, my version can not play video? what's wrong about this!
zhouluf, can you post the resulting binary somewhere, so I can test?
When using "ct-ng arm-none-linux-gnueabi" config x-tools, i am facing compiler warning "out/Release/obj/gen/policy/policy/policy_constants.cc:1: error: invalid floating point option: -mfpu=vfpv3-d16".
Please help.Thanks in advance.
I recently commit some changes to chromium which should help with the arm build. There is a script here: http://codereview.chromium.org/8967004/ which I have used for building chromium
rebertm, thanks for your script. I have compiled the latest version of chromium following your recipe 2(Ubuntu 11.10 32bit, Release mode, r112834). But it failed to launch on my embedded board and I'm analyzing the problem. Anyway, could you give me some background information about the rootfs that the script download from nacl sdk?(I assume this link is the latest versionhttp://gsdview.appspot.com/nativeclient-archive2/toolchain/latest/) I mean that the files in the 'arm_jail' folder. How does it work?
tella..., I do not think that arm_jail/ dir is used anymore unless you use qemu.
The step "chrome-setup.sh install-cross-toolchain-jail" mentioned above just installs a bunch of includes and libs necessary for building chrome
Oops, I misspoke. The downloaded files in arm_jail/ are the same you would get if you went through steps 1 and 2.
misspoke again. ;-)
The jail was produced by the following script: http://src.chromium.org/viewvc/native_client/trunk/src/native_client/tools/llvm/trusted-toolchain-creator2.sh?view=markup
which is part of the native client code base
I used Recipe2, for example: 1. set arm build path: cp files to /home/xxx/h1/trident/build, and new file: /home/xxx/h1/trident/build/h1_env: export PATH=$PATH:/home/xxx/h1/trident/build/compiler/bin:/home/xxx/h1/trident/script:/home/xxx/h1/trident/sdk/host/linux/bin export PKG_CONFIG_PATH=/home/xxx/h1/trident/build/pkgconfig export PRODUCT_ID=h1 export HOSTARCH=trident
2. get chrome source code to /home/share/chromium 3. new file /home/xxx/.gyp/include.gypi: {
4. modify files: /home/share/chromium/src/build/linux/system.gyp: --- system.gyp (revision 8282) +++ system.gyp (working copy) @@ -6,7 +6,8 @@
- 'pkg-config': './pkg-config-wrapper "<(sysroot)"', + 'pkg-config': 'pkg-config', + #'pkg-config': './pkg-config-wrapper "<(sysroot)"', @@ -23,6 +24,7 @@/home/share/chromium/src/build/linux/pkg-config-wrapper --- pkg-config-wrapper (revision 8157) +++ pkg-config-wrapper (working copy) @@ -21,9 +21,12 @@
-
-config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig +if -z "$PKG_CONFIG_PATH" ; then + config_path=$root/usr/lib/pkgconfig:$root/usr/share/pkgconfig +else + config_path=$PKG_CONFIG_PATH +fi4. new file: /home/share/chromium/src/make.trident source /home/xxx/h1/trident/build/h1_env
export CROSSTOOL=arm-linux export CXX=$CROSSTOOL-g++ export CC=$CROSSTOOL-gcc export AR=$CROSSTOOL-ar export AS=$CROSSTOOL-as export RANLIB=$CROSSTOOL-ranlib
#target_arch=arm-linux #build_param="CC.host=${target_arch}gcc CXX.host=${target_arch}-g++ LINK.host=CXX.host=${target_arch}-g++ AR.host=${target_arch}-ar" #echo build_param=$build_param
#check file /home/xxx/.gyp/include.gypi #export GYP_DEFINES='target_arch="arm" sysroot=/home/jinglun/h1/trident/build/compiler/arm-cortex-linux-gnueabi/sys-root disable-nacl=1 linux_use_tcmalloc=0 armv7=1 arm_thumb=1' ./build/gyp_chromium -fmake --ignore-environment "--toplevel-dir=/home/share/chromium/home/chrome-svn/tarball/chromium_trident/src" -Ibuild/common.gypi "--depth=/home/share/chromium/home/chrome-svn/tarball/chromium_trident/src" build/all.gyp
make V=1 BUILDTYPE=Release chrome
5. exec script /home/share/chromium/src/make.trident
I'm trying recipe:1.
I'm now able to create the build.ninja and related sub-ninja files. But when i run
"ninja -C out_waluigi/Release chrome" command, then i get following failure:
(cr) vhiremath@vhiremath ~/chrome_root/src $ ninja -C out$BOARD/Release/ -j4 chrome ninja: Entering directory `out$BOARD/Release/' [10/9381] CXX obj/v8/src/v8_base.platform-posix.o FAILED: armv7a-cros-linux-gnueabi-g++ --sysroot=/build/$BOARD/ -B/usr/x86_64-pc-linux-gnu/armv7a-cros-linux-gnueabi/binutils-bin/2.21-gold/ -funwind-tables -rdynamic -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3-d16 -mfloat-abi=softfp -MMD -MF obj/v8/src/v8_base.platform-posix.o.d -D_FILE_OFFSET_BITS=64 -DNO_TCMALLOC -DDISABLE_NACL -DCHROMIUM_BUILD -DTOOLKIT_VIEWS=1 -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_NSS=1 -DOS_CHROMEOS=1 -DFILE_MANAGER_EXTENSION=1 -DWEBUI_TASK_MANAGER=1 -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DENABLE_P2P_APIS=1 -DUSE_PROPRIETARY_CODECS -DENABLE_CONFIGURATION_POLICY -DENABLE_INPUT_SPEECH -DENABLE_NOTIFICATIONS -DENABLE_GPU=1 -DENABLE_EGLIMAGE=1 -DUSE_SKIA=1 -DENABLE_TASK_MANAGER=1 -DENABLE_WEB_INTENTS=1 -DENABLE_EXTENSIONS=1 -DENABLE_PROTECTOR_SERVICE=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_BACKGROUND=1 -DENABLE_PROMO_RESOURCE_SERVICE=1 -DENABLE_AUTOMATION=1 -DENABLE_DEBUGGER_SUPPORT -DV8_TARGET_ARCH_ARM -DUSE_EABI_HARDFLOAT=0 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -I../../v8/src -pthread -fno-exceptions -fno-strict-aliasing -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -m32 -Wno-format -Wno-unused-result -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon -fno-ident -fdata-sections -ffunction-sections -fdata-sections -ffunction-sections -fomit-frame-pointer -O3 -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -Wno-deprecated -Wno-abi -c ../../v8/src/platform-posix.cc -o obj/v8/src/v8_base.platform-posix.o cc1plus: error: unrecognized command line option ‘-m32’
How can i overcome the error related to -m32 and proceed further.
vhiremath: patch in http://codereview.chromium.org/10335014/ or wait for it to land & sync (might be done by monday morning your time). You might have to manually apply the diff to src/v8 in your chromium checkout.
The issue is now closed and i can also see this change committed as r11597 in https://code.google.com/p/v8/source/list.
But i cant find the fixes in chromium checkout source. I even updated the DEPS file to point v8 version to 11597
vhiremath: that CL landed into the "bleeding_edge" branch of v8, not trunk.