diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2022-06-17 23:31:07 +0200 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2022-06-18 00:00:43 +0200 |
commit | 92c6ffa14cdeb3edd50b46d30c830698705db9f5 (patch) | |
tree | bc6eebf4696f5943ccf14be40a8cf022308aada9 /clang/lib/Driver/Driver.cpp | |
parent | 7bc00ce5cd41aad5fd0775f58c8e85a0a8d9ee56 (diff) | |
download | llvm-92c6ffa14cdeb3edd50b46d30c830698705db9f5.zip llvm-92c6ffa14cdeb3edd50b46d30c830698705db9f5.tar.gz llvm-92c6ffa14cdeb3edd50b46d30c830698705db9f5.tar.bz2 |
[clang][driver] Ensure we don't accumulate entries in -MJ files
Previously, each job would overwrite the -MJ file. This didn't quite work for Clang invocations with multiple architectures, which got fixed in D121997 by always appending to the -MJ file. That's not correct either, since the file would grow indefinitely on subsequent Clang invocations. This patch ensures the driver always removes the file before jobs fill it in by appending.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D128098
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7b6e442..cbde266 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1314,6 +1314,10 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) { BitcodeEmbed = static_cast<BitcodeEmbedMode>(Model); } + // Remove existing compilation database so that each job can append to it. + if (Arg *A = Args.getLastArg(options::OPT_MJ)) + llvm::sys::fs::remove(A->getValue()); + // Setting up the jobs for some precompile cases depends on whether we are // treating them as PCH, implicit modules or C++20 ones. // TODO: inferring the mode like this seems fragile (it meets the objective |