This is an archive of the discontinued LLVM Phabricator instance.

Make a hack for LTO work only when you are actually doing LTO.
ClosedPublic

Authored by ruiu on Mar 14 2019, 10:46 AM.

Details

Summary

We allow an archive file without symbol table as a linker input as a
workaround for a very common error in LTO build. But that logic worked
even for an archive file containing non-bitcode files, which is not
expected. This patch limits that workaround to one that contains only
bitcode files.

Event Timeline

ruiu created this revision.Mar 14 2019, 10:46 AM
efriedma added inline comments.
lld/ELF/Driver.cpp
220

"return"? It seems weird to intentionally ignore archive files without a symbol table.

ruiu marked an inline comment as done.Mar 14 2019, 11:10 AM
ruiu added inline comments.
lld/ELF/Driver.cpp
220

But that is what other linkers do and is also a natural consequence of how linker works on archive files. When a linker visits an archive file, it reads its symbol table, and pulls out object files that defines symbols that are currently undefined. Therefore, if an archive doesn't contain a symbol table, nothing is pulled out, and the archive is effectively ignored.

efriedma accepted this revision.Mar 14 2019, 11:14 AM

LGTM

lld/ELF/Driver.cpp
220

I guess that's right; it's effectively the same as the other codepath which calls make<ArchiveFile>(). But it looks weird at first glance; maybe add an explicit comment noting that.

This revision is now accepted and ready to land.Mar 14 2019, 11:14 AM
This revision was automatically updated to reflect the committed changes.