Revert "linux: Move {f}xstat{at} to compat symbols" for static build

Message ID 20201229194929.130589-1-adhemerval.zanella@linaro.org
State Committed
Headers
Series Revert "linux: Move {f}xstat{at} to compat symbols" for static build |

Commit Message

Adhemerval Zanella Dec. 29, 2020, 7:49 p.m. UTC
  This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static
library.  This avoids the need to rebuild the world for the case where
libstdc++ (and potentially other libraries) are linked to a old glibc.

To avoid requering to provide xstat symbols for newer ABIs (such as
riscv32) a new LIB_COMPAT macro is added.  It is similar to SHLIB_COMPAT
but also works for static case (thus evaluating similar to SHLIB_COMPAT
for both shared and static case).

Checked with a check-abi on all affected ABIs. I also check if the
static library does contains the xstat symbols.
---
 include/shlib-compat.h               | 23 ++++++++++++++---------
 sysdeps/mach/hurd/fxstat.c           |  5 -----
 sysdeps/mach/hurd/fxstatat.c         |  3 +--
 sysdeps/mach/hurd/fxstatat64.c       |  3 +--
 sysdeps/mach/hurd/lxstat64.c         |  3 +--
 sysdeps/mach/hurd/xstat.c            |  2 +-
 sysdeps/unix/sysv/linux/fxstat.c     |  4 ++--
 sysdeps/unix/sysv/linux/fxstat64.c   |  4 ++--
 sysdeps/unix/sysv/linux/fxstatat.c   |  4 ++--
 sysdeps/unix/sysv/linux/fxstatat64.c |  4 ++--
 sysdeps/unix/sysv/linux/lxstat.c     |  2 +-
 sysdeps/unix/sysv/linux/lxstat64.c   |  4 ++--
 sysdeps/unix/sysv/linux/xstat.c      |  6 +++---
 sysdeps/unix/sysv/linux/xstat64.c    |  5 +++--
 14 files changed, 35 insertions(+), 37 deletions(-)
  

Comments

Adhemerval Zanella Jan. 20, 2021, 4:52 p.m. UTC | #1
Florian,

Do we want this for 2.33? If so it would be good if someone could take
a look and check if I am missing something here.

