This looks like the right approach, but I have a concern or two about the ramifications as noted inline. Let me know if my concerns are unwarranted.
I don't entirely understand the meaning of noEntry here, but your change affects whether this happens or not. Is that important? I don't know. See my comment on your new test.
This seems like a possible problem. Before, you couldn't get here without OPT_INPUTs--you either had some, or you had a DEF file which would provide the output file name. Now we can get here with just an archive, so we might be dereferencing an iterator at the beginning of an empty list.
I think the -out flag is preventing the potential crasher I mentioned above. Can you try it without the -out?
Maybe we need one with a DEF file as well.
Somewhat related to the comments, I believe lld-link's ability to generate an import library from a def file directly is non-standard. MSVC's toolchain requires you to go through lib for that.
This also ended up being a bug caught by the entry inference test.
Thanks, that's a real bug. I checked the Visual C++ linker's behavior, and they name the output after the first wholearchive argument. I did this: link -wholearchive:foo.lib and it produced foo.exe.
I updated two existing tests that deal with infering things from inputs:
I don't think the case of -def: -wholearchive: is interesting, the def file is going to control the name of the DLL in that case.