[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

Stefan Gränitz via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 9 04:15:41 PDT 2024


https://github.com/weliveindetail updated https://github.com/llvm/llvm-project/pull/111531

>From c7356d3c265869ff387c977dd18e9c617dc31c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Tue, 8 Oct 2024 15:40:37 +0200
Subject: [PATCH 1/2] [lldb] Add early CMake check for 'make' tool

Around 400 of LLDB's dotest.py based tests require the make tool to be found in Path. If it's not found, they fail with an obscure error and show up as UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but make is not part of that. Let's catch the situation early and raise an error if LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the configuration process. There might be other issues further down the line that can be caught in the same buildbot run.
---
 lldb/test/CMakeLists.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
         "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
     endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+    message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+    message(STATUS "Not found: make")
+    message(SEND_ERROR
+          "LLDB tests require 'make' tool. Please install and add it to Path "
+          "(or otherwise disable strict testing requirements with "
+          "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

>From 5e7bc2d26b54440936b3d756e12d708ae5218c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Wed, 9 Oct 2024 13:07:27 +0200
Subject: [PATCH 2/2] Pass make as an explicit argument to dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py |  2 ++
 lldb/test/API/CMakeLists.txt                  |  1 +
 lldb/test/API/lit.cfg.py                      |  3 +++
 lldb/test/API/lit.site.cfg.py.in              |  1 +
 lldb/test/CMakeLists.txt                      | 20 +++++++++++--------
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index b1ae896d3fd3b4..40294aec166381 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
         configuration.make_path = "gmake"
     else:
         configuration.make_path = "make"
+    if ' ' in configuration.make_path:
+        configuration.make_path = f'"{configuration.make_path}"'
 
     if args.dsymutil:
         configuration.dsymutil = args.dsymutil
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 27f285230cafaf..c426d76f7d9e76 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -58,6 +58,7 @@ endif()
 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing")
 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles")
+set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for building test executables")
 
 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
   message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 96520c7c826246..c6fa20a63424d4 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
     dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+    dotest_cmd += ["--make", config.make]
+
 if is_configured("llvm_tools_dir"):
     dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2a..9f647034dc9f97 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,6 +31,7 @@ config.lldb_executable = lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
+config.make = lit_config.substitute('@LLDB_TEST_MAKE@')
 config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 7993be2602e538..5b00e10af136f1 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -31,15 +31,19 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
   endforeach()
 
   # On Windows make is not part of the MSYS tools that llvm-lit takes care of
-  find_program(MAKE_TOOL make)
-  if(MAKE_TOOL)
-    message(STATUS "Found make: ${MAKE_TOOL}")
+  if(LLDB_TEST_MAKE)
+    set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
   else()
-    message(STATUS "Not found: make")
-    message(SEND_ERROR
-          "LLDB tests require 'make' tool. Please install and add it to Path "
-          "(or otherwise disable strict testing requirements with "
-          "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+    find_program(LLDB_DEFAULT_TEST_MAKE make)
+    if(LLDB_DEFAULT_TEST_MAKE)
+      message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
+    else()
+      message(STATUS "Not found: make")
+      message(SEND_ERROR
+            "LLDB tests require 'make' tool. Please pass via `LLDB_TEST_MAKE` "
+            "(or otherwise disable strict testing requirements with "
+            "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+    endif()
   endif()
 endif()
 



More information about the lldb-commits mailing list