On 29/12/2020 16:49, Adhemerval Zanella wrote:
> This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static
> library.  This avoids the need to rebuild the world for the case where
> libstdc++ (and potentially other libraries) are linked to a old glibc.
> 
> To avoid requering to provide xstat symbols for newer ABIs (such as
> riscv32) a new LIB_COMPAT macro is added.  It is similar to SHLIB_COMPAT
> but also works for static case (thus evaluating similar to SHLIB_COMPAT
> for both shared and static case).
> 
> Checked with a check-abi on all affected ABIs. I also check if the
> static library does contains the xstat symbols.
> ---
>  include/shlib-compat.h               | 23 ++++++++++++++---------
>  sysdeps/mach/hurd/fxstat.c           |  5 -----
>  sysdeps/mach/hurd/fxstatat.c         |  3 +--
>  sysdeps/mach/hurd/fxstatat64.c       |  3 +--
>  sysdeps/mach/hurd/lxstat64.c         |  3 +--
>  sysdeps/mach/hurd/xstat.c            |  2 +-
>  sysdeps/unix/sysv/linux/fxstat.c     |  4 ++--
>  sysdeps/unix/sysv/linux/fxstat64.c   |  4 ++--
>  sysdeps/unix/sysv/linux/fxstatat.c   |  4 ++--
>  sysdeps/unix/sysv/linux/fxstatat64.c |  4 ++--
>  sysdeps/unix/sysv/linux/lxstat.c     |  2 +-
>  sysdeps/unix/sysv/linux/lxstat64.c   |  4 ++--
>  sysdeps/unix/sysv/linux/xstat.c      |  6 +++---
>  sysdeps/unix/sysv/linux/xstat64.c    |  5 +++--
>  14 files changed, 35 insertions(+), 37 deletions(-)
> 
> diff --git a/include/shlib-compat.h b/include/shlib-compat.h
> index b58281857a..d6dae3bea9 100644
> --- a/include/shlib-compat.h
> +++ b/include/shlib-compat.h
> @@ -21,8 +21,6 @@
>  
>  # include <abi-versions.h>
>  
> -#ifdef SHARED
> -
>  /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
>     symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
>     code for each library.  For a version set that is subsumed by a later
> @@ -34,17 +32,24 @@
>     when the two version sets named are in fact two different ABIs we are
>     supporting.  If these do not differ, then there is no need to compile in
>     extra code to support this version set where it has been superseded by a
> -   newer version.  The compatibility code should be conditionalized with
> -   e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
> -   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
> -
> -# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
> -  _SHLIB_COMPAT (lib, introduced, obsoleted)
> -# define _SHLIB_COMPAT(lib, introduced, obsoleted)			      \
> +   newer version.  */
> +#define LIB_COMPAT(lib, introduced, obsoleted)			      	      \
> +  _LIB_COMPAT (lib, introduced, obsoleted)
> +#define _LIB_COMPAT(lib, introduced, obsoleted)			      	      \
>    (IS_IN (lib)								      \
>     && (!(ABI_##lib##_##obsoleted - 0)					      \
>         || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
>  
> +#ifdef SHARED
> +
> +/* Similar to LIB_COMPAT, but evaluate to 0 for static build.  The
> +   compatibility code should be conditionalized with e.g.
> +   `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
> +   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
> +
> +# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
> +  _LIB_COMPAT (lib, introduced, obsoleted)
> +
>  /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
>     the version set name to use for e.g. symbols first introduced into
>     libm in the GLIBC_2.1 version.  Definitions of symbols with explicit
> diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
> index 3201bb8cf1..e7e4b6e65e 100644
> --- a/sysdeps/mach/hurd/fxstat.c
> +++ b/sysdeps/mach/hurd/fxstat.c
> @@ -19,9 +19,6 @@
>  #include <stddef.h>
>  #include <sys/stat.h>
>  #include <hurd.h>
> -#include <shlib-compat.h>
> -
> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file descriptor FD in BUF.  */
>  int
> @@ -33,5 +30,3 @@ __fxstat (int vers, int fd, struct stat *buf)
>    return __fstat (fd, buf);
>  }
>  weak_alias (__fxstat, _fxstat)
> -
> -#endif
> diff --git a/sysdeps/mach/hurd/fxstatat.c b/sysdeps/mach/hurd/fxstatat.c
> index b71ab9fad5..b7f6ca742a 100644
> --- a/sysdeps/mach/hurd/fxstatat.c
> +++ b/sysdeps/mach/hurd/fxstatat.c
> @@ -22,7 +22,7 @@
>  #include <hurd.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  int
>  __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
> @@ -32,5 +32,4 @@ __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
>  
>    return __fstatat (fd, filename, buf, flag);
>  }
> -
>  #endif
> diff --git a/sysdeps/mach/hurd/fxstatat64.c b/sysdeps/mach/hurd/fxstatat64.c
> index f0c171f64c..8f401ddff2 100644
> --- a/sysdeps/mach/hurd/fxstatat64.c
> +++ b/sysdeps/mach/hurd/fxstatat64.c
> @@ -23,7 +23,7 @@
>  #include <hurd.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file descriptor FD in BUF.  */
>  int
> @@ -35,5 +35,4 @@ __fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf,
>  
>    return __fstatat64 (fd, filename, buf, flag);
>  }
> -
>  #endif
> diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
> index 7059bceb11..4975044ac3 100644
> --- a/sysdeps/mach/hurd/lxstat64.c
> +++ b/sysdeps/mach/hurd/lxstat64.c
> @@ -22,7 +22,7 @@
>  #include <hurd.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>  
>  /* Get information about the file descriptor FD in BUF.  */
>  int
> @@ -33,5 +33,4 @@ __lxstat64 (int vers, const char *file, struct stat64 *buf)
>  
>    return __lstat64 (file, buf);
>  }
> -
>  #endif
> diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
> index 8d56fe3c44..03b86ccb24 100644
> --- a/sysdeps/mach/hurd/xstat.c
> +++ b/sysdeps/mach/hurd/xstat.c
> @@ -20,7 +20,7 @@
>  #include <hurd.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get file information about FILE in BUF.  */
>  int
> diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
> index 528eedc272..0b89250b8b 100644
> --- a/sysdeps/unix/sysv/linux/fxstat.c
> +++ b/sysdeps/unix/sysv/linux/fxstat.c
> @@ -26,7 +26,7 @@
>  # include <xstatover.h>
>  # include <shlib-compat.h>
>  
> -# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  int
> @@ -61,6 +61,6 @@ __fxstat (int vers, int fd, struct stat *buf)
>      }
>  }
>  
> -# endif /* SHLIB_COMPAT  */
> +# endif /* LIB_COMPAT  */
>  
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
> index 9471d0be45..177233d759 100644
> --- a/sysdeps/unix/sysv/linux/fxstat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstat64.c
> @@ -26,7 +26,7 @@
>  #include <statx_cp.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  
> @@ -78,4 +78,4 @@ strong_alias (___fxstat64, __fxstat64)
>  strong_alias (___fxstat64, __fxstat)
>  #endif
>  
> -#endif /* SHLIB_COMPAT  */
> +#endif /* LIB_COMPAT  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
> index bd78971dea..78856742ef 100644
> --- a/sysdeps/unix/sysv/linux/fxstatat.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat.c
> @@ -26,7 +26,7 @@
>  # include <xstatover.h>
>  # include <shlib-compat.h>
>  
> -# if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
> +# if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  int
> @@ -50,6 +50,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
>  #endif
>  }
>  
> -# endif /* SHLIB_COMPAT  */
> +# endif /* LIB_COMPAT  */
>  
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
> index 091da83f1f..f23f877109 100644
> --- a/sysdeps/unix/sysv/linux/fxstatat64.c
> +++ b/sysdeps/unix/sysv/linux/fxstatat64.c
> @@ -26,7 +26,7 @@
>  #include <statx_cp.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
>  
>  /* Get information about the file FD in BUF.  */
>  
> @@ -69,4 +69,4 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
>  strong_alias (__fxstatat64, __fxstatat)
>  #endif
>  
> -#endif /* SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
> +#endif /* LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
> diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
> index c7d4507d7c..a11f58b453 100644
> --- a/sysdeps/unix/sysv/linux/lxstat.c
> +++ b/sysdeps/unix/sysv/linux/lxstat.c
> @@ -26,7 +26,7 @@
>  # include <xstatconv.h>
>  # include <xstatover.h>
>  
> -# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
> index 74e11f3467..4d9d058d4b 100644
> --- a/sysdeps/unix/sysv/linux/lxstat64.c
> +++ b/sysdeps/unix/sysv/linux/lxstat64.c
> @@ -26,7 +26,7 @@
>  #include <statx_cp.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  
> @@ -95,4 +95,4 @@ strong_alias (___lxstat64, __lxstat64);
>  strong_alias (___lxstat64,__lxstat)
>  #endif
>  
> -#endif /* SHLIB_COMPAT  */
> +#endif /* LIB_COMPAT  */
> diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
> index 87556af616..ff95479612 100644
> --- a/sysdeps/unix/sysv/linux/xstat.c
> +++ b/sysdeps/unix/sysv/linux/xstat.c
> @@ -20,13 +20,13 @@
>  #include <fcntl.h>
>  #include <kernel_stat.h>
>  #include <sysdep.h>
> -#include <shlib-compat.h>
>  
>  #if !XSTAT_IS_XSTAT64
>  # include <xstatconv.h>
>  # include <xstatover.h>
> +# include <shlib-compat.h>
>  
> -# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  int
> @@ -61,6 +61,6 @@ __xstat (int vers, const char *name, struct stat *buf)
>      }
>  }
>  
> -# endif /* SHLIB_COMPAT  */
> +# endif /* LIB_COMPAT  */
>  
>  #endif /* XSTAT_IS_XSTAT64  */
> diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
> index ec912fd2b9..9b05d1528b 100644
> --- a/sysdeps/unix/sysv/linux/xstat64.c
> +++ b/sysdeps/unix/sysv/linux/xstat64.c
> @@ -26,7 +26,7 @@
>  #include <statx_cp.h>
>  #include <shlib-compat.h>
>  
> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
> +#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file NAME in BUF.  */
>  
> @@ -92,4 +92,5 @@ compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
>  strong_alias (___xstat64, __xstat64)
>  #endif
>  
> -#endif /* SHLIB_COMPAT  */
> +
> +#endif /* LIB_COMPAT  */
>
  
