Hello Ian Thank you for the quick reply with explanations.
2010/1/19 Ian Lance Taylor <i...@google.com>: > Jon Grant <j...@jguk.org> writes: > >> Any easy way to evaluate and reduce command lines? Consider this: >> >> /usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../lib/crt1.o >> >> Is actually the same as: /usr/lib/crt1.o -- which is much clearer! > > Using this form of path makes it easy to move an installed gcc tree to > a new location and have it continue to work correctly. Since normal > users never see these paths, the goal is correctness rather than > clarity. Ok I understand. The reason to build it up from a root and a target /lib/crt*.o file. I thought it would be possible to resolve the back to a direct pathname though to use for the parameters. I see that some of the files are located in the -L library directory specified, crtbegin.o, crtend.o in which case, perhaps they both do not need their full long path specified. >> Also I notice lots of duplicate parameters: >> >> Is this directory really needed twice? >> -L/usr/lib/gcc/i486-linux-gnu/4.3.3 -L/usr/lib/gcc/i486-linux-gnu/4.3.3 > > No. I would encourage you to investigate why it is happening. i tried: gcc -o t -Wl,-debug test.c, I see collect2 gets the duplicates passed to it, and then it passes it on to ld. I would have thought that if collect2 was compiled with define LINK_ELIMINATE_DUPLICATE_LDIRECTORIES it would strip out the duplicate parameters before calling ld. It does not appear to be switched on in this Ubuntu package I am using though. Is it on by default? >> also -lgcc_s is mentioned twice, as is -gcc > > This is because on some systems there is a circular dependency between > -lgcc and -lc. Some of the functions in -lgcc require functions in > -lc. If -lc was compiled with gcc, then on some systems some of the > functions in -lc will require -lgcc. Fortunately the functions which > -lc requires in -lgcc will never themselves require -lc. So > mentioning -lgcc twice, once before -lc and once after, suffices on > all systems. > >> Finally, could collect2 output command lines when in -verbose mode? >> Currently I can't see what parameters it is calling "ld" with.. when >> ld fails. > > To see what collect2 is doing, use -Wl,-debug. Is this documented If I add this to my existing command line I see there not any output: $ gcc -### -o t -Wl,-debug test.c If I change to not have -### I see it does work, not sure why. So I understand that this passes -debug to collect2. As collect2 only has -v mode to display version. Would a patch to add --help to it be supported? Also could describe something about collect2's purpose at the top of that --help output. Additional queries: 1) collect.c:scan_libraries may not find ldd, in which case it displays message on output, and returns as normal. Should it not be fatal if ldd is required? 2) in collect2.c:main "-debug" is checked, and variable debug set to 1 (perhaps that should be "true" to match the style of other flags) Please keep my email address in any reply. Cheers, Jon