[Lldb-commits] [lldb] [lldb] Add extra logic to find llvm-nm in standalone builds (PR #227487)

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 29 14:55:04 PDT 2026


https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/227487

If one builds LLDB standalone against an LLVM that builds but does not export an llvm-nm target, then LLDB will fail to build when also using dynamic script interpreters.

To account for this, we use the same logic for finding llvm-tblgen. I intentionally did not deduplicate the logic because they are run in slightly different scenarios. I plan on joining these together with a macro once another tool is needed.

>From fcc266f8233bdb264418a216ff4fbab9ab52489a Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford at apple.com>
Date: Tue, 29 Sep 2026 14:46:50 -0700
Subject: [PATCH] [lldb] Add extra logic to find llvm-nm in standalone builds

If one builds LLDB standalone against an LLVM that builds but does not
export an llvm-nm target, then LLDB will fail to build when also using
dynamic script interpreters.

To account for this, we use the same logic for finding llvm-tblgen. I
intentionally did not deduplicate the logic because they are run in
slightly different scenarios. I plan on joining these together with a
macro once another tool is needed.
---
 lldb/cmake/modules/LLDBStandalone.cmake | 28 +++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lldb/cmake/modules/LLDBStandalone.cmake b/lldb/cmake/modules/LLDBStandalone.cmake
index 1a4cdbfbb1cc7..cb8be08aa723c 100644
--- a/lldb/cmake/modules/LLDBStandalone.cmake
+++ b/lldb/cmake/modules/LLDBStandalone.cmake
@@ -71,6 +71,34 @@ else()
   endif()
 endif()
 
+# If llvm-nm is built but the target is not exported, we need to find it to
+# build the dynamic script interpreters.
+if (NOT LLVM_NM)
+  if (CMAKE_CROSSCOMPILING)
+    set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
+    if (NOT EXISTS "${LLVM_NATIVE_BUILD}")
+      message(FATAL_ERROR "Attempting to cross-compile LLDB standalone but no native LLVM build found. Please cross-compile LLVM as well.")
+    endif()
+
+    if (CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
+      set(HOST_EXECUTABLE_SUFFIX ".exe")
+    endif()
+
+    if (NOT CMAKE_CONFIGURATION_TYPES)
+      set(LLVM_NM "${LLVM_NATIVE_BUILD}/bin/llvm-nm${HOST_EXECUTABLE_SUFFIX}")
+    else()
+      # NOTE: LLVM NATIVE build is always built Release, as is specified in
+      # CrossCompile.cmake
+      set(LLVM_NM
+        "${LLVM_NATIVE_BUILD}/Release/bin/llvm-nm${HOST_EXECUTABLE_SUFFIX}")
+    endif()
+  else()
+    set(nm_file_name "llvm-nm${CMAKE_EXECUTABLE_SUFFIX}")
+    append_configuration_directories(${LLVM_TOOLS_BINARY_DIR} config_dirs)
+    find_program(LLVM_NM ${nm_file_name} ${config_dirs} NO_DEFAULT_PATH)
+  endif()
+endif()
+
 # They are used as destination of target generators.
 set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
 set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})



More information about the lldb-commits mailing list