Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: build/config/compiler/pgo/BUILD.gn

Issue 2507333002: Add the possibility to build with PGO when using Clang (Closed)
Patch Set: Add the possibility to build with PGO when using Clang Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 # Applies linker flags necessary when profile-guided optimization is used.
10 # Flags are only added if PGO is enabled, so that this config is safe to
11 # include by default.
12 config("default_pgo_ldflags") {
Sébastien Marchand 2016/11/24 15:57:07 If we stick with this approach I'd prefer to keep
13 visibility = [ ":default_pgo_flags" ]
14 ldflags = []
15
16 if (is_clang) {
17 if (chrome_pgo_phase == 1) {
18 if (is_win) {
19 # Normally, we pass -fprofile-instr-generate to the compiler and it
20 # automatically passes the right flags to the linker.
21 # However, on Windows, we call the linker directly, without going
22 # through the compiler driver. This means we need to pass the right
23 # flags ourselves.
24 _clang_rt_base_path =
25 "$clang_base_path/lib/clang/$clang_version/lib/windows"
26 if (target_cpu == "x86") {
27 _clang_rt_suffix = "-i386.lib"
28 } else if (target_cpu == "x64") {
29 _clang_rt_suffix = "-x86_64.lib"
30 }
31 assert(_clang_rt_suffix != "", "target CPU $target_cpu not supported")
32 ldflags += [ "$_clang_rt_base_path/clang_rt.profile$_clang_rt_suffix" ]
33 } else {
34 ldflags += [ "-fprofile-instr-generate" ]
35 }
36 }
37 } else if (is_win) {
38 if (chrome_pgo_phase == 1) {
39 ldflags += [
40 # In MSVC, we must use /LTCG when using PGO.
41 "/LTCG",
42
43 # Make sure that enough memory gets allocated for the PGO profiling
44 # buffers and also cap this memory. Usually a PGI instrumented build
45 # of chrome_child.dll requires ~55MB of memory for storing its counter
46 # etc, normally the linker should automatically choose an appropriate
47 # amount of memory but it doesn't always do a good estimate and
48 # sometime allocates too little or too much (and so the instrumented
49 # image fails to start). Making sure that the buffer has a size in the
50 # [128 MB, 512 MB] range should prevent this from happening.
51 "/GENPROFILE:MEMMIN=134217728",
52 "/GENPROFILE:MEMMAX=536870912",
53 "/PogoSafeMode",
54 ]
55 } else if (chrome_pgo_phase == 2) {
56 ldflags += [
57 # In MSVC, we must use /LTCG when using PGO.
58 "/LTCG",
59 "/USEPROFILE",
60 ]
61 }
62 }
63 }
64
65 # Applies compiler flags necessary when profile-guided optimization is used.
66 # Flags are only added if PGO is enabled, so that this config is safe to
67 # include by default.
68 config("pgo_flags") {
69 visibility = [ ":default_pgo_flags" ]
70 cflags = []
71
72 if (is_clang && !is_nacl) {
73 if (chrome_pgo_phase == 1) {
74 cflags += [ "-fprofile-instr-generate" ]
75 } else if (chrome_pgo_phase == 2) {
76 assert(pgo_data_path != "",
77 "Please set pgo_data_path to point at the profile data")
78 cflags += [
79 "-fprofile-instr-use=$pgo_data_path",
80
81 # It's possible to have some profile data legitimately missing, and at l east some
Sébastien Marchand 2016/11/24 15:57:07 > 80 characters.
82 # profile data always ends up being considered out of date, so make sure we don't
83 # error for those cases.
84 "-Wno-profile-instr-unprofiled",
85 "-Wno-error=profile-instr-out-of-date",
86 ]
87 }
88 }
89 }
90
91 config("default_pgo_flags") {
92 configs = [
93 ":default_pgo_ldflags",
94 ":pgo_flags",
95 ]
96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698