From 70ba5a38d13516e39704adec2a4b1d4ba16421a9 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Tue, 19 Dec 2017 15:11:01 -0800 Subject: 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 --- cc/builder.go | 11 +++++++---- cc/compiler.go | 14 +++++++------- cc/library.go | 12 ++++++------ cc/ndk_library.go | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index e583834e..de85d6e7 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -290,7 +290,7 @@ func (a Objects) Append(b Objects) Objects { // 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 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and 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 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and 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 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and 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 4eae8982..c9dcf953 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -157,7 +157,8 @@ func NewBaseCompiler() *baseCompiler { 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 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD 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 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD // 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 d53bcfcb..9bd12a98 100644 --- a/cc/library.go +++ b/cc/library.go @@ -384,11 +384,11 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa 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 @@ func (library *libraryDecorator) link(ctx ModuleContext, } 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 @@ func (library *libraryDecorator) link(ctx ModuleContext, } 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 459d9808..5a76666e 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -288,7 +288,7 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vn 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 { -- cgit v1.2.3