Florian Weimer Jan. 20, 2021, 6:03 p.m. UTC | #2
* Adhemerval Zanella via Libc-alpha:

> Do we want this for 2.33? If so it would be good if someone could take
> a look and check if I am missing something here.

Sorry, I assumed that Andreas was going to review it.

I think we need it for GCC compatibility, at least for a few releases,
given that libstdc++.a references those static symbols.

Thanks,
Florian
  
Adhemerval Zanella Jan. 20, 2021, 6:28 p.m. UTC | #3
On 20/01/2021 15:03, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> Do we want this for 2.33? If so it would be good if someone could take
>> a look and check if I am missing something here.
> 
> Sorry, I assumed that Andreas was going to review it.
> 
> I think we need it for GCC compatibility, at least for a few releases,
> given that libstdc++.a references those static symbols.

Right, so we will need someone to review it during this week, next week
top.  I will focus on reviewing the v5 static-pie ifunc.

I would like to start the freeze next week to give us at least one
week for testing.
  
Andreas Schwab Jan. 21, 2021, 9:21 a.m. UTC | #4
On Dez 29 2020, Adhemerval Zanella wrote:

> diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
> index 3201bb8cf1..e7e4b6e65e 100644
> --- a/sysdeps/mach/hurd/fxstat.c
> +++ b/sysdeps/mach/hurd/fxstat.c
> @@ -19,9 +19,6 @@
>  #include <stddef.h>
>  #include <sys/stat.h>
>  #include <hurd.h>
> -#include <shlib-compat.h>
> -
> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>  
>  /* Get information about the file descriptor FD in BUF.  */
>  int
> @@ -33,5 +30,3 @@ __fxstat (int vers, int fd, struct stat *buf)
>    return __fstat (fd, buf);
>  }
>  weak_alias (__fxstat, _fxstat)
> -
> -#endif

