rust: made-to-order rust staticlibs

Whenever any two Rust static libraries are included
as static libraries anywhere in a CC dependency tree, we sometimes
get duplicate symbol errors. To avoid this, we no longer
directly link multiple rust static libs to CC modules.

Instead, we build rust_ffi_rlib modules and produce the actual
static library that gets linked against the CC module based on
that CC module's full list of Rust rlib dependencies.

This introduces a new static_rlibs property for cc modules to
define the rust_ffi_rlib dependencies, which are then used to
generate the module above.

This CL is intended to deprecate rust_ffi_static. It leaves
rust_ffi_static and rust_ffi static variants in place until
the remaining rust_ffi_static declarations and uses can be
removed. In the meantime, rust_ffi_static produces
rust_ffi_rlib variants as well to make the transition easier.

Bug: 254469782
Test: m # with no changes
Test: m libapexsupport # with static_rlibs
Test: m libunwindstack # with static_rlibs
Test: m netsimd # with static_rlibs, no duplicate symbols
Test: m blueprint_tests # New Soong tests

Change-Id: I47e27ac967ef0cad46d398ebf59d8275929ae28a
This commit is contained in:
Ivan Lozano
2024-05-13 21:03:34 -04:00
parent 28ed8f4f83
commit 0a468a4f3b
22 changed files with 643 additions and 127 deletions

View File

@@ -18,6 +18,7 @@ import (
"path/filepath"
"android/soong/android"
"github.com/google/blueprint"
)
@@ -425,6 +426,10 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
validations = append(validations, objs.tidyDepFiles...)
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)
if generatedLib := generateRustStaticlib(ctx, deps.RustRlibDeps); generatedLib != nil {
deps.StaticLibs = append(deps.StaticLibs, generatedLib)
}
// Register link action.
transformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs,
deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true,

View File

