diff options
author | Yu Liu <yudiliu@google.com> | 2024-04-18 19:35:34 +0000 |
---|---|---|
committer | Yu Liu <yudiliu@google.com> | 2024-04-18 19:35:34 +0000 |
commit | f0cf1cce985d7f35b8dc90013c94b9058664ab78 (patch) | |
tree | 92f1aae1460d5e35f7c9af1e2692da5016dd469c | |
parent | 17b9a5b8b401c1175eb7b3d4d59882adccf8f425 (diff) | |
download | soong-f0cf1cce985d7f35b8dc90013c94b9058664ab78.tar.gz |
Only link the profile extras lib for device variant for rust.
Bug: 297082598
Test: CI
Change-Id: Id66ce88d8c8a757c53ecb7ba0d101511d81eb911
-rw-r--r-- | rust/coverage.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/rust/coverage.go b/rust/coverage.go index bc6504ddc..91a78060d 100644 --- a/rust/coverage.go +++ b/rust/coverage.go @@ -39,9 +39,11 @@ func (cov *coverage) props() []interface{} { func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { if cov.Properties.NeedCoverageVariant { - ctx.AddVariationDependencies([]blueprint.Variation{ - {Mutator: "link", Variation: "static"}, - }, cc.CoverageDepTag, CovLibraryName) + if ctx.Device() { + ctx.AddVariationDependencies([]blueprint.Variation{ + {Mutator: "link", Variation: "static"}, + }, cc.CoverageDepTag, CovLibraryName) + } // no_std modules are missing libprofiler_builtins which provides coverage, so we need to add it as a dependency. if rustModule, ok := ctx.Module().(*Module); ok && rustModule.compiler.noStdlibs() { @@ -60,12 +62,14 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags if cov.Properties.CoverageEnabled { flags.Coverage = true - coverage := ctx.GetDirectDepWithTag(CovLibraryName, cc.CoverageDepTag).(cc.LinkableInterface) flags.RustFlags = append(flags.RustFlags, "-C instrument-coverage", "-g") - flags.LinkFlags = append(flags.LinkFlags, - profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") - deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path()) + if ctx.Device() { + coverage := ctx.GetDirectDepWithTag(CovLibraryName, cc.CoverageDepTag).(cc.LinkableInterface) + flags.LinkFlags = append(flags.LinkFlags, + profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") + deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path()) + } // no_std modules are missing libprofiler_builtins which provides coverage, so we need to add it as a dependency. if rustModule, ok := ctx.Module().(*Module); ok && rustModule.compiler.noStdlibs() { |