LLD resolves symbols regardless of LTO modes early when reading and parsing input files in order. The object files built from LTO passes are appended later.
Because LLD eagerly resolves the LC linker options while parsing a new object file (and its chain of dependent libraries), the prior decision on pending prevailing symbols (belonging to some bitcode files) can change to ones in those native libraries that are just loaded.
This patch delays processing LC linker options until all the native object files are added after LTO is done, similar to LD64. This way we preserve the decision on prevailing symbols LLD made, regardless of LTO modes.
- When parsing a new object file in parseLinkerOptions(), it just parses LC linker options in the header, and saves those contents to unprocessedLCLinkerOptions.
- After LTO is finished, resolveLCLinkerOptions() is called to recursively load dependent libraries, starting with initial linker options collected in unprocessedLCLinkerOptions (which also updates during recursions)
We have this contains check both here and in parseLCLinkerOption(). Do we need it in both places? Shouldn't just parseLCLinkerOption() be enough?