@@ -19,6 +19,7 @@ package cc
// functions.
import (
"fmt"
"path/filepath"
"runtime"
"strconv"
@@ -330,6 +331,15 @@ var (
CommandDeps: []string{"$cxxExtractor", "$kytheVnames"},
},
"cFlags")
// Function pointer for producting staticlibs from rlibs. Corresponds to
// rust.TransformRlibstoStaticlib(), initialized in soong-rust (rust/builder.go init())
//
// This is required since soong-rust depends on soong-cc, so soong-cc cannot depend on soong-rust
// without resulting in a circular dependency. Setting this function pointer in soong-rust allows
// soong-cc to call into this particular function.
TransformRlibstoStaticlib (func(ctx android.ModuleContext, mainSrc android.Path, deps []RustRlibDep,
outputFile android.WritablePath) android.Path) = nil
)
func PwdPrefix() string {
@@ -774,6 +784,47 @@ func transformObjToStaticLib(ctx android.ModuleContext,
}
}
// Generate a Rust staticlib from a list of rlibDeps. Returns nil if TransformRlibstoStaticlib is nil or rlibDeps is empty.
func generateRustStaticlib(ctx android.ModuleContext, rlibDeps []RustRlibDep) android.Path {
if TransformRlibstoStaticlib == nil && len(rlibDeps) > 0 {
// This should only be reachable if a module defines static_rlibs and
// soong-rust hasn't been loaded alongside soong-cc (e.g. in soong-cc tests).
panic(fmt.Errorf("TransformRlibstoStaticlib is not set and static_rlibs is defined in %s", ctx.ModuleName()))
} else if len(rlibDeps) == 0 {
return nil
}
output := android.PathForModuleOut(ctx, "generated_rust_staticlib", "lib"+ctx.ModuleName()+"_rust_staticlib.a")
stemFile := output.ReplaceExtension(ctx, "rs")
crateNames := []string{}
// Collect crate names
for _, lib := range rlibDeps {
// Exclude libstd so this can support no_std builds.
if lib.CrateName != "libstd" {
crateNames = append(crateNames, lib.CrateName)
}
}
// Deduplicate any crateNames just to be safe
crateNames = android.FirstUniqueStrings(crateNames)
// Write the source file
android.WriteFileRule(ctx, stemFile, genRustStaticlibSrcFile(crateNames))
return TransformRlibstoStaticlib(ctx, stemFile, rlibDeps, output)
}
func genRustStaticlibSrcFile(crateNames []string) string {
lines := []string{
"// @Soong generated Source",
}
for _, crate := range crateNames {
lines = append(lines, fmt.Sprintf("extern crate %s;", crate))
}
return strings.Join(lines, "\n")
}
// Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries,
// and shared libraries, to a shared library (.so) or dynamic executable
func transformObjToDynamicBinary(ctx android.ModuleContext,

View File

@@ -99,6 +99,7 @@ type Deps struct {
StaticLibs, LateStaticLibs, WholeStaticLibs []string
HeaderLibs []string
RuntimeLibs []string
Rlibs []string
// UnexportedStaticLibs are static libraries that are also passed to -Wl,--exclude-libs= to
// prevent automatically exporting symbols.
@@ -144,6 +145,17 @@ type Deps struct {
LlndkHeaderLibs []string
}
// A struct which to collect flags for rlib dependencies
type RustRlibDep struct {
LibPath android.Path // path to the rlib
LinkDirs []string // flags required for dependency (e.g. -L flags)
CrateName string // crateNames associated with rlibDeps
}
func EqRustRlibDeps(a RustRlibDep, b RustRlibDep) bool {
return a.LibPath == b.LibPath
}
// PathDeps is a struct containing file paths to dependencies of a module.
// It's constructed in depsToPath() by traversing the direct dependencies of the current module.
// It's used to construct flags for various build statements (such as for compiling and linking).
@@ -156,6 +168,8 @@ type PathDeps struct {
SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths
// Paths to .a files
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
// Paths and crateNames for RustStaticLib dependencies
RustRlibDeps []RustRlibDep
// Transitive static library dependencies of static libraries for use in ordering.
TranstiveStaticLibrariesForOrdering *android.DepSet[android.Path]
@@ -184,6 +198,7 @@ type PathDeps struct {
ReexportedFlags []string
ReexportedGeneratedHeaders android.Paths
ReexportedDeps android.Paths
ReexportedRustRlibDeps []RustRlibDep
// Paths to crt*.o files
CrtBegin, CrtEnd android.Paths
@@ -297,6 +312,7 @@ type BaseProperties struct {
AndroidMkSharedLibs []string `blueprint:"mutated"`
AndroidMkStaticLibs []string `blueprint:"mutated"`
AndroidMkRlibs []string `blueprint:"mutated"`
AndroidMkRuntimeLibs []string `blueprint:"mutated"`
AndroidMkWholeStaticLibs []string `blueprint:"mutated"`
AndroidMkHeaderLibs []string `blueprint:"mutated"`
@@ -653,6 +669,7 @@ const (
headerLibraryDependency = iota
sharedLibraryDependency
staticLibraryDependency
rlibLibraryDependency
)
func (k libraryDependencyKind) String() string {
@@ -663,6 +680,8 @@ func (k libraryDependencyKind) String() string {
return "sharedLibraryDependency"
case staticLibraryDependency:
return "staticLibraryDependency"
case rlibLibraryDependency:
return "rlibLibraryDependency"
default:
panic(fmt.Errorf("unknown libraryDependencyKind %d", k))
}
@@ -740,6 +759,11 @@ func (d libraryDependencyTag) static() bool {
return d.Kind == staticLibraryDependency
}
// rlib returns true if the libraryDependencyTag is tagging an rlib dependency.
func (d libraryDependencyTag) rlib() bool {
return d.Kind == rlibLibraryDependency
}
func (d libraryDependencyTag) LicenseAnnotations() []android.LicenseAnnotation {
if d.shared() {
return []android.LicenseAnnotation{android.LicenseAnnotationSharedDependency}
@@ -1108,6 +1132,14 @@ func (c *Module) RustLibraryInterface() bool {
return false
}
func (c *Module) CrateName() string {
panic(fmt.Errorf("CrateName called on non-Rust module: %q", c.BaseModuleName()))
}
func (c *Module) ExportedCrateLinkDirs() []string {
panic(fmt.Errorf("ExportedCrateLinkDirs called on non-Rust module: %q", c.BaseModuleName()))
}
func (c *Module) IsFuzzModule() bool {
if _, ok := c.compiler.(*fuzzBinary); ok {
return true
@@ -2300,6 +2332,7 @@ func (c *Module) deps(ctx DepsContext) Deps {
deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
deps.Rlibs = android.LastUniqueStrings(deps.Rlibs)
deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
@@ -2607,6 +2640,15 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}, depTag, lib)
}
for _, lib := range deps.Rlibs {
depTag := libraryDependencyTag{Kind: rlibLibraryDependency}
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: ""},
{Mutator: "rust_libraries", Variation: "rlib"},
{Mutator: "rust_stdlinkage", Variation: "rlib-std"},
}, depTag, lib)
}
// staticUnwinderDep is treated as staticDep for Q apexes
// so that native libraries/binaries are linked with static unwinder
// because Q libc doesn't have unwinder APIs
@@ -3216,6 +3258,14 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
default:
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
}
case libDepTag.rlib():
rlibDep := RustRlibDep{LibPath: linkFile.Path(), CrateName: ccDep.CrateName(), LinkDirs: ccDep.ExportedCrateLinkDirs()}
depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, rlibDep)
depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, rlibDep)
depPaths.IncludeDirs = append(depPaths.IncludeDirs, depExporterInfo.IncludeDirs...)
depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, depExporterInfo.IncludeDirs...)
case libDepTag.static():
staticLibraryInfo, isStaticLib := android.OtherModuleProvider(ctx, dep, StaticLibraryInfoProvider)
if !isStaticLib {
@@ -3268,6 +3318,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order))
}
}
// We re-export the Rust static_rlibs so rlib dependencies don't need to be redeclared by cc_library_static dependents.
// E.g. libfoo (cc_library_static) depends on libfoo.ffi (a rust_ffi rlib), libbar depending on libfoo shouldn't have to also add libfoo.ffi to static_rlibs.
depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, depExporterInfo.RustRlibDeps...)
depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, depExporterInfo.RustRlibDeps...)
if libDepTag.unexportedSymbols {
depPaths.LdFlags = append(depPaths.LdFlags,
"-Wl,--exclude-libs="+staticLibraryInfo.StaticLibrary.Base())
@@ -3320,6 +3376,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, depExporterInfo.SystemIncludeDirs...)
depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, depExporterInfo.Deps...)
depPaths.Flags = append(depPaths.Flags, depExporterInfo.Flags...)
depPaths.RustRlibDeps = append(depPaths.RustRlibDeps, depExporterInfo.RustRlibDeps...)
// Only re-export RustRlibDeps for cc static libs
if c.static() {
depPaths.ReexportedRustRlibDeps = append(depPaths.ReexportedRustRlibDeps, depExporterInfo.RustRlibDeps...)
}
if libDepTag.reexportFlags {
reexportExporter(depExporterInfo)
@@ -3392,11 +3454,14 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs)
depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs)
depPaths.GeneratedDeps = android.FirstUniquePaths(depPaths.GeneratedDeps)
depPaths.RustRlibDeps = android.FirstUniqueFunc(depPaths.RustRlibDeps, EqRustRlibDeps)
depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs)
depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs)
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)
depPaths.ReexportedGeneratedHeaders = android.FirstUniquePaths(depPaths.ReexportedGeneratedHeaders)
depPaths.ReexportedRustRlibDeps = android.FirstUniqueFunc(depPaths.ReexportedRustRlibDeps, EqRustRlibDeps)
if c.sabi != nil {
c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)

