[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
Thu Oct 10 03:35:33 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/7] [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/7] 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()
 

>From 908f0865907d62fce607e782259b04de58be3ac9 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:28:08 +0200
Subject: [PATCH 3/7] Fix Python code format detail

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 40294aec166381..083be5b468994b 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,7 +272,7 @@ def parseOptionsAndInitTestdirs():
         configuration.make_path = "gmake"
     else:
         configuration.make_path = "make"
-    if ' ' in configuration.make_path:
+    if " " in configuration.make_path:
         configuration.make_path = f'"{configuration.make_path}"'
 
     if args.dsymutil:

>From 3f6b93d932d9755c668d31b9c75c152bb3599bbe 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 18:55:19 +0200
Subject: [PATCH 4/7] [lldb] Generalize make tool detection in CMake

---
 lldb/test/API/CMakeLists.txt | 18 ++++++++++++++++++
 lldb/test/CMakeLists.txt     | 16 ----------------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index c426d76f7d9e76..a8602942cfac94 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -49,6 +49,24 @@ set(LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXEC
 
 set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTABLE_SUFFIX}")
 
+if(LLDB_TEST_MAKE)
+  set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+else()
+  if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+    find_program(LLDB_DEFAULT_TEST_MAKE gmake)
+  else()
+    find_program(LLDB_DEFAULT_TEST_MAKE make)
+  endif()
+  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 tests with `LLDB_INCLUDE_TESTS=OFF`)")
+  endif()
+endif()
+
 if (TARGET clang)
   set(LLDB_DEFAULT_TEST_COMPILER "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
 else()
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5b00e10af136f1..5ac474736eb63d 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,22 +29,6 @@ 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
-  if(LLDB_TEST_MAKE)
-    set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
-  else()
-    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()
 
 if(LLDB_BUILT_STANDALONE)

>From 994cb5acdcf60b040f7aa694074f883ebfdbc798 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 19:00:01 +0200
Subject: [PATCH 5/7] Drop special-case for BSDs in dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 083be5b468994b..2d626731f1020f 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -268,10 +268,6 @@ def parseOptionsAndInitTestdirs():
 
     if args.make:
         configuration.make_path = args.make
-    elif platform_system == "FreeBSD" or platform_system == "NetBSD":
-        configuration.make_path = "gmake"
-    else:
-        configuration.make_path = "make"
     if " " in configuration.make_path:
         configuration.make_path = f'"{configuration.make_path}"'
 

>From 2ce0f997bbf38440877965113f2e319ebe333901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Thu, 10 Oct 2024 12:31:56 +0200
Subject: [PATCH 6/7] Drop quoting for the make tool path in dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2d626731f1020f..681ea1638f2d6f 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -268,8 +268,6 @@ def parseOptionsAndInitTestdirs():
 
     if args.make:
         configuration.make_path = args.make
-    if " " in configuration.make_path:
-        configuration.make_path = f'"{configuration.make_path}"'
 
     if args.dsymutil:
         configuration.dsymutil = args.dsymutil

>From 7405281bf83988fc2da7b64e59471c32c16a01a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Thu, 10 Oct 2024 12:34:21 +0200
Subject: [PATCH 7/7] Detect make and gmake in a single CMake find_program and
 drop special-case for BSDs

---
 lldb/test/API/CMakeLists.txt | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index a8602942cfac94..896ce2c8c27724 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -52,11 +52,7 @@ set(LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_TOOLS_BINARY_DIR}/dsymutil${CMAKE_EXECUTA
 if(LLDB_TEST_MAKE)
   set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
 else()
-  if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
-    find_program(LLDB_DEFAULT_TEST_MAKE gmake)
-  else()
-    find_program(LLDB_DEFAULT_TEST_MAKE make)
-  endif()
+  find_program(LLDB_DEFAULT_TEST_MAKE make gmake)
   if(LLDB_DEFAULT_TEST_MAKE)
     message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")
   else()



More information about the lldb-commits mailing list