Should this use LIB_COMPAT?

Andreas.
  
Adhemerval Zanella Jan. 21, 2021, 4:41 p.m. UTC | #5
On 21/01/2021 06:21, Andreas Schwab wrote:
> On Dez 29 2020, Adhemerval Zanella wrote:
> 
>> diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
>> index 3201bb8cf1..e7e4b6e65e 100644
>> --- a/sysdeps/mach/hurd/fxstat.c
>> +++ b/sysdeps/mach/hurd/fxstat.c
>> @@ -19,9 +19,6 @@
>>  #include <stddef.h>
>>  #include <sys/stat.h>
>>  #include <hurd.h>
>> -#include <shlib-compat.h>
>> -
>> -#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
>>  
>>  /* Get information about the file descriptor FD in BUF.  */
>>  int
>> @@ -33,5 +30,3 @@ __fxstat (int vers, int fd, struct stat *buf)
>>    return __fstat (fd, buf);
>>  }
>>  weak_alias (__fxstat, _fxstat)
>> -
>> -#endif
> 
> Should this use LIB_COMPAT?
> 
> Andreas.
> 

Indeed, the Hurd part was incomplete. Below the fixed patch:

---
[PATCH] Revert "linux: Move {f}xstat{at} to compat symbols" for
 static build

This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static
library.  This avoids the need to rebuild the world for the case where
libstdc++ (and potentially other libraries) are linked to a old glibc.

To avoid requering to provide xstat symbols for newer ABIs (such as
riscv32) a new LIB_COMPAT macro is added.  It is similar to SHLIB_COMPAT
but also works for static case (thus evaluating similar to SHLIB_COMPAT
for both shared and static case).

