Skip to content

Compiling Chrome using flto

XiaokangFan edited this page Sep 7, 2017 · 21 revisions

1 Install depot_tools

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

$ export PATH="$PATH:/path/to/depot_tools"

2 Get the source code of Chrome

$ mkdir ~/chromium

$ cd ~/chromium

$ fetch --nohooks chromium

$ cd src

3 Install additional build dependencies

$ build/install-build-deps.sh

4 Run the hooks

$ gclient runhooks

5 Setting up the build (use gn)

5.1 Annotate a few compiler options in config files

(clang-4.0.0 does not accept these options)

"-Wno-unused-lambda-capture" and "-Wno-enum-compare-switch" in file build/config/compiler/BUILD.gn

ldflags += [ "-nostdlib++" ] in file build/config/posix/BUILD.gn

5.2 Create a build directory

$ gn args out/Default

This will bring up an editor (vi/vim). Enter the following options:

is_debug = false

is_component_build = true

symbol_level = 0

enable_nacl = false

clang_base_path = "HOME_TO_LLVM_BUILD"

clang_use_chrome_plugins = false

clang_version = "LOCAL_CLANG_VERSION"

Then save and quit the editor (:wq). "Default" can be replaced by any other name.

5.3 Add lto option (Optional)

Edit file "out/Default/toolchain.ninja" to add options for "lto" (add -flto before "cflags" and "ldflags")

6 Build Chromium

ninja -j 8 -C out/Default chrome

Browser benchmarks

dromaeo http://dromaeo.com/

jetstream http://browserbench.org/JetStream/

kraken http://krakenbenchmark.mozilla.org/

litebrite https://testdrive-archive.azurewebsites.net/Performance/LiteBrite/

octane https://developers.google.com/octane/

peacekeeper http://peacekeeper.futuremark.com/

sunspider https://webkit.org/perf/sunspider/sunspider.html

wirple-bmark https://www.wirple.com/bmark/