diff --git a/build/moz.configure/pgo.configure b/build/moz.configure/pgo.configure deleted file mode 100644 index ff66d44ffb87..000000000000 --- a/build/moz.configure/pgo.configure +++ /dev/null @@ -1,58 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'], - allow_missing=True) - -add_old_configure_assignment('LLVM_PROFDATA', llvm_profdata) - -# PGO -# ============================================================== -js_option('--enable-profile-generate', - help='Build a PGO instrumented binary') - -imply_option('MOZ_PGO', - depends_if('--enable-profile-generate')(lambda _: True)) - -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) - -option('--with-pgo-jarlog', - help='Use the provided jarlog file when packaging during a profile-use ' - 'build', - nargs=1) - -set_config('PGO_JARLOG_PATH', depends_if('--with-pgo-jarlog')(lambda p: p)) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index d016e5b2cbae..240b32ab6db8 100755 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -22,7 +22,6 @@ def developer_options(value): add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options) set_config('DEVELOPER_OPTIONS', developer_options) - # Code optimization # ============================================================== @@ -1482,6 +1481,57 @@ def is_windows(target, host): include('windows.configure', when=is_windows) +# PGO +# ============================================================== +llvm_profdata = check_prog('LLVM_PROFDATA', ['llvm-profdata'], + allow_missing=True) + +add_old_configure_assignment('LLVM_PROFDATA', llvm_profdata) + + +js_option('--enable-profile-generate', + help='Build a PGO instrumented binary') + +imply_option('MOZ_PGO', + depends_if('--enable-profile-generate')(lambda _: True)) + +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)) + + +@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) + +option('--with-pgo-jarlog', + help='Use the provided jarlog file when packaging during a profile-use ' + 'build', + nargs=1) + +set_config('PGO_JARLOG_PATH', depends_if('--with-pgo-jarlog')(lambda p: p)) + # LTO # ============================================================== diff --git a/moz.configure b/moz.configure index db3c7e8c692c..80070d406270 100755 --- a/moz.configure +++ b/moz.configure @@ -119,7 +119,11 @@ def debug_rust(): set_config('MOZ_DEBUG_RUST', debug_rust) set_define('MOZ_DEBUG_RUST', debug_rust) -include('build/moz.configure/pgo.configure') +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))) + include('build/moz.configure/pkg.configure') # Make this assignment here rather than in pkg.configure to avoid # requiring this file in unit tests.