Merge "Remove default_shared_libs" am: 2231f8a21c am: 0cddfa441d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1775072

Change-Id: Id3f0baada1ba1fdb209fdd24569ecbbf3fe99722
This commit is contained in:
Treehugger Robot
2021-07-23 21:28:09 +00:00
committed by Automerger Merge Worker
8 changed files with 37 additions and 232 deletions

View File

@@ -554,8 +554,7 @@ type specifiedDeps struct {
sharedLibs []string
// Note nil and [] are semantically distinct. [] prevents linking against the defaults (usually
// libc, libm, etc.)
systemSharedLibs []string
defaultSharedLibs []string
systemSharedLibs []string
}
// installer is the interface for an installer helper object. This helper is responsible for

View File

@@ -147,12 +147,11 @@ type StaticOrSharedProperties struct {
Cflags []string `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
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"`
Default_shared_libs []string `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
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"`
Export_shared_lib_headers []string `android:"arch_variant"`
Export_static_lib_headers []string `android:"arch_variant"`
@@ -1163,17 +1162,11 @@ func (library *libraryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
if library.StaticProperties.Static.System_shared_libs != nil {
library.baseLinker.Properties.System_shared_libs = library.StaticProperties.Static.System_shared_libs
}
if library.StaticProperties.Static.Default_shared_libs != nil {
library.baseLinker.Properties.Default_shared_libs = library.StaticProperties.Static.Default_shared_libs
}
} else if library.shared() {
// Compare with nil because an empty list needs to be propagated.
if library.SharedProperties.Shared.System_shared_libs != nil {
library.baseLinker.Properties.System_shared_libs = library.SharedProperties.Shared.System_shared_libs
}
if library.SharedProperties.Shared.Default_shared_libs != nil {
library.baseLinker.Properties.Default_shared_libs = library.SharedProperties.Shared.Default_shared_libs
}
}
deps = library.baseLinker.linkerDeps(ctx, deps)
@@ -1255,11 +1248,6 @@ func (library *libraryDecorator) linkerSpecifiedDeps(specifiedDeps specifiedDeps
} else {
specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, properties.System_shared_libs...)
}
if specifiedDeps.defaultSharedLibs == nil {
specifiedDeps.defaultSharedLibs = properties.Default_shared_libs
} else {
specifiedDeps.defaultSharedLibs = append(specifiedDeps.defaultSharedLibs, properties.Default_shared_libs...)
}
specifiedDeps.sharedLibs = android.FirstUniqueStrings(specifiedDeps.sharedLibs)
if len(specifiedDeps.systemSharedLibs) > 0 {
@@ -1267,11 +1255,6 @@ func (library *libraryDecorator) linkerSpecifiedDeps(specifiedDeps specifiedDeps
// retained.
specifiedDeps.systemSharedLibs = android.FirstUniqueStrings(specifiedDeps.systemSharedLibs)
}
if len(specifiedDeps.defaultSharedLibs) > 0 {
// Skip this if defaultSharedLibs is either nil or [], to ensure they are
// retained.
specifiedDeps.defaultSharedLibs = android.FirstUniqueStrings(specifiedDeps.defaultSharedLibs)
}
return specifiedDeps
}

View File

@@ -258,12 +258,6 @@ func addPossiblyArchSpecificProperties(sdkModuleContext android.ModuleContext, b
outputProperties.AddPropertyWithTag("system_shared_libs", libInfo.SystemSharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
// SystemSharedLibs needs to be propagated if it's a list, even if it's empty,
// so check for non-nil instead of nonzero length.
if libInfo.DefaultSharedLibs != nil {
outputProperties.AddPropertyWithTag("default_shared_libs", libInfo.DefaultSharedLibs, builder.SdkMemberReferencePropertyTag(false))
}
// Map from property name to the include dirs to add to the prebuilt module in the snapshot.
includeDirs := make(map[string][]string)
@@ -393,12 +387,6 @@ type nativeLibInfoProperties struct {
// This field is exported as its contents may not be arch specific.
SystemSharedLibs []string `android:"arch_variant"`
// The set of default shared libraries. Note nil and [] are semantically
// distinct - see BaseLinkerProperties.Default_shared_libs.
//
// This field is exported as its contents may not be arch specific.
DefaultSharedLibs []string `android:"arch_variant"`
// The specific stubs version for the lib variant, or empty string if stubs
// are not in use.
//
@@ -474,7 +462,6 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte
}
}
p.SystemSharedLibs = specifiedDeps.systemSharedLibs
p.DefaultSharedLibs = specifiedDeps.defaultSharedLibs
}
p.ExportedGeneratedHeaders = exportedInfo.GeneratedHeaders

View File

