On 29/01/2011 04:41, H.J. Lu wrote: > On Fri, Jan 28, 2011 at 8:37 PM, Dave Korn wrote: >> On 29/01/2011 02:05, H.J. Lu wrote: >> >>> I run your patch on those new LTO tests. I got relevant failures: >>> >>> FAIL: LTO 2 >>> FAIL: LTO 11 >>> FAIL: LTO 8 >>> >>> Your patch doesn't fix any failures and introduce a new one. >> It's not too bad. The new fail is the assert firing where it can't find a >> node to insert after when the only claimed objects come from a library; at the >> moment it's checking the claimed flag only for the overall archive, which is >> never set. I'll just make it check the claimed flag for the archive members >> and place the added files after the original archive in that case. >> >> LTO 2 passes both before and after on PE-COFF, and LTO 8 is ELF-only, so I'm >> building the whole thing up on cfarm to see what's going on with those. You >> didn't mention your target - x86_64-linux, I'm guessing? >> > > I tested it on Linux/x86. Right you are. This updated version is cleverer about where it inserts the replacement files into the statement list and file chains. ld/ChangeLog: 2011-01-29 Dave Korn <... * ldlang.h (lang_input_statement_type): Add new 'claim_archive' flag. * ldmain.c (add_archive_element): Set it if the member is claimed. * ldlang.c (new_afile): Initialise claim_archive and claimed members. (find_replacements_insert_point): New helper function. (lang_process): After adding and opening replacement files passed from plugin, splice them into correct place in statement list and file chains to preserve critical link order. (lang_list_insert_after): New helper function. (lang_list_remove_tail): Likewise. I tested this one on i686-unknown-linux-gnu. LTO 2 still fails, because there's no pass-through for -lm. LTO 8 still fails, because we're still generating undefined references to symbols from the original IR file's symtab that aren't supplied by the replacement file, which runs afoul of the elf linker: > /* If a non-weak symbol with non-default visibility is not defined > locally, it is a fatal error. */ ... despite the fact that there are no references to the symbol in question. Neither of those is to do with the link order though, so this patch wouldn't be expected to fix them. The one real bug, LTO 11 is OK now. On i686-pc-cygwin, LTO 2 and LTO 11 pass (as in fact do LTO 7 and LTO 8; they're not as ELF-specific as all that, after all). I've run g++.dg/stackalign.exp from the gcc testsuite, and all the EH failures I was previously experiencing are fixed. I'll run a full C/C++ testsuite later. I also tested it on x86_64-unknown-linux-gnu, including your ld-lto tests and a gcc testsuite run (c,c++ only); no regressions in any of that. OK now? cheers, DaveK