This works like /include, but is not fatal if the requested symbol wasn't found. This allows implementing the GNU ld option -u.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Our algorithm for the ELF -u option is as follows:
- resolve all symbols normally
- for each symbol given by -u, look up the symbol table, and if a returned symbol is a lazy symbol, call fetch
This way seems better than the way how it is implemented in this patch for the following two reasons:
- we don't need any Config member as -u option values are consumed in-place
- The cost of -u is proportional to the number of -u options instead of the number of (undefined) symbols
Yes, probably - thanks!
Since we fetch objects iteratively in the COFF linker, we probably need to wait until the normal link has converged, then fetch lazy objs for -u, and then keep iterating until it converges again?
Yeah, I guess so. Technically, fetching an object file can add a new archive to the input file set via a .drctive section which could in turn make other -u symbols can be resolved, so we need to iterate the whole process until it converges. That said, I don't think we have to cover that case though.
Adjusted to make it work more like how this is implemented in the ELF linker; still failing (and properly so) if there's real undefined references to a symbol that was requested with the new option (-u in GNU ld).
LGTM
COFF/Driver.cpp | ||
---|---|---|
1687–1690 ↗ | (On Diff #203596) | I think you can write them in one line if (auto *Sym = dyn_cast_or_null<Lazy>(Symtab->find(Arg->getValue())) |
COFF/Options.td | ||
170 ↗ | (On Diff #203596) | We use the same spellings for identifiers representing a symbol name, so I'd name this include_optional. |