linking shared libs with -lc considered harmful
[Please correct if that's completely bogus]
gcc-2.7 doesn't include -lc when linking shared libraries, egcs
does. If you don't add -lc on the command line:
gcc -shared -> ld -lgcc -lgcc
egcc -shared -> ld -lgcc -lc -lgcc
Adding -lc ...
gcc -shared -lc -> ld -lc -lgcc -lgcc
egcc -shared -lc -> ld -lc -lgcc -lc -lgcc
IMHO this is worse than linking without -lc, because libc is searched
before the internal libgcc. That's the cause of our
__register_frame_info problems. It was found in libc, not in libgcc.
What to do?
- Fix the gcc specs such that -lc is used when building a shared
library (should be done for slink, such that shared libs on slink
can be built without explicitely linking libc).
- As an interim solution, link shared libraries with -lgcc -lc
gcc -shared -lgcc -lc -> ld -lgcc -lc -lgcc -lgcc
egcc -shared -lgcc -lc -> ld -lgcc -lc -lgcc -lc -lgcc
- Another interim solution (not sure if that's right): change specs,
such when linking shared libs, each -lc is replaced with -lgcc -lc -lgcc
- As a final solution, don't link shared libs with -lc
Could linitan detect if a shared lib is linked first with -lgcc -lc or
simply with -lc?