[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFg_LQWB5hV9CLnavsCmsLbQCMdj1wqe-gVP7vp_mRGt+Eh+nQ@mail.gmail.com>
Date: Wed, 3 Aug 2022 21:58:51 +0800
From: Jinrong Liang <ljr.kernel@...il.com>
To: Andrew Jones <andrew.jones@...ux.dev>
Cc: Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Sean Christopherson <seanjc@...gle.com>,
Jim Mattson <jmattson@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Joerg Roedel <joro@...tes.org>,
Jinrong Liang <cloudliang@...cent.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests: kvm: Fix a compile error in selftests/kvm/rseq_test.c
My ldd version is (GNU libc) 2.28, and I get a compilation error in this case.
But I use another ldd (Ubuntu GLIBC 2.31-0ubuntu9.2) 2.31 is compiling fine.
This shows that compilation errors may occur in different GNU libc environments.
Would it be more appropriate to use syscall for better compatibility?
Thanks,
Jinrong Liang
Andrew Jones <andrew.jones@...ux.dev> 于2022年8月2日周二 23:08写道:
>
> On Tue, Aug 02, 2022 at 03:12:40PM +0800, Jinrong Liang wrote:
> > From: Jinrong Liang <cloudliang@...cent.com>
> >
> > The following warning appears when executing:
> > make -C tools/testing/selftests/kvm
> >
> > rseq_test.c: In function ‘main’:
> > rseq_test.c:237:33: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
> > (void *)(unsigned long)gettid());
> > ^~~~~~
> > getgid
> > /usr/bin/ld: /tmp/ccr5mMko.o: in function `main':
> > ../kvm/tools/testing/selftests/kvm/rseq_test.c:237: undefined reference to `gettid'
> > collect2: error: ld returned 1 exit status
> > make: *** [../lib.mk:173: ../kvm/tools/testing/selftests/kvm/rseq_test] Error 1
>
> The man page says we need
>
> #define _GNU_SOURCE
> #include <unistd.h>
>
> which rseq_test.c doesn't have. We have _GNU_SOURCE, but not unistd.h.
> IOW, I think this patch can be
>
> diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
> index a54d4d05a058..8d3d5eab5e19 100644
> --- a/tools/testing/selftests/kvm/rseq_test.c
> +++ b/tools/testing/selftests/kvm/rseq_test.c
> @@ -9,6 +9,7 @@
> #include <string.h>
> #include <signal.h>
> #include <syscall.h>
> +#include <unistd.h>
> #include <sys/ioctl.h>
> #include <sys/sysinfo.h>
> #include <asm/barrier.h>
>
> Thanks,
> drew
>
> >
> > Use the more compatible syscall(SYS_gettid) instead of gettid() to fix it.
> > More subsequent reuse may cause it to be wrapped in a lib file.
> >
> > Signed-off-by: Jinrong Liang <cloudliang@...cent.com>
> > ---
> > tools/testing/selftests/kvm/rseq_test.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/kvm/rseq_test.c b/tools/testing/selftests/kvm/rseq_test.c
> > index a54d4d05a058..299d316cc759 100644
> > --- a/tools/testing/selftests/kvm/rseq_test.c
> > +++ b/tools/testing/selftests/kvm/rseq_test.c
> > @@ -229,7 +229,7 @@ int main(int argc, char *argv[])
> > ucall_init(vm, NULL);
> >
> > pthread_create(&migration_thread, NULL, migration_worker,
> > - (void *)(unsigned long)gettid());
> > + (void *)(unsigned long)syscall(SYS_gettid));
> >
> > for (i = 0; !done; i++) {
> > vcpu_run(vcpu);
> > --
> > 2.37.1
> >
Powered by blists - more mailing lists