Message ID | 20240919111841.20226-1-liaoyu15@huawei.com |
---|---|
State | New |
Headers | show |
Series | selftests: vDSO: fix compile error for vdso_test_getrandom | expand |
On 2024/9/20 0:51, Shuah Khan wrote: >> diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c >> b/tools/testing/selftests/vDSO/vdso_test_getrandom.c >> index 72a1d9b43a84..84f2bbb2d5e0 100644 >> --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c >> +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c >> @@ -19,6 +19,7 @@ >> #include <sys/ptrace.h> >> #include <sys/wait.h> >> #include <sys/types.h> >> +#include <linux/sched.h> >> #include <linux/random.h> >> #include <linux/compiler.h> >> #include <linux/ptrace.h> > > Do you see this error after installing headers? Installing headers is > a dependency to be able to compile selftests. > Yes, this error still exists after installing header files. Here are my steps to reproduce: make headers_install make -C tools/testing/selftests TARGETS=vDSO After applying the patch, the error no longer appears. Best regards, Yu
Le 20/09/2024 à 03:54, Yu Liao a écrit : > [Vous ne recevez pas souvent de courriers de liaoyu15@huawei.com. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ] > > On 2024/9/20 0:51, Shuah Khan wrote: > >>> diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c >>> b/tools/testing/selftests/vDSO/vdso_test_getrandom.c >>> index 72a1d9b43a84..84f2bbb2d5e0 100644 >>> --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c >>> +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c >>> @@ -19,6 +19,7 @@ >>> #include <sys/ptrace.h> >>> #include <sys/wait.h> >>> #include <sys/types.h> >>> +#include <linux/sched.h> This not correct. According to man page of clone(2), CLONE_ macros are in <sched.h>, you should include <sched.h> instead. See https://man7.org/linux/man-pages/man2/clone.2.html By the way on my environment (gcc 12.2 + glibc 2.38), <sched.h> gets already indirectly included by <phread.h>, and at the end the CLONE_NEWTIME is in glibc headers in usr/include/bits/sched.h >>> #include <linux/random.h> >>> #include <linux/compiler.h> >>> #include <linux/ptrace.h> >> >> Do you see this error after installing headers? Installing headers is >> a dependency to be able to compile selftests. >> > > Yes, this error still exists after installing header files. Here are my steps > to reproduce: > > make headers_install > make -C tools/testing/selftests TARGETS=vDSO > > After applying the patch, the error no longer appears. > > Best regards, > Yu
diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c index 72a1d9b43a84..84f2bbb2d5e0 100644 --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c @@ -19,6 +19,7 @@ #include <sys/ptrace.h> #include <sys/wait.h> #include <sys/types.h> +#include <linux/sched.h> #include <linux/random.h> #include <linux/compiler.h> #include <linux/ptrace.h>
When building selftests/vDSO: $ make -C tools/testing/selftests TARGETS=vDSO I hit the following compilation error: vdso_test_getrandom.c:260:17: error: 'CLONE_NEWTIME' undeclared (first use in this function); did you mean 'CLONE_NEWIPC'? 260 | assert(unshare(CLONE_NEWTIME) == 0); | ^~~~~~~~~~~~~ CLONE_NEWTIME is defined in linux/sched.h, so fix this by including <linux/sched.h>. Fixes: 2aec90036dcd ("selftests: vDSO: ensure vgetrandom works in a time namespace") Signed-off-by: Yu Liao <liaoyu15@huawei.com> --- tools/testing/selftests/vDSO/vdso_test_getrandom.c | 1 + 1 file changed, 1 insertion(+)