diff --git a/Cargo.toml b/Cargo.toml index 67ac11dc26..32b18bc1d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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. diff --git a/infra/README.recipes.md b/infra/README.recipes.md index 44a9705fdc..5eb6f76c65 100644 --- a/infra/README.recipes.md +++ b/infra/README.recipes.md @@ -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] -— **def [RunSteps](/infra/recipes/build_linux.py#73)(api, properties):** +— **def [RunSteps](/infra/recipes/build_linux.py#74)(api, properties):** — **def [collect\_binary\_sizes](/infra/recipes/build_linux.py#24)(api, properties):** ### *recipes* / [build\_windows](/infra/recipes/build_windows.py) diff --git a/infra/recipes/build_linux.expected/build_x86_64.json b/infra/recipes/build_linux.expected/build_x86_64.json index 0fefa5a32e..fd0d46c99a 100644 --- a/infra/recipes/build_linux.expected/build_x86_64.json +++ b/infra/recipes/build_linux.expected/build_x86_64.json @@ -95,7 +95,8 @@ "./tools/build_release", "--json", "--platform=x86_64", - "--strip" + "--profile", + "chromeos" ], "cwd": "[CACHE]/builder/crosvm", "env": { diff --git a/infra/recipes/build_linux.py b/infra/recipes/build_linux.py index 820fc5ebed..c255b81b57 100644 --- a/infra/recipes/build_linux.py +++ b/infra/recipes/build_linux.py @@ -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), ) diff --git a/tools/build_release b/tools/build_release index 4c87745025..8b4c1d828e 100755 --- a/tools/build_release +++ b/tools/build_release @@ -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",