Build against cfi supported coverage lib

The change will detect if a module is compiled against cfi support, and
will usebuild the coverage build against the libprofile that supports cfi. This is to resolve compilation errors when
building against modules with cfi support.
Bug: 177098919
Test: forrest build for cf_x86_phone-userdebug_coverage http://go/forrest-run/L81700000786828933

Change-Id: I8e0421cdf1c6e499292cfa3457cefd3c42f13155
Merged-In: I8e0421cdf1c6e499292cfa3457cefd3c42f13155
This commit is contained in:
Cindy Zhou 2021-01-09 08:25:22 -08:00
parent 193ac2eb96
commit 5d5cfc164d
2 changed files with 12 additions and 0 deletions

View file

@ -456,6 +456,7 @@ type ModuleContextIntf interface {
nativeCoverage() bool
directlyInAnyApex() bool
isPreventInstall() bool
isCfiAssemblySupportEnabled() bool
}
type ModuleContext interface {
@ -1230,6 +1231,11 @@ func (c *Module) XrefCcFiles() android.Paths {
return c.kytheFiles
}
func (c *Module) isCfiAssemblySupportEnabled() bool {
return c.sanitize != nil &&
Bool(c.sanitize.Properties.Sanitize.Config.Cfi_assembly_support)
}
type baseModuleContext struct {
android.BaseModuleContext
moduleContextImpl
@ -1395,6 +1401,10 @@ func (ctx *moduleContextImpl) isPreventInstall() bool {
return ctx.mod.Properties.PreventInstall
}
func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool {
return ctx.mod.isCfiAssemblySupportEnabled()
}
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,

View file

@ -58,6 +58,8 @@ func getGcovProfileLibraryName(ctx ModuleContextIntf) string {
func getClangProfileLibraryName(ctx ModuleContextIntf) string {
if ctx.useSdk() {
return "libprofile-clang-extras_ndk"
} else if ctx.isCfiAssemblySupportEnabled() {
return "libprofile-clang-extras_cfi_support"
} else {
return "libprofile-clang-extras"
}