aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorAlex Brachet <abrachet@google.com>2022-11-03 00:12:10 +0000
committerAlex Brachet <abrachet@google.com>2022-11-03 00:12:10 +0000
commit78ed64d89fd6ea348a963516a2e49028e4079f65 (patch)
tree4d1a12014af29ff714b12ab58c5c75f5e9f4f87f /clang/lib/Driver/Driver.cpp
parent74d8628cf7cbf442f37fbc3a7012ed77e8749d3c (diff)
downloadllvm-78ed64d89fd6ea348a963516a2e49028e4079f65.zip
llvm-78ed64d89fd6ea348a963516a2e49028e4079f65.tar.gz
llvm-78ed64d89fd6ea348a963516a2e49028e4079f65.tar.bz2
[Driver] Don't preprocess source files when reproducing linker crashes
It's not necessary to redo the source file preprocessing for reproducing linker crashes because we must have successfully created the object file by this point. Skip this step, and also don't report the preprocessed source file or create the clang invocation shell script. The latter is no longer sensible without the preprocessed source, or helpful given the linker reproducer will have it's own shell script. Differential Revision: https://reviews.llvm.org/D137289
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp49
1 files changed, 29 insertions, 20 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 80e6ec7..5704902 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1527,6 +1527,11 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
return false;
}
+static const char BugReporMsg[] =
+ "\n********************\n\n"
+ "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
+ "Preprocessed source(s) and associated run script(s) are located at:";
+
// When clang crashes, produce diagnostic information including the fully
// preprocessed source file(s). Request that the developer attach the
// diagnostic information to a bug report.
@@ -1582,6 +1587,29 @@ void Driver::generateCompilationDiagnostics(
// Suppress tool output.
C.initCompilationForDiagnostics();
+ // If lld failed, rerun it again with --reproduce.
+ if (IsLLD) {
+ const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
+ Command NewLLDInvocation = Cmd;
+ llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
+ StringRef ReproduceOption =
+ C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+ ? "/reproduce:"
+ : "--reproduce=";
+ ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
+ NewLLDInvocation.replaceArguments(std::move(ArgList));
+
+ // Redirect stdout/stderr to /dev/null.
+ NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << TmpName;
+ Diag(clang::diag::note_drv_command_failed_diag_msg)
+ << "\n\n********************";
+ if (Report)
+ Report->TemporaryFiles.push_back(TmpName);
+ return;
+ }
+
// Construct the list of inputs.
InputList Inputs;
BuildInputs(C.getDefaultToolChain(), C.getArgs(), Inputs);
@@ -1659,22 +1687,6 @@ void Driver::generateCompilationDiagnostics(
return;
}
- // If lld failed, rerun it again with --reproduce.
- if (IsLLD) {
- const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
- Command NewLLDInvocation = Cmd;
- llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
- StringRef ReproduceOption =
- C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
- ? "/reproduce:"
- : "--reproduce=";
- ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
- NewLLDInvocation.replaceArguments(std::move(ArgList));
-
- // Redirect stdout/stderr to /dev/null.
- NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
- }
-
const ArgStringList &TempFiles = C.getTempFiles();
if (TempFiles.empty()) {
Diag(clang::diag::note_drv_command_failed_diag_msg)
@@ -1682,10 +1694,7 @@ void Driver::generateCompilationDiagnostics(
return;
}
- Diag(clang::diag::note_drv_command_failed_diag_msg)
- << "\n********************\n\n"
- "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
- "Preprocessed source(s) and associated run script(s) are located at:";
+ Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
SmallString<128> VFS;
SmallString<128> ReproCrashFilename;