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.
uclibc should 100% not be defining __GLIBC__ at all ..
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
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.