Cargo.toml: add "chromeos" and "lto" build profiles

Add a "chromeos" profile that mimics the flags used when compiling for
Chrome OS. This is useful to determine how much the crosvm binary will
inflate due to a given CL.

Also add an "lto" profile enabling LTO on top of the "chromeos" profile,
so we can easily see how much space we save by enabling LTO.

BUG=b:218473401
BUG=b:218566754
TEST=cargo build --profile chromeos
TEST=cargo build --profile lto

Change-Id: I2fd743b6c980b847af1f3db593a55b683cbb8d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450026
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
Alexandre Courbot 2022-02-08 18:44:10 +09:00 committed by Commit Bot
parent 12ae5e8bc8
commit 4da0e52ba5

View file

@ -21,6 +21,16 @@ required-features = [ "direct" ]
panic = 'abort'
overflow-checks = true
# Reproduces the options used when building crosvm for Chrome OS.
[profile.chromeos]
inherits = "release"
opt-level = "s"
# Enables LTO to further reduce the size of the binary.
[profile.lto]
inherits = "chromeos"
lto = true
# We currently need to exclude some crates from the workspace to allow
# these crates to be independently built by portage. These crates will
# eventually be moved into separate repositories.