elFarto / nvidia-vaapi-driver

A VA-API implemention using NVIDIA's NVDEC
Other
1.2k stars 56 forks source link

Fix undefined reference to 'gettid' on CentOS 8 #286

Closed nerijus closed 5 months ago

nerijus commented 5 months ago

The link error is:

../src/vabackend.c: In function ‘logger’:
../src/vabackend.c:166:98: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
     fprintf(LOG_OUTPUT, "%10ld.%09ld [%d-%d] %s:%4d %24s %s\n", tp.tv_sec, tp.tv_nsec, getpid(), gettid(), filename, line, function, formattedMessage);
                                                                                                  ^~~~~~
                                                                                                  getgid
...
nvidia_drv_video.so.p/src_vabackend.c.o: In function `logger':
/root/rpmbuild/BUILD/nvidia-vaapi-driver-0.0.11/x86_64-redhat-linux-gnu/../src/vabackend.c:166: undefined reference to `gettid'
collect2: error: ld returned 1 exit status

With this patch it compiles and works correctly on CentOS 8.

nerijus commented 5 months ago

Hmm, but gettid() should probably be defined only if it is not found, so my PR is not correct.

nerijus commented 5 months ago

I see gettid system call wrapper was added in glibc 2.30, while CentOS 8 has glibc 2.28: https://sourceware.org/bugzilla/show_bug.cgi?id=6399#c62

nerijus commented 5 months ago

Found https://lore.kernel.org/all/20190311150041.373-1-plautrba@redhat.com/T/ - will redo PR like this.

nerijus commented 5 months ago

Redid by introducing nv_gettid() like latest libselinux does by introducing selinux_gettid() - see https://github.com/SELinuxProject/selinux/blob/main/libselinux/src/procattr.c#L28

elFarto commented 5 months ago

Thanks for the patch!