Close https://github.com/llvm/llvm-project/issues/59874
D108850 changes ports to allocate CommonLinkerContext on the heap and destroys
lctx in lld/tools/lld/lld.cpp:lldMain. For API users of lld::*::link, they
need to manually call CommonLinkerContext::destroy() to prevent states from a
previous invocation. This is not ergonomic.
This patch moves CommonLinkerContext destruction into lld::*::link by using
local variables. COFFLinkerContext consumes ~5KiB stack space but it should be
fine.
Only one CommonLinkerContext::destroy() remains: in safeLldMain for
destruction after longjmp in the presence of a fatal error.