-
Notifications
You must be signed in to change notification settings - Fork 435
Compiling Chrome using flto
Follow this guide
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH="$PATH:/path/to/depot_tools"
$ mkdir ~/chromium
$ cd ~/chromium
$ fetch --nohooks chromium
$ cd src
$ build/install-build-deps.sh
$ gclient runhooks
In build/config/compiler/BUILD.gn
, comment the following:
"-Wno-ignored-pragma-optimize",
cflags += [ "-fcolor-diagnostics" ]
In build/config/posix/BUILD.gn
, comment the following:
ldflags += [ "-nostdlib++" ]
$ 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 = "PATH_TO_LLVM_BUILD"
clang_use_chrome_plugins = false
clang_version = "7.0.0"
Then save and quit the editor (:wq). "Default" can be replaced by any other name.
Edit file out/Default/toolchain.ninja
with the following changes to add options for "lto":
"${cflags}" ==> "-flto ${cflags}"
"${ldflags}" ==> "-flto ${ldflags}"
Edit file out/Default/toolchain.ninja
with the follow change:
"${arflags} -r -c -s -D" ==> "rcsT"
Edit file build/config/compiler/BUILD.gn
with the following changes:
"ldflags += [ "-fuse-ld=lld" ]" ==> "ldflags += [ "-fuse-ld=gold" ]"
"gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin", root_build_dir)"
==> "gold_path = "/usr/bin/ld""
Edit file build/config/compiler/compiler.gni
with the following changes:
"use_lld = -long boolean expression-" ==> "use_lld = false"
"use_gold = -long boolean expression-" ==> "use_gold = true"
Change to corresponding ninja version in the first line of out/Default/build.ninja
, e.g., ninja_required_version = 1.5.1
Finally, run:
$ ninja -j 8 -C out/Default chrome
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/