Add only compiler-flag dependencies as implicit

Bug: http://b/72343691

Change https://android-review.googlesource.com/c/572758, in addition to
dependencies from the compiler flags, also marked all exported
dependencies as implicit.  This can cause lots of unnecessary
recompiles.  This change moves exported dependencies back as order-only
dependencies.

Test: 1. mma in art after changing profile_compilation_info.h triggers
         only a limited number of recompiles.
      2. verify that changes to PGO profile files trigger recompiles.

Change-Id: Icb0f4cd2b6da0add3b6e5206661e6aa7a577602f
This commit is contained in:
Pirama Arumuga Nainar
2018-01-23 10:49:04 -08:00
parent d89f6621ae
commit f231b19017
3 changed files with 19 additions and 19 deletions

View File

@@ -289,7 +289,7 @@ func (a Objects) Append(b Objects) Objects {
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files // Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths, func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths,
flags builderFlags, pathDeps android.Paths, genDeps android.Paths) Objects { flags builderFlags, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
objFiles := make(android.Paths, len(srcFiles)) objFiles := make(android.Paths, len(srcFiles))
var tidyFiles android.Paths var tidyFiles android.Paths
@@ -362,8 +362,8 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
Description: "yasm " + srcFile.Rel(), Description: "yasm " + srcFile.Rel(),
Output: objFile, Output: objFile,
Input: srcFile, Input: srcFile,
Implicits: pathDeps, Implicits: cFlagsDeps,
OrderOnly: genDeps, OrderOnly: pathDeps,
Args: map[string]string{ Args: map[string]string{
"asFlags": flags.yasmFlags, "asFlags": flags.yasmFlags,
}, },
@@ -375,8 +375,8 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
Description: "windres " + srcFile.Rel(), Description: "windres " + srcFile.Rel(),
Output: objFile, Output: objFile,
Input: srcFile, Input: srcFile,
Implicits: pathDeps, Implicits: cFlagsDeps,
OrderOnly: genDeps, OrderOnly: pathDeps,
Args: map[string]string{ Args: map[string]string{
"windresCmd": gccCmd(flags.toolchain, "windres"), "windresCmd": gccCmd(flags.toolchain, "windres"),
"flags": flags.toolchain.WindresFlags(), "flags": flags.toolchain.WindresFlags(),
@@ -444,8 +444,8 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
Output: objFile, Output: objFile,
ImplicitOutputs: implicitOutputs, ImplicitOutputs: implicitOutputs,
Input: srcFile, Input: srcFile,
Implicits: pathDeps, Implicits: cFlagsDeps,
OrderOnly: genDeps, OrderOnly: pathDeps,
Args: map[string]string{ Args: map[string]string{
"cFlags": moduleCflags, "cFlags": moduleCflags,
"ccCmd": ccCmd, "ccCmd": ccCmd,

View File

@@ -160,7 +160,7 @@ func NewBaseCompiler() *baseCompiler {
type baseCompiler struct { type baseCompiler struct {
Properties BaseCompilerProperties Properties BaseCompilerProperties
Proto android.ProtoProperties Proto android.ProtoProperties
genDeps android.Paths cFlagsDeps android.Paths
pathDeps android.Paths pathDeps android.Paths
flags builderFlags flags builderFlags
@@ -548,16 +548,16 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
srcs := append(android.Paths(nil), compiler.srcsBeforeGen...) srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)
srcs, genDeps := genSources(ctx, srcs, buildFlags) srcs, genDeps := genSources(ctx, srcs, buildFlags)
pathDeps = append(pathDeps, flags.CFlagsDeps...) pathDeps = append(pathDeps, genDeps...)
compiler.pathDeps = pathDeps compiler.pathDeps = pathDeps
compiler.genDeps = genDeps compiler.cFlagsDeps = flags.CFlagsDeps
// Save src, buildFlags and context // Save src, buildFlags and context
compiler.srcs = srcs compiler.srcs = srcs
// Compile files listed in c.Properties.Srcs into objects // Compile files listed in c.Properties.Srcs into objects
objs := compileObjs(ctx, buildFlags, "", srcs, pathDeps, genDeps) objs := compileObjs(ctx, buildFlags, "", srcs, pathDeps, compiler.cFlagsDeps)
if ctx.Failed() { if ctx.Failed() {
return Objects{} return Objects{}
@@ -568,7 +568,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
// Compile a list of source files into objects a specified subdirectory // Compile a list of source files into objects a specified subdirectory
func compileObjs(ctx android.ModuleContext, flags builderFlags, func compileObjs(ctx android.ModuleContext, flags builderFlags,
subdir string, srcFiles, pathDeps android.Paths, genDeps android.Paths) Objects { subdir string, srcFiles, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
return TransformSourceToObj(ctx, subdir, srcFiles, flags, pathDeps, genDeps) return TransformSourceToObj(ctx, subdir, srcFiles, flags, pathDeps, cFlagsDeps)
} }

View File

@@ -384,11 +384,11 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
if library.static() { if library.static() {
srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs) srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
srcs, library.baseCompiler.pathDeps, library.baseCompiler.genDeps)) srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
} else if library.shared() { } else if library.shared() {
srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs) srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
srcs, library.baseCompiler.pathDeps, library.baseCompiler.genDeps)) srcs, library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
} }
return objs return objs
@@ -676,8 +676,8 @@ func (library *libraryDecorator) link(ctx ModuleContext,
} }
library.reexportFlags(flags) library.reexportFlags(flags)
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
library.reexportDeps(library.baseCompiler.genDeps) // TODO: restrict to aidl deps library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to aidl deps
library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.genDeps...) library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
} }
} }
@@ -689,8 +689,8 @@ func (library *libraryDecorator) link(ctx ModuleContext,
} }
library.reexportFlags(flags) library.reexportFlags(flags)
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
library.reexportDeps(library.baseCompiler.genDeps) // TODO: restrict to proto deps library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps
library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.genDeps...) library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
} }
} }