Skip to content

Commit 69f7aeb

Browse files
authored
Revert "[clang] Add -fcrash-diagnostics-tar for tarball of crash reproducer files" (#201622)
Reverts #198838 Test failing at https://lab.llvm.org/buildbot/#/builders/190/builds/43494
1 parent 5a4516c commit 69f7aeb

33 files changed

Lines changed: 37 additions & 170 deletions

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,6 @@ New Compiler Flags
354354
that ``bool`` values loaded from memory cannot have a bit pattern other
355355
than 0 or 1.
356356

357-
- New option ``-fcrash-diagnostics-tar`` added to create an archive of crash
358-
reproducer files for easier bug filing.
359-
360357
Deprecated Compiler Flags
361358
-------------------------
362359

clang/docs/UsersManual.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,6 @@ control the crash diagnostics.
763763
Like ``-fcrash-diagnostics-dir=<dir>``, specifies where to write the
764764
crash diagnostics files, but with lower precedence than the option.
765765

766-
.. option:: -fcrash-diagnostics-tar=<path>
767-
768-
Specify where to write the crash diagnostics files as a tarball.
769-
770766
Clang is also capable of generating preprocessed source file(s) and associated
771767
run script(s) even without a crash. This is especially useful when trying to
772768
generate a reproducer for warnings or errors while using modules.

clang/include/clang/Options/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,10 +2184,6 @@ def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
21842184
Group<f_clang_Group>, Flags<[NoArgumentUnused]>,
21852185
Visibility<[ClangOption, CLOption, DXCOption]>,
21862186
HelpText<"Put crash-report files in <dir>">, MetaVarName<"<dir>">;
2187-
def fcrash_diagnostics_tar : Joined<["-"], "fcrash-diagnostics-tar=">,
2188-
Group<f_clang_Group>, Flags<[NoArgumentUnused]>,
2189-
Visibility<[ClangOption, CLOption, DXCOption]>,
2190-
HelpText<"Put crash-report tarball at <path>">, MetaVarName<"<path>">;
21912187
def fcreate_profile : Flag<["-"], "fcreate-profile">, Group<f_Group>;
21922188
defm cxx_exceptions: BoolFOption<"cxx-exceptions",
21932189
LangOpts<"CXXExceptions">, DefaultFalse,

clang/lib/Driver/Driver.cpp

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,12 @@
9898
#include "llvm/Support/IOSandbox.h"
9999
#include "llvm/Support/JSON.h"
100100
#include "llvm/Support/MD5.h"
101-
#include "llvm/Support/MemoryBuffer.h"
102101
#include "llvm/Support/Path.h"
103102
#include "llvm/Support/PrettyStackTrace.h"
104103
#include "llvm/Support/Process.h"
105104
#include "llvm/Support/Program.h"
106105
#include "llvm/Support/Regex.h"
107106
#include "llvm/Support/StringSaver.h"
108-
#include "llvm/Support/TarWriter.h"
109107
#include "llvm/Support/VirtualFileSystem.h"
110108
#include "llvm/Support/raw_ostream.h"
111109
#include "llvm/TargetParser/Host.h"
@@ -1964,9 +1962,10 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
19641962
return false;
19651963
}
19661964

1967-
static const char BugReportMsg[] =
1965+
static const char BugReporMsg[] =
19681966
"\n********************\n\n"
1969-
"PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:";
1967+
"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
1968+
"Preprocessed source(s) and associated run script(s) are located at:";
19701969

