<div dir="ltr"><font size="4"><b>Background / Motivation</b></font><div><br>Both clang and lld have the ability to generate a reproducer (an archive with input files and invoker script to reproduce the clang/lld build). While clang will generate a reproducer archive when a crash happens, lld only generates a reproducer when '--reproduce' flag is explicitly set (this is equivalent to Clang's -gen-reproducer flag). This is not very helpful for debugging lld bugs, particularly when the crash happens in building big projects, since it will be unrealistic to set reproducer flags to generate reproducer archives for every lld invocation. This design also causes troubles when the crash happens on bots only, as in most cases, developers do not have access to the file system of these bots. It would be great to improve the lld reproducer generation for easier debugging in these scenarios.<br></div><div><br></div><div><font size="4"><b>Proposal</b></font><br></div><div><br></div><div>Given the use cases and status of clang and lld. I think there are 2 possible solutions.<br></div><div><br></div><div><b>Extend Clang driver</b></div><div>In most cases, lld is invoked by the clang driver instead of being invoked by the build system directly. Therefore, the clang driver can be changed to re-invoke lld with '--reproduce' flags when it detects the lld subprocess is crashed.<br></div><div><br></div><div>Advantages:</div><div>    * It probably does not require any changes to the lld and might be easier than handling the crash directly in lld.<br></div><div><br></div><div>Disadvantages:</div><div>    * In case when there is a racing condition in the build system, the input files might have changed between 1st lld crash and 2nd lld rerun with '--reproduce' flag. In this case, the generated lld reproducer archive might not be able to trigger a crash, makes it less useful.<br></div><div><br></div><div><b>Improve lld reproducer</b></div><div>Another way would be to make lld generate a reproducer archive when it crashes, just like what clang is doing.<br></div><div><br></div><div>Advantages:</div><div>    * It will work no matter if lld is invoked from Clang or from the build system.<br>    * It will catch the input file in case the crash is caused by build races.<br></div><div><br></div><div>Disadvantages:</div><div>    * It might need a lot of work if lld does not already have a sophisticated crash handler. It might still need some plumbing changes in clang driver so lld can honor the '-fcrash-diagnostic-dir' flag.<br></div><div><br></div><div><font size="4"><b>Comments?</b></font><br>Which approach do you prefer? Feel free to share your opinions.<br></div></div>