crosvm: Add more release build profiles

Add codegen-units=1 build profile to further reduce binary size
and potentially improve performance.
tools/build_release is updated to allow choice of build profiles.
To keep binary size measurement trend consistent, release build
recipe is running with chromeos profile.

crosvm size of different profiles at current cl:
relase profile (w/o strip symbols) 24192680,
chromeos profile (strip symbols from release) 15088272,
lto profile (fat lto & strip symbols) 14326144,
largecodegen profile (codegen-units=1 w/ fat lto) 13764896

TEST=./tools/build_release --profile largecodegen

BUG=b:181105093

Change-Id: I057ddfce3e78aa4dfe6b4810f4bcb1f13b954bb4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5027712
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Zihan Chen 2023-11-14 18:43:04 -08:00 committed by crosvm LUCI
parent f4c1624319
commit 0c57e655ed
5 changed files with 15 additions and 4 deletions

View file

@ -28,6 +28,11 @@ strip = "symbols"
inherits = "chromeos"
lto = true
# Set codegen units to 1 to further reduce binary size.
[profile.largecodegen]
inherits = "lto"
codegen-units = 1
[workspace]
# Explicitly list all crates of crosvm as workspace members since not all of them may be referenced
# by dependencies.

View file

@ -122,7 +122,7 @@ This recipe requires ambient luci authentication. To test locally run:
[DEPS](/infra/recipes/build_linux.py#11): [crosvm](#recipe_modules-crosvm), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step]
&mdash; **def [RunSteps](/infra/recipes/build_linux.py#73)(api, properties):**
&mdash; **def [RunSteps](/infra/recipes/build_linux.py#74)(api, properties):**
&mdash; **def [collect\_binary\_sizes](/infra/recipes/build_linux.py#24)(api, properties):**
### *recipes* / [build\_windows](/infra/recipes/build_windows.py)

View file

@ -95,7 +95,8 @@
"./tools/build_release",
"--json",
"--platform=x86_64",
"--strip"
"--profile",
"chromeos"
],
"cwd": "[CACHE]/builder/crosvm",
"env": {

View file

@ -28,7 +28,8 @@ def collect_binary_sizes(api, properties):
"./tools/build_release",
"--json",
"--platform=" + str(properties.test_arch),
"--strip",
"--profile",
"chromeos",
],
stdout=api.raw_io.output_text(name="Obtain release build output", add_output_log=True),
)

View file

@ -135,6 +135,9 @@ def main():
help="Output in JSON instead of human readable format.",
)
parser.add_argument("--strip", action="store_true", help="Strip output binaries")
parser.add_argument(
"--build-profile", help="Select compile profile, default to release.", default="release"
)
pgo_group = parser.add_mutually_exclusive_group()
pgo_group.add_argument(
"--profile-generate",
@ -167,7 +170,8 @@ def main():
features = build_target.feature_flag
cargo_args = [
"--release",
"--profile",
args.build_profile,
"--features=" + features,
f"--target={build_target}",
"--workspace",