<div dir="ltr">@Ben you accidentally commited CRLF linefeeds here. Be careful!<div><br></div><div>Could you revert this and re-commit your change w/o all the noise?<br><div><br></div><div>/Eric</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 8, 2017 at 7:15 AM, Ben Craig via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bcraig<br>
Date: Mon May 8 08:15:22 2017<br>
New Revision: 302421<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302421&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=302421&view=rev</a><br>
Log:<br>
Fix Windows tests when __config_site is present.<br>
Previously, the force includes would complain about a missing _DEBUG symbol.<br>
Now we dump macros before adding the force includes to the command line.<br>
<br>
Modified:<br>
libcxx/trunk/utils/libcxx/<wbr>test/config.py<br>
<br>
Modified: libcxx/trunk/utils/libcxx/<wbr>test/config.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=302421&r1=302420&r2=302421&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/utils/<wbr>libcxx/test/config.py?rev=<wbr>302421&r1=302420&r2=302421&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/utils/libcxx/<wbr>test/config.py (original)<br>
+++ libcxx/trunk/utils/libcxx/<wbr>test/config.py Mon May 8 08:15:22 2017<br>
@@ -1,1113 +1,1113 @@<br>
-#===-------------------------<wbr>------------------------------<wbr>---------------===##<br>
-#<br>
-# The LLVM Compiler Infrastructure<br>
-#<br>
-# This file is dual licensed under the MIT and the University of Illinois Open<br>
-# Source Licenses. See LICENSE.TXT for details.<br>
-#<br>
-#===-------------------------<wbr>------------------------------<wbr>---------------===##<br>
-<br>
-import locale<br>
-import os<br>
-import platform<br>
-import pkgutil<br>
-import pipes<br>
-import re<br>
-import shlex<br>
-import shutil<br>
-import sys<br>
-<br>
-from libcxx.compiler import CXXCompiler<br>
-from libcxx.test.target_info import make_target_info<br>
-from libcxx.test.executor import *<br>
-from libcxx.test.tracing import *<br>
-import libcxx.util<br>
-<br>
-def loadSiteConfig(lit_config, config, param_name, env_name):<br>
- # We haven't loaded the site specific configuration (the user is<br>
- # probably trying to run on a test file directly, and either the site<br>
- # configuration hasn't been created by the build system, or we are in an<br>
- # out-of-tree build situation).<br>
- site_cfg = lit_config.params.get(param_<wbr>name,<br>
- os.environ.get(env_name))<br>
- if not site_cfg:<br>
- lit_config.warning('No site specific configuration file found!'<br>
- ' Running the tests in the default configuration.')<br>
- elif not os.path.isfile(site_cfg):<br>
- lit_config.fatal(<br>
- "Specified site configuration file does not exist: '%s'" %<br>
- site_cfg)<br>
- else:<br>
- lit_config.note('using site specific configuration at %s' % site_cfg)<br>
- ld_fn = lit_config.load_config<br>
-<br>
- # Null out the load_config function so that lit.site.cfg doesn't<br>
- # recursively load a config even if it tries.<br>
- # TODO: This is one hell of a hack. Fix it.<br>
- def prevent_reload_fn(*args, **kwargs):<br>
- pass<br>
- lit_config.load_config = prevent_reload_fn<br>
- ld_fn(config, site_cfg)<br>
- lit_config.load_config = ld_fn<br>
-<br>
-class Configuration(object):<br>
- # pylint: disable=redefined-outer-name<br>
- def __init__(self, lit_config, config):<br>
- self.lit_config = lit_config<br>
- self.config = config<br>
- self.is_windows = platform.system() == 'Windows'<br>
- self.cxx = None<br>
- self.cxx_is_clang_cl = None<br>
- self.cxx_stdlib_under_test = None<br>
- self.project_obj_root = None<br>
- self.libcxx_src_root = None<br>
- self.libcxx_obj_root = None<br>
- self.cxx_library_root = None<br>
- self.cxx_runtime_root = None<br>
- self.abi_library_root = None<br>
- self.link_shared = self.get_lit_bool('enable_<wbr>shared', default=True)<br>
- self.debug_build = self.get_lit_bool('debug_<wbr>build', default=False)<br>
- self.exec_env = {}<br>
- self.use_target = False<br>
- self.use_system_cxx_lib = False<br>
- self.use_clang_verify = False<br>
- self.long_tests = None<br>
- self.execute_external = False<br>
-<br>
- def get_lit_conf(self, name, default=None):<br>
- val = self.lit_config.params.get(<wbr>name, None)<br>
- if val is None:<br>
- val = getattr(self.config, name, None)<br>
- if val is None:<br>
- val = default<br>
- return val<br>
-<br>
- def get_lit_bool(self, name, default=None, env_var=None):<br>
- def check_value(value, var_name):<br>
- if value is None:<br>
- return default<br>
- if isinstance(value, bool):<br>
- return value<br>
- if not isinstance(value, str):<br>
- raise TypeError('expected bool or string')<br>
- if value.lower() in ('1', 'true'):<br>
- return True<br>
- if value.lower() in ('', '0', 'false'):<br>
- return False<br>
- self.lit_config.fatal(<br>
- "parameter '{}' should be true or false".format(var_name))<br>
-<br>
- conf_val = self.get_lit_conf(name)<br>
- if env_var is not None and env_var in os.environ and \<br>
- os.environ[env_var] is not None:<br>
- val = os.environ[env_var]<br>
- if conf_val is not None:<br>
- self.lit_config.warning(<br>
- 'Environment variable %s=%s is overriding explicit '<br>
- '--param=%s=%s' % (env_var, val, name, conf_val))<br>
- return check_value(val, env_var)<br>
- return check_value(conf_val, name)<br>
-<br>
- def make_static_lib_name(self, name):<br>
- """Return the full filename for the specified library name"""<br>
- if self.is_windows:<br>
- assert name == 'c++' # Only allow libc++ to use this function for now.<br>
- return 'lib' + name + '.lib'<br>
- else:<br>
- return 'lib' + name + '.a'<br>
-<br>
- def configure(self):<br>
- self.configure_executor()<br>
- self.configure_use_system_cxx_<wbr>lib()<br>
- self.configure_target_info()<br>
- self.configure_cxx()<br>
- self.configure_triple()<br>
- self.configure_deployment()<br>
- self.configure_availability()<br>
- self.configure_src_root()<br>
- self.configure_obj_root()<br>
- self.configure_cxx_stdlib_<wbr>under_test()<br>
- self.configure_cxx_library_<wbr>root()<br>
- self.configure_use_clang_<wbr>verify()<br>
- self.configure_use_thread_<wbr>safety()<br>
- self.configure_execute_<wbr>external()<br>
- self.configure_ccache()<br>
- self.configure_compile_flags()<br>
- self.configure_filesystem_<wbr>compile_flags()<br>
- self.configure_link_flags()<br>
- self.configure_env()<br>
- self.configure_color_<wbr>diagnostics()<br>
- self.configure_debug_mode()<br>
- self.configure_warnings()<br>
- self.configure_sanitizer()<br>
- self.configure_coverage()<br>
- self.configure_modules()<br>
- self.configure_substitutions()<br>
- self.configure_features()<br>
-<br>
- def print_config_info(self):<br>
- # Print the final compile and link flags.<br>
- self.lit_config.note('Using compiler: %s' % self.cxx.path)<br>
- self.lit_config.note('Using flags: %s' % self.cxx.flags)<br>
- if self.cxx.use_modules:<br>
- self.lit_config.note('Using modules flags: %s' %<br>
- self.cxx.modules_flags)<br>
- self.lit_config.note('Using compile flags: %s'<br>
- % self.cxx.compile_flags)<br>
- if len(self.cxx.warning_flags):<br>
- self.lit_config.note('Using warnings: %s' % self.cxx.warning_flags)<br>
- self.lit_config.note('Using link flags: %s' % self.cxx.link_flags)<br>
- # Print as list to prevent "set([...])" from being printed.<br>
- self.lit_config.note('Using available_features: %s' %<br>
- list(self.config.available_<wbr>features))<br>
- self.lit_config.note('Using environment: %r' % self.exec_env)<br>
- sys.stderr.flush() # Force flushing to avoid broken output on Windows<br>
-<br>
- def get_test_format(self):<br>
- from libcxx.test.format import LibcxxTestFormat<br>
- return LibcxxTestFormat(<br>
- self.cxx,<br>
- self.use_clang_verify,<br>
- self.execute_external,<br>
- self.executor,<br>
- exec_env=self.exec_env)<br>
-<br>
- def configure_executor(self):<br>
- exec_str = self.get_lit_conf('executor', "None")<br>
- te = eval(exec_str)<br>
- if te:<br>
- self.lit_config.note("Using executor: %r" % exec_str)<br>
- if self.lit_config.useValgrind:<br>
- # We have no way of knowing where in the chain the<br>
- # ValgrindExecutor is supposed to go. It is likely<br>
- # that the user wants it at the end, but we have no<br>
- # way of getting at that easily.<br>
- selt.lit_config.fatal("Cannot infer how to create a Valgrind "<br>
- " executor.")<br>
- else:<br>
- te = LocalExecutor()<br>
- if self.lit_config.useValgrind:<br>
- te = ValgrindExecutor(self.lit_<wbr>config.valgrindArgs, te)<br>
- self.executor = te<br>
-<br>
- def configure_target_info(self):<br>
- self.target_info = make_target_info(self)<br>
-<br>
- def configure_cxx(self):<br>
- # Gather various compiler parameters.<br>
- cxx = self.get_lit_conf('cxx_under_<wbr>test')<br>
- self.cxx_is_clang_cl = cxx is not None and \<br>
- os.path.basename(cxx) == 'clang-cl.exe'<br>
- # If no specific cxx_under_test was given, attempt to infer it as<br>
- # clang++.<br>
- if cxx is None or self.cxx_is_clang_cl:<br>
- search_paths = self.config.environment['PATH'<wbr>]<br>
- if cxx is not None and os.path.isabs(cxx):<br>
- search_paths = os.path.dirname(cxx)<br>
- clangxx = libcxx.util.which('clang++', search_paths)<br>
- if clangxx:<br>
- cxx = clangxx<br>
- self.lit_config.note(<br>
- "inferred cxx_under_test as: %r" % cxx)<br>
- elif self.cxx_is_clang_cl:<br>
- self.lit_config.fatal('Failed to find clang++ substitution for'<br>
- ' clang-cl')<br>
- if not cxx:<br>
- self.lit_config.fatal('must specify user parameter cxx_under_test '<br>
- '(e.g., --param=cxx_under_test=clang++<wbr>)')<br>
- self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \<br>
- self._configure_clang_cl(cxx)<br>
- cxx_type = self.cxx.type<br>
- if cxx_type is not None:<br>
- assert self.cxx.version is not None<br>
- maj_v, min_v, _ = self.cxx.version<br>
- self.config.available_<wbr>features.add(cxx_type)<br>
- self.config.available_<wbr>features.add('%s-%s' % (cxx_type, maj_v))<br>
- self.config.available_<wbr>features.add('%s-%s.%s' % (<br>
- cxx_type, maj_v, min_v))<br>
- self.cxx.compile_env = dict(os.environ)<br>
- # 'CCACHE_CPP2' prevents ccache from stripping comments while<br>
- # preprocessing. This is required to prevent stripping of '-verify'<br>
- # comments.<br>
- self.cxx.compile_env['CCACHE_<wbr>CPP2'] = '1'<br>
-<br>
- def _configure_clang_cl(self, clang_path):<br>
- def _split_env_var(var):<br>
- return [p.strip() for p in os.environ.get(var, '').split(';') if p.strip()]<br>
-<br>
- def _prefixed_env_list(var, prefix):<br>
- from itertools import chain<br>
- return list(chain.from_iterable((<wbr>prefix, path) for path in _split_env_var(var)))<br>
-<br>
- assert self.cxx_is_clang_cl<br>
- flags = []<br>
- compile_flags = _prefixed_env_list('INCLUDE', '-isystem')<br>
- link_flags = _prefixed_env_list('LIB', '-L')<br>
- for path in _split_env_var('LIB'):<br>
- self.add_path(self.exec_env, path)<br>
- return CXXCompiler(clang_path, flags=flags,<br>
- compile_flags=compile_flags,<br>
- link_flags=link_flags)<br>
-<br>
-<br>
- def configure_src_root(self):<br>
- self.libcxx_src_root = self.get_lit_conf(<br>
- 'libcxx_src_root', os.path.dirname(self.config.<wbr>test_source_root))<br>
-<br>
- def configure_obj_root(self):<br>
- self.project_obj_root = self.get_lit_conf('project_<wbr>obj_root')<br>
- self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_<wbr>root')<br>
- if not self.libcxx_obj_root and self.project_obj_root is not None:<br>
- possible_root = os.path.join(self.project_obj_<wbr>root, 'projects', 'libcxx')<br>
- if os.path.isdir(possible_root):<br>
- self.libcxx_obj_root = possible_root<br>
- else:<br>
- self.libcxx_obj_root = self.project_obj_root<br>
-<br>
- def configure_cxx_library_root(<wbr>self):<br>
- self.cxx_library_root = self.get_lit_conf('cxx_<wbr>library_root',<br>
- self.libcxx_obj_root)<br>
- self.cxx_runtime_root = self.get_lit_conf('cxx_<wbr>runtime_root',<br>
- self.cxx_library_root)<br>
-<br>
- def configure_use_system_cxx_lib(<wbr>self):<br>
- # This test suite supports testing against either the system library or<br>
- # the locally built one; the former mode is useful for testing ABI<br>
- # compatibility between the current headers and a shipping dynamic<br>
- # library.<br>
- # Default to testing against the locally built libc++ library.<br>
- self.use_system_cxx_lib = self.get_lit_conf('use_system_<wbr>cxx_lib')<br>
- if self.use_system_cxx_lib == 'true':<br>
- self.use_system_cxx_lib = True<br>
- elif self.use_system_cxx_lib == 'false':<br>
- self.use_system_cxx_lib = False<br>
- elif self.use_system_cxx_lib:<br>
- assert os.path.isdir(self.use_system_<wbr>cxx_lib)<br>
- self.lit_config.note(<br>
- "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)<br>
-<br>
- def configure_availability(self):<br>
- # See <a href="http://llvm.org/docs/AvailabilityMarkup.html" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>AvailabilityMarkup.html</a><br>
- self.with_availability = self.get_lit_bool('with_<wbr>availability', False)<br>
- self.lit_config.note(<br>
- "inferred with_availability as: %r" % self.with_availability)<br>
-<br>
- def configure_cxx_stdlib_under_<wbr>test(self):<br>
- self.cxx_stdlib_under_test = self.get_lit_conf(<br>
- 'cxx_stdlib_under_test', 'libc++')<br>
- if self.cxx_stdlib_under_test not in \<br>
- ['libc++', 'libstdc++', 'msvc', 'cxx_default']:<br>
- self.lit_config.fatal(<br>
- 'unsupported value for "cxx_stdlib_under_test": %s'<br>
- % self.cxx_stdlib_under_test)<br>
- self.config.available_<wbr>features.add(self.cxx_stdlib_<wbr>under_test)<br>
- if self.cxx_stdlib_under_test == 'libstdc++':<br>
- self.config.available_<wbr>features.add('libstdc++')<br>
- # Manually enable the experimental and filesystem tests for libstdc++<br>
- # if the options aren't present.<br>
- # FIXME this is a hack.<br>
- if self.get_lit_conf('enable_<wbr>experimental') is None:<br>
- self.config.enable_<wbr>experimental = 'true'<br>
- if self.get_lit_conf('enable_<wbr>filesystem') is None:<br>
- self.config.enable_filesystem = 'true'<br>
-<br>
- def configure_use_clang_verify(<wbr>self):<br>
- '''If set, run clang with -verify on failing tests.'''<br>
- if self.with_availability:<br>
- self.use_clang_verify = False<br>
- return<br>
- self.use_clang_verify = self.get_lit_bool('use_clang_<wbr>verify')<br>
- if self.use_clang_verify is None:<br>
- # NOTE: We do not test for the -verify flag directly because<br>
- # -verify will always exit with non-zero on an empty file.<br>
- self.use_clang_verify = self.cxx.isVerifySupported()<br>
- self.lit_config.note(<br>
- "inferred use_clang_verify as: %r" % self.use_clang_verify)<br>
- if self.use_clang_verify:<br>
- self.config.available_<wbr>features.add('verify-support')<br>
-<br>
- def configure_use_thread_safety(<wbr>self):<br>
- '''If set, run clang with -verify on failing tests.'''<br>
- has_thread_safety = self.cxx.hasCompileFlag('-<wbr>Werror=thread-safety')<br>
- if has_thread_safety:<br>
- self.cxx.compile_flags += ['-Werror=thread-safety']<br>
- self.config.available_<wbr>features.add('thread-safety')<br>
- self.lit_config.note("enabling thread-safety annotations")<br>
-<br>
- def configure_execute_external(<wbr>self):<br>
- # Choose between lit's internal shell pipeline runner and a real shell.<br>
- # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the<br>
- # default value. Otherwise we ask the target_info.<br>
- use_lit_shell_default = os.environ.get('LIT_USE_<wbr>INTERNAL_SHELL')<br>
- if use_lit_shell_default is not None:<br>
- use_lit_shell_default = use_lit_shell_default != '0'<br>
- else:<br>
- use_lit_shell_default = self.target_info.use_lit_<wbr>shell_default()<br>
- # Check for the command line parameter using the default value if it is<br>
- # not present.<br>
- use_lit_shell = self.get_lit_bool('use_lit_<wbr>shell',<br>
- use_lit_shell_default)<br>
- self.execute_external = not use_lit_shell<br>
-<br>
- def configure_ccache(self):<br>
- use_ccache_default = os.environ.get('LIBCXX_USE_<wbr>CCACHE') is not None<br>
- use_ccache = self.get_lit_bool('use_ccache'<wbr>, use_ccache_default)<br>
- if use_ccache:<br>
- self.cxx.use_ccache = True<br>
- self.lit_config.note('enabling ccache')<br>
-<br>
- def add_deployment_feature(self, feature):<br>
- (arch, name, version) = self.config.deployment<br>
- self.config.available_<wbr>features.add('%s=%s-%s' % (feature, arch, name))<br>
- self.config.available_<wbr>features.add('%s=%s' % (feature, name))<br>
- self.config.available_<wbr>features.add('%s=%s%s' % (feature, name, version))<br>
-<br>
- def configure_features(self):<br>
- additional_features = self.get_lit_conf('additional_<wbr>features')<br>
- if additional_features:<br>
- for f in additional_features.split(',')<wbr>:<br>
- self.config.available_<wbr>features.add(f.strip())<br>
- self.target_info.add_locale_<wbr>features(self.config.<wbr>available_features)<br>
-<br>
- target_platform = self.target_info.platform()<br>
-<br>
- # Write an "available feature" that combines the triple when<br>
- # use_system_cxx_lib is enabled. This is so that we can easily write<br>
- # XFAIL markers for tests that are known to fail with versions of<br>
- # libc++ as were shipped with a particular triple.<br>
- if self.use_system_cxx_lib:<br>
- self.config.available_<wbr>features.add('with_system_cxx_<wbr>lib')<br>
- self.config.available_<wbr>features.add(<br>
- 'with_system_cxx_lib=%s' % self.config.target_triple)<br>
-<br>
- # Add subcomponents individually.<br>
- target_components = self.config.target_triple.<wbr>split('-')<br>
- for component in target_components:<br>
- self.config.available_<wbr>features.add(<br>
- 'with_system_cxx_lib=%s' % component)<br>
-<br>
- # Add available features for more generic versions of the target<br>
- # triple attached to with_system_cxx_lib.<br>
- if self.use_deployment:<br>
- self.add_deployment_feature('<wbr>with_system_cxx_lib')<br>
-<br>
- # Configure the availability markup checks features.<br>
- if self.with_availability:<br>
- self.config.available_<wbr>features.add('availability_<wbr>markup')<br>
- self.add_deployment_feature('<wbr>availability_markup')<br>
-<br>
- if self.use_system_cxx_lib or self.with_availability:<br>
- self.config.available_<wbr>features.add('availability')<br>
- self.add_deployment_feature('<wbr>availability')<br>
-<br>
- if platform.system() == 'Darwin':<br>
- self.config.available_<wbr>features.add('apple-darwin')<br>
-<br>
- # Insert the platform name into the available features as a lower case.<br>
- self.config.available_<wbr>features.add(target_platform)<br>
-<br>
- # Simulator testing can take a really long time for some of these tests<br>
- # so add a feature check so we can REQUIRES: long_tests in them<br>
- self.long_tests = self.get_lit_bool('long_tests'<wbr>)<br>
- if self.long_tests is None:<br>
- # Default to running long tests.<br>
- self.long_tests = True<br>
- self.lit_config.note(<br>
- "inferred long_tests as: %r" % self.long_tests)<br>
-<br>
- if self.long_tests:<br>
- self.config.available_<wbr>features.add('long_tests')<br>
-<br>
- # Run a compile test for the -fsized-deallocation flag. This is needed<br>
- # in test/std/language.support/<wbr>support.dynamic/new.delete<br>
- if self.cxx.hasCompileFlag('-<wbr>fsized-deallocation'):<br>
- self.config.available_<wbr>features.add('fsized-<wbr>deallocation')<br>
-<br>
- if self.cxx.hasCompileFlag('-<wbr>faligned-allocation'):<br>
- self.config.available_<wbr>features.add('-faligned-<wbr>allocation')<br>
- else:<br>
- # FIXME remove this once more than just clang-4.0 support<br>
- # C++17 aligned allocation.<br>
- self.config.available_<wbr>features.add('no-aligned-<wbr>allocation')<br>
-<br>
- if self.get_lit_bool('has_<wbr>libatomic', False):<br>
- self.config.available_<wbr>features.add('libatomic')<br>
-<br>
- macros = self.cxx.dumpMacros()<br>
- if '__cpp_if_constexpr' not in macros:<br>
- self.config.available_<wbr>features.add('libcpp-no-if-<wbr>constexpr')<br>
-<br>
- if '__cpp_structured_bindings' not in macros:<br>
- self.config.available_<wbr>features.add('libcpp-no-<wbr>structured-bindings')<br>
-<br>
- if '__cpp_deduction_guides' not in macros:<br>
- self.config.available_<wbr>features.add('libcpp-no-<wbr>deduction-guides')<br>
-<br>
- if self.is_windows:<br>
- self.config.available_<wbr>features.add('windows')<br>
- if self.cxx_stdlib_under_test == 'libc++':<br>
- # LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the<br>
- # initial Windows failures until they can be properly diagnosed<br>
- # and fixed. This allows easier detection of new test failures<br>
- # and regressions. Note: New failures should not be suppressed<br>
- # using this feature. (Also see <a href="http://llvm.org/PR32730" rel="noreferrer" target="_blank">llvm.org/PR32730</a>)<br>
- self.config.available_<wbr>features.add('LIBCXX-WINDOWS-<wbr>FIXME')<br>
-<br>
- # Attempt to detect the glibc version by querying for __GLIBC__<br>
- # in 'features.h'.<br>
- macros = self.cxx.dumpMacros(flags=['-<wbr>include', 'features.h'])<br>
- if macros is not None and '__GLIBC__' in macros:<br>
- maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__'])<br>
- self.config.available_<wbr>features.add('glibc')<br>
- self.config.available_<wbr>features.add('glibc-%s' % maj_v)<br>
- self.config.available_<wbr>features.add('glibc-%s.%s' % (maj_v, min_v))<br>
-<br>
- def configure_compile_flags(self):<br>
- no_default_flags = self.get_lit_bool('no_default_<wbr>flags', False)<br>
- if not no_default_flags:<br>
- self.configure_default_<wbr>compile_flags()<br>
- # This include is always needed so add so add it regardless of<br>
- # 'no_default_flags'.<br>
- support_path = os.path.join(self.libcxx_src_<wbr>root, 'test/support')<br>
- self.cxx.compile_flags += ['-I' + support_path]<br>
- # Configure extra flags<br>
- compile_flags_str = self.get_lit_conf('compile_<wbr>flags', '')<br>
- self.cxx.compile_flags += shlex.split(compile_flags_str)<br>
- # FIXME: Can we remove this?<br>
- if self.is_windows:<br>
- self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS']<br>
-<br>
- def configure_default_compile_<wbr>flags(self):<br>
- # Try and get the std version from the command line. Fall back to<br>
- # default given in lit.site.cfg is not present. If default is not<br>
- # present then force c++11.<br>
- std = self.get_lit_conf('std')<br>
- if not std:<br>
- # Choose the newest possible language dialect if none is given.<br>
- possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']<br>
- if self.cxx.type == 'gcc':<br>
- maj_v, _, _ = self.cxx.version<br>
- maj_v = int(maj_v)<br>
- if maj_v < 7:<br>
- possible_stds.remove('c++1z')<br>
- # FIXME: How many C++14 tests actually fail under GCC 5 and 6?<br>
- # Should we XFAIL them individually instead?<br>
- if maj_v <= 6:<br>
- possible_stds.remove('c++14')<br>
- for s in possible_stds:<br>
- if self.cxx.hasCompileFlag('-std=<wbr>%s' % s):<br>
- std = s<br>
- self.lit_config.note(<br>
- 'inferred language dialect as: %s' % std)<br>
- break<br>
- if not std:<br>
- self.lit_config.fatal(<br>
- 'Failed to infer a supported language dialect from one of %r'<br>
- % possible_stds)<br>
- self.cxx.compile_flags += ['-std={0}'.format(std)]<br>
- self.config.available_<wbr>features.add(std.replace('gnu+<wbr>+', 'c++'))<br>
- # Configure include paths<br>
- self.configure_compile_flags_<wbr>header_includes()<br>
- self.target_info.add_cxx_<wbr>compile_flags(self.cxx.<wbr>compile_flags)<br>
- # Configure feature flags.<br>
- self.configure_compile_flags_<wbr>exceptions()<br>
- self.configure_compile_flags_<wbr>rtti()<br>
- self.configure_compile_flags_<wbr>abi_version()<br>
- enable_32bit = self.get_lit_bool('enable_<wbr>32bit', False)<br>
- if enable_32bit:<br>
- self.cxx.flags += ['-m32']<br>
- # Use verbose output for better errors<br>
- self.cxx.flags += ['-v']<br>
- sysroot = self.get_lit_conf('sysroot')<br>
- if sysroot:<br>
- self.cxx.flags += ['--sysroot', sysroot]<br>
- gcc_toolchain = self.get_lit_conf('gcc_<wbr>toolchain')<br>
- if gcc_toolchain:<br>
- self.cxx.flags += ['-gcc-toolchain', gcc_toolchain]<br>
- # NOTE: the _DEBUG definition must preceed the triple check because for<br>
- # the Windows build of libc++, the forced inclusion of a header requires<br>
- # that _DEBUG is defined. Incorrect ordering will result in -target<br>
- # being elided.<br>
- if self.is_windows and self.debug_build:<br>
- self.cxx.compile_flags += ['-D_DEBUG']<br>
- if self.use_target:<br>
- if not self.cxx.addFlagIfSupported(<br>
- ['-target', self.config.target_triple]):<br>
- self.lit_config.warning('use_<wbr>target is true but -target is '\<br>
- 'not supported by the compiler')<br>
- if self.use_deployment:<br>
- arch, name, version = self.config.deployment<br>
- self.cxx.flags += ['-arch', arch]<br>
- self.cxx.flags += ['-m' + name + '-version-min=' + version]<br>
-<br>
- # Disable availability unless explicitely requested<br>
- if not self.with_availability:<br>
- self.cxx.flags += ['-D_LIBCPP_DISABLE_<wbr>AVAILABILITY']<br>
-<br>
- def configure_compile_flags_<wbr>header_includes(self):<br>
- support_path = os.path.join(self.libcxx_src_<wbr>root, 'test', 'support')<br>
- if self.cxx_stdlib_under_test != 'libstdc++' and \<br>
- not self.is_windows:<br>
- self.cxx.compile_flags += [<br>
- '-include', os.path.join(support_path, 'nasty_macros.hpp')]<br>
- if self.cxx_stdlib_under_test == 'msvc':<br>
- self.cxx.compile_flags += [<br>
- '-include', os.path.join(support_path,<br>
- 'msvc_stdlib_force_include.<wbr>hpp')]<br>
- pass<br>
- if self.is_windows and self.debug_build and \<br>
- self.cxx_stdlib_under_test != 'msvc':<br>
- self.cxx.compile_flags += [<br>
- '-include', os.path.join(support_path,<br>
- 'set_windows_crt_report_mode.<wbr>h')<br>
- ]<br>
- self.configure_config_site_<wbr>header()<br>
- cxx_headers = self.get_lit_conf('cxx_<wbr>headers')<br>
- if cxx_headers == '' or (cxx_headers is None<br>
- and self.cxx_stdlib_under_test != 'libc++'):<br>
- self.lit_config.note('using the system cxx headers')<br>
- return<br>
- self.cxx.compile_flags += ['-nostdinc++']<br>
- if cxx_headers is None:<br>
- cxx_headers = os.path.join(self.libcxx_src_<wbr>root, 'include')<br>
- if not os.path.isdir(cxx_headers):<br>
- self.lit_config.fatal("cxx_<wbr>headers='%s' is not a directory."<br>
- % cxx_headers)<br>
- self.cxx.compile_flags += ['-I' + cxx_headers]<br>
- if self.libcxx_obj_root is not None:<br>
- cxxabi_headers = os.path.join(self.libcxx_obj_<wbr>root, 'include',<br>
- 'c++build')<br>
- if os.path.isdir(cxxabi_headers):<br>
- self.cxx.compile_flags += ['-I' + cxxabi_headers]<br>
-<br>
- def configure_config_site_header(<wbr>self):<br>
- # Check for a possible __config_site in the build directory. We<br>
- # use this if it exists.<br>
- if self.libcxx_obj_root is None:<br>
- return<br>
- config_site_header = os.path.join(self.libcxx_obj_<wbr>root, '__config_site')<br>
- if not os.path.isfile(config_site_<wbr>header):<br>
- return<br>
- contained_macros = self.parse_config_site_and_<wbr>add_features(<br>
- config_site_header)<br>
- self.lit_config.note('Using __config_site header %s with macros: %r'<br>
- % (config_site_header, contained_macros))<br>
- # FIXME: This must come after the call to<br>
- # 'parse_config_site_and_add_<wbr>features(...)' in order for it to work.<br>
- self.cxx.compile_flags += ['-include', config_site_header]<br>
-<br>
- def parse_config_site_and_add_<wbr>features(self, header):<br>
- """ parse_config_site_and_add_<wbr>features - Deduce and add the test<br>
- features that that are implied by the #define's in the __config_site<br>
- header. Return a dictionary containing the macros found in the<br>
- '__config_site' header.<br>
- """<br>
- # Parse the macro contents of __config_site by dumping the macros<br>
- # using 'c++ -dM -E' and filtering the predefines.<br>
- predefines = self.cxx.dumpMacros()<br>
- macros = self.cxx.dumpMacros(header)<br>
- feature_macros_keys = set(macros.keys()) - set(predefines.keys())<br>
- feature_macros = {}<br>
- for k in feature_macros_keys:<br>
- feature_macros[k] = macros[k]<br>
- # We expect the header guard to be one of the definitions<br>
- assert '_LIBCPP_CONFIG_SITE' in feature_macros<br>
- del feature_macros['_LIBCPP_<wbr>CONFIG_SITE']<br>
- # The __config_site header should be non-empty. Otherwise it should<br>
- # have never been emitted by CMake.<br>
- assert len(feature_macros) > 0<br>
- # Transform each macro name into the feature name used in the tests.<br>
- # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads<br>
- for m in feature_macros:<br>
- if m == '_LIBCPP_DISABLE_VISIBILITY_<wbr>ANNOTATIONS':<br>
- continue<br>
- if m == '_LIBCPP_ABI_VERSION':<br>
- self.config.available_<wbr>features.add('libcpp-abi-<wbr>version-v%s'<br>
- % feature_macros[m])<br>
- continue<br>
- assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE'<br>
- m = m.lower()[1:].replace('_', '-')<br>
- self.config.available_<wbr>features.add(m)<br>
- return feature_macros<br>
-<br>
-<br>
-<br>
- def configure_compile_flags_<wbr>exceptions(self):<br>
- enable_exceptions = self.get_lit_bool('enable_<wbr>exceptions', True)<br>
- if not enable_exceptions:<br>
- self.config.available_<wbr>features.add('libcpp-no-<wbr>exceptions')<br>
- self.cxx.compile_flags += ['-fno-exceptions']<br>
-<br>
- def configure_compile_flags_rtti(<wbr>self):<br>
- enable_rtti = self.get_lit_bool('enable_<wbr>rtti', True)<br>
- if not enable_rtti:<br>
- self.config.available_<wbr>features.add('libcpp-no-rtti')<br>
- self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']<br>
-<br>
- def configure_compile_flags_abi_<wbr>version(self):<br>
- abi_version = self.get_lit_conf('abi_<wbr>version', '').strip()<br>
- abi_unstable = self.get_lit_bool('abi_<wbr>unstable')<br>
- # Only add the ABI version when it is non-default.<br>
- # FIXME(EricWF): Get the ABI version from the "__config_site".<br>
- if abi_version and abi_version != '1':<br>
- self.cxx.compile_flags += ['-D_LIBCPP_ABI_VERSION=' + abi_version]<br>
- if abi_unstable:<br>
- self.config.available_<wbr>features.add('libcpp-abi-<wbr>unstable')<br>
- self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']<br>
-<br>
- def configure_filesystem_compile_<wbr>flags(self):<br>
- enable_fs = self.get_lit_bool('enable_<wbr>filesystem', default=False)<br>
- if not enable_fs:<br>
- return<br>
- enable_experimental = self.get_lit_bool('enable_<wbr>experimental', default=False)<br>
- if not enable_experimental:<br>
- self.lit_config.fatal(<br>
- 'filesystem is enabled but libc++experimental.a is not.')<br>
- self.config.available_<wbr>features.add('c++filesystem')<br>
- static_env = os.path.join(self.libcxx_src_<wbr>root, 'test', 'std',<br>
- 'experimental', 'filesystem', 'Inputs', 'static_test_env')<br>
- static_env = os.path.realpath(static_env)<br>
- assert os.path.isdir(static_env)<br>
- self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_<wbr>TEST_ROOT="%s"' % static_env]<br>
-<br>
- dynamic_env = os.path.join(self.config.test_<wbr>exec_root,<br>
- 'filesystem', 'Output', 'dynamic_env')<br>
- dynamic_env = os.path.realpath(dynamic_env)<br>
- if not os.path.isdir(dynamic_env):<br>
- os.makedirs(dynamic_env)<br>
- self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_<wbr>TEST_ROOT="%s"' % dynamic_env]<br>
- self.exec_env['LIBCXX_<wbr>FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env)<br>
-<br>
- dynamic_helper = os.path.join(self.libcxx_src_<wbr>root, 'test', 'support',<br>
- 'filesystem_dynamic_test_<wbr>helper.py')<br>
- assert os.path.isfile(dynamic_helper)<br>
-<br>
- self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_<wbr>TEST_HELPER="%s %s"'<br>
- % (sys.executable, dynamic_helper)]<br>
-<br>
-<br>
- def configure_link_flags(self):<br>
- no_default_flags = self.get_lit_bool('no_default_<wbr>flags', False)<br>
- if not no_default_flags:<br>
- # Configure library path<br>
- self.configure_link_flags_cxx_<wbr>library_path()<br>
- self.configure_link_flags_abi_<wbr>library_path()<br>
-<br>
- # Configure libraries<br>
- if self.cxx_stdlib_under_test == 'libc++':<br>
- self.cxx.link_flags += ['-nodefaultlibs']<br>
- # FIXME: Handle MSVCRT as part of the ABI library handling.<br>
- if self.is_windows:<br>
- self.cxx.link_flags += ['-nostdlib']<br>
- self.configure_link_flags_cxx_<wbr>library()<br>
- self.configure_link_flags_abi_<wbr>library()<br>
- self.configure_extra_library_<wbr>flags()<br>
- elif self.cxx_stdlib_under_test == 'libstdc++':<br>
- enable_fs = self.get_lit_bool('enable_<wbr>filesystem',<br>
- default=False)<br>
- if enable_fs:<br>
- self.config.available_<wbr>features.add('c++experimental'<wbr>)<br>
- self.cxx.link_flags += ['-lstdc++fs']<br>
- self.cxx.link_flags += ['-lm', '-pthread']<br>
- elif self.cxx_stdlib_under_test == 'msvc':<br>
- # FIXME: Correctly setup debug/release flags here.<br>
- pass<br>
- elif self.cxx_stdlib_under_test == 'cxx_default':<br>
- self.cxx.link_flags += ['-pthread']<br>
- else:<br>
- self.lit_config.fatal(<br>
- 'unsupported value for "use_stdlib_type": %s'<br>
- % use_stdlib_type)<br>
-<br>
- link_flags_str = self.get_lit_conf('link_flags'<wbr>, '')<br>
- self.cxx.link_flags += shlex.split(link_flags_str)<br>
-<br>
- def configure_link_flags_cxx_<wbr>library_path(self):<br>
- if not self.use_system_cxx_lib:<br>
- if self.cxx_library_root:<br>
- self.cxx.link_flags += ['-L' + self.cxx_library_root]<br>
- if self.is_windows and self.link_shared:<br>
- self.add_path(self.cxx.<wbr>compile_env, self.cxx_library_root)<br>
- if self.cxx_runtime_root:<br>
- if not self.is_windows:<br>
- self.cxx.link_flags += ['-Wl,-rpath,' +<br>
- self.cxx_runtime_root]<br>
- elif self.is_windows and self.link_shared:<br>
- self.add_path(self.exec_env, self.cxx_runtime_root)<br>
- elif os.path.isdir(str(self.use_<wbr>system_cxx_lib)):<br>
- self.cxx.link_flags += ['-L' + self.use_system_cxx_lib]<br>
- if not self.is_windows:<br>
- self.cxx.link_flags += ['-Wl,-rpath,' +<br>
- self.use_system_cxx_lib]<br>
- if self.is_windows and self.link_shared:<br>
- self.add_path(self.cxx.<wbr>compile_env, self.use_system_cxx_lib)<br>
-<br>
- def configure_link_flags_abi_<wbr>library_path(self):<br>
- # Configure ABI library paths.<br>
- self.abi_library_root = self.get_lit_conf('abi_<wbr>library_path')<br>
- if self.abi_library_root:<br>
- self.cxx.link_flags += ['-L' + self.abi_library_root]<br>
- if not self.is_windows:<br>
- self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root]<br>
- else:<br>
- self.add_path(self.exec_env, self.abi_library_root)<br>
-<br>
- def configure_link_flags_cxx_<wbr>library(self):<br>
- libcxx_experimental = self.get_lit_bool('enable_<wbr>experimental', default=False)<br>
- if libcxx_experimental:<br>
- self.config.available_<wbr>features.add('c++experimental'<wbr>)<br>
- self.cxx.link_flags += ['-lc++experimental']<br>
- if self.link_shared:<br>
- self.cxx.link_flags += ['-lc++']<br>
- else:<br>
- cxx_library_root = self.get_lit_conf('cxx_<wbr>library_root')<br>
- if cxx_library_root:<br>
- libname = self.make_static_lib_name('c++<wbr>')<br>
- abs_path = os.path.join(cxx_library_root, libname)<br>
- assert os.path.exists(abs_path) and \<br>
- "static libc++ library does not exist"<br>
- self.cxx.link_flags += [abs_path]<br>
- else:<br>
- self.cxx.link_flags += ['-lc++']<br>
-<br>
- def configure_link_flags_abi_<wbr>library(self):<br>
- cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')<br>
- if cxx_abi == 'libstdc++':<br>
- self.cxx.link_flags += ['-lstdc++']<br>
- elif cxx_abi == 'libsupc++':<br>
- self.cxx.link_flags += ['-lsupc++']<br>
- elif cxx_abi == 'libcxxabi':<br>
- if self.target_info.allow_cxxabi_<wbr>link():<br>
- libcxxabi_shared = self.get_lit_bool('libcxxabi_<wbr>shared', default=True)<br>
- if libcxxabi_shared:<br>
- self.cxx.link_flags += ['-lc++abi']<br>
- else:<br>
- cxxabi_library_root = self.get_lit_conf('abi_<wbr>library_path')<br>
- if cxxabi_library_root:<br>
- libname = self.make_static_lib_name('c++<wbr>abi')<br>
- abs_path = os.path.join(cxxabi_library_<wbr>root, libname)<br>
- self.cxx.link_flags += [abs_path]<br>
- else:<br>
- self.cxx.link_flags += ['-lc++abi']<br>
- elif cxx_abi == 'libcxxrt':<br>
- self.cxx.link_flags += ['-lcxxrt']<br>
- elif cxx_abi == 'vcruntime':<br>
- debug_suffix = 'd' if self.debug_build else ''<br>
- self.cxx.link_flags += ['-l%s%s' % (lib, debug_suffix) for lib in<br>
- ['vcruntime', 'ucrt', 'msvcrt']]<br>
- elif cxx_abi == 'none' or cxx_abi == 'default':<br>
- if self.is_windows:<br>
- debug_suffix = 'd' if self.debug_build else ''<br>
- self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix]<br>
- else:<br>
- self.lit_config.fatal(<br>
- 'C++ ABI setting %s unsupported for tests' % cxx_abi)<br>
-<br>
- def configure_extra_library_flags(<wbr>self):<br>
- if self.get_lit_bool('cxx_ext_<wbr>threads', default=False):<br>
- self.cxx.link_flags += ['-lc++external_threads']<br>
- self.target_info.add_cxx_link_<wbr>flags(self.cxx.link_flags)<br>
-<br>
- def configure_color_diagnostics(<wbr>self):<br>
- use_color = self.get_lit_conf('color_<wbr>diagnostics')<br>
- if use_color is None:<br>
- use_color = os.environ.get('LIBCXX_COLOR_<wbr>DIAGNOSTICS')<br>
- if use_color is None:<br>
- return<br>
- if use_color != '':<br>
- self.lit_config.fatal('Invalid value for color_diagnostics "%s".'<br>
- % use_color)<br>
- color_flag = '-fdiagnostics-color=always'<br>
- # Check if the compiler supports the color diagnostics flag. Issue a<br>
- # warning if it does not since color diagnostics have been requested.<br>
- if not self.cxx.hasCompileFlag(color_<wbr>flag):<br>
- self.lit_config.warning(<br>
- 'color diagnostics have been requested but are not supported '<br>
- 'by the compiler')<br>
- else:<br>
- self.cxx.flags += [color_flag]<br>
-<br>
- def configure_debug_mode(self):<br>
- debug_level = self.get_lit_conf('debug_<wbr>level', None)<br>
- if not debug_level:<br>
- return<br>
- if debug_level not in ['0', '1']:<br>
- self.lit_config.fatal('Invalid value for debug_level "%s".'<br>
- % debug_level)<br>
- self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level]<br>
-<br>
- def configure_warnings(self):<br>
- # Turn on warnings by default for Clang based compilers when C++ >= 11<br>
- default_enable_warnings = self.cxx.type in ['clang', 'apple-clang'] \<br>
- and len(self.config.available_<wbr>features.intersection(<br>
- ['c++11', 'c++14', 'c++1z'])) != 0<br>
- enable_warnings = self.get_lit_bool('enable_<wbr>warnings',<br>
- default_enable_warnings)<br>
- self.cxx.useWarnings(enable_<wbr>warnings)<br>
- self.cxx.warning_flags += [<br>
- '-D_LIBCPP_HAS_NO_PRAGMA_<wbr>SYSTEM_HEADER',<br>
- '-Wall', '-Wextra', '-Werror'<br>
- ]<br>
- if self.cxx.hasWarningFlag('-<wbr>Wuser-defined-warnings'):<br>
- self.cxx.warning_flags += ['-Wuser-defined-warnings']<br>
- self.config.available_<wbr>features.add('diagnose-if-<wbr>support')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wshadow')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-command-line-<wbr>argument')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-attributes')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-pessimizing-move')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-c++11-extensions')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-user-defined-literals')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-noexcept-type')<br>
- # These warnings should be enabled in order to support the MSVC<br>
- # team using the test suite; They enable the warnings below and<br>
- # expect the test suite to be clean.<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wsign-compare')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunused-variable')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunused-parameter')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunreachable-code')<br>
- # FIXME: Enable the two warnings below.<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-conversion')<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-local-typedef')<br>
- std = self.get_lit_conf('std', None)<br>
- if std in ['c++98', 'c++03']:<br>
- # The '#define static_assert' provided by libc++ in C++03 mode<br>
- # causes an unused local typedef whenever it is used.<br>
- self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-local-typedef')<br>
-<br>
- def configure_sanitizer(self):<br>
- san = self.get_lit_conf('use_<wbr>sanitizer', '').strip()<br>
- if san:<br>
- self.target_info.add_<wbr>sanitizer_features(san, self.config.available_<wbr>features)<br>
- # Search for llvm-symbolizer along the compiler path first<br>
- # and then along the PATH env variable.<br>
- symbolizer_search_paths = os.environ.get('PATH', '')<br>
- cxx_path = libcxx.util.which(self.cxx.<wbr>path)<br>
- if cxx_path is not None:<br>
- symbolizer_search_paths = (<br>
- os.path.dirname(cxx_path) +<br>
- os.pathsep + symbolizer_search_paths)<br>
- llvm_symbolizer = libcxx.util.which('llvm-<wbr>symbolizer',<br>
- symbolizer_search_paths)<br>
-<br>
- def add_ubsan():<br>
- self.cxx.flags += ['-fsanitize=undefined',<br>
- '-fno-sanitize=vptr,function,<wbr>float-divide-by-zero',<br>
- '-fno-sanitize-recover=all']<br>
- self.exec_env['UBSAN_OPTIONS'] = 'print_stacktrace=1'<br>
- self.config.available_<wbr>features.add('ubsan')<br>
-<br>
- # Setup the sanitizer compile flags<br>
- self.cxx.flags += ['-g', '-fno-omit-frame-pointer']<br>
- if san == 'Address' or san == 'Address;Undefined' or san == 'Undefined;Address':<br>
- self.cxx.flags += ['-fsanitize=address']<br>
- if llvm_symbolizer is not None:<br>
- self.exec_env['ASAN_<wbr>SYMBOLIZER_PATH'] = llvm_symbolizer<br>
- # FIXME: Turn ODR violation back on after PR28391 is resolved<br>
- # <a href="https://bugs.llvm.org/show_bug.cgi?id=28391" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=28391</a><br>
- self.exec_env['ASAN_OPTIONS'] = 'detect_odr_violation=0'<br>
- self.config.available_<wbr>features.add('asan')<br>
- self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
- self.cxx.compile_flags += ['-O1']<br>
- if san == 'Address;Undefined' or san == 'Undefined;Address':<br>
- add_ubsan()<br>
- elif san == 'Memory' or san == 'MemoryWithOrigins':<br>
- self.cxx.flags += ['-fsanitize=memory']<br>
- if san == 'MemoryWithOrigins':<br>
- self.cxx.compile_flags += [<br>
- '-fsanitize-memory-track-<wbr>origins']<br>
- if llvm_symbolizer is not None:<br>
- self.exec_env['MSAN_<wbr>SYMBOLIZER_PATH'] = llvm_symbolizer<br>
- self.config.available_<wbr>features.add('msan')<br>
- self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
- self.cxx.compile_flags += ['-O1']<br>
- elif san == 'Undefined':<br>
- add_ubsan()<br>
- self.cxx.compile_flags += ['-O2']<br>
- elif san == 'Thread':<br>
- self.cxx.flags += ['-fsanitize=thread']<br>
- self.config.available_<wbr>features.add('tsan')<br>
- self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
- else:<br>
- self.lit_config.fatal('<wbr>unsupported value for '<br>
- 'use_sanitizer: {0}'.format(san))<br>
- san_lib = self.get_lit_conf('sanitizer_<wbr>library')<br>
- if san_lib:<br>
- self.cxx.link_flags += [<br>
- san_lib, '-Wl,-rpath,%s' % os.path.dirname(san_lib)]<br>
-<br>
- def configure_coverage(self):<br>
- self.generate_coverage = self.get_lit_bool('generate_<wbr>coverage', False)<br>
- if self.generate_coverage:<br>
- self.cxx.flags += ['-g', '--coverage']<br>
- self.cxx.compile_flags += ['-O0']<br>
-<br>
- def configure_modules(self):<br>
- modules_flags = ['-fmodules']<br>
- if platform.system() != 'Darwin':<br>
- modules_flags += ['-Xclang', '-fmodules-local-submodule-<wbr>visibility']<br>
- supports_modules = self.cxx.hasCompileFlag(<wbr>modules_flags)<br>
- enable_modules = self.get_lit_bool('enable_<wbr>modules',<br>
- default=False,<br>
- env_var='LIBCXX_ENABLE_<wbr>MODULES')<br>
- if enable_modules and not supports_modules:<br>
- self.lit_config.fatal(<br>
- '-fmodules is enabled but not supported by the compiler')<br>
- if not supports_modules:<br>
- return<br>
- self.config.available_<wbr>features.add('modules-support'<wbr>)<br>
- module_cache = os.path.join(self.config.test_<wbr>exec_root,<br>
- 'modules.cache')<br>
- module_cache = os.path.realpath(module_cache)<br>
- if os.path.isdir(module_cache):<br>
- shutil.rmtree(module_cache)<br>
- os.makedirs(module_cache)<br>
- self.cxx.modules_flags = modules_flags + \<br>
- ['-fmodules-cache-path=' + module_cache]<br>
- if enable_modules:<br>
- self.config.available_<wbr>features.add('-fmodules')<br>
- self.cxx.useModules()<br>
-<br>
- def configure_substitutions(self):<br>
- sub = self.config.substitutions<br>
- cxx_path = pipes.quote(self.cxx.path)<br>
- # Configure compiler substitutions<br>
- sub.append(('%cxx', cxx_path))<br>
- # Configure flags substitutions<br>
- flags_str = ' '.join([pipes.quote(f) for f in self.cxx.flags])<br>
- compile_flags_str = ' '.join([pipes.quote(f) for f in self.cxx.compile_flags])<br>
- link_flags_str = ' '.join([pipes.quote(f) for f in self.cxx.link_flags])<br>
- all_flags = '%s %s %s' % (flags_str, compile_flags_str, link_flags_str)<br>
- sub.append(('%flags', flags_str))<br>
- sub.append(('%compile_flags', compile_flags_str))<br>
- sub.append(('%link_flags', link_flags_str))<br>
- sub.append(('%all_flags', all_flags))<br>
- if self.cxx.isVerifySupported():<br>
- verify_str = ' ' + ' '.join(self.cxx.verify_flags) + ' '<br>
- sub.append(('%verify', verify_str))<br>
- # Add compile and link shortcuts<br>
- compile_str = (cxx_path + ' -o %t.o %s -c ' + flags_str<br>
- + ' ' + compile_flags_str)<br>
- link_str = (cxx_path + ' -o %t.exe %t.o ' + flags_str + ' '<br>
- + link_flags_str)<br>
- assert type(link_str) is str<br>
- build_str = cxx_path + ' -o %t.exe %s ' + all_flags<br>
- if self.cxx.use_modules:<br>
- sub.append(('%compile_module', compile_str))<br>
- sub.append(('%build_module', build_str))<br>
- elif self.cxx.modules_flags is not None:<br>
- modules_str = ' '.join(self.cxx.modules_flags) + ' '<br>
- sub.append(('%compile_module', compile_str + ' ' + modules_str))<br>
- sub.append(('%build_module', build_str + ' ' + modules_str))<br>
- sub.append(('%compile', compile_str))<br>
- sub.append(('%link', link_str))<br>
- sub.append(('%build', build_str))<br>
- # Configure exec prefix substitutions.<br>
- exec_env_str = ''<br>
- if not self.is_windows and len(self.exec_env) != 0:<br>
- exec_env_str = 'env '<br>
- for k, v in self.exec_env.items():<br>
- exec_env_str += ' %s=%s' % (k, v)<br>
- # Configure run env substitution.<br>
- exec_str = exec_env_str<br>
- if self.lit_config.useValgrind:<br>
- exec_str = ' '.join(self.lit_config.<wbr>valgrindArgs) + exec_env_str<br>
- sub.append(('%exec', exec_str))<br>
- # Configure run shortcut<br>
- sub.append(('%run', exec_str + ' %t.exe'))<br>
- # Configure not program substitutions<br>
- not_py = os.path.join(self.libcxx_src_<wbr>root, 'utils', 'not.py')<br>
- not_str = '%s %s ' % (pipes.quote(sys.executable), pipes.quote(not_py))<br>
- sub.append(('not ', not_str))<br>
-<br>
- def can_use_deployment(self):<br>
- # Check if the host is on an Apple platform using clang.<br>
- if not self.target_info.platform() == "darwin":<br>
- return False<br>
- if not self.target_info.is_host_<wbr>macosx():<br>
- return False<br>
- if not self.cxx.type.endswith('clang'<wbr>):<br>
- return False<br>
- return True<br>
-<br>
- def configure_triple(self):<br>
- # Get or infer the target triple.<br>
- target_triple = self.get_lit_conf('target_<wbr>triple')<br>
- self.use_target = self.get_lit_bool('use_target'<wbr>, False)<br>
- if self.use_target and target_triple:<br>
- self.lit_config.warning('use_<wbr>target is true but no triple is specified')<br>
-<br>
- # Use deployment if possible.<br>
- self.use_deployment = not self.use_target and self.can_use_deployment()<br>
- if self.use_deployment:<br>
- return<br>
-<br>
- # Save the triple (and warn on Apple platforms).<br>
- self.config.target_triple = target_triple<br>
- if self.use_target and 'apple' in target_triple:<br>
- self.lit_config.warning('<wbr>consider using arch and platform instead'<br>
- ' of target_triple on Apple platforms')<br>
-<br>
- # If no target triple was given, try to infer it from the compiler<br>
- # under test.<br>
- if not self.config.target_triple:<br>
- target_triple = self.cxx.getTriple()<br>
- # Drop sub-major version components from the triple, because the<br>
- # current XFAIL handling expects exact matches for feature checks.<br>
- # Example: x86_64-apple-darwin14.0.0 -> x86_64-apple-darwin14<br>
- # The 5th group handles triples greater than 3 parts<br>
- # (ex x86_64-pc-linux-gnu).<br>
- target_triple = re.sub(r'([^-]+)-([^-]+)-([^.]<wbr>+)([^-]*)(.*)',<br>
- r'\1-\2-\3\5', target_triple)<br>
- # linux-gnu is needed in the triple to properly identify linuxes<br>
- # that use GLIBC. Handle redhat and opensuse triples as special<br>
- # cases and append the missing `-gnu` portion.<br>
- if (target_triple.endswith('<wbr>redhat-linux') or<br>
- target_triple.endswith('suse-<wbr>linux')):<br>
- target_triple += '-gnu'<br>
- self.config.target_triple = target_triple<br>
- self.lit_config.note(<br>
- "inferred target_triple as: %r" % self.config.target_triple)<br>
-<br>
- def configure_deployment(self):<br>
- assert not self.use_deployment is None<br>
- assert not self.use_target is None<br>
- if not self.use_deployment:<br>
- # Warn about ignored parameters.<br>
- if self.get_lit_conf('arch'):<br>
- self.lit_config.warning('<wbr>ignoring arch, using target_triple')<br>
- if self.get_lit_conf('platform'):<br>
- self.lit_config.warning('<wbr>ignoring platform, using target_triple')<br>
- return<br>
-<br>
- assert not self.use_target<br>
- assert self.target_info.is_host_<wbr>macosx()<br>
-<br>
- # Always specify deployment explicitly on Apple platforms, since<br>
- # otherwise a platform is picked up from the SDK. If the SDK version<br>
- # doesn't match the system version, tests that use the system library<br>
- # may fail spuriously.<br>
- arch = self.get_lit_conf('arch')<br>
- if not arch:<br>
- arch = self.cxx.getTriple().split('-'<wbr>, 1)[0]<br>
- self.lit_config.note("inferred arch as: %r" % arch)<br>
-<br>
- inferred_platform, name, version = self.target_info.get_platform(<wbr>)<br>
- if inferred_platform:<br>
- self.lit_config.note("inferred platform as: %r" % (name + version))<br>
- self.config.deployment = (arch, name, version)<br>
-<br>
- # Set the target triple for use by lit.<br>
- self.config.target_triple = arch + '-apple-' + name + version<br>
- self.lit_config.note(<br>
- "computed target_triple as: %r" % self.config.target_triple)<br>
-<br>
- def configure_env(self):<br>
- self.target_info.configure_<wbr>env(self.exec_env)<br>
-<br>
- def add_path(self, dest_env, new_path):<br>
- if 'PATH' not in dest_env:<br>
- dest_env['PATH'] = new_path<br>
- else:<br>
- split_char = ';' if self.is_windows else ':'<br>
- dest_env['PATH'] = '%s%s%s' % (new_path, split_char,<br>
- dest_env['PATH'])<br>
+#===-------------------------<wbr>------------------------------<wbr>---------------===##<br>
+#<br>
+# The LLVM Compiler Infrastructure<br>
+#<br>
+# This file is dual licensed under the MIT and the University of Illinois Open<br>
+# Source Licenses. See LICENSE.TXT for details.<br>
+#<br>
+#===-------------------------<wbr>------------------------------<wbr>---------------===##<br>
+<br>
+import locale<br>
+import os<br>
+import platform<br>
+import pkgutil<br>
+import pipes<br>
+import re<br>
+import shlex<br>
+import shutil<br>
+import sys<br>
+<br>
+from libcxx.compiler import CXXCompiler<br>
+from libcxx.test.target_info import make_target_info<br>
+from libcxx.test.executor import *<br>
+from libcxx.test.tracing import *<br>
+import libcxx.util<br>
+<br>
+def loadSiteConfig(lit_config, config, param_name, env_name):<br>
+ # We haven't loaded the site specific configuration (the user is<br>
+ # probably trying to run on a test file directly, and either the site<br>
+ # configuration hasn't been created by the build system, or we are in an<br>
+ # out-of-tree build situation).<br>
+ site_cfg = lit_config.params.get(param_<wbr>name,<br>
+ os.environ.get(env_name))<br>
+ if not site_cfg:<br>
+ lit_config.warning('No site specific configuration file found!'<br>
+ ' Running the tests in the default configuration.')<br>
+ elif not os.path.isfile(site_cfg):<br>
+ lit_config.fatal(<br>
+ "Specified site configuration file does not exist: '%s'" %<br>
+ site_cfg)<br>
+ else:<br>
+ lit_config.note('using site specific configuration at %s' % site_cfg)<br>
+ ld_fn = lit_config.load_config<br>
+<br>
+ # Null out the load_config function so that lit.site.cfg doesn't<br>
+ # recursively load a config even if it tries.<br>
+ # TODO: This is one hell of a hack. Fix it.<br>
+ def prevent_reload_fn(*args, **kwargs):<br>
+ pass<br>
+ lit_config.load_config = prevent_reload_fn<br>
+ ld_fn(config, site_cfg)<br>
+ lit_config.load_config = ld_fn<br>
+<br>
+class Configuration(object):<br>
+ # pylint: disable=redefined-outer-name<br>
+ def __init__(self, lit_config, config):<br>
+ self.lit_config = lit_config<br>
+ self.config = config<br>
+ self.is_windows = platform.system() == 'Windows'<br>
+ self.cxx = None<br>
+ self.cxx_is_clang_cl = None<br>
+ self.cxx_stdlib_under_test = None<br>
+ self.project_obj_root = None<br>
+ self.libcxx_src_root = None<br>
+ self.libcxx_obj_root = None<br>
+ self.cxx_library_root = None<br>
+ self.cxx_runtime_root = None<br>
+ self.abi_library_root = None<br>
+ self.link_shared = self.get_lit_bool('enable_<wbr>shared', default=True)<br>
+ self.debug_build = self.get_lit_bool('debug_<wbr>build', default=False)<br>
+ self.exec_env = {}<br>
+ self.use_target = False<br>
+ self.use_system_cxx_lib = False<br>
+ self.use_clang_verify = False<br>
+ self.long_tests = None<br>
+ self.execute_external = False<br>
+<br>
+ def get_lit_conf(self, name, default=None):<br>
+ val = self.lit_config.params.get(<wbr>name, None)<br>
+ if val is None:<br>
+ val = getattr(self.config, name, None)<br>
+ if val is None:<br>
+ val = default<br>
+ return val<br>
+<br>
+ def get_lit_bool(self, name, default=None, env_var=None):<br>
+ def check_value(value, var_name):<br>
+ if value is None:<br>
+ return default<br>
+ if isinstance(value, bool):<br>
+ return value<br>
+ if not isinstance(value, str):<br>
+ raise TypeError('expected bool or string')<br>
+ if value.lower() in ('1', 'true'):<br>
+ return True<br>
+ if value.lower() in ('', '0', 'false'):<br>
+ return False<br>
+ self.lit_config.fatal(<br>
+ "parameter '{}' should be true or false".format(var_name))<br>
+<br>
+ conf_val = self.get_lit_conf(name)<br>
+ if env_var is not None and env_var in os.environ and \<br>
+ os.environ[env_var] is not None:<br>
+ val = os.environ[env_var]<br>
+ if conf_val is not None:<br>
+ self.lit_config.warning(<br>
+ 'Environment variable %s=%s is overriding explicit '<br>
+ '--param=%s=%s' % (env_var, val, name, conf_val))<br>
+ return check_value(val, env_var)<br>
+ return check_value(conf_val, name)<br>
+<br>
+ def make_static_lib_name(self, name):<br>
+ """Return the full filename for the specified library name"""<br>
+ if self.is_windows:<br>
+ assert name == 'c++' # Only allow libc++ to use this function for now.<br>
+ return 'lib' + name + '.lib'<br>
+ else:<br>
+ return 'lib' + name + '.a'<br>
+<br>
+ def configure(self):<br>
+ self.configure_executor()<br>
+ self.configure_use_system_cxx_<wbr>lib()<br>
+ self.configure_target_info()<br>
+ self.configure_cxx()<br>
+ self.configure_triple()<br>
+ self.configure_deployment()<br>
+ self.configure_availability()<br>
+ self.configure_src_root()<br>
+ self.configure_obj_root()<br>
+ self.configure_cxx_stdlib_<wbr>under_test()<br>
+ self.configure_cxx_library_<wbr>root()<br>
+ self.configure_use_clang_<wbr>verify()<br>
+ self.configure_use_thread_<wbr>safety()<br>
+ self.configure_execute_<wbr>external()<br>
+ self.configure_ccache()<br>
+ self.configure_compile_flags()<br>
+ self.configure_filesystem_<wbr>compile_flags()<br>
+ self.configure_link_flags()<br>
+ self.configure_env()<br>
+ self.configure_color_<wbr>diagnostics()<br>
+ self.configure_debug_mode()<br>
+ self.configure_warnings()<br>
+ self.configure_sanitizer()<br>
+ self.configure_coverage()<br>
+ self.configure_modules()<br>
+ self.configure_substitutions()<br>
+ self.configure_features()<br>
+<br>
+ def print_config_info(self):<br>
+ # Print the final compile and link flags.<br>
+ self.lit_config.note('Using compiler: %s' % self.cxx.path)<br>
+ self.lit_config.note('Using flags: %s' % self.cxx.flags)<br>
+ if self.cxx.use_modules:<br>
+ self.lit_config.note('Using modules flags: %s' %<br>
+ self.cxx.modules_flags)<br>
+ self.lit_config.note('Using compile flags: %s'<br>
+ % self.cxx.compile_flags)<br>
+ if len(self.cxx.warning_flags):<br>
+ self.lit_config.note('Using warnings: %s' % self.cxx.warning_flags)<br>
+ self.lit_config.note('Using link flags: %s' % self.cxx.link_flags)<br>
+ # Print as list to prevent "set([...])" from being printed.<br>
+ self.lit_config.note('Using available_features: %s' %<br>
+ list(self.config.available_<wbr>features))<br>
+ self.lit_config.note('Using environment: %r' % self.exec_env)<br>
+ sys.stderr.flush() # Force flushing to avoid broken output on Windows<br>
+<br>
+ def get_test_format(self):<br>
+ from libcxx.test.format import LibcxxTestFormat<br>
+ return LibcxxTestFormat(<br>
+ self.cxx,<br>
+ self.use_clang_verify,<br>
+ self.execute_external,<br>
+ self.executor,<br>
+ exec_env=self.exec_env)<br>
+<br>
+ def configure_executor(self):<br>
+ exec_str = self.get_lit_conf('executor', "None")<br>
+ te = eval(exec_str)<br>
+ if te:<br>
+ self.lit_config.note("Using executor: %r" % exec_str)<br>
+ if self.lit_config.useValgrind:<br>
+ # We have no way of knowing where in the chain the<br>
+ # ValgrindExecutor is supposed to go. It is likely<br>
+ # that the user wants it at the end, but we have no<br>
+ # way of getting at that easily.<br>
+ selt.lit_config.fatal("Cannot infer how to create a Valgrind "<br>
+ " executor.")<br>
+ else:<br>
+ te = LocalExecutor()<br>
+ if self.lit_config.useValgrind:<br>
+ te = ValgrindExecutor(self.lit_<wbr>config.valgrindArgs, te)<br>
+ self.executor = te<br>
+<br>
+ def configure_target_info(self):<br>
+ self.target_info = make_target_info(self)<br>
+<br>
+ def configure_cxx(self):<br>
+ # Gather various compiler parameters.<br>
+ cxx = self.get_lit_conf('cxx_under_<wbr>test')<br>
+ self.cxx_is_clang_cl = cxx is not None and \<br>
+ os.path.basename(cxx) == 'clang-cl.exe'<br>
+ # If no specific cxx_under_test was given, attempt to infer it as<br>
+ # clang++.<br>
+ if cxx is None or self.cxx_is_clang_cl:<br>
+ search_paths = self.config.environment['PATH'<wbr>]<br>
+ if cxx is not None and os.path.isabs(cxx):<br>
+ search_paths = os.path.dirname(cxx)<br>
+ clangxx = libcxx.util.which('clang++', search_paths)<br>
+ if clangxx:<br>
+ cxx = clangxx<br>
+ self.lit_config.note(<br>
+ "inferred cxx_under_test as: %r" % cxx)<br>
+ elif self.cxx_is_clang_cl:<br>
+ self.lit_config.fatal('Failed to find clang++ substitution for'<br>
+ ' clang-cl')<br>
+ if not cxx:<br>
+ self.lit_config.fatal('must specify user parameter cxx_under_test '<br>
+ '(e.g., --param=cxx_under_test=clang++<wbr>)')<br>
+ self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \<br>
+ self._configure_clang_cl(cxx)<br>
+ cxx_type = self.cxx.type<br>
+ if cxx_type is not None:<br>
+ assert self.cxx.version is not None<br>
+ maj_v, min_v, _ = self.cxx.version<br>
+ self.config.available_<wbr>features.add(cxx_type)<br>
+ self.config.available_<wbr>features.add('%s-%s' % (cxx_type, maj_v))<br>
+ self.config.available_<wbr>features.add('%s-%s.%s' % (<br>
+ cxx_type, maj_v, min_v))<br>
+ self.cxx.compile_env = dict(os.environ)<br>
+ # 'CCACHE_CPP2' prevents ccache from stripping comments while<br>
+ # preprocessing. This is required to prevent stripping of '-verify'<br>
+ # comments.<br>
+ self.cxx.compile_env['CCACHE_<wbr>CPP2'] = '1'<br>
+<br>
+ def _configure_clang_cl(self, clang_path):<br>
+ def _split_env_var(var):<br>
+ return [p.strip() for p in os.environ.get(var, '').split(';') if p.strip()]<br>
+<br>
+ def _prefixed_env_list(var, prefix):<br>
+ from itertools import chain<br>
+ return list(chain.from_iterable((<wbr>prefix, path) for path in _split_env_var(var)))<br>
+<br>
+ assert self.cxx_is_clang_cl<br>
+ flags = []<br>
+ compile_flags = _prefixed_env_list('INCLUDE', '-isystem')<br>
+ link_flags = _prefixed_env_list('LIB', '-L')<br>
+ for path in _split_env_var('LIB'):<br>
+ self.add_path(self.exec_env, path)<br>
+ return CXXCompiler(clang_path, flags=flags,<br>
+ compile_flags=compile_flags,<br>
+ link_flags=link_flags)<br>
+<br>
+<br>
+ def configure_src_root(self):<br>
+ self.libcxx_src_root = self.get_lit_conf(<br>
+ 'libcxx_src_root', os.path.dirname(self.config.<wbr>test_source_root))<br>
+<br>
+ def configure_obj_root(self):<br>
+ self.project_obj_root = self.get_lit_conf('project_<wbr>obj_root')<br>
+ self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_<wbr>root')<br>
+ if not self.libcxx_obj_root and self.project_obj_root is not None:<br>
+ possible_root = os.path.join(self.project_obj_<wbr>root, 'projects', 'libcxx')<br>
+ if os.path.isdir(possible_root):<br>
+ self.libcxx_obj_root = possible_root<br>
+ else:<br>
+ self.libcxx_obj_root = self.project_obj_root<br>
+<br>
+ def configure_cxx_library_root(<wbr>self):<br>
+ self.cxx_library_root = self.get_lit_conf('cxx_<wbr>library_root',<br>
+ self.libcxx_obj_root)<br>
+ self.cxx_runtime_root = self.get_lit_conf('cxx_<wbr>runtime_root',<br>
+ self.cxx_library_root)<br>
+<br>
+ def configure_use_system_cxx_lib(<wbr>self):<br>
+ # This test suite supports testing against either the system library or<br>
+ # the locally built one; the former mode is useful for testing ABI<br>
+ # compatibility between the current headers and a shipping dynamic<br>
+ # library.<br>
+ # Default to testing against the locally built libc++ library.<br>
+ self.use_system_cxx_lib = self.get_lit_conf('use_system_<wbr>cxx_lib')<br>
+ if self.use_system_cxx_lib == 'true':<br>
+ self.use_system_cxx_lib = True<br>
+ elif self.use_system_cxx_lib == 'false':<br>
+ self.use_system_cxx_lib = False<br>
+ elif self.use_system_cxx_lib:<br>
+ assert os.path.isdir(self.use_system_<wbr>cxx_lib)<br>
+ self.lit_config.note(<br>
+ "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)<br>
+<br>
+ def configure_availability(self):<br>
+ # See <a href="http://llvm.org/docs/AvailabilityMarkup.html" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>AvailabilityMarkup.html</a><br>
+ self.with_availability = self.get_lit_bool('with_<wbr>availability', False)<br>
+ self.lit_config.note(<br>
+ "inferred with_availability as: %r" % self.with_availability)<br>
+<br>
+ def configure_cxx_stdlib_under_<wbr>test(self):<br>
+ self.cxx_stdlib_under_test = self.get_lit_conf(<br>
+ 'cxx_stdlib_under_test', 'libc++')<br>
+ if self.cxx_stdlib_under_test not in \<br>
+ ['libc++', 'libstdc++', 'msvc', 'cxx_default']:<br>
+ self.lit_config.fatal(<br>
+ 'unsupported value for "cxx_stdlib_under_test": %s'<br>
+ % self.cxx_stdlib_under_test)<br>
+ self.config.available_<wbr>features.add(self.cxx_stdlib_<wbr>under_test)<br>
+ if self.cxx_stdlib_under_test == 'libstdc++':<br>
+ self.config.available_<wbr>features.add('libstdc++')<br>
+ # Manually enable the experimental and filesystem tests for libstdc++<br>
+ # if the options aren't present.<br>
+ # FIXME this is a hack.<br>
+ if self.get_lit_conf('enable_<wbr>experimental') is None:<br>
+ self.config.enable_<wbr>experimental = 'true'<br>
+ if self.get_lit_conf('enable_<wbr>filesystem') is None:<br>
+ self.config.enable_filesystem = 'true'<br>
+<br>
+ def configure_use_clang_verify(<wbr>self):<br>
+ '''If set, run clang with -verify on failing tests.'''<br>
+ if self.with_availability:<br>
+ self.use_clang_verify = False<br>
+ return<br>
+ self.use_clang_verify = self.get_lit_bool('use_clang_<wbr>verify')<br>
+ if self.use_clang_verify is None:<br>
+ # NOTE: We do not test for the -verify flag directly because<br>
+ # -verify will always exit with non-zero on an empty file.<br>
+ self.use_clang_verify = self.cxx.isVerifySupported()<br>
+ self.lit_config.note(<br>
+ "inferred use_clang_verify as: %r" % self.use_clang_verify)<br>
+ if self.use_clang_verify:<br>
+ self.config.available_<wbr>features.add('verify-support')<br>
+<br>
+ def configure_use_thread_safety(<wbr>self):<br>
+ '''If set, run clang with -verify on failing tests.'''<br>
+ has_thread_safety = self.cxx.hasCompileFlag('-<wbr>Werror=thread-safety')<br>
+ if has_thread_safety:<br>
+ self.cxx.compile_flags += ['-Werror=thread-safety']<br>
+ self.config.available_<wbr>features.add('thread-safety')<br>
+ self.lit_config.note("enabling thread-safety annotations")<br>
+<br>
+ def configure_execute_external(<wbr>self):<br>
+ # Choose between lit's internal shell pipeline runner and a real shell.<br>
+ # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the<br>
+ # default value. Otherwise we ask the target_info.<br>
+ use_lit_shell_default = os.environ.get('LIT_USE_<wbr>INTERNAL_SHELL')<br>
+ if use_lit_shell_default is not None:<br>
+ use_lit_shell_default = use_lit_shell_default != '0'<br>
+ else:<br>
+ use_lit_shell_default = self.target_info.use_lit_<wbr>shell_default()<br>
+ # Check for the command line parameter using the default value if it is<br>
+ # not present.<br>
+ use_lit_shell = self.get_lit_bool('use_lit_<wbr>shell',<br>
+ use_lit_shell_default)<br>
+ self.execute_external = not use_lit_shell<br>
+<br>
+ def configure_ccache(self):<br>
+ use_ccache_default = os.environ.get('LIBCXX_USE_<wbr>CCACHE') is not None<br>
+ use_ccache = self.get_lit_bool('use_ccache'<wbr>, use_ccache_default)<br>
+ if use_ccache:<br>
+ self.cxx.use_ccache = True<br>
+ self.lit_config.note('enabling ccache')<br>
+<br>
+ def add_deployment_feature(self, feature):<br>
+ (arch, name, version) = self.config.deployment<br>
+ self.config.available_<wbr>features.add('%s=%s-%s' % (feature, arch, name))<br>
+ self.config.available_<wbr>features.add('%s=%s' % (feature, name))<br>
+ self.config.available_<wbr>features.add('%s=%s%s' % (feature, name, version))<br>
+<br>
+ def configure_features(self):<br>
+ additional_features = self.get_lit_conf('additional_<wbr>features')<br>
+ if additional_features:<br>
+ for f in additional_features.split(',')<wbr>:<br>
+ self.config.available_<wbr>features.add(f.strip())<br>
+ self.target_info.add_locale_<wbr>features(self.config.<wbr>available_features)<br>
+<br>
+ target_platform = self.target_info.platform()<br>
+<br>
+ # Write an "available feature" that combines the triple when<br>
+ # use_system_cxx_lib is enabled. This is so that we can easily write<br>
+ # XFAIL markers for tests that are known to fail with versions of<br>
+ # libc++ as were shipped with a particular triple.<br>
+ if self.use_system_cxx_lib:<br>
+ self.config.available_<wbr>features.add('with_system_cxx_<wbr>lib')<br>
+ self.config.available_<wbr>features.add(<br>
+ 'with_system_cxx_lib=%s' % self.config.target_triple)<br>
+<br>
+ # Add subcomponents individually.<br>
+ target_components = self.config.target_triple.<wbr>split('-')<br>
+ for component in target_components:<br>
+ self.config.available_<wbr>features.add(<br>
+ 'with_system_cxx_lib=%s' % component)<br>
+<br>
+ # Add available features for more generic versions of the target<br>
+ # triple attached to with_system_cxx_lib.<br>
+ if self.use_deployment:<br>
+ self.add_deployment_feature('<wbr>with_system_cxx_lib')<br>
+<br>
+ # Configure the availability markup checks features.<br>
+ if self.with_availability:<br>
+ self.config.available_<wbr>features.add('availability_<wbr>markup')<br>
+ self.add_deployment_feature('<wbr>availability_markup')<br>
+<br>
+ if self.use_system_cxx_lib or self.with_availability:<br>
+ self.config.available_<wbr>features.add('availability')<br>
+ self.add_deployment_feature('<wbr>availability')<br>
+<br>
+ if platform.system() == 'Darwin':<br>
+ self.config.available_<wbr>features.add('apple-darwin')<br>
+<br>
+ # Insert the platform name into the available features as a lower case.<br>
+ self.config.available_<wbr>features.add(target_platform)<br>
+<br>
+ # Simulator testing can take a really long time for some of these tests<br>
+ # so add a feature check so we can REQUIRES: long_tests in them<br>
+ self.long_tests = self.get_lit_bool('long_tests'<wbr>)<br>
+ if self.long_tests is None:<br>
+ # Default to running long tests.<br>
+ self.long_tests = True<br>
+ self.lit_config.note(<br>
+ "inferred long_tests as: %r" % self.long_tests)<br>
+<br>
+ if self.long_tests:<br>
+ self.config.available_<wbr>features.add('long_tests')<br>
+<br>
+ # Run a compile test for the -fsized-deallocation flag. This is needed<br>
+ # in test/std/language.support/<wbr>support.dynamic/new.delete<br>
+ if self.cxx.hasCompileFlag('-<wbr>fsized-deallocation'):<br>
+ self.config.available_<wbr>features.add('fsized-<wbr>deallocation')<br>
+<br>
+ if self.cxx.hasCompileFlag('-<wbr>faligned-allocation'):<br>
+ self.config.available_<wbr>features.add('-faligned-<wbr>allocation')<br>
+ else:<br>
+ # FIXME remove this once more than just clang-4.0 support<br>
+ # C++17 aligned allocation.<br>
+ self.config.available_<wbr>features.add('no-aligned-<wbr>allocation')<br>
+<br>
+ if self.get_lit_bool('has_<wbr>libatomic', False):<br>
+ self.config.available_<wbr>features.add('libatomic')<br>
+<br>
+ macros = self.cxx.dumpMacros()<br>
+ if '__cpp_if_constexpr' not in macros:<br>
+ self.config.available_<wbr>features.add('libcpp-no-if-<wbr>constexpr')<br>
+<br>
+ if '__cpp_structured_bindings' not in macros:<br>
+ self.config.available_<wbr>features.add('libcpp-no-<wbr>structured-bindings')<br>
+<br>
+ if '__cpp_deduction_guides' not in macros:<br>
+ self.config.available_<wbr>features.add('libcpp-no-<wbr>deduction-guides')<br>
+<br>
+ if self.is_windows:<br>
+ self.config.available_<wbr>features.add('windows')<br>
+ if self.cxx_stdlib_under_test == 'libc++':<br>
+ # LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the<br>
+ # initial Windows failures until they can be properly diagnosed<br>
+ # and fixed. This allows easier detection of new test failures<br>
+ # and regressions. Note: New failures should not be suppressed<br>
+ # using this feature. (Also see <a href="http://llvm.org/PR32730" rel="noreferrer" target="_blank">llvm.org/PR32730</a>)<br>
+ self.config.available_<wbr>features.add('LIBCXX-WINDOWS-<wbr>FIXME')<br>
+<br>
+ # Attempt to detect the glibc version by querying for __GLIBC__<br>
+ # in 'features.h'.<br>
+ macros = self.cxx.dumpMacros(flags=['-<wbr>include', 'features.h'])<br>
+ if macros is not None and '__GLIBC__' in macros:<br>
+ maj_v, min_v = (macros['__GLIBC__'], macros['__GLIBC_MINOR__'])<br>
+ self.config.available_<wbr>features.add('glibc')<br>
+ self.config.available_<wbr>features.add('glibc-%s' % maj_v)<br>
+ self.config.available_<wbr>features.add('glibc-%s.%s' % (maj_v, min_v))<br>
+<br>
+ def configure_compile_flags(self):<br>
+ no_default_flags = self.get_lit_bool('no_default_<wbr>flags', False)<br>
+ if not no_default_flags:<br>
+ self.configure_default_<wbr>compile_flags()<br>
+ # This include is always needed so add so add it regardless of<br>
+ # 'no_default_flags'.<br>
+ support_path = os.path.join(self.libcxx_src_<wbr>root, 'test/support')<br>
+ self.cxx.compile_flags += ['-I' + support_path]<br>
+ # Configure extra flags<br>
+ compile_flags_str = self.get_lit_conf('compile_<wbr>flags', '')<br>
+ self.cxx.compile_flags += shlex.split(compile_flags_str)<br>
+ # FIXME: Can we remove this?<br>
+ if self.is_windows:<br>
+ self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS']<br>
+<br>
+ def configure_default_compile_<wbr>flags(self):<br>
+ # Try and get the std version from the command line. Fall back to<br>
+ # default given in lit.site.cfg is not present. If default is not<br>
+ # present then force c++11.<br>
+ std = self.get_lit_conf('std')<br>
+ if not std:<br>
+ # Choose the newest possible language dialect if none is given.<br>
+ possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03']<br>
+ if self.cxx.type == 'gcc':<br>
+ maj_v, _, _ = self.cxx.version<br>
+ maj_v = int(maj_v)<br>
+ if maj_v < 7:<br>
+ possible_stds.remove('c++1z')<br>
+ # FIXME: How many C++14 tests actually fail under GCC 5 and 6?<br>
+ # Should we XFAIL them individually instead?<br>
+ if maj_v <= 6:<br>
+ possible_stds.remove('c++14')<br>
+ for s in possible_stds:<br>
+ if self.cxx.hasCompileFlag('-std=<wbr>%s' % s):<br>
+ std = s<br>
+ self.lit_config.note(<br>
+ 'inferred language dialect as: %s' % std)<br>
+ break<br>
+ if not std:<br>
+ self.lit_config.fatal(<br>
+ 'Failed to infer a supported language dialect from one of %r'<br>
+ % possible_stds)<br>
+ self.cxx.compile_flags += ['-std={0}'.format(std)]<br>
+ self.config.available_<wbr>features.add(std.replace('gnu+<wbr>+', 'c++'))<br>
+ # Configure include paths<br>
+ self.configure_compile_flags_<wbr>header_includes()<br>
+ self.target_info.add_cxx_<wbr>compile_flags(self.cxx.<wbr>compile_flags)<br>
+ # Configure feature flags.<br>
+ self.configure_compile_flags_<wbr>exceptions()<br>
+ self.configure_compile_flags_<wbr>rtti()<br>
+ self.configure_compile_flags_<wbr>abi_version()<br>
+ enable_32bit = self.get_lit_bool('enable_<wbr>32bit', False)<br>
+ if enable_32bit:<br>
+ self.cxx.flags += ['-m32']<br>
+ # Use verbose output for better errors<br>
+ self.cxx.flags += ['-v']<br>
+ sysroot = self.get_lit_conf('sysroot')<br>
+ if sysroot:<br>
+ self.cxx.flags += ['--sysroot', sysroot]<br>
+ gcc_toolchain = self.get_lit_conf('gcc_<wbr>toolchain')<br>
+ if gcc_toolchain:<br>
+ self.cxx.flags += ['-gcc-toolchain', gcc_toolchain]<br>
+ # NOTE: the _DEBUG definition must preceed the triple check because for<br>
+ # the Windows build of libc++, the forced inclusion of a header requires<br>
+ # that _DEBUG is defined. Incorrect ordering will result in -target<br>
+ # being elided.<br>
+ if self.is_windows and self.debug_build:<br>
+ self.cxx.compile_flags += ['-D_DEBUG']<br>
+ if self.use_target:<br>
+ if not self.cxx.addFlagIfSupported(<br>
+ ['-target', self.config.target_triple]):<br>
+ self.lit_config.warning('use_<wbr>target is true but -target is '\<br>
+ 'not supported by the compiler')<br>
+ if self.use_deployment:<br>
+ arch, name, version = self.config.deployment<br>
+ self.cxx.flags += ['-arch', arch]<br>
+ self.cxx.flags += ['-m' + name + '-version-min=' + version]<br>
+<br>
+ # Disable availability unless explicitely requested<br>
+ if not self.with_availability:<br>
+ self.cxx.flags += ['-D_LIBCPP_DISABLE_<wbr>AVAILABILITY']<br>
+<br>
+ def configure_compile_flags_<wbr>header_includes(self):<br>
+ support_path = os.path.join(self.libcxx_src_<wbr>root, 'test', 'support')<br>
+ self.configure_config_site_<wbr>header()<br>
+ if self.cxx_stdlib_under_test != 'libstdc++' and \<br>
+ not self.is_windows:<br>
+ self.cxx.compile_flags += [<br>
+ '-include', os.path.join(support_path, 'nasty_macros.hpp')]<br>
+ if self.cxx_stdlib_under_test == 'msvc':<br>
+ self.cxx.compile_flags += [<br>
+ '-include', os.path.join(support_path,<br>
+ 'msvc_stdlib_force_include.<wbr>hpp')]<br>
+ pass<br>
+ if self.is_windows and self.debug_build and \<br>
+ self.cxx_stdlib_under_test != 'msvc':<br>
+ self.cxx.compile_flags += [<br>
+ '-include', os.path.join(support_path,<br>
+ 'set_windows_crt_report_mode.<wbr>h')<br>
+ ]<br>
+ cxx_headers = self.get_lit_conf('cxx_<wbr>headers')<br>
+ if cxx_headers == '' or (cxx_headers is None<br>
+ and self.cxx_stdlib_under_test != 'libc++'):<br>
+ self.lit_config.note('using the system cxx headers')<br>
+ return<br>
+ self.cxx.compile_flags += ['-nostdinc++']<br>
+ if cxx_headers is None:<br>
+ cxx_headers = os.path.join(self.libcxx_src_<wbr>root, 'include')<br>
+ if not os.path.isdir(cxx_headers):<br>
+ self.lit_config.fatal("cxx_<wbr>headers='%s' is not a directory."<br>
+ % cxx_headers)<br>
+ self.cxx.compile_flags += ['-I' + cxx_headers]<br>
+ if self.libcxx_obj_root is not None:<br>
+ cxxabi_headers = os.path.join(self.libcxx_obj_<wbr>root, 'include',<br>
+ 'c++build')<br>
+ if os.path.isdir(cxxabi_headers):<br>
+ self.cxx.compile_flags += ['-I' + cxxabi_headers]<br>
+<br>
+ def configure_config_site_header(<wbr>self):<br>
+ # Check for a possible __config_site in the build directory. We<br>
+ # use this if it exists.<br>
+ if self.libcxx_obj_root is None:<br>
+ return<br>
+ config_site_header = os.path.join(self.libcxx_obj_<wbr>root, '__config_site')<br>
+ if not os.path.isfile(config_site_<wbr>header):<br>
+ return<br>
+ contained_macros = self.parse_config_site_and_<wbr>add_features(<br>
+ config_site_header)<br>
+ self.lit_config.note('Using __config_site header %s with macros: %r'<br>
+ % (config_site_header, contained_macros))<br>
+ # FIXME: This must come after the call to<br>
+ # 'parse_config_site_and_add_<wbr>features(...)' in order for it to work.<br>
+ self.cxx.compile_flags += ['-include', config_site_header]<br>
+<br>
+ def parse_config_site_and_add_<wbr>features(self, header):<br>
+ """ parse_config_site_and_add_<wbr>features - Deduce and add the test<br>
+ features that that are implied by the #define's in the __config_site<br>
+ header. Return a dictionary containing the macros found in the<br>
+ '__config_site' header.<br>
+ """<br>
+ # Parse the macro contents of __config_site by dumping the macros<br>
+ # using 'c++ -dM -E' and filtering the predefines.<br>
+ predefines = self.cxx.dumpMacros()<br>
+ macros = self.cxx.dumpMacros(header)<br>
+ feature_macros_keys = set(macros.keys()) - set(predefines.keys())<br>
+ feature_macros = {}<br>
+ for k in feature_macros_keys:<br>
+ feature_macros[k] = macros[k]<br>
+ # We expect the header guard to be one of the definitions<br>
+ assert '_LIBCPP_CONFIG_SITE' in feature_macros<br>
+ del feature_macros['_LIBCPP_<wbr>CONFIG_SITE']<br>
+ # The __config_site header should be non-empty. Otherwise it should<br>
+ # have never been emitted by CMake.<br>
+ assert len(feature_macros) > 0<br>
+ # Transform each macro name into the feature name used in the tests.<br>
+ # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads<br>
+ for m in feature_macros:<br>
+ if m == '_LIBCPP_DISABLE_VISIBILITY_<wbr>ANNOTATIONS':<br>
+ continue<br>
+ if m == '_LIBCPP_ABI_VERSION':<br>
+ self.config.available_<wbr>features.add('libcpp-abi-<wbr>version-v%s'<br>
+ % feature_macros[m])<br>
+ continue<br>
+ assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE'<br>
+ m = m.lower()[1:].replace('_', '-')<br>
+ self.config.available_<wbr>features.add(m)<br>
+ return feature_macros<br>
+<br>
+<br>
+<br>
+ def configure_compile_flags_<wbr>exceptions(self):<br>
+ enable_exceptions = self.get_lit_bool('enable_<wbr>exceptions', True)<br>
+ if not enable_exceptions:<br>
+ self.config.available_<wbr>features.add('libcpp-no-<wbr>exceptions')<br>
+ self.cxx.compile_flags += ['-fno-exceptions']<br>
+<br>
+ def configure_compile_flags_rtti(<wbr>self):<br>
+ enable_rtti = self.get_lit_bool('enable_<wbr>rtti', True)<br>
+ if not enable_rtti:<br>
+ self.config.available_<wbr>features.add('libcpp-no-rtti')<br>
+ self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI']<br>
+<br>
+ def configure_compile_flags_abi_<wbr>version(self):<br>
+ abi_version = self.get_lit_conf('abi_<wbr>version', '').strip()<br>
+ abi_unstable = self.get_lit_bool('abi_<wbr>unstable')<br>
+ # Only add the ABI version when it is non-default.<br>
+ # FIXME(EricWF): Get the ABI version from the "__config_site".<br>
+ if abi_version and abi_version != '1':<br>
+ self.cxx.compile_flags += ['-D_LIBCPP_ABI_VERSION=' + abi_version]<br>
+ if abi_unstable:<br>
+ self.config.available_<wbr>features.add('libcpp-abi-<wbr>unstable')<br>
+ self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']<br>
+<br>
+ def configure_filesystem_compile_<wbr>flags(self):<br>
+ enable_fs = self.get_lit_bool('enable_<wbr>filesystem', default=False)<br>
+ if not enable_fs:<br>
+ return<br>
+ enable_experimental = self.get_lit_bool('enable_<wbr>experimental', default=False)<br>
+ if not enable_experimental:<br>
+ self.lit_config.fatal(<br>
+ 'filesystem is enabled but libc++experimental.a is not.')<br>
+ self.config.available_<wbr>features.add('c++filesystem')<br>
+ static_env = os.path.join(self.libcxx_src_<wbr>root, 'test', 'std',<br>
+ 'experimental', 'filesystem', 'Inputs', 'static_test_env')<br>
+ static_env = os.path.realpath(static_env)<br>
+ assert os.path.isdir(static_env)<br>
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_<wbr>TEST_ROOT="%s"' % static_env]<br>
+<br>
+ dynamic_env = os.path.join(self.config.test_<wbr>exec_root,<br>
+ 'filesystem', 'Output', 'dynamic_env')<br>
+ dynamic_env = os.path.realpath(dynamic_env)<br>
+ if not os.path.isdir(dynamic_env):<br>
+ os.makedirs(dynamic_env)<br>
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_<wbr>TEST_ROOT="%s"' % dynamic_env]<br>
+ self.exec_env['LIBCXX_<wbr>FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env)<br>
+<br>
+ dynamic_helper = os.path.join(self.libcxx_src_<wbr>root, 'test', 'support',<br>
+ 'filesystem_dynamic_test_<wbr>helper.py')<br>
+ assert os.path.isfile(dynamic_helper)<br>
+<br>
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_<wbr>TEST_HELPER="%s %s"'<br>
+ % (sys.executable, dynamic_helper)]<br>
+<br>
+<br>
+ def configure_link_flags(self):<br>
+ no_default_flags = self.get_lit_bool('no_default_<wbr>flags', False)<br>
+ if not no_default_flags:<br>
+ # Configure library path<br>
+ self.configure_link_flags_cxx_<wbr>library_path()<br>
+ self.configure_link_flags_abi_<wbr>library_path()<br>
+<br>
+ # Configure libraries<br>
+ if self.cxx_stdlib_under_test == 'libc++':<br>
+ self.cxx.link_flags += ['-nodefaultlibs']<br>
+ # FIXME: Handle MSVCRT as part of the ABI library handling.<br>
+ if self.is_windows:<br>
+ self.cxx.link_flags += ['-nostdlib']<br>
+ self.configure_link_flags_cxx_<wbr>library()<br>
+ self.configure_link_flags_abi_<wbr>library()<br>
+ self.configure_extra_library_<wbr>flags()<br>
+ elif self.cxx_stdlib_under_test == 'libstdc++':<br>
+ enable_fs = self.get_lit_bool('enable_<wbr>filesystem',<br>
+ default=False)<br>
+ if enable_fs:<br>
+ self.config.available_<wbr>features.add('c++experimental'<wbr>)<br>
+ self.cxx.link_flags += ['-lstdc++fs']<br>
+ self.cxx.link_flags += ['-lm', '-pthread']<br>
+ elif self.cxx_stdlib_under_test == 'msvc':<br>
+ # FIXME: Correctly setup debug/release flags here.<br>
+ pass<br>
+ elif self.cxx_stdlib_under_test == 'cxx_default':<br>
+ self.cxx.link_flags += ['-pthread']<br>
+ else:<br>
+ self.lit_config.fatal(<br>
+ 'unsupported value for "use_stdlib_type": %s'<br>
+ % use_stdlib_type)<br>
+<br>
+ link_flags_str = self.get_lit_conf('link_flags'<wbr>, '')<br>
+ self.cxx.link_flags += shlex.split(link_flags_str)<br>
+<br>
+ def configure_link_flags_cxx_<wbr>library_path(self):<br>
+ if not self.use_system_cxx_lib:<br>
+ if self.cxx_library_root:<br>
+ self.cxx.link_flags += ['-L' + self.cxx_library_root]<br>
+ if self.is_windows and self.link_shared:<br>
+ self.add_path(self.cxx.<wbr>compile_env, self.cxx_library_root)<br>
+ if self.cxx_runtime_root:<br>
+ if not self.is_windows:<br>
+ self.cxx.link_flags += ['-Wl,-rpath,' +<br>
+ self.cxx_runtime_root]<br>
+ elif self.is_windows and self.link_shared:<br>
+ self.add_path(self.exec_env, self.cxx_runtime_root)<br>
+ elif os.path.isdir(str(self.use_<wbr>system_cxx_lib)):<br>
+ self.cxx.link_flags += ['-L' + self.use_system_cxx_lib]<br>
+ if not self.is_windows:<br>
+ self.cxx.link_flags += ['-Wl,-rpath,' +<br>
+ self.use_system_cxx_lib]<br>
+ if self.is_windows and self.link_shared:<br>
+ self.add_path(self.cxx.<wbr>compile_env, self.use_system_cxx_lib)<br>
+<br>
+ def configure_link_flags_abi_<wbr>library_path(self):<br>
+ # Configure ABI library paths.<br>
+ self.abi_library_root = self.get_lit_conf('abi_<wbr>library_path')<br>
+ if self.abi_library_root:<br>
+ self.cxx.link_flags += ['-L' + self.abi_library_root]<br>
+ if not self.is_windows:<br>
+ self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root]<br>
+ else:<br>
+ self.add_path(self.exec_env, self.abi_library_root)<br>
+<br>
+ def configure_link_flags_cxx_<wbr>library(self):<br>
+ libcxx_experimental = self.get_lit_bool('enable_<wbr>experimental', default=False)<br>
+ if libcxx_experimental:<br>
+ self.config.available_<wbr>features.add('c++experimental'<wbr>)<br>
+ self.cxx.link_flags += ['-lc++experimental']<br>
+ if self.link_shared:<br>
+ self.cxx.link_flags += ['-lc++']<br>
+ else:<br>
+ cxx_library_root = self.get_lit_conf('cxx_<wbr>library_root')<br>
+ if cxx_library_root:<br>
+ libname = self.make_static_lib_name('c++<wbr>')<br>
+ abs_path = os.path.join(cxx_library_root, libname)<br>
+ assert os.path.exists(abs_path) and \<br>
+ "static libc++ library does not exist"<br>
+ self.cxx.link_flags += [abs_path]<br>
+ else:<br>
+ self.cxx.link_flags += ['-lc++']<br>
+<br>
+ def configure_link_flags_abi_<wbr>library(self):<br>
+ cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')<br>
+ if cxx_abi == 'libstdc++':<br>
+ self.cxx.link_flags += ['-lstdc++']<br>
+ elif cxx_abi == 'libsupc++':<br>
+ self.cxx.link_flags += ['-lsupc++']<br>
+ elif cxx_abi == 'libcxxabi':<br>
+ if self.target_info.allow_cxxabi_<wbr>link():<br>
+ libcxxabi_shared = self.get_lit_bool('libcxxabi_<wbr>shared', default=True)<br>
+ if libcxxabi_shared:<br>
+ self.cxx.link_flags += ['-lc++abi']<br>
+ else:<br>
+ cxxabi_library_root = self.get_lit_conf('abi_<wbr>library_path')<br>
+ if cxxabi_library_root:<br>
+ libname = self.make_static_lib_name('c++<wbr>abi')<br>
+ abs_path = os.path.join(cxxabi_library_<wbr>root, libname)<br>
+ self.cxx.link_flags += [abs_path]<br>
+ else:<br>
+ self.cxx.link_flags += ['-lc++abi']<br>
+ elif cxx_abi == 'libcxxrt':<br>
+ self.cxx.link_flags += ['-lcxxrt']<br>
+ elif cxx_abi == 'vcruntime':<br>
+ debug_suffix = 'd' if self.debug_build else ''<br>
+ self.cxx.link_flags += ['-l%s%s' % (lib, debug_suffix) for lib in<br>
+ ['vcruntime', 'ucrt', 'msvcrt']]<br>
+ elif cxx_abi == 'none' or cxx_abi == 'default':<br>
+ if self.is_windows:<br>
+ debug_suffix = 'd' if self.debug_build else ''<br>
+ self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix]<br>
+ else:<br>
+ self.lit_config.fatal(<br>
+ 'C++ ABI setting %s unsupported for tests' % cxx_abi)<br>
+<br>
+ def configure_extra_library_flags(<wbr>self):<br>
+ if self.get_lit_bool('cxx_ext_<wbr>threads', default=False):<br>
+ self.cxx.link_flags += ['-lc++external_threads']<br>
+ self.target_info.add_cxx_link_<wbr>flags(self.cxx.link_flags)<br>
+<br>
+ def configure_color_diagnostics(<wbr>self):<br>
+ use_color = self.get_lit_conf('color_<wbr>diagnostics')<br>
+ if use_color is None:<br>
+ use_color = os.environ.get('LIBCXX_COLOR_<wbr>DIAGNOSTICS')<br>
+ if use_color is None:<br>
+ return<br>
+ if use_color != '':<br>
+ self.lit_config.fatal('Invalid value for color_diagnostics "%s".'<br>
+ % use_color)<br>
+ color_flag = '-fdiagnostics-color=always'<br>
+ # Check if the compiler supports the color diagnostics flag. Issue a<br>
+ # warning if it does not since color diagnostics have been requested.<br>
+ if not self.cxx.hasCompileFlag(color_<wbr>flag):<br>
+ self.lit_config.warning(<br>
+ 'color diagnostics have been requested but are not supported '<br>
+ 'by the compiler')<br>
+ else:<br>
+ self.cxx.flags += [color_flag]<br>
+<br>
+ def configure_debug_mode(self):<br>
+ debug_level = self.get_lit_conf('debug_<wbr>level', None)<br>
+ if not debug_level:<br>
+ return<br>
+ if debug_level not in ['0', '1']:<br>
+ self.lit_config.fatal('Invalid value for debug_level "%s".'<br>
+ % debug_level)<br>
+ self.cxx.compile_flags += ['-D_LIBCPP_DEBUG=%s' % debug_level]<br>
+<br>
+ def configure_warnings(self):<br>
+ # Turn on warnings by default for Clang based compilers when C++ >= 11<br>
+ default_enable_warnings = self.cxx.type in ['clang', 'apple-clang'] \<br>
+ and len(self.config.available_<wbr>features.intersection(<br>
+ ['c++11', 'c++14', 'c++1z'])) != 0<br>
+ enable_warnings = self.get_lit_bool('enable_<wbr>warnings',<br>
+ default_enable_warnings)<br>
+ self.cxx.useWarnings(enable_<wbr>warnings)<br>
+ self.cxx.warning_flags += [<br>
+ '-D_LIBCPP_HAS_NO_PRAGMA_<wbr>SYSTEM_HEADER',<br>
+ '-Wall', '-Wextra', '-Werror'<br>
+ ]<br>
+ if self.cxx.hasWarningFlag('-<wbr>Wuser-defined-warnings'):<br>
+ self.cxx.warning_flags += ['-Wuser-defined-warnings']<br>
+ self.config.available_<wbr>features.add('diagnose-if-<wbr>support')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wshadow')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-command-line-<wbr>argument')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-attributes')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-pessimizing-move')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-c++11-extensions')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-user-defined-literals')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-noexcept-type')<br>
+ # These warnings should be enabled in order to support the MSVC<br>
+ # team using the test suite; They enable the warnings below and<br>
+ # expect the test suite to be clean.<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wsign-compare')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunused-variable')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunused-parameter')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wunreachable-code')<br>
+ # FIXME: Enable the two warnings below.<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-conversion')<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-local-typedef')<br>
+ std = self.get_lit_conf('std', None)<br>
+ if std in ['c++98', 'c++03']:<br>
+ # The '#define static_assert' provided by libc++ in C++03 mode<br>
+ # causes an unused local typedef whenever it is used.<br>
+ self.cxx.<wbr>addWarningFlagIfSupported('-<wbr>Wno-unused-local-typedef')<br>
+<br>
+ def configure_sanitizer(self):<br>
+ san = self.get_lit_conf('use_<wbr>sanitizer', '').strip()<br>
+ if san:<br>
+ self.target_info.add_<wbr>sanitizer_features(san, self.config.available_<wbr>features)<br>
+ # Search for llvm-symbolizer along the compiler path first<br>
+ # and then along the PATH env variable.<br>
+ symbolizer_search_paths = os.environ.get('PATH', '')<br>
+ cxx_path = libcxx.util.which(self.cxx.<wbr>path)<br>
+ if cxx_path is not None:<br>
+ symbolizer_search_paths = (<br>
+ os.path.dirname(cxx_path) +<br>
+ os.pathsep + symbolizer_search_paths)<br>
+ llvm_symbolizer = libcxx.util.which('llvm-<wbr>symbolizer',<br>
+ symbolizer_search_paths)<br>
+<br>
+ def add_ubsan():<br>
+ self.cxx.flags += ['-fsanitize=undefined',<br>
+ '-fno-sanitize=vptr,function,<wbr>float-divide-by-zero',<br>
+ '-fno-sanitize-recover=all']<br>
+ self.exec_env['UBSAN_OPTIONS'] = 'print_stacktrace=1'<br>
+ self.config.available_<wbr>features.add('ubsan')<br>
+<br>
+ # Setup the sanitizer compile flags<br>
+ self.cxx.flags += ['-g', '-fno-omit-frame-pointer']<br>
+ if san == 'Address' or san == 'Address;Undefined' or san == 'Undefined;Address':<br>
+ self.cxx.flags += ['-fsanitize=address']<br>
+ if llvm_symbolizer is not None:<br>
+ self.exec_env['ASAN_<wbr>SYMBOLIZER_PATH'] = llvm_symbolizer<br>
+ # FIXME: Turn ODR violation back on after PR28391 is resolved<br>
+ # <a href="https://bugs.llvm.org/show_bug.cgi?id=28391" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=28391</a><br>
+ self.exec_env['ASAN_OPTIONS'] = 'detect_odr_violation=0'<br>
+ self.config.available_<wbr>features.add('asan')<br>
+ self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
+ self.cxx.compile_flags += ['-O1']<br>
+ if san == 'Address;Undefined' or san == 'Undefined;Address':<br>
+ add_ubsan()<br>
+ elif san == 'Memory' or san == 'MemoryWithOrigins':<br>
+ self.cxx.flags += ['-fsanitize=memory']<br>
+ if san == 'MemoryWithOrigins':<br>
+ self.cxx.compile_flags += [<br>
+ '-fsanitize-memory-track-<wbr>origins']<br>
+ if llvm_symbolizer is not None:<br>
+ self.exec_env['MSAN_<wbr>SYMBOLIZER_PATH'] = llvm_symbolizer<br>
+ self.config.available_<wbr>features.add('msan')<br>
+ self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
+ self.cxx.compile_flags += ['-O1']<br>
+ elif san == 'Undefined':<br>
+ add_ubsan()<br>
+ self.cxx.compile_flags += ['-O2']<br>
+ elif san == 'Thread':<br>
+ self.cxx.flags += ['-fsanitize=thread']<br>
+ self.config.available_<wbr>features.add('tsan')<br>
+ self.config.available_<wbr>features.add('sanitizer-new-<wbr>delete')<br>
+ else:<br>
+ self.lit_config.fatal('<wbr>unsupported value for '<br>
+ 'use_sanitizer: {0}'.format(san))<br>
+ san_lib = self.get_lit_conf('sanitizer_<wbr>library')<br>
+ if san_lib:<br>
+ self.cxx.link_flags += [<br>
+ san_lib, '-Wl,-rpath,%s' % os.path.dirname(san_lib)]<br>
+<br>
+ def configure_coverage(self):<br>
+ self.generate_coverage = self.get_lit_bool('generate_<wbr>coverage', False)<br>
+ if self.generate_coverage:<br>
+ self.cxx.flags += ['-g', '--coverage']<br>
+ self.cxx.compile_flags += ['-O0']<br>
+<br>
+ def configure_modules(self):<br>
+ modules_flags = ['-fmodules']<br>
+ if platform.system() != 'Darwin':<br>
+ modules_flags += ['-Xclang', '-fmodules-local-submodule-<wbr>visibility']<br>
+ supports_modules = self.cxx.hasCompileFlag(<wbr>modules_flags)<br>
+ enable_modules = self.get_lit_bool('enable_<wbr>modules',<br>
+ default=False,<br>
+ env_var='LIBCXX_ENABLE_<wbr>MODULES')<br>
+ if enable_modules and not supports_modules:<br>
+ self.lit_config.fatal(<br>
+ '-fmodules is enabled but not supported by the compiler')<br>
+ if not supports_modules:<br>
+ return<br>
+ self.config.available_<wbr>features.add('modules-support'<wbr>)<br>
+ module_cache = os.path.join(self.config.test_<wbr>exec_root,<br>
+ 'modules.cache')<br>
+ module_cache = os.path.realpath(module_cache)<br>
+ if os.path.isdir(module_cache):<br>
+ shutil.rmtree(module_cache)<br>
+ os.makedirs(module_cache)<br>
+ self.cxx.modules_flags = modules_flags + \<br>
+ ['-fmodules-cache-path=' + module_cache]<br>
+ if enable_modules:<br>
+ self.config.available_<wbr>features.add('-fmodules')<br>
+ self.cxx.useModules()<br>
+<br>
+ def configure_substitutions(self):<br>
+ sub = self.config.substitutions<br>
+ cxx_path = pipes.quote(self.cxx.path)<br>
+ # Configure compiler substitutions<br>
+ sub.append(('%cxx', cxx_path))<br>
+ # Configure flags substitutions<br>
+ flags_str = ' '.join([pipes.quote(f) for f in self.cxx.flags])<br>
+ compile_flags_str = ' '.join([pipes.quote(f) for f in self.cxx.compile_flags])<br>
+ link_flags_str = ' '.join([pipes.quote(f) for f in self.cxx.link_flags])<br>
+ all_flags = '%s %s %s' % (flags_str, compile_flags_str, link_flags_str)<br>
+ sub.append(('%flags', flags_str))<br>
+ sub.append(('%compile_flags', compile_flags_str))<br>
+ sub.append(('%link_flags', link_flags_str))<br>
+ sub.append(('%all_flags', all_flags))<br>
+ if self.cxx.isVerifySupported():<br>
+ verify_str = ' ' + ' '.join(self.cxx.verify_flags) + ' '<br>
+ sub.append(('%verify', verify_str))<br>
+ # Add compile and link shortcuts<br>
+ compile_str = (cxx_path + ' -o %t.o %s -c ' + flags_str<br>
+ + ' ' + compile_flags_str)<br>
+ link_str = (cxx_path + ' -o %t.exe %t.o ' + flags_str + ' '<br>
+ + link_flags_str)<br>
+ assert type(link_str) is str<br>
+ build_str = cxx_path + ' -o %t.exe %s ' + all_flags<br>
+ if self.cxx.use_modules:<br>
+ sub.append(('%compile_module', compile_str))<br>
+ sub.append(('%build_module', build_str))<br>
+ elif self.cxx.modules_flags is not None:<br>
+ modules_str = ' '.join(self.cxx.modules_flags) + ' '<br>
+ sub.append(('%compile_module', compile_str + ' ' + modules_str))<br>
+ sub.append(('%build_module', build_str + ' ' + modules_str))<br>
+ sub.append(('%compile', compile_str))<br>
+ sub.append(('%link', link_str))<br>
+ sub.append(('%build', build_str))<br>
+ # Configure exec prefix substitutions.<br>
+ exec_env_str = ''<br>
+ if not self.is_windows and len(self.exec_env) != 0:<br>
+ exec_env_str = 'env '<br>
+ for k, v in self.exec_env.items():<br>
+ exec_env_str += ' %s=%s' % (k, v)<br>
+ # Configure run env substitution.<br>
+ exec_str = exec_env_str<br>
+ if self.lit_config.useValgrind:<br>
+ exec_str = ' '.join(self.lit_config.<wbr>valgrindArgs) + exec_env_str<br>
+ sub.append(('%exec', exec_str))<br>
+ # Configure run shortcut<br>
+ sub.append(('%run', exec_str + ' %t.exe'))<br>
+ # Configure not program substitutions<br>
+ not_py = os.path.join(self.libcxx_src_<wbr>root, 'utils', 'not.py')<br>
+ not_str = '%s %s ' % (pipes.quote(sys.executable), pipes.quote(not_py))<br>
+ sub.append(('not ', not_str))<br>
+<br>
+ def can_use_deployment(self):<br>
+ # Check if the host is on an Apple platform using clang.<br>
+ if not self.target_info.platform() == "darwin":<br>
+ return False<br>
+ if not self.target_info.is_host_<wbr>macosx():<br>
+ return False<br>
+ if not self.cxx.type.endswith('clang'<wbr>):<br>
+ return False<br>
+ return True<br>
+<br>
+ def configure_triple(self):<br>
+ # Get or infer the target triple.<br>
+ target_triple = self.get_lit_conf('target_<wbr>triple')<br>
+ self.use_target = self.get_lit_bool('use_target'<wbr>, False)<br>
+ if self.use_target and target_triple:<br>
+ self.lit_config.warning('use_<wbr>target is true but no triple is specified')<br>
+<br>
+ # Use deployment if possible.<br>
+ self.use_deployment = not self.use_target and self.can_use_deployment()<br>
+ if self.use_deployment:<br>
+ return<br>
+<br>
+ # Save the triple (and warn on Apple platforms).<br>
+ self.config.target_triple = target_triple<br>
+ if self.use_target and 'apple' in target_triple:<br>
+ self.lit_config.warning('<wbr>consider using arch and platform instead'<br>
+ ' of target_triple on Apple platforms')<br>
+<br>
+ # If no target triple was given, try to infer it from the compiler<br>
+ # under test.<br>
+ if not self.config.target_triple:<br>
+ target_triple = self.cxx.getTriple()<br>
+ # Drop sub-major version components from the triple, because the<br>
+ # current XFAIL handling expects exact matches for feature checks.<br>
+ # Example: x86_64-apple-darwin14.0.0 -> x86_64-apple-darwin14<br>
+ # The 5th group handles triples greater than 3 parts<br>
+ # (ex x86_64-pc-linux-gnu).<br>
+ target_triple = re.sub(r'([^-]+)-([^-]+)-([^.]<wbr>+)([^-]*)(.*)',<br>
+ r'\1-\2-\3\5', target_triple)<br>
+ # linux-gnu is needed in the triple to properly identify linuxes<br>
+ # that use GLIBC. Handle redhat and opensuse triples as special<br>
+ # cases and append the missing `-gnu` portion.<br>
+ if (target_triple.endswith('<wbr>redhat-linux') or<br>
+ target_triple.endswith('suse-<wbr>linux')):<br>
+ target_triple += '-gnu'<br>
+ self.config.target_triple = target_triple<br>
+ self.lit_config.note(<br>
+ "inferred target_triple as: %r" % self.config.target_triple)<br>
+<br>
+ def configure_deployment(self):<br>
+ assert not self.use_deployment is None<br>
+ assert not self.use_target is None<br>
+ if not self.use_deployment:<br>
+ # Warn about ignored parameters.<br>
+ if self.get_lit_conf('arch'):<br>
+ self.lit_config.warning('<wbr>ignoring arch, using target_triple')<br>
+ if self.get_lit_conf('platform'):<br>
+ self.lit_config.warning('<wbr>ignoring platform, using target_triple')<br>
+ return<br>
+<br>
+ assert not self.use_target<br>
+ assert self.target_info.is_host_<wbr>macosx()<br>
+<br>
+ # Always specify deployment explicitly on Apple platforms, since<br>
+ # otherwise a platform is picked up from the SDK. If the SDK version<br>
+ # doesn't match the system version, tests that use the system library<br>
+ # may fail spuriously.<br>
+ arch = self.get_lit_conf('arch')<br>
+ if not arch:<br>
+ arch = self.cxx.getTriple().split('-'<wbr>, 1)[0]<br>
+ self.lit_config.note("inferred arch as: %r" % arch)<br>
+<br>
+ inferred_platform, name, version = self.target_info.get_platform(<wbr>)<br>
+ if inferred_platform:<br>
+ self.lit_config.note("inferred platform as: %r" % (name + version))<br>
+ self.config.deployment = (arch, name, version)<br>
+<br>
+ # Set the target triple for use by lit.<br>
+ self.config.target_triple = arch + '-apple-' + name + version<br>
+ self.lit_config.note(<br>
+ "computed target_triple as: %r" % self.config.target_triple)<br>
+<br>
+ def configure_env(self):<br>
+ self.target_info.configure_<wbr>env(self.exec_env)<br>
+<br>
+ def add_path(self, dest_env, new_path):<br>
+ if 'PATH' not in dest_env:<br>
+ dest_env['PATH'] = new_path<br>
+ else:<br>
+ split_char = ';' if self.is_windows else ':'<br>
+ dest_env['PATH'] = '%s%s%s' % (new_path, split_char,<br>
+ dest_env['PATH'])<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>