19711970
// When clang crashes, produce diagnostic information including the fully
19721971
// preprocessed source file(s). Request that the developer attach the
@@ -1977,8 +1976,6 @@ void Driver::generateCompilationDiagnostics(
19771976
if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
19781977
return;
19791978

1980-
bool HasCrashTar = C.getArgs().hasArg(options::OPT_fcrash_diagnostics_tar);
1981-
19821979
unsigned Level = 1;
19831980
if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_EQ)) {
19841981
Level = llvm::StringSwitch<unsigned>(A->getValue())
@@ -2039,7 +2036,7 @@ void Driver::generateCompilationDiagnostics(
20392036

20402037
// Redirect stdout/stderr to /dev/null.
20412038
NewLLDInvocation.Execute({std::nullopt, {""}, {""}}, nullptr, nullptr);
2042-
Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReportMsg;
2039+
Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
20432040
Diag(clang::diag::note_drv_command_failed_diag_msg) << TmpName;
20442041
Diag(clang::diag::note_drv_command_failed_diag_msg)
20452042
<< "\n\n********************";
@@ -2180,13 +2177,12 @@ void Driver::generateCompilationDiagnostics(
21802177
TempFiles.push_back(std::string(Path.begin(), Path.end()));
21812178
}
21822179

2183-
Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReportMsg;
2180+
Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
21842181

21852182
SmallString<128> VFS;
21862183
SmallString<128> ReproCrashFilename;
21872184
for (std::string &TempFile : TempFiles) {
2188-
if (!HasCrashTar)
2189-
Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
2185+
Diag(clang::diag::note_drv_command_failed_diag_msg) << TempFile;
21902186
if (Report)
21912187
Report->TemporaryFiles.push_back(TempFile);
21922188
if (ReproCrashFilename.empty()) {
@@ -2228,69 +2224,7 @@ void Driver::generateCompilationDiagnostics(
22282224
<< "\n";
22292225
if (Report)
22302226
Report->TemporaryFiles.push_back(std::string(Script));
2231-
TempFiles.push_back(std::string(Script));
2232-
ScriptOS.close();
2233-
if (!HasCrashTar)
2234-
Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
2235-
}
2236-
2237-
if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_tar)) {
2238-
StringRef CrashDiagnosticsTar = A->getValue();
2239-
Expected<std::unique_ptr<llvm::TarWriter>> TarOrErr =
2240-
llvm::TarWriter::create(CrashDiagnosticsTar,
2241-
llvm::sys::path::stem(CrashDiagnosticsTar));
2242-
if (!TarOrErr) {
2243-
Diag(clang::diag::note_drv_command_failed_diag_msg)
2244-
<< (std::string("Error creating reproducer tarball: ") +
2245-
llvm::toString(TarOrErr.takeError()));
2246-
} else {
2247-
std::unique_ptr<llvm::TarWriter> &Tar = *TarOrErr;
2248-
for (const std::string &TempFile : TempFiles) {
2249-
if (llvm::sys::fs::is_directory(TempFile)) {
2250-
std::error_code EC;
2251-
for (llvm::sys::fs::recursive_directory_iterator I(TempFile, EC), E;
2252-
I != E && !EC; I.increment(EC)) {
2253-
if (llvm::sys::fs::is_regular_file(I->path())) {
2254-
auto BufferOrErr = llvm::MemoryBuffer::getFile(I->path());
2255-
if (BufferOrErr) {
2256-
// Construct path of file relative to TempFile.
2257-
llvm::SmallString<128> PathInTar =
2258-
llvm::sys::path::filename(TempFile);
2259-
StringRef SubPath = I->path();
2260-
if (SubPath.consume_front(TempFile)) {
2261-
if (!SubPath.empty() &&
2262-
llvm::sys::path::is_separator(SubPath.front())) {
2263-
SubPath = SubPath.drop_front();
2264-
}
2265-
llvm::sys::path::append(PathInTar, SubPath);
2266-
Tar->append(PathInTar, (*BufferOrErr)->getBuffer());
2267-
}
2268-
} else {
2269-
Diag(clang::diag::note_drv_command_failed_diag_msg)
2270-
<< (std::string("Error reading file for tarball: ") +
2271-
I->path());
2272-
}
2273-
}
2274-
}
2275-
if (EC) {
2276-
Diag(clang::diag::note_drv_command_failed_diag_msg)
2277-
<< (std::string("Error iterating directory for tarball: ") +
2278-
TempFile + " " + EC.message());
2279-
}
2280-
} else {
2281-
auto BufferOrErr = llvm::MemoryBuffer::getFile(TempFile);
2282-
if (BufferOrErr) {
2283-
Tar->append(llvm::sys::path::filename(TempFile),
2284-
(*BufferOrErr)->getBuffer());
2285-
} else {
2286-
Diag(clang::diag::note_drv_command_failed_diag_msg)
2287-
<< (std::string("Error reading file for tarball: ") + TempFile);
2288-
}
2289-
}
2290-
}
2291-
Diag(clang::diag::note_drv_command_failed_diag_msg)
2292-
<< CrashDiagnosticsTar;
2293-
}
2227+
Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
22942228
}
22952229

22962230
// On darwin, provide information about the .crash diagnostic report.

clang/test/Driver/Inputs/empty.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/test/Driver/Inputs/module.modulemap

Lines changed: 0 additions & 3 deletions
This file was deleted.

clang/test/Driver/crash-diagnostics-dir-3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// RUN: rm -rf %t
33
// RUN: not %crash_opt env CLANG_CRASH_DIAGNOSTICS_DIR=%t %clang -c %s -o - 2>&1 | FileCheck %s
44
#pragma clang __debug parser_crash
5-
// CHECK: PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:
5+
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
66
// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir-3.c.tmp{{(/|\\).*}}.c

clang/test/Driver/crash-diagnostics-dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
// RUN: rm -rf %t
33
// RUN: not %crash_opt %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
44
#pragma clang __debug parser_crash
5-
// CHECK: PLEASE ATTACH THE FOLLOWING CRASH REPRODUCER FILES TO THE BUG REPORT:
5+
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
66
// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c

clang/test/Driver/crash-diagnostics-modules.c

Lines changed: 0 additions & 16 deletions
This file was deleted.

clang/test/Driver/crash-diagnostics-tar.c

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)