@@ -46,18 +46,11 @@ type BaseLinkerProperties struct {
// list of module-specific flags that will be used for all link steps
Ldflags []string `android:"arch_variant"`
// list of system libraries that will be dynamically linked to shared library and executable
// modules that build against bionic (device or Linux bionic modules). If unset, generally
// defaults to libc, libm, and libdl. Set to [] to prevent linking against the defaults.
// Equivalent to default_shared_libs for modules that build against bionic, and ignored on
// modules that do not build against bionic.
// 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 `android:"arch_variant"`
// 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. Equivalent to system_shared_libs, but applies to all modules.
Default_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
// dependencies. Set this flag to true to remove --no-undefined from the linker flags.
@@ -239,18 +232,6 @@ func (linker *baseLinker) appendLdflags(flags []string) {
linker.Properties.Ldflags = append(linker.Properties.Ldflags, flags...)
}
// overrideDefaultSharedLibraries returns the contents of the default_shared_libs or
// system_shared_libs properties, and records an error if both are set.
func (linker *baseLinker) overrideDefaultSharedLibraries(ctx BaseModuleContext) []string {
if linker.Properties.System_shared_libs != nil && linker.Properties.Default_shared_libs != nil {
ctx.PropertyErrorf("system_shared_libs", "cannot be specified if default_shared_libs is also specified")
}
if linker.Properties.System_shared_libs != nil {
return linker.Properties.System_shared_libs
}
return linker.Properties.Default_shared_libs
}
// linkerInit initializes dynamic properties of the linker (such as runpath).
func (linker *baseLinker) linkerInit(ctx BaseModuleContext) {
if ctx.toolchain().Is64Bit() {
@@ -351,13 +332,13 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...)
}
deps.SystemSharedLibs = linker.overrideDefaultSharedLibraries(ctx)
deps.SystemSharedLibs = linker.Properties.System_shared_libs
// In Bazel conversion mode, variations have not been specified, so SystemSharedLibs may
// inaccuarately appear unset, which can cause issues with circular dependencies.
if deps.SystemSharedLibs == nil && !ctx.BazelConversionMode() {
// Provide a default set of shared libraries if default_shared_libs and system_shared_libs
// are unspecified. Note: If an empty list [] is specified, it implies that the module
// declines the default shared libraries.
// Provide a default system_shared_libs if it is unspecified. Note: If an
// empty list [] is specified, it implies that the module declines the
// default system_shared_libs.
deps.SystemSharedLibs = append(deps.SystemSharedLibs, ctx.toolchain().DefaultSharedLibraries()...)
}
@@ -577,11 +558,6 @@ func (linker *baseLinker) linkerSpecifiedDeps(specifiedDeps specifiedDeps) speci
} else {
specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, linker.Properties.System_shared_libs...)
}
if specifiedDeps.defaultSharedLibs == nil {
specifiedDeps.defaultSharedLibs = linker.Properties.Default_shared_libs
} else {
specifiedDeps.defaultSharedLibs = append(specifiedDeps.defaultSharedLibs, linker.Properties.Default_shared_libs...)
}
return specifiedDeps
}

View File

@@ -78,7 +78,7 @@ type ObjectLinkerProperties struct {
// list of default libraries that will provide headers for this module. If unset, generally
// defaults to libc, libm, and libdl. Set to [] to prevent using headers from the defaults.
Default_shared_libs []string `android:"arch_variant"`
System_shared_libs []string `android:"arch_variant"`
// names of other cc_object modules to link into this module using partial linking
Objs []string `android:"arch_variant"`
@@ -219,9 +219,9 @@ func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
deps.StaticLibs = append(deps.StaticLibs, object.Properties.Static_libs...)
deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...)
deps.SystemSharedLibs = object.Properties.Default_shared_libs
deps.SystemSharedLibs = object.Properties.System_shared_libs
if deps.SystemSharedLibs == nil {
// Provide a default set of shared libraries if default_shared_libs is unspecified.
// Provide a default set of shared libraries if system_shared_libs is unspecified.
// Note: If an empty list [] is specified, it implies that the module declines the
// default shared libraries.
deps.SystemSharedLibs = append(deps.SystemSharedLibs, ctx.toolchain().DefaultSharedLibraries()...)
@@ -278,12 +278,12 @@ func (object *objectLinker) link(ctx ModuleContext,
func (object *objectLinker) linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps {
specifiedDeps.sharedLibs = append(specifiedDeps.sharedLibs, object.Properties.Shared_libs...)
// Must distinguish nil and [] in default_shared_libs - ensure that [] in
// Must distinguish nil and [] in system_shared_libs - ensure that [] in
// either input list doesn't come out as nil.
if specifiedDeps.defaultSharedLibs == nil {
specifiedDeps.defaultSharedLibs = object.Properties.Default_shared_libs
if specifiedDeps.systemSharedLibs == nil {
specifiedDeps.systemSharedLibs = object.Properties.System_shared_libs
} else {
specifiedDeps.defaultSharedLibs = append(specifiedDeps.defaultSharedLibs, object.Properties.Default_shared_libs...)
specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, object.Properties.System_shared_libs...)
}
return specifiedDeps

View File

@@ -365,7 +365,7 @@ func commonDefaultModules() string {
stl: "none",
min_sdk_version: "16",
crt: true,
default_shared_libs: [],
system_shared_libs: [],
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",