From 42db23579bbaf438a6599bd87ee04411cc3166d5 Mon Sep 17 00:00:00 2001 From: Old-Ding <35417409+Old-Ding@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:15:59 +0800 Subject: [PATCH] Fix glibc detection The existing probe treats any libc with backtrace() as glibc and propagates the result variable name instead of its value. Check the glibc identification macro and return the actual compiler test result to the caller. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com> --- cmake/check_c_compiler_uses_glibc.cmake | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmake/check_c_compiler_uses_glibc.cmake b/cmake/check_c_compiler_uses_glibc.cmake index 46755bec..4cb9f346 100644 --- a/cmake/check_c_compiler_uses_glibc.cmake +++ b/cmake/check_c_compiler_uses_glibc.cmake @@ -21,16 +21,17 @@ function(check_c_compiler_uses_glibc result_variable) include(CheckCSourceCompiles) set(GLIBC_TEST_CODE [====[ - #include + #include + #if defined(__GLIBC__) int main() { - void * buffer[1]; - int size = sizeof(buffer) / sizeof(void *); - backtrace(&buffer, size); 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()