Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import("//build/config/clang/clang.gni") | |
| 6 import("//build/config/compiler/compiler.gni") | |
| 7 import("//build/config/compiler/pgo/pgo.gni") | |
| 8 | |
| 9 # Configuration that enables PGO instrumentation. | |
| 10 config("pgo_instrumentation_flags") { | |
| 11 visibility = [ ":default_pgo_flags" ] | |
| 12 cflags = [] | |
| 13 ldflags = [] | |
| 14 if (is_clang) { | |
| 15 cflags = [ "-fprofile-instr-generate" ] | |
| 16 if (is_win) { | |
| 17 # Normally, we pass -fprofile-instr-generate to the compiler and it | |
| 18 # automatically passes the right flags to the linker. | |
| 19 # However, on Windows, we call the linker directly, without going | |
| 20 # through the compiler driver. This means we need to pass the right | |
| 21 # flags ourselves. | |
| 22 _clang_rt_base_path = | |
| 23 "$clang_base_path/lib/clang/$clang_version/lib/windows" | |
| 24 if (target_cpu == "x86") { | |
| 25 _clang_rt_suffix = "-i386.lib" | |
| 26 } else if (target_cpu == "x64") { | |
| 27 _clang_rt_suffix = "-x86_64.lib" | |
| 28 } | |
| 29 assert(_clang_rt_suffix != "", "target CPU $target_cpu not supported") | |
| 30 ldflags += [ "$_clang_rt_base_path/clang_rt.profile$_clang_rt_suffix" ] | |
| 31 } else { | |
| 32 ldflags += [ "-fprofile-instr-generate" ] | |
| 33 } | |
| 34 } else if (is_win) { | |
| 35 ldflags = [ | |
| 36 # In MSVC, we must use /LTCG when using PGO. | |
| 37 "/LTCG", | |
| 38 | |
| 39 # Make sure that enough memory gets allocated for the PGO profiling | |
| 40 # buffers and also cap this memory. Usually a PGI instrumented build | |
| 41 # of chrome_child.dll requires ~55MB of memory for storing its counter | |
| 42 # etc, normally the linker should automatically choose an appropriate | |
| 43 # amount of memory but it doesn't always do a good estimate and | |
| 44 # sometime allocates too little or too much (and so the instrumented | |
| 45 # image fails to start). Making sure that the buffer has a size in the | |
| 46 # [128 MB, 512 MB] range should prevent this from happening. | |
| 47 "/GENPROFILE:MEMMIN=134217728", | |
| 48 "/GENPROFILE:MEMMAX=536870912", | |
| 49 "/PogoSafeMode", | |
| 50 ] | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 # Configuration that enables optimization using profile data. | |
| 55 config("pgo_optimization_flags") { | |
| 56 visibility = [ ":default_pgo_flags" ] | |
| 57 cflags = [] | |
| 58 ldflags = [] | |
| 59 if (is_clang) { | |
| 60 assert(pgo_data_path != "", | |
| 61 "Please set pgo_data_path to point at the profile data") | |
| 62 cflags += [ | |
| 63 "-fprofile-instr-use=$pgo_data_path", | |
| 64 | |
| 65 # It's possible to have some profile data legitimately missing, | |
| 66 # and at least some profile data always ends up being considered | |
| 67 # out of date, so make sure we don't error for those cases. | |
| 68 "-Wno-profile-instr-unprofiled", | |
| 69 "-Wno-error=profile-instr-out-of-date", | |
|
Nico
2016/12/02 02:48:11
A general remark: We want chrome builds to be sile
inglorion
2016/12/02 21:44:25
Sorry, I missed your comment earlier. I plan to fo
| |
| 70 ] | |
| 71 } else if (is_win) { | |
| 72 ldflags += [ | |
| 73 # In MSVC, we must use /LTCG when using PGO. | |
| 74 "/LTCG", | |
| 75 "/USEPROFILE", | |
| 76 ] | |
| 77 } | |
| 78 } | |
| 79 | |
| 80 # Applies flags necessary when profile-guided optimization is used. | |
| 81 # Flags are only added if PGO is enabled, so that this config is safe to | |
| 82 # include by default. | |
| 83 config("default_pgo_flags") { | |
| 84 if (chrome_pgo_phase == 0) { | |
| 85 # Nothing. This config should be a no-op when chrome_pgo_phase == 0. | |
| 86 } else if (chrome_pgo_phase == 1) { | |
| 87 configs = [ ":pgo_instrumentation_flags" ] | |
| 88 } else if (chrome_pgo_phase == 2) { | |
| 89 configs = [ ":pgo_optimization_flags" ] | |
| 90 } | |
| 91 } | |
| OLD | NEW |