From 5d5cfc164d33f0c4a8409dcf3f161d746192929b Mon Sep 17 00:00:00 2001 From: Cindy Zhou Date: Sat, 9 Jan 2021 08:25:22 -0800 Subject: [PATCH] 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 --- cc/cc.go | 10 ++++++++++ cc/coverage.go | 2 ++ 2 files changed, 12 insertions(+) diff --git a/cc/cc.go b/cc/cc.go index ca2bd4fd4..7fa3840a2 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -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, diff --git a/cc/coverage.go b/cc/coverage.go index acf98ddcf..5b5ccf2f0 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -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" }