diff options
author | Bikal Lem <gbikal+git@gmail.com> | 2021-11-12 17:28:32 +0000 |
---|---|---|
committer | Bikal Lem <gbikal+git@gmail.com> | 2021-11-12 18:20:11 +0000 |
commit | 44b12f54191574462df337f0b2a2bcad147fd80b (patch) | |
tree | e5e97fc2d6a1a34d7ab55c3993ab4984aae73af3 | |
parent | a0039bd99910b3a9e28c8c70a52cadbd69e7c0f0 (diff) | |
download | liburing-44b12f54191574462df337f0b2a2bcad147fd80b.tar.gz liburing-44b12f54191574462df337f0b2a2bcad147fd80b.tar.bz2 |
fix 'make' when using glibc >= 2.28
glibc >= 2.28 supports `statx` out of the box. This means we get an
error when attempting to build `liburing` when glibc is >= 2.28, for
e.g. in my glibc version 2.33 I get the following errors
```
:26:8: error: redefinition of ‘struct statx_timestamp’
26 | struct statx_timestamp
| ^~~~~~~~~~~~~~~
In file included from statx.c:14:
```
or
```
error: redefinition of ‘struct statx’
30 | struct statx
| ^~~~~
In file included from statx.c:14:
```
This commit fixes 'make' error by choosing to use the glibc version
of `statx` if available.
glibc 2.28 release notes:
https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS;h=154ab22d7ca065af5233406927302bb7f6a66890;hb=3c03baca37fdcb52c3881e653ca392bba7a99c2b#l84
Signed-off-by: Bikal Lem <gbikal+git@gmail.com>
-rwxr-xr-x | configure | 31 | ||||
-rw-r--r-- | src/include/liburing.h | 1 | ||||
-rw-r--r-- | test/Makefile | 4 | ||||
-rw-r--r-- | test/file-verify.c | 1 | ||||
-rw-r--r-- | test/rename.c | 1 | ||||
-rw-r--r-- | test/unlink.c | 1 |
6 files changed, 37 insertions, 2 deletions
@@ -268,7 +268,6 @@ print_config "__kernel_timespec" "$__kernel_timespec" open_how="no" cat > $TMPC << EOF #include <sys/types.h> -#include <sys/stat.h> #include <fcntl.h> #include <string.h> #include <linux/openat2.h> @@ -309,6 +308,27 @@ fi print_config "statx" "$statx" ########################################## +# check for glibc statx +glibc_statx="no" +cat > $TMPC << EOF +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <linux/stat.h> +int main(int argc, char **argv) +{ + struct statx x; + + return memset(&x, 0, sizeof(x)) != NULL; +} +EOF +if compile_prog "" "" "glibc_statx"; then + glibc_statx="yes" +fi +print_config "glibc_statx" "$glibc_statx" + +########################################## # check for C++ has_cxx="no" cat > $TMPC << EOF @@ -380,6 +400,9 @@ fi if test "$statx" = "yes"; then output_sym "CONFIG_HAVE_STATX" fi +if test "$glibc_statx" = "yes"; then + output_sym "CONFIG_HAVE_GLIBC_STATX" +fi if test "$has_cxx" = "yes"; then output_sym "CONFIG_HAVE_CXX" fi @@ -448,6 +471,12 @@ else cat >> $compat_h << EOF EOF fi +if test "$glibc_statx" = "no" && "$statx" = "yes"; then +cat >> $compat_h << EOF +#include <sys/stat.h> + +EOF +fi cat >> $compat_h << EOF #endif diff --git a/src/include/liburing.h b/src/include/liburing.h index fc81542..169e098 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -8,7 +8,6 @@ #include <sys/socket.h> #include <sys/uio.h> -#include <sys/stat.h> #include <errno.h> #include <signal.h> #include <stdbool.h> diff --git a/test/Makefile b/test/Makefile index f7eafad..d6e7227 100644 --- a/test/Makefile +++ b/test/Makefile @@ -157,6 +157,10 @@ include ../Makefile.quiet ifdef CONFIG_HAVE_STATX test_srcs += statx.c endif + +ifdef CONFIG_HAVE_GLIBC_STATX + test_srcs += statx.c +endif all_targets += statx diff --git a/test/file-verify.c b/test/file-verify.c index 50cad45..327cb1d 100644 --- a/test/file-verify.c +++ b/test/file-verify.c @@ -12,6 +12,7 @@ #include <assert.h> #include <string.h> #include <sys/ioctl.h> +#include <sys/stat.h> #include <linux/fs.h> #include "helpers.h" diff --git a/test/rename.c b/test/rename.c index af09d65..7798d43 100644 --- a/test/rename.c +++ b/test/rename.c @@ -9,6 +9,7 @@ #include <stdlib.h> #include <string.h> #include <fcntl.h> +#include <sys/stat.h> #include "liburing.h" diff --git a/test/unlink.c b/test/unlink.c index f8c7639..e4c210b 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -9,6 +9,7 @@ #include <stdlib.h> #include <string.h> #include <fcntl.h> +#include <sys/stat.h> #include "liburing.h" |