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
This commit is contained in:
Eric Fiselier
2017-10-02 22:52:51 +00:00
parent f17205d6a8
commit 5fe8797d57
2 changed files with 16 additions and 6 deletions

View File

@@ -204,7 +204,7 @@ class CXXCompiler(object):
flags = ['-dM'] + flags flags = ['-dM'] + flags
cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd) cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd)
if rc != 0: if rc != 0:
return None return cmd, out, err, rc
parsed_macros = {} parsed_macros = {}
lines = [l.strip() for l in out.split('\n') if l.strip()] lines = [l.strip() for l in out.split('\n') if l.strip()]
for l in lines: for l in lines:

View File

@@ -259,6 +259,16 @@ class Configuration(object):
compile_flags=compile_flags, compile_flags=compile_flags,
link_flags=link_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): def configure_src_root(self):
self.libcxx_src_root = self.get_lit_conf( self.libcxx_src_root = self.get_lit_conf(
@@ -446,7 +456,7 @@ class Configuration(object):
if self.get_lit_bool('has_libatomic', False): if self.get_lit_bool('has_libatomic', False):
self.config.available_features.add('libatomic') self.config.available_features.add('libatomic')
macros = self.cxx.dumpMacros() macros = self._dump_macros_verbose()
if '__cpp_if_constexpr' not in macros: if '__cpp_if_constexpr' not in macros:
self.config.available_features.add('libcpp-no-if-constexpr') 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__ # Attempt to detect the glibc version by querying for __GLIBC__
# in 'features.h'. # 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: if macros is not None and '__GLIBC__' in macros:
maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__']) maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__'])
self.config.available_features.add('glibc') self.config.available_features.add('glibc')
@@ -627,8 +637,8 @@ class Configuration(object):
""" """
# Parse the macro contents of __config_site by dumping the macros # Parse the macro contents of __config_site by dumping the macros
# using 'c++ -dM -E' and filtering the predefines. # using 'c++ -dM -E' and filtering the predefines.
predefines = self.cxx.dumpMacros() predefines = self._dump_macros_verbose()
macros = self.cxx.dumpMacros(header) macros = self._dump_macros_verbose(header)
feature_macros_keys = set(macros.keys()) - set(predefines.keys()) feature_macros_keys = set(macros.keys()) - set(predefines.keys())
feature_macros = {} feature_macros = {}
for k in feature_macros_keys: for k in feature_macros_keys:
@@ -980,7 +990,7 @@ class Configuration(object):
def configure_coroutines(self): def configure_coroutines(self):
if self.cxx.hasCompileFlag('-fcoroutines-ts'): 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: if '__cpp_coroutines' not in macros:
self.lit_config.warning('-fcoroutines-ts is supported but ' self.lit_config.warning('-fcoroutines-ts is supported but '
'__cpp_coroutines is not defined') '__cpp_coroutines is not defined')