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

gettid wrapper #639

Merged
merged 1 commit into from
Jan 24, 2023
Merged

gettid wrapper #639

merged 1 commit into from
Jan 24, 2023

Conversation

dmitris
Copy link
Contributor

@dmitris dmitris commented Jan 17, 2023

when trying to build on RHEL8 (with CONTAINER_ENGINE='sudo podman' LOCAL_CLANG=1 LOCAL_CLANG_FORMAT=1 make), I'm getting a build failure due to missing gettid function. This seems to be a problem with glibc... The suggested workaround gets the codebase to compile - would like you r(and CI builds' 😄 ) opinion whether this would generally work and be the right way to fix this. NB: this is cumulative with #637, I'll rebase once that one is merged.

make -C "contrib/tester-progs"
make[1]: Entering directory '/home/dmitris/gh/cilium/tetragon/contrib/tester-progs'
gcc -Wall exit-tester.c -o exit-tester -lpthread
exit-tester.c: In function ‘thread’:
exit-tester.c:34:41: warning: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Wimplicit-function-declaration]
  printf("thread: pid:%d tid:%d\n", pid, gettid());
                                         ^~~~~~
                                         getgid
/tmp/ccEikzeG.o: In function `thread':
exit-tester.c:(.text+0x168): undefined reference to `gettid'
/tmp/ccEikzeG.o: In function `main':
exit-tester.c:(.text+0x284): undefined reference to `gettid'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:24: exit-tester] Error 1
make[1]: Leaving directory '/home/dmitris/gh/cilium/tetragon/contrib/tester-progs'
make: *** [Makefile:279: tester-progs] Error 2

@tpapagian
Copy link
Member

Thanks! Based on https://man7.org/linux/man-pages/man2/gettid.2.html it seems that gettid is introduced in glibc 2.30. So I believe that you are using an older version of glibc in you local setup.

Using syscall(__NR_gettid) seems to be the correct approach but you also need to use some type of #ifdef/#endif to check the glibc version as well to avoid errors seen in the CI.

@dmitris dmitris force-pushed the gettid-wrapper branch 2 times, most recently from 215fd46 to 0a09ed4 Compare January 18, 2023 14:11
@dmitris dmitris marked this pull request as ready for review January 18, 2023 19:45
@dmitris dmitris requested a review from a team as a code owner January 18, 2023 19:45
@dmitris dmitris requested a review from olsajiri January 18, 2023 19:45
@dmitris
Copy link
Contributor Author

dmitris commented Jan 18, 2023

@tpapagian I added the conditional with a check of the glibc version, please take a look.

Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
@jrfastab
Copy link
Contributor

LGTM. @tpapagian wdyt? Happy with latest push?

Copy link
Member

@tpapagian tpapagian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kkourt kkourt merged commit 4cb26cc into cilium:main Jan 24, 2023
@dmitris dmitris deleted the gettid-wrapper branch January 24, 2023 16:54
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.

4 participants