Merge "Apply system_shared_libs to static libraries"
am: 6f3e24ab55
Change-Id: I67b4841cf66fd01528e542334a28734c6aa0c8dd
This commit is contained in:
@@ -36,6 +36,7 @@ type LibraryProperties struct {
|
||||
Whole_static_libs []string `android:"arch_variant"`
|
||||
Static_libs []string `android:"arch_variant"`
|
||||
Shared_libs []string `android:"arch_variant"`
|
||||
System_shared_libs []string `android:"arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
Shared struct {
|
||||
Srcs []string `android:"arch_variant"`
|
||||
@@ -45,6 +46,7 @@ type LibraryProperties struct {
|
||||
Whole_static_libs []string `android:"arch_variant"`
|
||||
Static_libs []string `android:"arch_variant"`
|
||||
Shared_libs []string `android:"arch_variant"`
|
||||
System_shared_libs []string `android:"arch_variant"`
|
||||
} `android:"arch_variant"`
|
||||
|
||||
// local file name to pass to the linker as -unexported_symbols_list
|
||||
@@ -488,6 +490,16 @@ func (library *libraryDecorator) linkerInit(ctx BaseModuleContext) {
|
||||
}
|
||||
|
||||
func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
if library.static() {
|
||||
if library.Properties.Static.System_shared_libs != nil {
|
||||
library.baseLinker.Properties.System_shared_libs = library.Properties.Static.System_shared_libs
|
||||
}
|
||||
} else if library.shared() {
|
||||
if library.Properties.Shared.System_shared_libs != nil {
|
||||
library.baseLinker.Properties.System_shared_libs = library.Properties.Shared.System_shared_libs
|
||||
}
|
||||
}
|
||||
|
||||
deps = library.baseLinker.linkerDeps(ctx, deps)
|
||||
|
||||
if library.static() {
|
||||
@@ -921,8 +933,19 @@ func NewLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator)
|
||||
func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Module) {
|
||||
if staticCompiler, ok := static.compiler.(*libraryDecorator); ok {
|
||||
sharedCompiler := shared.compiler.(*libraryDecorator)
|
||||
|
||||
// Check libraries in addition to cflags, since libraries may be exporting different
|
||||
// include directories.
|
||||
if len(staticCompiler.Properties.Static.Cflags) == 0 &&
|
||||
len(sharedCompiler.Properties.Shared.Cflags) == 0 {
|
||||
len(sharedCompiler.Properties.Shared.Cflags) == 0 &&
|
||||
len(staticCompiler.Properties.Static.Whole_static_libs) == 0 &&
|
||||
len(sharedCompiler.Properties.Shared.Whole_static_libs) == 0 &&
|
||||
len(staticCompiler.Properties.Static.Static_libs) == 0 &&
|
||||
len(sharedCompiler.Properties.Shared.Static_libs) == 0 &&
|
||||
len(staticCompiler.Properties.Static.Shared_libs) == 0 &&
|
||||
len(sharedCompiler.Properties.Shared.Shared_libs) == 0 &&
|
||||
staticCompiler.Properties.Static.System_shared_libs == nil &&
|
||||
sharedCompiler.Properties.Shared.System_shared_libs == nil {
|
||||
|
||||
mctx.AddInterVariantDependency(reuseObjTag, shared, static)
|
||||
sharedCompiler.baseCompiler.Properties.OriginalSrcs =
|
||||
|
13
cc/linker.go
13
cc/linker.go
@@ -49,7 +49,7 @@ type BaseLinkerProperties struct {
|
||||
// list of system libraries that will be dynamically linked to
|
||||
// shared library and executable modules. If unset, generally defaults to libc,
|
||||
// libm, and libdl. Set to [] to prevent linking against the defaults.
|
||||
System_shared_libs []string
|
||||
System_shared_libs []string `android:"arch_variant"`
|
||||
|
||||
// allow the module to contain undefined symbols. By default,
|
||||
// modules cannot contain undefined symbols that are not satisified by their immediate
|
||||
@@ -237,8 +237,10 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
deps.LateStaticLibs = append(deps.LateStaticLibs, "libgcc")
|
||||
}
|
||||
|
||||
if !ctx.static() {
|
||||
systemSharedLibs := linker.Properties.System_shared_libs
|
||||
var systemSharedLibs []string
|
||||
if !ctx.useSdk() && !ctx.useVndk() {
|
||||
systemSharedLibs = linker.Properties.System_shared_libs
|
||||
}
|
||||
if systemSharedLibs == nil {
|
||||
systemSharedLibs = []string{"libc", "libm", "libdl"}
|
||||
}
|
||||
@@ -255,7 +257,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
}
|
||||
}
|
||||
|
||||
// If libc and libdl are both in system_shared_libs make sure libd comes after libc
|
||||
// If libc and libdl are both in system_shared_libs make sure libdl comes after libc
|
||||
// to avoid loading libdl before libc.
|
||||
if inList("libdl", systemSharedLibs) && inList("libc", systemSharedLibs) &&
|
||||
indexList("libdl", systemSharedLibs) < indexList("libc", systemSharedLibs) {
|
||||
@@ -263,9 +265,6 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||
}
|
||||
|
||||
deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...)
|
||||
} else if ctx.useSdk() || ctx.useVndk() {
|
||||
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.Windows() {
|
||||
|
Reference in New Issue
Block a user