[libcxx] r314735 - Improve test runner output for broken configurations.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 15:52:51 PDT 2017
Author: ericwf
Date: Mon Oct 2 15:52:51 2017
New Revision: 314735
URL: http://llvm.org/viewvc/llvm-project?rev=314735&view=rev
Log:
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.
Modified:
libcxx/trunk/utils/libcxx/compiler.py
libcxx/trunk/utils/libcxx/test/config.py
Modified: libcxx/trunk/utils/libcxx/compiler.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/compiler.py?rev=314735&r1=314734&r2=314735&view=diff
==============================================================================
--- libcxx/trunk/utils/libcxx/compiler.py (original)
+++ libcxx/trunk/utils/libcxx/compiler.py Mon Oct 2 15:52:51 2017
@@ -204,7 +204,7 @@ class CXXCompiler(object):
flags = ['-dM'] + flags
cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd)
if rc != 0:
- return None
+ return cmd, out, err, rc
parsed_macros = {}
lines = [l.strip() for l in out.split('\n') if l.strip()]
for l in lines:
Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=314735&r1=314734&r2=314735&view=diff
==============================================================================
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Mon Oct 2 15:52:51 2017
@@ -259,6 +259,16 @@ class Configuration(object):
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 @@ class Configuration(object):
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 @@ class Configuration(object):
# 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 @@ class Configuration(object):
"""
# 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 @@ class Configuration(object):
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')
More information about the cfe-commits
mailing list