configure.ac: fix mount_attr detection
PATCH 1/1 configure.ac: fix mount_attr detection
Commit b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60 tried to fix build with latest glibc which provides mount_attr in sys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included in include/lapi/fsmount.h:
In file included from fsconfig01.c:9:../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'struct mount_attr'
55 | struct mount_attr {
| ^~~~~~~~~~
In file included from ../../../../include/lapi/fsmount.h:14:
/home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8: note: originally defined here
210 | struct mount_attr
| ^~~~~~~~~~Fixes:
- http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865
--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
configure.ac +3 -3
@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>]) AC_CHECK_TYPES([struct mount_attr],,,[ -#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])
Signature · 5 lines
2.39.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 29 lines
Commit
b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60tried to fix build with latest glibc which providesmount_attrinsys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included ininclude/lapi/fsmount.h:In file included from fsconfig01.c:9:
../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'structmount_attr'55 | struct mount_attr { | ^~~~~~~~~~ In file included from ../../../../include/lapi/fsmount.h:14: /home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~Fixes:
- http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865Signed-off-by Fabrice Fontaine <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-0@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>])
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc · line 233
Quoted 10 lines
configure.ac +3
-3AC_CHECK_TYPES([struct mount_attr],,,[ -#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])
I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.
@Li Wang where does the the sys/mount.h and linux/mount.h conflict? As far as I can tell the UAPI linux/mount.h never defined any functions, just constants, which should be solvable without the complex ifdefs, we just need to check for existence of the types and define them only if missing.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
[ Cc Li - question from Cyril at the end ]
Fabrice, thanks for fixing this long standing issue.
Quoted 46 lines
Hi!
Quoted 29 lines
Commit
b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60tried to fix build with latest glibc which providesmount_attrinsys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included ininclude/lapi/fsmount.h:In file included from fsconfig01.c:9:
../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'structmount_attr'55 | struct mount_attr { | ^~~~~~~~~~ In file included from ../../../../include/lapi/fsmount.h:14: /home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~Fixes:
- http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865Signed-off-by Fabrice Fontaine <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-0@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>])configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc · line 233
Quoted 10 lines
configure.ac +3
-3AC_CHECK_TYPES([struct mount_attr],,,[ -#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.
Quoted 5 lines
@Li Wang where does the the
sys/mount.handlinux/mount.hconflict? As far as I can tell the UAPIlinux/mount.hnever defined any functions, just constants, which should be solvable without the complex ifdefs, we just need to check for existence of the types and define them only if missing.
Quoting [1]:
The newer Glibc already provided wrapper for the series pidfd syscall, so let's include the header file conditionally.
# rpm -q glibc-devel glibc-devel-2.35.9000-31.fc37.ppc64le
# rpm -ql glibc-devel | grep pidfd /usr/include/sys/pidfd.h
To get rid of compiling error from fedora-rawhide:
tst_safe_macros.c: In function ‘safe_pidfd_open’:
tst_safe_macros.c:135:16: error: implicit declaration of function ‘pidfd_open’ [-Werror=implicit-function-declaration]
135 | rval = pidfd_open(pid, flags);
|=> Li, does the problem still persists? If yes, I'd be for merging this patch. Could you also test it on newest glibc in Fedora?
Cyril, FYI musl never includes linux headers (Rich Felker has always been against this practise).
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/[email protected]/
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 79 lines · Petr Vorel
Hi all,
[ Cc Li - question from Cyril at the end ]
Fabrice, thanks for fixing this long standing issue.
Quoted 8 lines
Hi!
Quoted 7 lines
Commit
b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60tried to fix build with latest glibc which providesmount_attrinsys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included ininclude/lapi/fsmount.h:In file included from fsconfig01.c:9:
../../../../include/lapi/fsmount.h:55:8: error: redefinition of'struct
mount_attr'Quoted 4 lines
Quoted 4 lines
55 | struct mount_attr { | ^~~~~~~~~~In file included from
../../../../include/lapi/fsmount.h:14:
/home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8:
note: originally defined hereQuoted 5 lines
Quoted 5 lines
210 | struct
mount_attr| ^~~~~~~~~~Fixes:
-http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865
Quoted 10 lines
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval,
Quoted 10 lines
Signed-off-by Fabrice Fontaine <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-0@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval,struct
__kernel_old_timespec, strucQuoted 17 lines
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc · line 233
Quoted 11 lines
configure.ac +3
-3AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>]) AC_CHECK_TYPES([struct mount_attr],,,[ -#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.Quoted 5 lines
@Li Wang where does the the
sys/mount.handlinux/mount.hconflict? As far as I can tell the UAPIlinux/mount.hnever defined any functions, just constants, which should be solvable without the complex ifdefs, we just need to check for existence of the types and define them only if missing.Quoting [1]:
The newer Glibc already provided wrapper for the series pidfd syscall, so let's include the header file conditionally.
# rpm -q glibc-devel glibc-devel-2.35.9000-31.fc37.ppc64le# rpm -ql glibc-devel | grep pidfd /usr/include/sys/pidfd.hTo get rid of compiling error from fedora-rawhide:
tst_safe_macros.c: In function ‘safe_pidfd_open’:
tst_safe_macros.c:135:16: error: implicit declaration of function
‘pidfd_open’ [-Werror=implicit-function-declaration]
Quoted 7 lines
135 | rval = pidfd_open(pid, flags); |=> Li, does the problem still persists? If yes, I'd be for merging this patch.
Could you also test it on newest glibc in Fedora?
Of course yes, I have requested a fedora-rawhide for the LTP building, but tomorrow is the soonest I can provide the result :).
Quoted 11 lines
Cyril, FYI musl never includes linux headers (Rich Felker has always been against this practise).
Kind regards,
Petr
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 51 lines · Cyril Hrubis
Hi!
Quoted 7 lines
Commit
b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60tried to fix build with latest glibc which providesmount_attrinsys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included ininclude/lapi/fsmount.h:In file included from fsconfig01.c:9:
../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'struct
mount_attr'Quoted 4 lines
55 | struct mount_attr { | ^~~~~~~~~~In file included from
../../../../include/lapi/fsmount.h:14:
/home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8:
note: originally defined hereQuoted 5 lines
210 | struct
mount_attr| ^~~~~~~~~~Fixes:
-http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval,
Quoted 11 lines
Signed-off-by Fabrice Fontaine <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-0@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval,struct
__kernel_old_timespec, strucconfigure.ac AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc · line 233
Quoted 12 lines
configure.ac +3
-3AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>]) AC_CHECK_TYPES([struct mount_attr],,,[ -#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.
Quoted 2 lines
@Li Wang where does the the
sys/mount.handlinux/mount.hconflict? As
I remember in the newer Glibc that added new definitions (e.g. mount_setattr, fsopen) support in sys/mount.h which conflict with linux/mount.h.
That's the reason I submit the patch to resolve it for some middle version of Glibc exists the problem.
But that problem later resolves in Glibc as well by:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
Check my Fedora37:
---------------------------
$ rpm -qf /usr/include/sys/mount.h glibc-headers-x86-2.34-49.fc35.noarch
$ grep mount_attr /usr/include/sys/mount.h #define MOUNT_ATTR_IDMAP 0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */ struct mount_attr struct mount_attr *__uattr, size_t __usize)
$ rpm -qf /usr/include/linux/mount.h kernel-headers-6.1.5-200.fc37.x86_64
$ grep mount_attr /usr/include/linux/mount.h
#define MOUNT_ATTR_IDMAP 0x00100000 /* Idmap mount to @userns_fd in struct
mount_attr. */
struct mount_attr {
/* List of all mount_attr versions. */far as I can tell the UAPI linux/mount.h never defined any functions,
Quoted 12 lines
just constants, which should be solvable without the complex ifdefs, we just need to check for existence of the types and define them only if missing.
--
Cyril Hrubis
[email protected]--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 34 lines · Cyril Hrubis
Hi!
Quoted 7 lines
Commit
b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60tried to fix build with latest glibc which providesmount_attrinsys/mount.h. Unfortunately, the following build failure is still raised because sys/mount is now unconditionally included ininclude/lapi/fsmount.h:In file included from fsconfig01.c:9:
../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'struct
mount_attr'Quoted 4 lines
55 | struct mount_attr { | ^~~~~~~~~~In file included from
../../../../include/lapi/fsmount.h:14:
/home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8:
note: originally defined hereQuoted 5 lines
210 | struct
mount_attr| ^~~~~~~~~~Fixes:
-http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval,
Quoted 11 lines
Signed-off-by Fabrice Fontaine <[email protected]>--- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)configure.ac +0
-0@@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval,struct
__kernel_old_timespec, strucQuoted 1 line
Quoted 17 lines
configure.ac AC_CHECK_TYPES([struct __kernel_old_timeval, struct __kernel_old_timespec, struc · line 233
Quoted 11 lines
AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>])AC_CHECK_TYPES([struct mount_attr],,,[configure.ac +3
-3-#ifdef HAVE_LINUX_MOUNT_H -# include <linux/mount.h> -#else +#ifdef HAVE_MOUNT_SETATTR # include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> #endif ])I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.
This is indeed correct if only face the latest Glibc, but that might have problems when building LTP on a middle version of Glibc/Kernel-headers. The bug I mentioned in the last email was fixed since glibc-2.37~426.
@Fabrice, what kind of version of Glibc/Kernel-headers do you use? and which platform?
Btw, this patch builds LTP successfully in CI:
- https://github.com/wangli5665/ltp/actions/runs/4380739470
And I manually tried with fedora-rawhide/fedora34/35/37/38 all looks good.
Maybe we can just apply this patch to keep everything with no big changes.
@Cyril, Petr, what do you think?
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
...
Quoted 9 lines
Quoted 4 lines
I wonder if we can get this whole mess of two different fallback headers simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.This is indeed correct if only face the latest Glibc, but that might have problems when building LTP on a middle version of Glibc/Kernel-headers. The bug I mentioned in the last email was fixed since glibc-2.37~426.
Do you know which exact commit has fixed it? It'd help us to realize when this fix is not needed any more (it'd be good to put it into the commit message).
Quoted 2 lines
@Fabrice, what kind of version of Glibc/Kernel-headers do you use? and which platform?
http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865/config
arch: arm
# Buildroot 2023.02-rc1-22-ga39e328bb2 Configuration => 2.36-81-g4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c kernel headers 5.10.
Specific Buildroot toolchain.
Quoted 2 lines
Btw, this patch builds LTP successfully in CI:
- https://github.com/wangli5665/ltp/actions/runs/4380739470
Buildroot often founds problems for embedded folks, because they use different toolchain than traditional linux distros.
Quoted 1 line
And I manually tried with fedora-rawhide/fedora34/35/37/38 all looks good.
Thanks for checking.
Quoted 3 lines
Maybe we can just apply this patch to keep everything with no big changes.
@Cyril, Petr, what do you think?
Unless there is a simple way to improve things, I'm for merging this.
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines · Petr Vorel
Hi all,
...
Quoted 1 line
Quoted 1 line
I wonder if we can get this whole mess of two different fallback
headers
Quoted 3 lines
Quoted 3 lines
simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.
Quoted 8 lines
Quoted 3 lines
This is indeed correct if only face the latest Glibc, but that might have problems when building LTP on a middle version of Glibc/Kernel-headers. The bug I mentioned in the last email was fixed since glibc-2.37~426.
Do you know which exact commit has fixed it? It'd help us to realize when this
fix is not needed any more (it'd be good to put it into the commit message).
I mean this commit:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
Quoted 29 lines
Quoted 3 lines
@Fabrice, what kind of version of Glibc/Kernel-headers do you use? and which platform?
http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865/config
arch: arm
# Buildroot 2023.02-rc1-22-ga39e328bb2 Configuration => 2.36-81-g4f4d7a13edfd2fdc57c9d76e1fd6d017fb47550c kernel headers 5.10.
Specific Buildroot toolchain.Quoted 2 lines
Btw, this patch builds LTP successfully in CI:
- https://github.com/wangli5665/ltp/actions/runs/4380739470Buildroot often founds problems for embedded folks, because they use different
toolchain than traditional linux distros.Quoted 1 line
And I manually tried with fedora-rawhide/fedora34/35/37/38 all looks
good.
Thanks for checking.Quoted 1 line
Maybe we can just apply this patch to keep everything with no big
changes.
Quoted 1 line
@Cyril, Petr, what do you think?
Unless there is a simple way to improve things, I'm for merging this.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Li,
Quoted 15 lines · Petr Vorel
Quoted 14 lines
Hi all,
...
Quoted 1 line
Quoted 1 line
I wonder if we can get this whole mess of two different fallback
headers
Quoted 8 lines
Quoted 3 lines
simplified. Looking at the glibc implementation it seems to include "
linux/mount.h" if it does exist. So most reasonable solution would do the same I guess which we did before the commit you reference.This is indeed correct if only face the latest Glibc, but that might have problems when building LTP on a middle version of Glibc/Kernel-headers. The bug I mentioned in the last email was fixed since glibc-2.37~426.
Quoted 8 lines
Quoted 4 lines
Do you know which exact commit has fixed it? It'd help us to realize when this
fix is not needed any more (it'd be good to put it into the commit message).I mean this commit:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6
Thanks for info. Fix from 2.37, it was also cherry picked to release/2.36/master branch, but not to branches for older releases (2.35 and 2.34).
I suppose there will be always some toolchain/distro with older glibc without this fix, thus I'd merge it now, and made simplification Cyril suggested sometimes next year.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
...
Quoted 9 lines
Quoted 2 lines
I mean this commit:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6Thanks for info. Fix from 2.37, it was also cherry picked to release/2.36/master branch, but not to branches for older releases (2.35 and 2.34).
I suppose there will be always some toolchain/distro with older glibc without this fix, thus I'd merge it now, and made simplification Cyril suggested sometimes next year.
I finally merged this patch adding info why original workaround from b857f8723 is needed.
Li, thanks for your input, Fabrice, thanks for the fix and your patience.
Kind regards,
Petr
Quoted 2 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp