In the ELF linker, we create the buffer identifier for bitcode files by appending the object name to the archive name. This change makes the COFF linker do the same. Without the change, ThinLTO builds can fail with an error message about multiple ThinLTO modules per object file, caused by object files contained in different archives having the same name.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
In ELF I believe the offset to the member name is also added. Because an archive can contain two member with the same name.
And it is possible to construct such an archive using lib.exe with some effort:
>touch foo.cpp >cl /c foo.cpp Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64 Copyright (C) Microsoft Corporation. All rights reserved. foo.cpp >lib /out:foo.lib foo.obj Microsoft (R) Library Manager Version 14.00.24215.1 Copyright (C) Microsoft Corporation. All rights reserved. >copy foo.lib foo2.lib 1 file(s) copied. >lib /out:foo3.lib foo.lib foo2.lib Microsoft (R) Library Manager Version 14.00.24215.1 Copyright (C) Microsoft Corporation. All rights reserved. >\src\llvm-project\ra\bin\llvm-ar t foo3.lib foo.obj foo.obj
So we probably want to support such archives eventually. I see it as a lower priority than this bug, though, so up to you whether you want to fix it now.
For this change, please add a test case.
Adding the offset also affects non-LTO archive members, right? If so, I prefer to fix that in a follow up. For this one, I'd like to change ParentName + MB.getBufferIdentifier() to toString(this), which is more consistent with how we form the names in other places. I will also add a test.
That doesn't seem like a good idea to me. toString is mostly meant to be used for error reporting. Here's the implementation: http://llvm-cs.pcc.me.uk/tools/lld/COFF/InputFiles.cpp#395
As you can see it converts names to basenames and normalizes case, so you'd have problems with files with similar names.
Yes, toString() is for generating error messages, and message contents can change anytime. It is not designed for other purposes.