Checked with a check-abi on all affected ABIs. I also check if the
static library does contains the xstat symbols.
---
 include/shlib-compat.h               | 23 ++++++++++++++---------
 sysdeps/mach/hurd/fxstat.c           |  4 ++--
 sysdeps/mach/hurd/fxstat64.c         |  2 +-
 sysdeps/mach/hurd/fxstatat.c         |  3 +--
 sysdeps/mach/hurd/fxstatat64.c       |  3 +--
 sysdeps/mach/hurd/lxstat.c           |  2 +-
 sysdeps/mach/hurd/lxstat64.c         |  3 +--
 sysdeps/mach/hurd/xstat.c            |  2 +-
 sysdeps/mach/hurd/xstat64.c          |  2 +-
 sysdeps/unix/sysv/linux/fxstat.c     |  4 ++--
 sysdeps/unix/sysv/linux/fxstat64.c   |  4 ++--
 sysdeps/unix/sysv/linux/fxstatat.c   |  4 ++--
 sysdeps/unix/sysv/linux/fxstatat64.c |  4 ++--
 sysdeps/unix/sysv/linux/lxstat.c     |  2 +-
 sysdeps/unix/sysv/linux/lxstat64.c   |  4 ++--
 sysdeps/unix/sysv/linux/xstat.c      |  6 +++---
 sysdeps/unix/sysv/linux/xstat64.c    |  5 +++--
 17 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/include/shlib-compat.h b/include/shlib-compat.h
index b58281857a..d6dae3bea9 100644
--- a/include/shlib-compat.h
+++ b/include/shlib-compat.h
@@ -21,8 +21,6 @@
 
 # include <abi-versions.h>
 
-#ifdef SHARED
-
 /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
    symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
    code for each library.  For a version set that is subsumed by a later
@@ -34,17 +32,24 @@
    when the two version sets named are in fact two different ABIs we are
    supporting.  If these do not differ, then there is no need to compile in
    extra code to support this version set where it has been superseded by a
