Page MenuHomePhabricator

[clang] Make crash reproducer work with clang-cl
ClosedPublic

Authored by thakis on Sep 29 2021, 4:00 PM.

Details

Summary

When clang crashes, it writes a standalone source file and shell script
to reproduce the crash.

The Driver used to set Mode = CPPMode in generateCompilationDiagnostics()
to force preprocessing mode. This has the side effect of making
IsCLMode() return false, which in turn meant Clang::AddClangCLArgs()
didn't get called when creating the standalone source file, which meant
the stand-alone file was preprocessed with the gcc driver's defaults
In particular, exceptions default to on with the gcc driver, but to
off with the cl driver. The .sh script did use the original command
line, so in the reproducer for a clang-cl crash, the standalone source
file could contain exception-using code after preprocessing that the
compiler invocation in the shell script would then complain about.

This patch removes the Mode = CPPMode; line and instead additionally
checks for CCGenDiagnostics in most places that check `CCCIsCPP().
This also matches the strategy Clang::ConstructJob() uses to add
-frewrite-includes for creating the standalone source file for a crash
report.

Fixes PR52007.

Diff Detail

Event Timeline

thakis requested review of this revision.Sep 29 2021, 4:00 PM
thakis created this revision.
hans accepted this revision.Sep 30 2021, 7:17 AM

lgtm, thanks for digging into this!

This revision is now accepted and ready to land.Sep 30 2021, 7:17 AM
This revision was landed with ongoing or failed builds.Sep 30 2021, 11:33 AM
This revision was automatically updated to reflect the committed changes.
dyung added a subscriber: dyung.Sep 30 2021, 3:43 PM

Hi, the test you modified Driver/crash-report.cpp is failing on the PS4 bot after your change. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/10939

Hi, the test you modified Driver/crash-report.cpp is failing on the PS4 bot after your change. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/10939

Seems like adding -fexceptions to the response file fixes it.

Orlando added a subscriber: Orlando.Oct 1 2021, 5:08 AM
thakis added a comment.Oct 1 2021, 6:33 AM

Hi, the test you modified Driver/crash-report.cpp is failing on the PS4 bot after your change. Can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/10939

Hopefully better after ec4a82286674c44c9216e9585235b0fa5df4ae9f

Hopefully better after ec4a82286674c44c9216e9585235b0fa5df4ae9f

Your bot cycled green after that change: https://lab.llvm.org/buildbot/#/builders/139/builds/10976

Thanks for the fix