When using /msvclto, lld and MSVC's linker both do their own symbol resolution. This can cause them to select different archive members, which can result in undefined references. This change avoids that situation by extracting archive members that are selected by lld and passing those to link.exe before any archives, so that MSVC's uses those objects for symbol resolution instead of different archive members.
Details
Diff Detail
- Build Status
Buildable 5734 Build 5734: arc lint + arc unit
Event Timeline
COFF/Driver.cpp | ||
---|---|---|
156 | Instead of handling this here, I think you can handle it entirely within the /msvclto implementation by creating temporary files for all members of Symtab.ObjectFiles that have a ParentName. |
COFF/Driver.cpp | ||
---|---|---|
156 | I like that idea, but I'm not sure how I would write the object file to disk. Its MemoryBufferRef is protected. I could make it public or create a public accessor. Or I could use the ParentName to try and locate the archive and find the object file in there...but that feels kind of brittle. I'm not sure I like either implementation better than what I've already written and tested. If you have a better suggestion, or prefer one of the alternatives I presented, I'll be happy to implement that, though. |
COFF/Driver.cpp | ||
---|---|---|
156 | I would just make it public. Generally we make things public when there is a need to do so. (For example, the MB in the ELF linker's InputFile is public so that we can pass it to a DWARF parser among other things.) |
COFF/Driver.cpp | ||
---|---|---|
161 | FWIW, it doesn't look like these temporary files are ever deleted. |
test/COFF/msvclto-order.ll | ||
---|---|---|
12 | We actually still pass the library, so that check would fail. We could add some code to not pass libraries, but I'm not sure that's always correct, so I decided to not make that effort and just keep the library path in the list of things to be passed to MSVC's linker, even if we don't expect any objects in that library to be used in the link. |
test/COFF/msvclto-order.ll | ||
---|---|---|
12 | After in person conversion, I realize you meant to check for the absence of the other object file, not the other library. Will do. |
Instead of handling this here, I think you can handle it entirely within the /msvclto implementation by creating temporary files for all members of Symtab.ObjectFiles that have a ParentName.