On 31 May 2011 15:35, Richard Earnshaw rearnsha@arm.com wrote:
I think the difficulty here is that glibc expects either the compiler, or libgcc to provide the sync primitives; and while GCC can tie the inlined copy of the primitive to use of CPUs with the relevant instruction, the libgcc version doesn't know how to specify that the code it's relying on requires a minimal kernel version...
It could throw the dependency back on glibc, but then you've got an expensive operation (the libgcc copies are normally implemented as private, per-library, helpers to avoid a PLT call overhead).
You say 'the libgcc version doesn't know how to specify that the code it's relying on requires a minimal kernel version...'
but why isn't that code just in libgcc; if the libgcc helper gets called and the kernel interface is too old it throws an error.
If the compiler knows it's on 6k or above it inlines else it calls libgcc If libgcc was built with a 6k compiler it inlines (in case something explicitly calls the library routine) If libgcc was built with a <6k compiler it checks to see if it finds itself on a new enough kernel else it errors.
eglibc always uses the compilers sync primitives
(I've not checked if all of eglibc's atomic's match gcc's or if it needs any more).
Dave