Ignore shared libs for static executables.

Ie42edc5184f315f998db953594e425214b810e0e added system_shared_libs to
static libraries so that their exported headers can be referenced.
However, it also added unrequired dependencies, which is an
error-triggering issue for static executables.

This change addresses it by adding a condition to shared libs handling code
in binary.go.

Bug: 121152570
Test: cc_test.go, library_test.go
Change-Id: I1828442c4e496f8d815fccaeca970cd5766bdf5d
This commit is contained in:
Jaewoong Jung
2018-12-18 11:08:25 -08:00
parent 539f409d78
commit 232c07c217
2 changed files with 47 additions and 5 deletions

View File

@@ -299,9 +299,6 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
var linkerDeps android.Paths
sharedLibs := deps.SharedLibs
sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
if deps.LinkerFlagsFile.Valid() {
flags.LdFlags = append(flags.LdFlags, "$$(cat "+deps.LinkerFlagsFile.String()+")")
linkerDeps = append(linkerDeps, deps.LinkerFlagsFile.Path())
@@ -363,8 +360,15 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
binary.injectHostBionicLinkerSymbols(ctx, outputFile, deps.DynamicLinker.Path(), injectedOutputFile)
}
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
var sharedLibs android.Paths
// Ignore shared libs for static executables.
if !binary.static() {
sharedLibs = deps.SharedLibs
sharedLibs = append(sharedLibs, deps.LateSharedLibs...)
linkerDeps = append(linkerDeps, deps.SharedLibsDeps...)
linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...)
}
linkerDeps = append(linkerDeps, objs.tidyFiles...)
linkerDeps = append(linkerDeps, flags.LdFlagsDeps...)