Add compile-time pathDeps as implicit dependencies
Bug: http://b/70820751
Bug: http://b/70857959
Clang does not output file dependencies from the -fprofile-use= flag
during -MD/-MM. Add this and other path dependencies as implicit Ninja
dependencies. Generated header dependencies are retained as OrderOnly
dependencies.
Test: Perturb profdata files for hwui/skia in internal branch and verify
that the sources get rebuilt.
Change-Id: I3247d995ee27a4882172eb15ff36acf56536b6f7
diff --git a/cc/builder.go b/cc/builder.go
index e583834..de85d6e 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -290,7 +290,7 @@
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths,
- flags builderFlags, deps android.Paths) Objects {
+ flags builderFlags, pathDeps android.Paths, genDeps android.Paths) Objects {
objFiles := make(android.Paths, len(srcFiles))
var tidyFiles android.Paths
@@ -363,7 +363,8 @@
Description: "yasm " + srcFile.Rel(),
Output: objFile,
Input: srcFile,
- OrderOnly: deps,
+ Implicits: pathDeps,
+ OrderOnly: genDeps,
Args: map[string]string{
"asFlags": flags.yasmFlags,
},
@@ -375,7 +376,8 @@
Description: "windres " + srcFile.Rel(),
Output: objFile,
Input: srcFile,
- OrderOnly: deps,
+ Implicits: pathDeps,
+ OrderOnly: genDeps,
Args: map[string]string{
"windresCmd": gccCmd(flags.toolchain, "windres"),
"flags": flags.toolchain.WindresFlags(),
@@ -443,7 +445,8 @@
Output: objFile,
ImplicitOutputs: implicitOutputs,
Input: srcFile,
- OrderOnly: deps,
+ Implicits: pathDeps,
+ OrderOnly: genDeps,
Args: map[string]string{
"cFlags": moduleCflags,
"ccCmd": ccCmd,
diff --git a/cc/compiler.go b/cc/compiler.go
index 4eae898..c9dcf95 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -157,7 +157,8 @@
type baseCompiler struct {
Properties BaseCompilerProperties
Proto android.ProtoProperties
- deps android.Paths
+ genDeps android.Paths
+ pathDeps android.Paths
flags builderFlags
// Sources that were passed to the C/C++ compiler
@@ -536,17 +537,16 @@
srcs := append(android.Paths(nil), compiler.srcsBeforeGen...)
srcs, genDeps := genSources(ctx, srcs, buildFlags)
-
- pathDeps = append(pathDeps, genDeps...)
pathDeps = append(pathDeps, flags.CFlagsDeps...)
- compiler.deps = pathDeps
+ compiler.pathDeps = pathDeps
+ compiler.genDeps = genDeps
// Save src, buildFlags and context
compiler.srcs = srcs
// Compile files listed in c.Properties.Srcs into objects
- objs := compileObjs(ctx, buildFlags, "", srcs, compiler.deps)
+ objs := compileObjs(ctx, buildFlags, "", srcs, pathDeps, genDeps)
if ctx.Failed() {
return Objects{}
@@ -557,7 +557,7 @@
// Compile a list of source files into objects a specified subdirectory
func compileObjs(ctx android.ModuleContext, flags builderFlags,
- subdir string, srcFiles, deps android.Paths) Objects {
+ subdir string, srcFiles, pathDeps android.Paths, genDeps android.Paths) Objects {
- return TransformSourceToObj(ctx, subdir, srcFiles, flags, deps)
+ return TransformSourceToObj(ctx, subdir, srcFiles, flags, pathDeps, genDeps)
}
diff --git a/cc/library.go b/cc/library.go
index d53bcfc..9bd12a9 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -384,11 +384,11 @@
if library.static() {
srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
- srcs, library.baseCompiler.deps))
+ srcs, library.baseCompiler.pathDeps, library.baseCompiler.genDeps))
} else if library.shared() {
srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
- srcs, library.baseCompiler.deps))
+ srcs, library.baseCompiler.pathDeps, library.baseCompiler.genDeps))
}
return objs
@@ -671,8 +671,8 @@
}
library.reexportFlags(flags)
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
- library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
- library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
+ library.reexportDeps(library.baseCompiler.genDeps) // TODO: restrict to aidl deps
+ library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.genDeps...)
}
}
@@ -684,8 +684,8 @@
}
library.reexportFlags(flags)
library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
- library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
- library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
+ library.reexportDeps(library.baseCompiler.genDeps) // TODO: restrict to proto deps
+ library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.genDeps...)
}
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 459d980..5a76666 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -288,7 +288,7 @@
subdir := ""
srcs := []android.Path{stubSrcPath}
- return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil), versionScriptPath
+ return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil, nil), versionScriptPath
}
func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {