From b6e6f99521cee714c066fa33369d8d38f5cca17a Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 17 Aug 2023 17:42:26 -0700 Subject: Add transitive shared libs to LOCAL_SHARED_LIBRARIES for rust modules Rust modules are different from C++ modules in that they will install their transitive shared libs alongside a binary. C++ modules don't do this, you have to install the transitive shared lib manually. (but they do install direct shared libs) It does this by using InstallDepNeeded, a mechanism that adds dependencies from installed files to the installed copies of dependencies if InstallDepNeeded() returns true. This mechanism does not end up tracking the installed files all the way to FULL_SYSTEMIMAGE_DEPS. We're attempting to make FULL_SYSTEMIMAGE_DEPS more accurate so that we can track the files that should be installed properly, and remove the need for `m installclean`. Listing the libraries a binary uses in LOCAL_SHARED_LIBRARIES does properly track them and end up listing them in FULL_SYSTEMIMAGE_DEPS. Bug: 205632228 Test: Building the systemimage with a change to delete anything not in FULL_SYSTEMIMAGE_DEPS Change-Id: I4ba75b40b3ac77250297209a851bc9ba377782f5 --- rust/rust.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'rust/rust.go') diff --git a/rust/rust.go b/rust/rust.go index dab35323a..fe5b30317 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -66,7 +66,6 @@ type BaseProperties struct { AndroidMkRlibs []string `blueprint:"mutated"` AndroidMkDylibs []string `blueprint:"mutated"` AndroidMkProcMacroLibs []string `blueprint:"mutated"` - AndroidMkSharedLibs []string `blueprint:"mutated"` AndroidMkStaticLibs []string `blueprint:"mutated"` ImageVariationPrefix string `blueprint:"mutated"` @@ -168,6 +167,8 @@ type Module struct { // For apex variants, this is set as apex.min_sdk_version apexSdkVersion android.ApiLevel + + transitiveAndroidMkSharedLibs *android.DepSet[string] } func (mod *Module) Header() bool { @@ -1217,6 +1218,9 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { }) } + var transitiveAndroidMkSharedLibs []*android.DepSet[string] + var directAndroidMkSharedLibs []string + ctx.VisitDirectDeps(func(dep android.Module) { depName := ctx.OtherModuleName(dep) depTag := ctx.OtherModuleDependencyTag(dep) @@ -1255,6 +1259,8 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { mod.Properties.AndroidMkProcMacroLibs = append(mod.Properties.AndroidMkProcMacroLibs, makeLibName) } + transitiveAndroidMkSharedLibs = append(transitiveAndroidMkSharedLibs, rustDep.transitiveAndroidMkSharedLibs) + if android.IsSourceDepTagWithOutputTag(depTag, "") { // Since these deps are added in path_properties.go via AddDependencies, we need to ensure the correct // OS/Arch variant is used. @@ -1382,7 +1388,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // Record baseLibName for snapshots. mod.Properties.SnapshotSharedLibs = append(mod.Properties.SnapshotSharedLibs, cc.BaseLibName(depName)) - mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, makeLibName) + directAndroidMkSharedLibs = append(directAndroidMkSharedLibs, makeLibName) exportDep = true case cc.IsHeaderDepTag(depTag): exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo) @@ -1419,6 +1425,8 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } }) + mod.transitiveAndroidMkSharedLibs = android.NewDepSet[string](android.PREORDER, directAndroidMkSharedLibs, transitiveAndroidMkSharedLibs) + var rlibDepFiles RustLibraries for _, dep := range directRlibDeps { rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.UnstrippedOutputFile(), CrateName: dep.CrateName()}) -- cgit v1.2.3-59-g8ed1b