Enable toc optimization for host builds
The toc optimization had been disabled for host builds to ensure that the timestamp of the final binary changed whenever its implementation changed, in order to support rerunning host tools that were modified during incremental builds. However, only the final install rule must be re-run to update the timestamp, and not the link rule. Update the shared library install dependencies to use normal dependencies instead of order-only dependencies for host modules, and then enable the the toc optimization for host modules. If the implementation of a library changes it will be reinstalled, and libraries or binaries that depend on it will also be reinstalled. Also move toc generation to happen on the packed, stripped library, which is what will be used for linking, to ensure that it is available at link time when depending only on the toc file. Bug: 26015464 Test: m -j; touch system/tools/hidl/Annotation.cpp; m -j, verify out/soong/host/linux-x86/bin/hidl-gen is updated Change-Id: I8953261d2209376f3dccbf0b1a93f7af4e45c4d0
This commit is contained in:
parent
4d67642cbd
commit
89562dc308
|
@ -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(),
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue