With /winsysroot and without /machine, we don't know which paths to add to the search paths.
We do autodetect machine type and add winsysroot search paths in SymbolTable::addFile(), but that happens after all input files are opened. So in the loop where we read files, if we fail to open a file we can retry with the winsysroot search path potentially added by reading a previous file. This will fail if we try to open something in the winsysroot before reading a file that can give us the architecture, but shrug.
Fixes #54409
Can you please expand on this comment? The important thing is that, because we retry synchronously here, the order of inputs and symbol resolution doesn't change. This won't work if the first input on the command line comes from the MSVC installation, as you show in the tests, but maybe that's OK. Folks will get in trouble with a command like:
And, because we ignore LIB when /winsysroot is present, we aren't open to changes in behavior from the environment, right? Basically, if you are using /winsysroot, an input file with an architecture has to come first, or there will be link errors.