diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-10-01 13:39:43 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-10-01 13:39:43 +0000 |
commit | 9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8 (patch) | |
tree | a822243583ece7fc0348c7bb75066dd685d2c234 /llvm/lib/TableGen/Main.cpp | |
parent | e4e305e5eea536fb9d9dc64f612b164822d4bf34 (diff) | |
download | bcm5719-llvm-9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8.tar.gz bcm5719-llvm-9eb2bd6b8d6d31cee53f4f89dd9189da721ed4a8.zip |
Revert rL349624 : Let TableGen write output only if it changed, instead of doing so in cmake, attempt 2
Differential Revision: https://reviews.llvm.org/D55842
-----------------
As discussed on PR43385 this is causing Visual Studio msbuilds to perpetually rebuild all tablegen generated files
llvm-svn: 373338
Diffstat (limited to 'llvm/lib/TableGen/Main.cpp')
-rw-r--r-- | llvm/lib/TableGen/Main.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp index 34195c31a8b..bf97e37f324 100644 --- a/llvm/lib/TableGen/Main.cpp +++ b/llvm/lib/TableGen/Main.cpp @@ -99,39 +99,23 @@ int llvm::TableGenMain(char *argv0, TableGenMainFn *MainFn) { if (Parser.ParseFile()) return 1; - // Write output to memory. - std::string OutString; - raw_string_ostream Out(OutString); - if (MainFn(Out, Records)) - return 1; - - // Always write the depfile, even if the main output hasn't changed. - // If it's missing, Ninja considers the output dirty. If this was below - // the early exit below and someone deleted the .inc.d file but not the .inc - // file, tablegen would never write the depfile. + std::error_code EC; + ToolOutputFile Out(OutputFilename, EC, sys::fs::OF_None); + if (EC) + return reportError(argv0, "error opening " + OutputFilename + ":" + + EC.message() + "\n"); if (!DependFilename.empty()) { if (int Ret = createDependencyFile(Parser, argv0)) return Ret; } - // Only updates the real output file if there are any differences. - // This prevents recompilation of all the files depending on it if there - // aren't any. - if (auto ExistingOrErr = MemoryBuffer::getFile(OutputFilename)) - if (std::move(ExistingOrErr.get())->getBuffer() == Out.str()) - return 0; - - std::error_code EC; - ToolOutputFile OutFile(OutputFilename, EC, sys::fs::OF_None); - if (EC) - return reportError(argv0, "error opening " + OutputFilename + ":" + - EC.message() + "\n"); - OutFile.os() << Out.str(); + if (MainFn(Out.os(), Records)) + return 1; if (ErrorsPrinted > 0) return reportError(argv0, Twine(ErrorsPrinted) + " errors.\n"); // Declare success. - OutFile.keep(); + Out.keep(); return 0; } |