-   newer version.  The compatibility code should be conditionalized with
-   e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
-   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
-
-# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
-  _SHLIB_COMPAT (lib, introduced, obsoleted)
-# define _SHLIB_COMPAT(lib, introduced, obsoleted)			      \
+   newer version.  */
+#define LIB_COMPAT(lib, introduced, obsoleted)			      	      \
+  _LIB_COMPAT (lib, introduced, obsoleted)
+#define _LIB_COMPAT(lib, introduced, obsoleted)			      	      \
   (IS_IN (lib)								      \
    && (!(ABI_##lib##_##obsoleted - 0)					      \
        || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
 
+#ifdef SHARED
+
+/* Similar to LIB_COMPAT, but evaluate to 0 for static build.  The
+   compatibility code should be conditionalized with e.g.
+   `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
+   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
+
+# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
+  _LIB_COMPAT (lib, introduced, obsoleted)
+
 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
    the version set name to use for e.g. symbols first introduced into
    libm in the GLIBC_2.1 version.  Definitions of symbols with explicit
diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
index 3201bb8cf1..d3bf41a0dd 100644
--- a/sysdeps/mach/hurd/fxstat.c
+++ b/sysdeps/mach/hurd/fxstat.c
@@ -21,7 +21,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -34,4 +34,4 @@ __fxstat (int vers, int fd, struct stat *buf)
 }
 weak_alias (__fxstat, _fxstat)
 
-#endif
+#endif /* LIB_COMPAT  */
diff --git a/sysdeps/mach/hurd/fxstat64.c b/sysdeps/mach/hurd/fxstat64.c
index 6b404b296c..9beb2950ce 100644
--- a/sysdeps/mach/hurd/fxstat64.c
+++ b/sysdeps/mach/hurd/fxstat64.c
@@ -21,7 +21,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
diff --git a/sysdeps/mach/hurd/fxstatat.c b/sysdeps/mach/hurd/fxstatat.c
index b71ab9fad5..b7f6ca742a 100644
--- a/sysdeps/mach/hurd/fxstatat.c
+++ b/sysdeps/mach/hurd/fxstatat.c
@@ -22,7 +22,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 int
 __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
@@ -32,5 +32,4 @@ __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
 
   return __fstatat (fd, filename, buf, flag);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/fxstatat64.c b/sysdeps/mach/hurd/fxstatat64.c
index f0c171f64c..8f401ddff2 100644
--- a/sysdeps/mach/hurd/fxstatat64.c
+++ b/sysdeps/mach/hurd/fxstatat64.c
@@ -23,7 +23,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -35,5 +35,4 @@ __fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf,
 
   return __fstatat64 (fd, filename, buf, flag);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/lxstat.c b/sysdeps/mach/hurd/lxstat.c
index ba40612f50..12e10f0106 100644
--- a/sysdeps/mach/hurd/lxstat.c
+++ b/sysdeps/mach/hurd/lxstat.c
@@ -21,7 +21,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 int
 __lxstat (int vers, const char *file, struct stat *buf)
diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
index 7059bceb11..4975044ac3 100644
--- a/sysdeps/mach/hurd/lxstat64.c
+++ b/sysdeps/mach/hurd/lxstat64.c
@@ -22,7 +22,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -33,5 +33,4 @@ __lxstat64 (int vers, const char *file, struct stat64 *buf)
 
   return __lstat64 (file, buf);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
index 8d56fe3c44..03b86ccb24 100644
--- a/sysdeps/mach/hurd/xstat.c
+++ b/sysdeps/mach/hurd/xstat.c
@@ -20,7 +20,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get file information about FILE in BUF.  */
 int
diff --git a/sysdeps/mach/hurd/xstat64.c b/sysdeps/mach/hurd/xstat64.c
index 26bf5e2c79..e293c8adec 100644
--- a/sysdeps/mach/hurd/xstat64.c
+++ b/sysdeps/mach/hurd/xstat64.c
@@ -21,7 +21,7 @@
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index 528eedc272..0b89250b8b 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -26,7 +26,7 @@
 # include <xstatover.h>
 # include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
@@ -61,6 +61,6 @@ __fxstat (int vers, int fd, struct stat *buf)
     }
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index 9471d0be45..177233d759 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -26,7 +26,7 @@
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
@@ -78,4 +78,4 @@ strong_alias (___fxstat64, __fxstat64)
 strong_alias (___fxstat64, __fxstat)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+#endif /* LIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index bd78971dea..78856742ef 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -26,7 +26,7 @@
 # include <xstatover.h>
 # include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
@@ -50,6 +50,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 #endif
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index 091da83f1f..f23f877109 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -26,7 +26,7 @@
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
@@ -69,4 +69,4 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 strong_alias (__fxstatat64, __fxstatat)
 #endif
 
-#endif /* SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
+#endif /* LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index c7d4507d7c..a11f58b453 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -26,7 +26,7 @@
 # include <xstatconv.h>
 # include <xstatover.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 74e11f3467..4d9d058d4b 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -26,7 +26,7 @@
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
@@ -95,4 +95,4 @@ strong_alias (___lxstat64, __lxstat64);
 strong_alias (___lxstat64,__lxstat)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+#endif /* LIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index 87556af616..ff95479612 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -20,13 +20,13 @@
 #include <fcntl.h>
 #include <kernel_stat.h>
 #include <sysdep.h>
-#include <shlib-compat.h>
 
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
+# include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
@@ -61,6 +61,6 @@ __xstat (int vers, const char *name, struct stat *buf)
     }
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index ec912fd2b9..9b05d1528b 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -26,7 +26,7 @@
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
@@ -92,4 +92,5 @@ compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
 strong_alias (___xstat64, __xstat64)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+
+#endif /* LIB_COMPAT  */
  
Andreas Schwab Jan. 21, 2021, 5:04 p.m. UTC | #6
On Jan 21 2021, Adhemerval Zanella wrote:

> [PATCH] Revert "linux: Move {f}xstat{at} to compat symbols" for
>  static build
>
> This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static
> library.  This avoids the need to rebuild the world for the case where
> libstdc++ (and potentially other libraries) are linked to a old glibc.
>
> To avoid requering to provide xstat symbols for newer ABIs (such as
> riscv32) a new LIB_COMPAT macro is added.  It is similar to SHLIB_COMPAT
> but also works for static case (thus evaluating similar to SHLIB_COMPAT
> for both shared and static case).
>
> Checked with a check-abi on all affected ABIs. I also check if the
> static library does contains the xstat symbols.

Ok.

Andreas.
  

Patch

diff --git a/include/shlib-compat.h b/include/shlib-compat.h
index b58281857a..d6dae3bea9 100644
--- a/include/shlib-compat.h
+++ b/include/shlib-compat.h
@@ -21,8 +21,6 @@ 
 
 # include <abi-versions.h>
 
-#ifdef SHARED
-
 /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
    symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
    code for each library.  For a version set that is subsumed by a later
@@ -34,17 +32,24 @@ 
    when the two version sets named are in fact two different ABIs we are
    supporting.  If these do not differ, then there is no need to compile in
    extra code to support this version set where it has been superseded by a
-   newer version.  The compatibility code should be conditionalized with
-   e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
-   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
-
-# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
-  _SHLIB_COMPAT (lib, introduced, obsoleted)
-# define _SHLIB_COMPAT(lib, introduced, obsoleted)			      \
+   newer version.  */
+#define LIB_COMPAT(lib, introduced, obsoleted)			      	      \
+  _LIB_COMPAT (lib, introduced, obsoleted)
+#define _LIB_COMPAT(lib, introduced, obsoleted)			      	      \
   (IS_IN (lib)								      \
    && (!(ABI_##lib##_##obsoleted - 0)					      \
        || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
 
+#ifdef SHARED
+
+/* Similar to LIB_COMPAT, but evaluate to 0 for static build.  The
+   compatibility code should be conditionalized with e.g.
+   `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
+   in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
+
+# define SHLIB_COMPAT(lib, introduced, obsoleted)			      \
+  _LIB_COMPAT (lib, introduced, obsoleted)
+
 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
    the version set name to use for e.g. symbols first introduced into
    libm in the GLIBC_2.1 version.  Definitions of symbols with explicit
diff --git a/sysdeps/mach/hurd/fxstat.c b/sysdeps/mach/hurd/fxstat.c
index 3201bb8cf1..e7e4b6e65e 100644
--- a/sysdeps/mach/hurd/fxstat.c
+++ b/sysdeps/mach/hurd/fxstat.c
@@ -19,9 +19,6 @@ 
 #include <stddef.h>
 #include <sys/stat.h>
 #include <hurd.h>
-#include <shlib-compat.h>
-
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -33,5 +30,3 @@  __fxstat (int vers, int fd, struct stat *buf)
   return __fstat (fd, buf);
 }
 weak_alias (__fxstat, _fxstat)
-
-#endif
diff --git a/sysdeps/mach/hurd/fxstatat.c b/sysdeps/mach/hurd/fxstatat.c
index b71ab9fad5..b7f6ca742a 100644
--- a/sysdeps/mach/hurd/fxstatat.c
+++ b/sysdeps/mach/hurd/fxstatat.c
@@ -22,7 +22,7 @@ 
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 int
 __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
@@ -32,5 +32,4 @@  __fxstatat (int vers, int fd, const char *filename, struct stat *buf, int flag)
 
   return __fstatat (fd, filename, buf, flag);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/fxstatat64.c b/sysdeps/mach/hurd/fxstatat64.c
index f0c171f64c..8f401ddff2 100644
--- a/sysdeps/mach/hurd/fxstatat64.c
+++ b/sysdeps/mach/hurd/fxstatat64.c
@@ -23,7 +23,7 @@ 
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -35,5 +35,4 @@  __fxstatat64 (int vers, int fd, const char *filename, struct stat64 *buf,
 
   return __fstatat64 (fd, filename, buf, flag);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/lxstat64.c b/sysdeps/mach/hurd/lxstat64.c
index 7059bceb11..4975044ac3 100644
--- a/sysdeps/mach/hurd/lxstat64.c
+++ b/sysdeps/mach/hurd/lxstat64.c
@@ -22,7 +22,7 @@ 
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file descriptor FD in BUF.  */
 int
@@ -33,5 +33,4 @@  __lxstat64 (int vers, const char *file, struct stat64 *buf)
 
   return __lstat64 (file, buf);
 }
-
 #endif
diff --git a/sysdeps/mach/hurd/xstat.c b/sysdeps/mach/hurd/xstat.c
index 8d56fe3c44..03b86ccb24 100644
--- a/sysdeps/mach/hurd/xstat.c
+++ b/sysdeps/mach/hurd/xstat.c
@@ -20,7 +20,7 @@ 
 #include <hurd.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get file information about FILE in BUF.  */
 int
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index 528eedc272..0b89250b8b 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -26,7 +26,7 @@ 
 # include <xstatover.h>
 # include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
@@ -61,6 +61,6 @@  __fxstat (int vers, int fd, struct stat *buf)
     }
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstat64.c b/sysdeps/unix/sysv/linux/fxstat64.c
index 9471d0be45..177233d759 100644
--- a/sysdeps/unix/sysv/linux/fxstat64.c
+++ b/sysdeps/unix/sysv/linux/fxstat64.c
@@ -26,7 +26,7 @@ 
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
@@ -78,4 +78,4 @@  strong_alias (___fxstat64, __fxstat64)
 strong_alias (___fxstat64, __fxstat)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+#endif /* LIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index bd78971dea..78856742ef 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -26,7 +26,7 @@ 
 # include <xstatover.h>
 # include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 int
@@ -50,6 +50,6 @@  __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 #endif
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index 091da83f1f..f23f877109 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -26,7 +26,7 @@ 
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)
 
 /* Get information about the file FD in BUF.  */
 
@@ -69,4 +69,4 @@  __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 strong_alias (__fxstatat64, __fxstatat)
 #endif
 
-#endif /* SHLIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
+#endif /* LIB_COMPAT(libc, GLIBC_2_4, GLIBC_2_33)  */
diff --git a/sysdeps/unix/sysv/linux/lxstat.c b/sysdeps/unix/sysv/linux/lxstat.c
index c7d4507d7c..a11f58b453 100644
--- a/sysdeps/unix/sysv/linux/lxstat.c
+++ b/sysdeps/unix/sysv/linux/lxstat.c
@@ -26,7 +26,7 @@ 
 # include <xstatconv.h>
 # include <xstatover.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index 74e11f3467..4d9d058d4b 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -26,7 +26,7 @@ 
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
@@ -95,4 +95,4 @@  strong_alias (___lxstat64, __lxstat64);
 strong_alias (___lxstat64,__lxstat)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+#endif /* LIB_COMPAT  */
diff --git a/sysdeps/unix/sysv/linux/xstat.c b/sysdeps/unix/sysv/linux/xstat.c
index 87556af616..ff95479612 100644
--- a/sysdeps/unix/sysv/linux/xstat.c
+++ b/sysdeps/unix/sysv/linux/xstat.c
@@ -20,13 +20,13 @@ 
 #include <fcntl.h>
 #include <kernel_stat.h>
 #include <sysdep.h>
-#include <shlib-compat.h>
 
 #if !XSTAT_IS_XSTAT64
 # include <xstatconv.h>
 # include <xstatover.h>
+# include <shlib-compat.h>
 
-# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+# if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 int
@@ -61,6 +61,6 @@  __xstat (int vers, const char *name, struct stat *buf)
     }
 }
 
-# endif /* SHLIB_COMPAT  */
+# endif /* LIB_COMPAT  */
 
 #endif /* XSTAT_IS_XSTAT64  */
diff --git a/sysdeps/unix/sysv/linux/xstat64.c b/sysdeps/unix/sysv/linux/xstat64.c
index ec912fd2b9..9b05d1528b 100644
--- a/sysdeps/unix/sysv/linux/xstat64.c
+++ b/sysdeps/unix/sysv/linux/xstat64.c
@@ -26,7 +26,7 @@ 
 #include <statx_cp.h>
 #include <shlib-compat.h>
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
+#if LIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_33)
 
 /* Get information about the file NAME in BUF.  */
 
@@ -92,4 +92,5 @@  compat_symbol (libc, __old__xstat64, __xstat64, GLIBC_2_1);
 strong_alias (___xstat64, __xstat64)
 #endif
 
-#endif /* SHLIB_COMPAT  */
+
+#endif /* LIB_COMPAT  */