On 2 Jun 2005, Peter S. Mazinger murmured: > On Thu, 2 Jun 2005, Jakub Jelinek wrote: > >> On Thu, Jun 02, 2005 at 01:59:46PM +0200, Peter S. Mazinger wrote: >> > Hello! >> > >> > the sequence used for linking on x86 (but most archs will have it too) >> > -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s >> > --no-as-needed >> > contains duplicate. Is this really necessary? > > Is it necessary to have it before -lc and after?
Probably not. I think the first --as-needed -lgcc_s --no-as-needed could probably be removed, but this would actually introduce complexity: both of the `-lgcc --as-needed -lgcc_s- --no-as-needed' sequences come from expansion of the same %G spec, so we'd have to introduce a new spec letter just to deal with this, for, effectively, no benefit. (Maybe we'd save an unmeasurably small of time in the link phase.) >> > Will the '--as-needed -lgcc_s --no-as-needed' ever apply? >> >> > The missing symbols will be found in -lgcc. >> >> That's not true. The EH stuff is not in -lgcc, so if -lc needs it, >> it wouldn't be found. > > so this construct is used only to get EH stuff from libgcc_s.so? Is there > stuff in libgcc.a that is not present in libgcc_s.so too? If not, what > about moving this around (or remove -lgcc) and get everything from > libgcc_s, if we already depend on it? The point of that trickery is to avoid introducing a dependency on the shared libgcc for programs that don't use exception handling. If they do, it'll come from the shared libgcc: otherwise, the shared libgcc gets entirely dropped thanks to --as-needed. (This is *not* quite the same as dropping it for C programs and keeping it for C++ programs: C programs can be linked with -fexceptions for the same of exception propagation from C++, and then they'd pull in symbols from libgcc_s, even if they are themselves not using the symbol anywhere else: perhaps they're a shared library, or will dlopen() something written in C++ which may throw.) -- `Once again, I must remark on the far-reaching extent of my ladylike nature.' --- Rosie Taylor