When calling COFF::link() with CanExitEarly set to false, the function needs to clean up several global variable caches to ensure that the next invocation of the function starts from a clean slate. The MergeChunk::Instances cache is missing from this cleanup code, and as a result will create nondeterministic memory access errors and sometimes infinite loops due to invalid memory being referenced on the next call to COFF::link().
This fix simply calls MergeChunk::Instances.clear() before exiting the function.
An additional review of the COFF library was made to try and find any other missing global caches, but I was unable to find any other than MergeChunk. Someone more familiar with the global variables might want to do their own check.
This fix was made to support inNative's .wast script compiler, which must build multiple incremental builds. It relies on statically linking LLD because the entire compiler must be a single statically embeddable library, thus preventing it from being able to call LLD as a new process.