diff --git a/android/module.go b/android/module.go index 95bd9ea07..f815ced7f 100644 --- a/android/module.go +++ b/android/module.go @@ -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(), }) diff --git a/cc/library.go b/cc/library.go index 5a7afe19e..2c5f22f9c 100644 --- a/cc/library.go +++ b/cc/library.go @@ -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 }