From cf7c1322a38653e68b69a25309fe445b88c13b42 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Wed, 5 Feb 2025 21:19:24 +0000 Subject: rust: Use libprofile-clang-extras_ndk for SDK cov Bug: 203478530 Test: m & m rust Change-Id: I902cfb761794debf52e6443c44c409593c389292 --- rust/coverage.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'rust/coverage.go') diff --git a/rust/coverage.go b/rust/coverage.go index ae95e46b1..798b21d78 100644 --- a/rust/coverage.go +++ b/rust/coverage.go @@ -16,12 +16,12 @@ package rust import ( "android/soong/android" + "github.com/google/blueprint" "android/soong/cc" ) -var CovLibraryName = "libprofile-clang-extras" var ProfilerBuiltins = "libprofiler_builtins.rust_sysroot" // Add '%c' to default specifier after we resolve http://b/210012154 @@ -38,12 +38,20 @@ func (cov *coverage) props() []interface{} { return []interface{}{&cov.Properties} } +func getClangProfileLibraryName(ctx ModuleContextIntf) string { + if ctx.RustModule().UseSdk() { + return "libprofile-clang-extras_ndk" + } else { + return "libprofile-clang-extras" + } +} + func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { if cov.Properties.NeedCoverageVariant { if ctx.Device() { ctx.AddVariationDependencies([]blueprint.Variation{ {Mutator: "link", Variation: "static"}, - }, cc.CoverageDepTag, CovLibraryName) + }, cc.CoverageDepTag, getClangProfileLibraryName(ctx)) } // no_std modules are missing libprofiler_builtins which provides coverage, so we need to add it as a dependency. @@ -66,7 +74,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.RustFlags = append(flags.RustFlags, "-C instrument-coverage", "-g") if ctx.Device() { - m := ctx.GetDirectDepProxyWithTag(CovLibraryName, cc.CoverageDepTag) + m := ctx.GetDirectDepProxyWithTag(getClangProfileLibraryName(ctx), cc.CoverageDepTag) coverage := android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider) flags.LinkFlags = append(flags.LinkFlags, profileInstrFlag, "-g", coverage.OutputFile.Path().String(), "-Wl,--wrap,open") -- cgit v1.2.3-59-g8ed1b