When an object file contains an export directive, we normally do some
amount of deferred processing of them at the end of the linking
process. The -includeoptional option was handled after this, and
any object files (defining new exports) weren't handled.
Move the handling of the -includeoptional into the same late loop
which does the fixups for e.g. export directives.
Ideally, this would also be done for object files that are pulled
in by the wrap options, and for mingw autoimports, but those changes
require more modifications, to make them safe for potentially
being executed multiple times.
Personally, I think long lambdas can make it hard to figure out the structure of the code, so I'd like to try and avoid them if possible, and if necessary, make it a standalone function or method.