Author: Will Hawkins Date: 2024-08-20T21:09:08-07:00 New Revision: 35cec805bfa91fd9b83c29c45f3a5877e484bd85
URL: https://github.com/llvm/llvm-project/commit/35cec805bfa91fd9b83c29c45f3a5877e484bd85 DIFF: https://github.com/llvm/llvm-project/commit/35cec805bfa91fd9b83c29c45f3a5877e484bd85.diff LOG: [lldb][test] Workaround older systems that lack gettid (#104831) Older glibc versions do not provide `gettid`. Provide our own `gettid` in these cases. Fixes a build failure caused by #104109. Added: Modified: lldb/unittests/Process/elf-core/CMakeLists.txt lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp Removed: ################################################################################ diff --git a/lldb/unittests/Process/elf-core/CMakeLists.txt b/lldb/unittests/Process/elf-core/CMakeLists.txt index b852a3ffb863c1..68ab6e0683c182 100644 --- a/lldb/unittests/Process/elf-core/CMakeLists.txt +++ b/lldb/unittests/Process/elf-core/CMakeLists.txt @@ -1,3 +1,6 @@ +include(CheckSymbolExists) +include(CMakePushCheckState) + add_lldb_unittest(ProcessElfCoreTests ThreadElfCoreTest.cpp @@ -13,3 +16,11 @@ add_lldb_unittest(ProcessElfCoreTests LINK_COMPONENTS Support ) + +cmake_push_check_state() +set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) +check_symbol_exists(gettid "unistd.h" HAVE_GETTID) +if(HAVE_GETTID) + target_compile_definitions(ProcessElfCoreTests PRIVATE HAVE_GETTID) +endif() +cmake_pop_check_state() diff --git a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp index 3bc8b9053d2009..288729b4470607 100644 --- a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp +++ b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp @@ -24,6 +24,11 @@ #include <sys/resource.h> #include <unistd.h> +#ifndef HAVE_GETTID +#include <sys/syscall.h> +pid_t gettid() { return ((pid_t)syscall(SYS_gettid)); } +#endif + using namespace lldb_private; namespace { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits