[Lldb-commits] [lldb] [lldb][cmake] Error out when building debugserver with CMake 4 (PR #138020)
Chelsea Cassanova via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 30 15:03:36 PDT 2025
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138020
>From 4e7c20930b3f8bb0b8d4503544d278d1a561f0fd Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova <chelsea_cassanova at apple.com>
Date: Mon, 28 Apr 2025 10:28:03 -0700
Subject: [PATCH] [lldb][cmake] Error out when building debugserver with CMake
4
CMake 4 no longer sets the `CMAKE_OSX_SYSROOT` variable by default. If
you've updated to CMake 4 on macOS (e.g. with brew) and try building LLDB with
CMake/ninja, this will yield an error when building debugserver that
clang is unable to run since it tries to compile files that don't exist.
These files are supposed to be generated by the `mig` process. `mig`
needs the `CMAKE_OSX_SYSROOT` variable in order to work and without it,
it silently fails to generate the files that later on need to be
compiled.
This commit will fatal error out of config when building debugserver
without having set CMAKE_OSX_SYSROOT.
---
lldb/tools/debugserver/source/CMakeLists.txt | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lldb/tools/debugserver/source/CMakeLists.txt b/lldb/tools/debugserver/source/CMakeLists.txt
index 1a433898f6aa4..bf40a3fb492ac 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -154,6 +154,20 @@ endif()
add_definitions(-DLLDB_USE_OS_LOG)
+if(NOT CMAKE_OSX_SYSROOT)
+ execute_process(COMMAND xcodebuild -version -sdk macosx Path
+ OUTPUT_VARIABLE SDKROOT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT EXISTS ${SDKROOT})
+ message(FATAL_ERROR "Unable to obtain macOS SDK root, debugserver cannot be built.")
+ endif()
+
+ message(STATUS "Using macOS SDK root: ${SDKROOT}")
+ set(CMAKE_OSX_SYSROOT ${SDKROOT})
+endif()
+
if(${CMAKE_OSX_SYSROOT} MATCHES ".Internal.sdk$")
message(STATUS "LLDB debugserver energy support is enabled")
add_definitions(-DLLDB_ENERGY)
More information about the lldb-commits
mailing list