Improve test runner output for broken configurations.
Previously LIT would often fail while attempting to set up/configure
the test compiler; normally when attempting to dump the builtin macros.
This sort of failure provided no useful information about what went
wrong with the compiler, making the actual issues hard --- if not
impossible --- to debug easily.
This patch changes the LIT configuration to report the failure explicitly,
including the failed compile command and the stdout/stderr output.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314735 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/libcxx/test/config.py b/utils/libcxx/test/config.py
index 2ee4192..8d41793 100644
--- a/utils/libcxx/test/config.py
+++ b/utils/libcxx/test/config.py
@@ -259,6 +259,16 @@
compile_flags=compile_flags,
link_flags=link_flags)
+ def _dump_macros_verbose(self, *args, **kwargs):
+ macros_or_error = self.cxx.dumpMacros(*args, **kwargs)
+ if isinstance(macros_or_error, tuple):
+ cmd, out, err, rc = macros_or_error
+ report = libcxx.util.makeReport(cmd, out, err, rc)
+ report += "Compiler failed unexpectedly when dumping macros!"
+ self.lit_config.fatal(report)
+ return None
+ assert isinstance(macros_or_error, dict)
+ return macros_or_error
def configure_src_root(self):
self.libcxx_src_root = self.get_lit_conf(
@@ -446,7 +456,7 @@
if self.get_lit_bool('has_libatomic', False):
self.config.available_features.add('libatomic')
- macros = self.cxx.dumpMacros()
+ macros = self._dump_macros_verbose()
if '__cpp_if_constexpr' not in macros:
self.config.available_features.add('libcpp-no-if-constexpr')
@@ -468,7 +478,7 @@
# Attempt to detect the glibc version by querying for __GLIBC__
# in 'features.h'.
- macros = self.cxx.dumpMacros(flags=['-include', 'features.h'])
+ macros = self._dump_macros_verbose(flags=['-include', 'features.h'])
if macros is not None and '__GLIBC__' in macros:
maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__'])
self.config.available_features.add('glibc')
@@ -627,8 +637,8 @@
"""
# Parse the macro contents of __config_site by dumping the macros
# using 'c++ -dM -E' and filtering the predefines.
- predefines = self.cxx.dumpMacros()
- macros = self.cxx.dumpMacros(header)
+ predefines = self._dump_macros_verbose()
+ macros = self._dump_macros_verbose(header)
feature_macros_keys = set(macros.keys()) - set(predefines.keys())
feature_macros = {}
for k in feature_macros_keys:
@@ -980,7 +990,7 @@
def configure_coroutines(self):
if self.cxx.hasCompileFlag('-fcoroutines-ts'):
- macros = self.cxx.dumpMacros(flags=['-fcoroutines-ts'])
+ macros = self._dump_macros_verbose(flags=['-fcoroutines-ts'])
if '__cpp_coroutines' not in macros:
self.lit_config.warning('-fcoroutines-ts is supported but '
'__cpp_coroutines is not defined')