Enable toc optimization for host builds am: 89562dc308 am: 8a60db561d

am: dbd0800adf

Change-Id: Iafbe90b0e9ac0cbdd045470935b95144aa581a71
This commit is contained in:
Colin Cross 2016-10-04 21:08:48 +00:00 committed by android-build-merger
commit e548f2c92a
2 changed files with 22 additions and 16 deletions

View File

@ -594,11 +594,22 @@ func (a *androidModuleContext) InstallFileName(installPath OutputPath, name stri
if a.Host() || !a.AConfig().SkipDeviceInstall() {
deps = append(deps, a.installDeps...)
var implicitDeps, orderOnlyDeps Paths
if a.Host() {
// Installed host modules might be used during the build, depend directly on their
// dependencies so their timestamp is updated whenever their dependency is updated
implicitDeps = deps
} else {
orderOnlyDeps = deps
}
a.ModuleBuild(pctx, ModuleBuildParams{
Rule: Cp,
Output: fullInstallPath,
Input: srcPath,
OrderOnly: Paths(deps),
Implicits: implicitDeps,
OrderOnly: orderOnlyDeps,
Default: !a.AConfig().EmbeddedInMake(),
})

View File

@ -404,6 +404,16 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
builderFlags := flagsToBuilderFlags(flags)
if !ctx.Darwin() {
// Optimize out relinking against shared libraries whose interface hasn't changed by
// depending on a table of contents file instead of the library itself.
tocPath := outputFile.RelPathString()
tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
tocFile := android.PathForOutput(ctx, tocPath)
library.tocFile = android.OptionalPathForPath(tocFile)
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
}
if library.relocationPacker.needsPacking(ctx) {
packedOutputFile := outputFile
outputFile = android.PathForModuleOut(ctx, "unpacked", fileName)
@ -445,21 +455,6 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs,
linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile)
if ctx.Device() {
// For device targets, optimize out relinking against shared
// libraries whose interface hasn't changed by depending on
// a table of contents file instead of the library itself.
// For host targets, the library might be part of a host tool
// that is run during the build, use the library directly so
// that the timestamp of the binary changes whenever a library
// changes and any necessary tools get re-run.
tocPath := outputFile.RelPathString()
tocPath = pathtools.ReplaceExtension(tocPath, flags.Toolchain.ShlibSuffix()[1:]+".toc")
tocFile := android.PathForOutput(ctx, tocPath)
library.tocFile = android.OptionalPathForPath(tocFile)
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
}
return ret
}