[pgo] Sampling PGO does not require benchmark property
Test: build with Sampling PGO
Bug: 79161490
Change-Id: I70bb8dc2e4492d6a3713ca16fcb3f1216615f8ac
diff --git a/cc/pgo.go b/cc/pgo.go
index 9298e7a..42bc5d2 100644
--- a/cc/pgo.go
+++ b/cc/pgo.go
@@ -199,8 +199,8 @@
return false
}
- // If at least one property exists, validate that all properties exist
- if !profileKindPresent || !filePresent || !benchmarksPresent {
+ // profileKindPresent and filePresent are mandatory properties.
+ if !profileKindPresent || !filePresent {
var missing []string
if !profileKindPresent {
missing = append(missing, "profile kind (either \"instrumentation\" or \"sampling\" property)")
@@ -208,13 +208,15 @@
if !filePresent {
missing = append(missing, "profile_file property")
}
- if !benchmarksPresent {
- missing = append(missing, "non-empty benchmarks property")
- }
missingProps := strings.Join(missing, ", ")
ctx.ModuleErrorf("PGO specification is missing properties: " + missingProps)
}
+ // Benchmark property is mandatory for instrumentation PGO.
+ if isInstrumentation && !benchmarksPresent {
+ ctx.ModuleErrorf("Instrumentation PGO specification is missing benchmark property")
+ }
+
if isSampling && isInstrumentation {
ctx.PropertyErrorf("pgo", "Exactly one of \"instrumentation\" and \"sampling\" properties must be set")
}