Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 6, 2024
Merged

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

merged 4 commits into from
May 6, 2024

Conversation

nerijus
Copy link
Contributor

@nerijus nerijus commented May 3, 2024

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
Copy link
Contributor Author

nerijus commented May 3, 2024

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

@nerijus
Copy link
Contributor Author

nerijus commented May 3, 2024

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
Copy link
Contributor Author

nerijus commented May 3, 2024

Found https://lore.kernel.org/all/[email protected]/T/ - will redo PR like this.

@nerijus
Copy link
Contributor Author

nerijus commented May 4, 2024

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 elFarto merged commit fc5ce86 into elFarto:master May 6, 2024
2 checks passed
@elFarto
Copy link
Owner

elFarto commented May 6, 2024

Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants