[PATCH] D47799: [COFF] add /errorrepro to save reproducer on error

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 15:26:53 PDT 2018


inglorion added inline comments.


================
Comment at: lld/COFF/Driver.cpp:56
+      : OutputFileName(OutputFileName), Prefix(Prefix) {}
+  ~ReproWriter() {
+    if (lld::errorCount() == 0)
----------------
inglorion wrote:
> ruiu wrote:
> > Is this really called when lld exits? I think by default lld calls _exit() to avoid the cost of destruction, so dtors are not called on exit.
> Good point. In an earlier version I had implemented hooks to be run by exitLld() so that I could write the error repro there. This version was an attempt to simplify that, based on the idea that the destructor for ReproWriter is run before control leaves LinkerDriver::link(). That works fine for some cases, but not cases where we exceed the error limit and ExitEarly is true, or we call fatal(). Let me see if I can come up with a better way.
I think we are guaranteed that we will either leave the scope of LinkerDriver::link(), or we will call exitLld() (there is another case where we die from a signal, but that's not a case I'm looking to address here; we can address that in a later patch if we want to). 

This patch as it is already addresses the case of going out of scope, so we need to address the exitLld() case. exitLld() already calls llvm_shutdown(), so we could use ManagedStatic...but I prefer to actually add a way to register hooks for exitLld().

I'll go ahead and add that, unless someone objects.


https://reviews.llvm.org/D47799





More information about the llvm-commits mailing list