rt: Turn forwards from librt to libc into compatibility symbols
Commit Message
Without this change, a typical configure check looking for a
library that contains (say) clock_gettime will find and link
against librt, even though nothing in the program might actually
require librt after the move of clock_gettime from librt to libc.
Tested on x86-64, with and without --disable-multi-arch.
2019-02-07 Florian Weimer <fweimer@redhat.com>
* rt/clock-compat.c (COMPAT_REDIRECT): Turn librt forwarders into
compatibility symbols.
Comments
On 2/7/19 11:56 AM, Florian Weimer wrote:
> Without this change, a typical configure check looking for a
> library that contains (say) clock_gettime will find and link
> against librt, even though nothing in the program might actually
> require librt after the move of clock_gettime from librt to libc.
>
> Tested on x86-64, with and without --disable-multi-arch.
I reviewed the original thread from 2012 for this:
https://www.sourceware.org/ml/libc-alpha/2012-10/msg00475.html
There was no indication that we intended to keep the symbols in
librt forever, and making them compatibility symbols means that
programs with similar requirements to libstdc++ that want
clock_gettime without libpthread, can also do so more easily.
Therefore this change looks good to me, but this is a a publicly
visible change that needs a bug #, and a NEWS entry. We are officially
deprecating the API out of librt with this change.
> 2019-02-07 Florian Weimer <fweimer@redhat.com>
>
> * rt/clock-compat.c (COMPAT_REDIRECT): Turn librt forwarders into
> compatibility symbols.
OK for master with bug # and NEWS entry.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> diff --git a/rt/clock-compat.c b/rt/clock-compat.c
> index c603f40b69..d8ced3cdc1 100644
> --- a/rt/clock-compat.c
> +++ b/rt/clock-compat.c
> @@ -30,14 +30,16 @@
> #if HAVE_IFUNC
> # undef INIT_ARCH
> # define INIT_ARCH()
> -# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name)
> +# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name) \
> + compat_symbol (librt, name, name, GLIBC_2_2);
> #else
> # define COMPAT_REDIRECT(name, proto, arglist) \
> int \
> name proto \
> { \
> return __##name arglist; \
> - }
> + } \
> + compat_symbol (librt, name, name, GLIBC_2_2);
> #endif
>
> COMPAT_REDIRECT (clock_getres,
>
@@ -30,14 +30,16 @@
#if HAVE_IFUNC
# undef INIT_ARCH
# define INIT_ARCH()
-# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name)
+# define COMPAT_REDIRECT(name, proto, arglist) libc_ifunc (name, &__##name) \
+ compat_symbol (librt, name, name, GLIBC_2_2);
#else
# define COMPAT_REDIRECT(name, proto, arglist) \
int \
name proto \
{ \
return __##name arglist; \
- }
+ } \
+ compat_symbol (librt, name, name, GLIBC_2_2);
#endif
COMPAT_REDIRECT (clock_getres,