Bug 111322 - non-canonical reference to canonical protected function `__pthread_key_create'
Summary: non-canonical reference to canonical protected function `__pthread_key_create'
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: libgcc (show other bugs)
Version: 13.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-07 08:27 UTC by Chris Packham
Modified: 2023-09-13 13:43 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-uclibc
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Exclude UCLIBC from GLIBC thread check (743 bytes, application/mbox)
2023-09-07 08:27 UTC, Chris Packham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Packham 2023-09-07 08:27:57 UTC
Created attachment 55849 [details]
Exclude UCLIBC from GLIBC thread check

With binutils-2.40, uClibc-ng-1.0.43 and gcc-13.2.0 the following link error is seen for some C++ code (ISL in this case).

ld.bfd: isl_test_cpp17.o: non-canonical reference to canonical protected function `__pthread_key_create' in x86_64-multilib-linux-uclibc/sysroot/lib64/libc.so.1
ld.bfd: failed to set dynamic section sizes: bad value

The problem appears to be that GCC uses the presence of __pthread_key_create() to detect the use of pthreads with GNU libc but because uclibc-ng also defines __GLIBC__ it ends up using the same symbol which for uclibc-ng is marked protected. It looks as though the intended symbol should be pthread_cancel() as for other libcs.

The attached patch is my attempt to resolve the issue.
Comment 1 Andrew Pinski 2023-09-07 08:31:02 UTC
uclibc should 100% not be defining __GLIBC__  at all ..
Comment 2 Chris Packham 2023-09-07 08:44:05 UTC
I don't disagree but it appears to have been that way for some time. There are other instances of the __GLIBC__ && !__UCLIBC__ in other corners
Comment 3 Waldemar Brodkorb 2023-09-07 09:06:01 UTC
uClibc is doing this nearly since the beginning (commit f91e94f6c5a1f1d6dfd3e5a535df303b805bf321 in 2001). I think normally this is okay, because uClibc tries to be compatible to glibc. There are cornercases like this issue. I think the patch is useful and should be applied.