Merge "rust: Add whole_static_libs, revert static_lib"
This commit is contained in:
37
rust/rust.go
37
rust/rust.go
@@ -273,14 +273,15 @@ func (mod *Module) SplitPerApiLevel() bool {
|
||||
}
|
||||
|
||||
type Deps struct {
|
||||
Dylibs []string
|
||||
Rlibs []string
|
||||
Rustlibs []string
|
||||
Stdlibs []string
|
||||
ProcMacros []string
|
||||
SharedLibs []string
|
||||
StaticLibs []string
|
||||
HeaderLibs []string
|
||||
Dylibs []string
|
||||
Rlibs []string
|
||||
Rustlibs []string
|
||||
Stdlibs []string
|
||||
ProcMacros []string
|
||||
SharedLibs []string
|
||||
StaticLibs []string
|
||||
WholeStaticLibs []string
|
||||
HeaderLibs []string
|
||||
|
||||
CrtBegin, CrtEnd string
|
||||
}
|
||||
@@ -755,7 +756,7 @@ func (mod *Module) deps(ctx DepsContext) Deps {
|
||||
deps.ProcMacros = android.LastUniqueStrings(deps.ProcMacros)
|
||||
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
|
||||
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
|
||||
|
||||
deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
|
||||
return deps
|
||||
|
||||
}
|
||||
@@ -915,16 +916,13 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
||||
exportDep := false
|
||||
switch {
|
||||
case cc.IsStaticDepTag(depTag):
|
||||
// Only pass -lstatic for rlibs as it results in dylib bloat.
|
||||
if lib, ok := ctx.Module().(*Module).compiler.(libraryInterface); ok && lib.rlib() {
|
||||
// Link cc static libraries using "-lstatic" so rustc can reason about how to handle these
|
||||
// (for example, bundling them into rlibs).
|
||||
//
|
||||
// rustc does not support linking libraries with the "-l" flag unless they are prefixed by "lib".
|
||||
// If we need to link a library that isn't prefixed by "lib", we'll just link to it directly through
|
||||
// linkObjects; such a library may need to be redeclared by static dependents.
|
||||
if cc.IsWholeStaticLib(depTag) {
|
||||
// rustc will bundle static libraries when they're passed with "-lstatic=<lib>". This will fail
|
||||
// if the library is not prefixed by "lib".
|
||||
if libName, ok := libNameFromFilePath(linkObject.Path()); ok {
|
||||
depPaths.depFlags = append(depPaths.depFlags, "-lstatic="+libName)
|
||||
} else {
|
||||
ctx.ModuleErrorf("'%q' cannot be listed as a whole_static_library in Rust modules unless the output is prefixed by 'lib'", depName, ctx.ModuleName())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1103,7 +1101,10 @@ func (mod *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
cc.SharedDepTag(), deps.SharedLibs...)
|
||||
actx.AddVariationDependencies(append(commonDepVariations,
|
||||
blueprint.Variation{Mutator: "link", Variation: "static"}),
|
||||
cc.StaticDepTag(), deps.StaticLibs...)
|
||||
cc.StaticDepTag(false), deps.StaticLibs...)
|
||||
actx.AddVariationDependencies(append(commonDepVariations,
|
||||
blueprint.Variation{Mutator: "link", Variation: "static"}),
|
||||
cc.StaticDepTag(true), deps.WholeStaticLibs...)
|
||||
|
||||
actx.AddVariationDependencies(nil, cc.HeaderDepTag(), deps.HeaderLibs...)
|
||||
|
||||
|
Reference in New Issue
Block a user