View File

@@ -772,6 +772,9 @@ type RustBindgenClangProperties struct {
// be added to the include path using -I
Local_include_dirs []string `android:"arch_variant,variant_prepend"`
// list of Rust static libraries.
Static_rlibs []string `android:"arch_variant,variant_prepend"`
// list of static libraries that provide headers for this binding.
Static_libs []string `android:"arch_variant,variant_prepend"`

View File

@@ -597,7 +597,7 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) (android.RuleBuilde
ctx.WalkDeps(func(child, parent android.Module) bool {
// If this is a Rust module which is not rust_ffi_shared, we still want to bundle any transitive
// shared dependencies (even for rust_ffi_static)
// shared dependencies (even for rust_ffi_rlib or rust_ffi_static)
if rustmod, ok := child.(LinkableInterface); ok && rustmod.RustLibraryInterface() && !rustmod.Shared() {
if recursed[ctx.OtherModuleName(child)] {
return false

View File

@@ -274,11 +274,12 @@ func LibraryHostSharedFactory() android.Module {
type flagExporter struct {
Properties FlagExporterProperties
dirs android.Paths // Include directories to be included with -I
systemDirs android.Paths // System include directories to be included with -isystem
flags []string // Exported raw flags.
deps android.Paths
headers android.Paths
dirs android.Paths // Include directories to be included with -I
systemDirs android.Paths // System include directories to be included with -isystem
flags []string // Exported raw flags.
deps android.Paths
headers android.Paths
rustRlibDeps []RustRlibDep
}
// exportedIncludes returns the effective include paths for this module and
@@ -339,6 +340,10 @@ func (f *flagExporter) reexportDeps(deps ...android.Path) {
f.deps = append(f.deps, deps...)
}
func (f *flagExporter) reexportRustStaticDeps(deps ...RustRlibDep) {
f.rustRlibDeps = append(f.rustRlibDeps, deps...)
}
// addExportedGeneratedHeaders does nothing but collects generated header files.
// This can be differ to exportedDeps which may contain phony files to minimize ninja.
func (f *flagExporter) addExportedGeneratedHeaders(headers ...android.Path) {
@@ -356,6 +361,8 @@ func (f *flagExporter) setProvider(ctx android.ModuleContext) {
// Used sparingly, for extra files that need to be explicitly exported to dependers,
// or for phony files to minimize ninja.
Deps: f.deps,
// Used for exporting rlib deps of static libraries to dependents.
RustRlibDeps: f.rustRlibDeps,
// For exported generated headers, such as exported aidl headers, proto headers, or
// sysprop headers.
GeneratedHeaders: f.headers,
@@ -1132,9 +1139,14 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
linkerDeps = append(linkerDeps, deps.EarlySharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
if generatedLib := generateRustStaticlib(ctx, deps.RustRlibDeps); generatedLib != nil {
deps.StaticLibs = append(deps.StaticLibs, generatedLib)
}
transformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs,
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile, implicitOutputs, objs.tidyDepFiles)
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin,
deps.CrtEnd, false, builderFlags, outputFile, implicitOutputs, objs.tidyDepFiles)
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
@@ -1594,6 +1606,10 @@ func (library *libraryDecorator) link(ctx ModuleContext,
library.reexportDeps(deps.ReexportedDeps...)
library.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
if library.static() && len(deps.ReexportedRustRlibDeps) > 0 {
library.reexportRustStaticDeps(deps.ReexportedRustRlibDeps...)
}
// Optionally export aidl headers.
if Bool(library.Properties.Aidl.Export_aidl_headers) {
if library.baseCompiler.hasAidl(deps) {
@@ -2121,14 +2137,12 @@ func LinkageMutator(mctx android.BottomUpMutatorContext) {
// Header only
}
} else if library, ok := mctx.Module().(LinkableInterface); ok && library.CcLibraryInterface() {
} else if library, ok := mctx.Module().(LinkableInterface); ok && (library.CcLibraryInterface() || library.RustLibraryInterface()) {
// Non-cc.Modules may need an empty variant for their mutators.
variations := []string{}
if library.NonCcVariants() {
variations = append(variations, "")
}
isLLNDK := false
if m, ok := mctx.Module().(*Module); ok {
isLLNDK = m.IsLlndk()

View File

@@ -73,6 +73,12 @@ type LinkableInterface interface {
// RustLibraryInterface returns true if this is a Rust library module
RustLibraryInterface() bool
// CrateName returns the crateName for a Rust library, panics if not a Rust library.
CrateName() string
// DepFlags returns a slice of Rustc string flags, panics if not a Rust library
ExportedCrateLinkDirs() []string
// BaseModuleName returns the android.ModuleBase.BaseModuleName() value for this module.
BaseModuleName() string
@@ -380,6 +386,7 @@ type FlagExporterInfo struct {
SystemIncludeDirs android.Paths // System include directories to be included with -isystem
Flags []string // Exported raw flags.
Deps android.Paths
RustRlibDeps []RustRlibDep
GeneratedHeaders android.Paths
}

View File

@@ -39,6 +39,9 @@ type BaseLinkerProperties struct {
// the dependency's .a file will be linked into this module using -Wl,--whole-archive.
Whole_static_libs []string `android:"arch_variant,variant_prepend"`
// list of Rust libs that should be statically linked into this module.
Static_rlibs []string `android:"arch_variant"`
// list of modules that should be statically linked into this module.
Static_libs []string `android:"arch_variant,variant_prepend"`
@@ -116,10 +119,14 @@ type BaseLinkerProperties struct {
// product variant of the C/C++ module.
Static_libs []string
// list of ehader libs that only should be used to build vendor or product
// list of header libs that only should be used to build vendor or product
// variant of the C/C++ module.
Header_libs []string
// list of Rust libs that should be statically linked to build vendor or product
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build vendor or
// product variant of the C/C++ module.
Exclude_shared_libs []string
@@ -148,6 +155,10 @@ type BaseLinkerProperties struct {
// variant of the C/C++ module.
Static_libs []string
// list of Rust libs that should be statically linked to build the recovery
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build
// the recovery variant of the C/C++ module.
Exclude_shared_libs []string
@@ -165,10 +176,14 @@ type BaseLinkerProperties struct {
Exclude_runtime_libs []string
}
Ramdisk struct {
// list of static libs that only should be used to build the recovery
// list of static libs that only should be used to build the ramdisk
// variant of the C/C++ module.
Static_libs []string
// list of Rust libs that should be statically linked to build the ramdisk
// variant.
Static_rlibs []string
// list of shared libs that should not be used to build
// the ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
@@ -183,9 +198,13 @@ type BaseLinkerProperties struct {
}
Vendor_ramdisk struct {
// list of shared libs that should not be used to build
// the recovery variant of the C/C++ module.
// the vendor ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
// list of Rust libs that should be statically linked to build the vendor ramdisk
// variant.
Static_rlibs []string
// list of static libs that should not be used to build
// the vendor ramdisk variant of the C/C++ module.
Exclude_static_libs []string
@@ -201,6 +220,10 @@ type BaseLinkerProperties struct {
// variants.
Shared_libs []string
// list of Rust libs that should be statically linked to build the vendor ramdisk
// variant.
Static_rlibs []string
// list of ehader libs that only should be used to build platform variant of
// the C/C++ module.
Header_libs []string
@@ -291,6 +314,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.WholeStaticLibs = append(deps.WholeStaticLibs, linker.Properties.Whole_static_libs...)
deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Header_libs...)
deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Static_libs...)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Static_rlibs...)
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Shared_libs...)
deps.RuntimeLibs = append(deps.RuntimeLibs, linker.Properties.Runtime_libs...)
@@ -333,6 +357,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Vendor.Static_rlibs...)
}
if ctx.inProduct() {
@@ -345,6 +370,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Product.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Product.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Product.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Product.Static_rlibs...)
}
if ctx.inRecovery() {
@@ -358,6 +384,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Recovery.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Recovery.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Recovery.Static_rlibs...)
}
if ctx.inRamdisk() {
@@ -368,6 +395,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Ramdisk.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Ramdisk.Static_rlibs...)
}
if ctx.inVendorRamdisk() {
@@ -377,6 +405,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor_ramdisk.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor_ramdisk.Exclude_runtime_libs)
deps.Rlibs = append(deps.Rlibs, linker.Properties.Target.Vendor_ramdisk.Static_rlibs...)
}
if !ctx.useSdk() {

View File

@@ -299,6 +299,7 @@ func commonDefaultModules() string {
system_shared_libs: [],
stl: "none",
vendor_available: true,
vendor_ramdisk_available: true,
product_available: true,
recovery_available: true,
host_supported: true,
@@ -570,17 +571,17 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
// Additional files needed in tests that disallow non-existent source.
android.MockFS{
"defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.map.txt": nil,
"defaults/cc/common/libft2.map.txt": nil,
"defaults/cc/common/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil,
"defaults/cc/common/crtbegin.c": nil,
"defaults/cc/common/crtend_so.c": nil,
"defaults/cc/common/crtend.c": nil,
"defaults/cc/common/crtbrand.c": nil,
"external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil,
"defaults/cc/common/libc.map.txt": nil,
"defaults/cc/common/libdl.map.txt": nil,
"defaults/cc/common/libft2.map.txt": nil,
"defaults/cc/common/libm.map.txt": nil,
"defaults/cc/common/ndk_libc++_shared": nil,
"defaults/cc/common/crtbegin_so.c": nil,
"defaults/cc/common/crtbegin.c": nil,
"defaults/cc/common/crtend_so.c": nil,
"defaults/cc/common/crtend.c": nil,
"defaults/cc/common/crtbrand.c": nil,
"external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil,
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil,
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a": nil,