r203885 - [Modules] Emit the module file paths as dependencies of the PCH when we are building one.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 8 18:30:09 PDT 2015
On Thu, Mar 13, 2014 at 8:07 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com>
wrote:
> Author: akirtzidis
> Date: Thu Mar 13 22:07:38 2014
> New Revision: 203885
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203885&view=rev
> Log:
> [Modules] Emit the module file paths as dependencies of the PCH when we
> are building one.
>
> This is because the PCH is tied to the module files, if one of the module
> files changes or gets removed
> the build system should re-build the PCH file.
>
Is there any reason this has its own -cc1 flag instead of being tied to
-emit-pch?
> rdar://16321245
>
> Added:
> cfe/trunk/test/Driver/pch-deps.c
> cfe/trunk/test/Modules/dependency-gen-pch.m
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Frontend/DependencyFile.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Mar 13 22:07:38 2014
> @@ -223,6 +223,8 @@ def dependent_lib : Joined<["--"], "depe
>
> def sys_header_deps : Flag<["-"], "sys-header-deps">,
> HelpText<"Include system headers in dependency output">;
> +def module_file_deps : Flag<["-"], "module-file-deps">,
> + HelpText<"Include module files in dependency output">;
> def header_include_file : Separate<["-"], "header-include-file">,
> HelpText<"Filename (or -) to write header include output to">;
> def show_includes : Flag<["--"], "show-includes">,
>
> Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Thu Mar 13
> 22:07:38 2014
> @@ -26,6 +26,7 @@ public:
> /// problems.
> unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to
> dependency list
> unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes
> info.
> + unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
>
> /// The file to write dependency output to.
> std::string OutputFile;
> @@ -50,6 +51,7 @@ public:
> UsePhonyTargets = 0;
> AddMissingHeaderDeps = 0;
> PrintShowIncludes = 0;
> + IncludeModuleFiles = 0;
> }
> };
>
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Mar 13 22:07:38
> 2014
> @@ -171,6 +171,9 @@ public:
> virtual void ReadCounter(const serialization::ModuleFile &M,
> unsigned Value) {}
>
> + /// This is called for each AST file loaded.
> + virtual void visitModuleFile(StringRef Filename) {}
> +
> /// \brief Returns true if this \c ASTReaderListener wants to receive
> the
> /// input files of the AST file via \c visitInputFile, false otherwise.
> virtual bool needsInputFileVisitation() { return false; }
> @@ -217,6 +220,7 @@ public:
> void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
> override;
> bool needsInputFileVisitation() override;
> bool needsSystemInputFileVisitation() override;
> + void visitModuleFile(StringRef Filename) override;
> bool visitInputFile(StringRef Filename, bool isSystem,
> bool isOverridden) override;
> };
>
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Thu Mar 13 22:07:38 2014
> @@ -295,6 +295,9 @@ void Clang::AddPreprocessingOptions(Comp
> if (A->getOption().matches(options::OPT_M) ||
> A->getOption().matches(options::OPT_MD))
> CmdArgs.push_back("-sys-header-deps");
> +
> + if (isa<PrecompileJobAction>(JA))
> + CmdArgs.push_back("-module-file-deps");
> }
>
> if (Args.hasArg(options::OPT_MG)) {
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 13 22:07:38 2014
> @@ -528,6 +528,7 @@ static void ParseDependencyOutputArgs(De
> Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);
> Opts.Targets = Args.getAllArgValues(OPT_MT);
> Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
> + Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
> Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
> Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
> Opts.HeaderIncludeOutputFile =
> Args.getLastArgValue(OPT_header_include_file);
>
> Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
> +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Mar 13 22:07:38 2014
> @@ -40,6 +40,7 @@ class DFGImpl : public PPCallbacks {
> bool PhonyTarget;
> bool AddMissingHeaderDeps;
> bool SeenMissingHeader;
> + bool IncludeModuleFiles;
> private:
> bool FileMatchesDepCriteria(const char *Filename,
> SrcMgr::CharacteristicKind FileType);
> @@ -51,7 +52,8 @@ public:
> IncludeSystemHeaders(Opts.IncludeSystemHeaders),
> PhonyTarget(Opts.UsePhonyTargets),
> AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
> - SeenMissingHeader(false) {}
> + SeenMissingHeader(false),
> + IncludeModuleFiles(Opts.IncludeModuleFiles) {}
>
> void FileChanged(SourceLocation Loc, FileChangeReason Reason,
> SrcMgr::CharacteristicKind FileType,
> @@ -68,6 +70,7 @@ public:
>
> void AddFilename(StringRef Filename);
> bool includeSystemHeaders() const { return IncludeSystemHeaders; }
> + bool includeModuleFiles() const { return IncludeModuleFiles; }
> };
>
> class DFGASTReaderListener : public ASTReaderListener {
> @@ -79,6 +82,7 @@ public:
> bool needsSystemInputFileVisitation() override {
> return Parent.includeSystemHeaders();
> }
> + void visitModuleFile(StringRef Filename) override;
> bool visitInputFile(StringRef Filename, bool isSystem,
> bool isOverridden) override;
> };
> @@ -268,3 +272,7 @@ bool DFGASTReaderListener::visitInputFil
> return true;
> }
>
> +void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename) {
> + if (Parent.includeModuleFiles())
> + Parent.AddFilename(Filename);
> +}
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=203885&r1=203884&r2=203885&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Mar 13 22:07:38 2014
> @@ -118,6 +118,10 @@ bool ChainedASTReaderListener::needsSyst
> return First->needsSystemInputFileVisitation() ||
> Second->needsSystemInputFileVisitation();
> }
> +void ChainedASTReaderListener::visitModuleFile(StringRef Filename) {
> + First->visitModuleFile(Filename);
> + Second->visitModuleFile(Filename);
> +}
> bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
> bool isSystem,
> bool isOverridden) {
> @@ -2118,6 +2122,9 @@ ASTReader::ReadControlBlock(ModuleFile &
> }
> }
>
> + if (Listener)
> + Listener->visitModuleFile(F.FileName);
> +
> if (Listener && Listener->needsInputFileVisitation()) {
> unsigned N = Listener->needsSystemInputFileVisitation() ?
> NumInputs
> :
> NumUserInputs;
>
> Added: cfe/trunk/test/Driver/pch-deps.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pch-deps.c?rev=203885&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Driver/pch-deps.c (added)
> +++ cfe/trunk/test/Driver/pch-deps.c Thu Mar 13 22:07:38 2014
> @@ -0,0 +1,10 @@
> +// RUN: %clang -x c-header %s -o %t.pch -MMD -MT dependencies -MF %t.d
> -### 2> %t
> +// RUN: FileCheck %s -input-file=%t
> +// CHECK: -emit-pch
> +// CHECK: -dependency-file
> +// CHECK: -module-file-deps
> +
> +// RUN: %clang -c %s -o %t -MMD -MT dependencies -MF %t.d -### 2> %t
> +// RUN: FileCheck %s -check-prefix=CHECK-NOPCH -input-file=%t
> +// CHECK-NOPCH: -dependency-file
> +// CHECK-NOPCH-NOT: -module-file-deps
>
> Added: cfe/trunk/test/Modules/dependency-gen-pch.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=203885&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Modules/dependency-gen-pch.m (added)
> +++ cfe/trunk/test/Modules/dependency-gen-pch.m Thu Mar 13 22:07:38 2014
> @@ -0,0 +1,12 @@
> +// RUN: rm -rf %t-mcp
> +// RUN: mkdir -p %t-mcp
> +
> +// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple
> x86_64-apple-darwin10 -module-file-deps -dependency-file %t.d -MT %s.o -I
> %S/Inputs -fmodules -fmodules-cache-path=%t-mcp -emit-pch -o %t.pch %s
> +// RUN: FileCheck %s < %t.d
> +// CHECK: dependency-gen-pch.m.o
> +// CHECK-NEXT: dependency-gen-pch.m
> +// CHECK-NEXT: diamond_top.pcm
> +// CHECK-NEXT: Inputs{{.}}diamond_top.h
> +// CHECK-NEXT: Inputs{{.}}module.map
> +
> +#import "diamond_top.h"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150808/1ed1871d/attachment-0001.html>
More information about the cfe-commits
mailing list