[libcxx-commits] [libcxx] [libc++] Address missing cmake in libcxx.test.googlebenchmark (PR #225590)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 22 23:53:08 PDT 2026


https://github.com/zeroomega updated https://github.com/llvm/llvm-project/pull/225590

>From 4b694d36cb9f36ee39093565771da10d2f569470 Mon Sep 17 00:00:00 2001
From: Haowei Wu <haowei at google.com>
Date: Tue, 22 Sep 2026 21:38:50 -0700
Subject: [PATCH] [libc++] Address missing cmake in libcxx.test.googlebenchmark

We are seeing python exception after #224192 was landed as cmake
could not be found if "CMAKE" is absent from environment variables.
This patch addresses this issue by using cmake from lit config.
This patch also passthrough CMAKE_MAKE_PROGRAM and -G from lit
to avoid implicit dependency on GNU make, which may be absent on
host.
---
 libcxx/test/CMakeLists.txt                  |  3 ++
 libcxx/utils/libcxx/test/googlebenchmark.py | 55 ++++++++++++++-------
 2 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 85fa6aacc7796..74524c2330bd0 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -24,6 +24,9 @@ set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!"
 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
 
 serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}")
+serialize_lit_string_param(SERIALIZED_LIT_PARAMS cmake "${CMAKE_COMMAND}")
+serialize_lit_string_param(SERIALIZED_LIT_PARAMS cmake_generator "${CMAKE_GENERATOR}")
+serialize_lit_string_param(SERIALIZED_LIT_PARAMS cmake_make_program "${CMAKE_MAKE_PROGRAM}")
 
 if (LIBCXX_INCLUDE_BENCHMARKS)
   set(_libcxx_benchmark_mode "dry-run")
diff --git a/libcxx/utils/libcxx/test/googlebenchmark.py b/libcxx/utils/libcxx/test/googlebenchmark.py
index b5fe708e67f8c..5c496fa890754 100644
--- a/libcxx/utils/libcxx/test/googlebenchmark.py
+++ b/libcxx/utils/libcxx/test/googlebenchmark.py
@@ -180,31 +180,50 @@ def prepare(config, litConfig):
     installDir = os.path.join(prefix, "install")
     os.makedirs(root, exist_ok=True)
 
-    cmake = os.environ.get("CMAKE", "cmake")
+    cmake = (
+        litConfig.params.get("cmake")
+        or getattr(config, "cmake", None)
+        or os.environ.get("CMAKE", "cmake")
+    )
+    cmake_generator = (
+        litConfig.params.get("cmake_generator")
+        or getattr(config, "cmake_generator", None)
+        or os.environ.get("CMAKE_GENERATOR")
+    )
+    cmake_make_program = (
+        litConfig.params.get("cmake_make_program")
+        or getattr(config, "cmake_make_program", None)
+        or os.environ.get("CMAKE_MAKE_PROGRAM")
+    )
 
     if not os.path.exists(os.path.join(buildDir, "CMakeCache.txt")):
         litConfig.note("Configuring GoogleBenchmark in {}".format(buildDir))
         compiler = _expand(config, _getSubstitution("%{cxx}", config))
+        configure_cmd = [
+            cmake,
+            "-S", SOURCE_DIR,
+            "-B", buildDir,
+            "-DCMAKE_BUILD_TYPE=Release",
+            "-DCMAKE_CXX_COMPILER={}".format(compiler),
+            "-DCMAKE_CXX_FLAGS={}".format(" ".join(flags)),
+            # Set CMAKE_EXE_LINKER_FLAGS in addition to BENCHMARK_CXX_LIBRARIES since we
+            # need CMake's own probe executables to have the right linker flags.
+            "-DCMAKE_EXE_LINKER_FLAGS={}".format(" ".join("-l{}".format(lib) for lib in libraries)),
+            "-DCMAKE_INSTALL_PREFIX={}".format(installDir),
+            "-DCMAKE_INSTALL_LIBDIR=lib",
+            "-DBENCHMARK_CXX_LIBRARIES={}".format(";".join(libraries)),
+            "-DBENCHMARK_ENABLE_TESTING=OFF",
+            "-DBENCHMARK_ENABLE_WERROR=OFF",
+            "-DBENCHMARK_INSTALL_DOCS=OFF",
+        ]
+        if cmake_generator:
+            configure_cmd += ["-G", cmake_generator]
+        if cmake_make_program:
+            configure_cmd += ["-DCMAKE_MAKE_PROGRAM={}".format(cmake_make_program)]
         _run(
             litConfig,
             "configure",
-            [
-                cmake,
-                "-S", SOURCE_DIR,
-                "-B", buildDir,
-                "-DCMAKE_BUILD_TYPE=Release",
-                "-DCMAKE_CXX_COMPILER={}".format(compiler),
-                "-DCMAKE_CXX_FLAGS={}".format(" ".join(flags)),
-                # Set CMAKE_EXE_LINKER_FLAGS in addition to BENCHMARK_CXX_LIBRARIES since we
-                # need CMake's own probe executables to have the right linker flags.
-                "-DCMAKE_EXE_LINKER_FLAGS={}".format(" ".join("-l{}".format(lib) for lib in libraries)),
-                "-DCMAKE_INSTALL_PREFIX={}".format(installDir),
-                "-DCMAKE_INSTALL_LIBDIR=lib",
-                "-DBENCHMARK_CXX_LIBRARIES={}".format(";".join(libraries)),
-                "-DBENCHMARK_ENABLE_TESTING=OFF",
-                "-DBENCHMARK_ENABLE_WERROR=OFF",
-                "-DBENCHMARK_INSTALL_DOCS=OFF",
-            ],
+            configure_cmd,
             cwd=root,
         )
 



More information about the libcxx-commits mailing list