From 92474e5b8ff49a62d80d83a2a660f9f99fde7af1 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Thu, 16 Jan 2020 17:04:38 -0800 Subject: [PATCH] Add "-no-warn-sample-unuse=true" to work around AutoFDO issue Autofdo generates profile for an instruction even if there is no debug information associated with it or no debug information associated with the function. A bogus offset will be produced in the profile. Add the flag to suppress Clang from generating error for such cases. Test: build with ETM profile Bug: 147844018 Bug: 79161490 Change-Id: I37da1ba3a4962072ccdf01f79fbf2c2b4c77b56b --- cc/pgo.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cc/pgo.go b/cc/pgo.go index 0072355fb..e341d039a 100644 --- a/cc/pgo.go +++ b/cc/pgo.go @@ -177,6 +177,10 @@ func (props *PgoProperties) addProfileUseFlags(ctx ModuleContext, flags Flags) F // if profileFile gets updated flags.CFlagsDeps = append(flags.CFlagsDeps, profileFilePath) flags.LdFlagsDeps = append(flags.LdFlagsDeps, profileFilePath) + + if props.isSampling() { + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,-no-warn-sample-unused=true") + } } return flags }