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
diff --git a/cc/cc.go b/cc/cc.go
index ca2bd4f..7fa3840 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -456,6 +456,7 @@
nativeCoverage() bool
directlyInAnyApex() bool
isPreventInstall() bool
+ isCfiAssemblySupportEnabled() bool
}
type ModuleContext interface {
@@ -1230,6 +1231,11 @@
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 @@
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 acf98dd..5b5ccf2 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -58,6 +58,8 @@
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"
}