Bug 1507344 - Add configure machinery for MOZ_PROFILE_USE and merging profile. r=nalexander

Differential Revision: https://phabricator.services.mozilla.com/D13863

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Manchester 2018-12-21 19:02:11 +00:00
parent d64a93fbd2
commit 0851ff9f4a
4 changed files with 53 additions and 5 deletions

11
build/merge_profdata.py Normal file
View File

@ -0,0 +1,11 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import subprocess
import buildconfig
def main(_, profile_file):
subprocess.check_call([buildconfig.substs['LLVM_PROFDATA'], 'merge',
'-o', 'merged.profdata', profile_file])

View File

@ -19,6 +19,12 @@ def developer_options(value):
return True
llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'],
allow_missing=True)
add_old_configure_assignment('LLVM_PROFDATA', llvm_profdata)
add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options)
set_config('DEVELOPER_OPTIONS', developer_options)
@ -33,11 +39,36 @@ imply_option('MOZ_PGO',
set_config('MOZ_PROFILE_GENERATE',
depends_if('--enable-profile-generate')(lambda _: True))
js_option('--enable-profile-use',
help='Use a generated profile during the build')
js_option('--with-pgo-profile-path',
help='Path to the (unmerged) profile path to use during the build',
nargs=1)
imply_option('MOZ_PGO',
depends_if('--enable-profile-use')(lambda _: True))
set_config('MOZ_PROFILE_USE',
depends_if('--enable-profile-use')(lambda _: True))
js_option(env='MOZ_PGO', help='Build with profile guided optimizations')
set_config('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
add_old_configure_assignment('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
@depends('--with-pgo-profile-path', '--enable-profile-use', 'LLVM_PROFDATA')
def pgo_profile_path(path, pgo_use, profdata):
if not path:
return
if path and not pgo_use:
die('Pass --enable-profile-use to use --with-pgo-profile-path.')
if path and not profdata:
die('LLVM_PROFDATA must be set to process the pgo profile.')
return path[0]
set_config('PGO_PROFILE_PATH', pgo_profile_path)
# Code optimization
# ==============================================================
@ -1473,11 +1504,6 @@ set_config('PROFILE_GEN_LDFLAGS', pgo_flags.gen_ldflags)
set_config('PROFILE_USE_CFLAGS', pgo_flags.use_cflags)
set_config('PROFILE_USE_LDFLAGS', pgo_flags.use_ldflags)
llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'],
allow_missing=True)
add_old_configure_assignment('LLVM_PROFDATA', llvm_profdata)
@depends(c_compiler)
def preprocess_option(compiler):

View File

@ -117,6 +117,16 @@ if not CONFIG['JS_STANDALONE'] or not CONFIG['MOZ_BUILD_APP']:
'build',
]
if CONFIG['PGO_PROFILE_PATH']:
profdata_gen = ('merged.profdata.stub', 'merged.profdata')
GENERATED_FILES += [
profdata_gen
]
GENERATED_FILES[profdata_gen].script = 'build/merge_profdata.py'
GENERATED_FILES[profdata_gen].inputs = [
CONFIG['PGO_PROFILE_PATH'],
]
DIRS += [
'mfbt',
]

View File

@ -1174,6 +1174,7 @@ class GeneratedFile(ContextDerived):
'.rs',
'node.stub', # To avoid VPATH issues with installing node files: https://bugzilla.mozilla.org/show_bug.cgi?id=1461714#c55
'android_apks', # We need to compile Java to generate JNI wrappers for native code compilation to consume.
'.profdata',
)
self.required_for_compile = [f for f in self.outputs if f.endswith(suffixes) or 'stl_wrappers/' in f]