[Lldb-commits] [lldb] [lldb][test] Improve error for C++ compiler detection and improve docs (PR #214199)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 5 04:19:36 PDT 2026
https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/214199
I did not realise that LLDB_TEST_COMPILER should be the C compiler, so I got:
cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
TypeError: can only concatenate str (not "NoneType") to str Config=aarch64-/usr/bin/g++
I have simplified the logic and added a more informative error: RuntimeError: Could not infer C++ compiler name from compiler type "g++" Config=aarch64-/usr/bin/g++
Added a note to the documentation.
The CMake description does say "C compiler", but it's easy to gloss over that so I extended that to say how we get the C++ compiler.
>From f303611a831b13dfb3ec93181446c0a8e4660a80 Mon Sep 17 00:00:00 2001
From: David Spickett <david.spickett at arm.com>
Date: Wed, 5 Aug 2026 10:34:42 +0000
Subject: [PATCH] [lldb][test] Improve error for C++ compiler detection and
improve docs
I did not realise that LLDB_TEST_COMPILER should be the C compiler,
so I got:
cxx = cc_dir / (cc_prefix + cxx_type + cc_ext)
TypeError: can only concatenate str (not "NoneType") to str
Config=aarch64-/usr/bin/g++
I have simplified the logic and added a more informative error:
RuntimeError: Could not infer C++ compiler name from compiler type "g++"
Config=aarch64-/usr/bin/g++
Added a note to the documentation.
The CMake description does say "C compiler", but it's easy to
gloss over that so I extended that to say how we get the C++
compiler.
---
lldb/docs/resources/build.md | 6 ++++++
.../Python/lldbsuite/test/builders/builder.py | 14 +++++++++++---
lldb/test/API/CMakeLists.txt | 2 +-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/lldb/docs/resources/build.md b/lldb/docs/resources/build.md
index aa819483f47a1..e3c3250006051 100644
--- a/lldb/docs/resources/build.md
+++ b/lldb/docs/resources/build.md
@@ -263,6 +263,12 @@ $ cmake -G Ninja \
<path to root of llvm source tree>
```
+:::{note}
+`LLDB_TEST_COMPILER` points to a single compiler. It is expected that this is
+the C compiler and that the C++ compiler's name can be inferred from the name
+of the C compiler.
+:::
+
It is strongly recommend to use a release build for the compiler to speed up
test execution.
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index b5f0f28a8df8a..47ef61030fa16 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -149,10 +149,18 @@ def getToolchainSpec(self, compiler):
"xcrun clang": "xcrun clang++",
}
# Determine the C++ compiler based on the given compiler path/command.
- cxx_type = cxx_types.get(compiler)
- if cxx_type is None:
+ try:
+ cxx_type = cxx_types[compiler]
+ except KeyError:
# If that did not work, then use the inferred cc_type.
- cxx_type = cxx_types.get(cc_type, cxx_type)
+ try:
+ cxx_type = cxx_types[cc_type]
+ except KeyError:
+ err = "Could not infer C++ compiler name from "
+ if compiler is not None:
+ err += f'compiler name "{compiler}" or '
+ err += f'compiler type "{cc_type}"'
+ raise RuntimeError(err)
cc_dir = cc_path.parent
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index bff3bac438d6b..82c95b87e02f2 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -89,7 +89,7 @@ else()
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_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors (the C++ compiler will be inferred from this)")
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")
set(LLDB_TEST_RESOURCE_DIR "" CACHE PATH "Clang resource directory for cross-compiling test inferiors")
More information about the lldb-commits
mailing list