glibc detection is broken (patch included)
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 77
- Forks
- 135
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 10
Description
Hi,
The test in cmake/check_c_compiler_uses_glibc.cmake doesn't work reliably because backtrace(3) is not a glibc unique feature (e.g. NetBSD libc has a compatible backtrace(3) function).
Also, the result of the test is not properly affected to the parent scope variable.
Here is a quick fix:
--- cmake/check_c_compiler_uses_glibc.cmake~ 2026-05-06 20:34:17.000000000 +0200
+++ cmake/check_c_compiler_uses_glibc.cmake 2026-06-04 19:56:41.358940607 +0200
@@ -21,16 +21,15 @@
include(CheckCSourceCompiles)
set(GLIBC_TEST_CODE [====[
- #include <execinfo.h>
+#include <features.h>
- int main() {
- void * buffer[1];
- int size = sizeof(buffer) / sizeof(void *);
- backtrace(&buffer, size);
- return 0;
- }
+#if defined(__GLIBC__)
+int main() { return 0; }
+#else
+#error
+#endif
]====])
check_c_source_compiles("${GLIBC_TEST_CODE}" ${result_variable})
- set(${result_variable} ${result_variable} PARENT_SCOPE)
+ set(${result_variable} ${${result_variable}} PARENT_SCOPE)
endfunction()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cmake/check_c_compiler_uses_glibc.cmake, focusing on GLIBC_TEST_CODE and how check_c_source_compiles stores and propagates its result. Compare the current detection with the included patch, then verify that the result distinguishes glibc from compatible non-glibc libc implementations and is available in the parent scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100