summaryrefslogtreecommitdiff
path: root/test/libcxx/test/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/libcxx/test/config.py')
-rw-r--r--test/libcxx/test/config.py117
1 files changed, 91 insertions, 26 deletions
diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py
index f8096ad15f8a..593f9805447d 100644
--- a/test/libcxx/test/config.py
+++ b/test/libcxx/test/config.py
@@ -61,6 +61,7 @@ class Configuration(object):
self.libcxx_src_root = None
self.libcxx_obj_root = None
self.cxx_library_root = None
+ self.cxx_runtime_root = None
self.abi_library_root = None
self.env = {}
self.use_target = False
@@ -98,9 +99,11 @@ class Configuration(object):
self.configure_cxx_library_root()
self.configure_use_system_cxx_lib()
self.configure_use_clang_verify()
+ self.configure_use_thread_safety()
self.configure_execute_external()
self.configure_ccache()
self.configure_compile_flags()
+ self.configure_filesystem_compile_flags()
self.configure_link_flags()
self.configure_env()
self.configure_color_diagnostics()
@@ -194,6 +197,8 @@ class Configuration(object):
def configure_cxx_library_root(self):
self.cxx_library_root = self.get_lit_conf('cxx_library_root',
self.libcxx_obj_root)
+ self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root',
+ self.cxx_library_root)
def configure_use_system_cxx_lib(self):
# This test suite supports testing against either the system library or
@@ -218,6 +223,14 @@ class Configuration(object):
self.lit_config.note(
"inferred use_clang_verify as: %r" % self.use_clang_verify)
+ def configure_use_thread_safety(self):
+ '''If set, run clang with -verify on failing tests.'''
+ has_thread_safety = self.cxx.hasCompileFlag('-Werror=thread-safety')
+ if has_thread_safety:
+ self.cxx.compile_flags += ['-Werror=thread-safety']
+ self.config.available_features.add('thread-safety')
+ self.lit_config.note("enabling thread-safety annotations")
+
def configure_execute_external(self):
# Choose between lit's internal shell pipeline runner and a real shell.
# If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
@@ -277,10 +290,17 @@ class Configuration(object):
if self.cxx.hasCompileFlag('-fsized-deallocation'):
self.config.available_features.add('fsized-deallocation')
+ if self.get_lit_bool('has_libatomic', False):
+ self.config.available_features.add('libatomic')
+
def configure_compile_flags(self):
no_default_flags = self.get_lit_bool('no_default_flags', False)
if not no_default_flags:
self.configure_default_compile_flags()
+ # This include is always needed so add so add it regardless of
+ # 'no_default_flags'.
+ support_path = os.path.join(self.libcxx_src_root, 'test/support')
+ self.cxx.compile_flags += ['-I' + support_path]
# Configure extra flags
compile_flags_str = self.get_lit_conf('compile_flags', '')
self.cxx.compile_flags += shlex.split(compile_flags_str)
@@ -329,7 +349,6 @@ class Configuration(object):
def configure_compile_flags_header_includes(self):
support_path = os.path.join(self.libcxx_src_root, 'test/support')
- self.cxx.compile_flags += ['-I' + support_path]
self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
self.configure_config_site_header()
libcxx_headers = self.get_lit_conf(
@@ -412,6 +431,37 @@ class Configuration(object):
self.config.available_features.add('libcpp-abi-unstable')
self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE']
+ def configure_filesystem_compile_flags(self):
+ enable_fs = self.get_lit_bool('enable_filesystem', default=False)
+ if not enable_fs:
+ return
+ enable_experimental = self.get_lit_bool('enable_experimental', default=False)
+ if not enable_experimental:
+ self.lit_config.fatal(
+ 'filesystem is enabled but libc++experimental.a is not.')
+ self.config.available_features.add('c++filesystem')
+ static_env = os.path.join(self.libcxx_src_root, 'test', 'std',
+ 'experimental', 'filesystem', 'Inputs', 'static_test_env')
+ static_env = os.path.realpath(static_env)
+ assert os.path.isdir(static_env)
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="%s"' % static_env]
+
+ dynamic_env = os.path.join(self.libcxx_obj_root, 'test',
+ 'filesystem', 'Output', 'dynamic_env')
+ dynamic_env = os.path.realpath(dynamic_env)
+ if not os.path.isdir(dynamic_env):
+ os.makedirs(dynamic_env)
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="%s"' % dynamic_env]
+ self.env['LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT'] = ("%s" % dynamic_env)
+
+ dynamic_helper = os.path.join(self.libcxx_src_root, 'test', 'support',
+ 'filesystem_dynamic_test_helper.py')
+ assert os.path.isfile(dynamic_helper)
+
+ self.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="%s %s"'
+ % (sys.executable, dynamic_helper)]
+
+
def configure_link_flags(self):
no_default_flags = self.get_lit_bool('no_default_flags', False)
if not no_default_flags:
@@ -430,23 +480,11 @@ class Configuration(object):
self.cxx.link_flags += shlex.split(link_flags_str)
def configure_link_flags_cxx_library_path(self):
- libcxx_library = self.get_lit_conf('libcxx_library')
- # Configure libc++ library paths.
- if libcxx_library is not None:
- # Check that the given value for libcxx_library is valid.
- if not os.path.isfile(libcxx_library):
- self.lit_config.fatal(
- "libcxx_library='%s' is not a valid file." %
- libcxx_library)
- if self.use_system_cxx_lib:
- self.lit_config.fatal(
- "Conflicting options: 'libcxx_library' cannot be used "
- "with 'use_system_cxx_lib=true'")
- self.cxx.link_flags += ['-Wl,-rpath,' +
- os.path.dirname(libcxx_library)]
- elif not self.use_system_cxx_lib and self.cxx_library_root:
- self.cxx.link_flags += ['-L' + self.cxx_library_root,
- '-Wl,-rpath,' + self.cxx_library_root]
+ if not self.use_system_cxx_lib:
+ if self.cxx_library_root:
+ self.cxx.link_flags += ['-L' + self.cxx_library_root]
+ if self.cxx_runtime_root:
+ self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
def configure_link_flags_abi_library_path(self):
# Configure ABI library paths.
@@ -456,11 +494,20 @@ class Configuration(object):
'-Wl,-rpath,' + self.abi_library_root]
def configure_link_flags_cxx_library(self):
- libcxx_library = self.get_lit_conf('libcxx_library')
- if libcxx_library:
- self.cxx.link_flags += [libcxx_library]
- else:
+ libcxx_experimental = self.get_lit_bool('enable_experimental', default=False)
+ if libcxx_experimental:
+ self.config.available_features.add('c++experimental')
+ self.cxx.link_flags += ['-lc++experimental']
+ libcxx_shared = self.get_lit_bool('enable_shared', default=True)
+ if libcxx_shared:
self.cxx.link_flags += ['-lc++']
+ else:
+ cxx_library_root = self.get_lit_conf('cxx_library_root')
+ if cxx_library_root:
+ abs_path = os.path.join(cxx_library_root, 'libc++.a')
+ self.cxx.link_flags += [abs_path]
+ else:
+ self.cxx.link_flags += ['-lc++']
def configure_link_flags_abi_library(self):
cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
@@ -470,7 +517,16 @@ class Configuration(object):
self.cxx.link_flags += ['-lsupc++']
elif cxx_abi == 'libcxxabi':
if self.target_info.allow_cxxabi_link():
- self.cxx.link_flags += ['-lc++abi']
+ libcxxabi_shared = self.get_lit_bool('libcxxabi_shared', default=True)
+ if libcxxabi_shared:
+ self.cxx.link_flags += ['-lc++abi']
+ else:
+ cxxabi_library_root = self.get_lit_conf('abi_library_path')
+ if cxxabi_library_root:
+ abs_path = os.path.join(cxxabi_library_root, 'libc++abi.a')
+ self.cxx.link_flags += [abs_path]
+ else:
+ self.cxx.link_flags += ['-lc++abi']
elif cxx_abi == 'libcxxrt':
self.cxx.link_flags += ['-lcxxrt']
elif cxx_abi == 'none':
@@ -515,8 +571,9 @@ class Configuration(object):
if enable_warnings:
self.cxx.compile_flags += [
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
- '-Wall', '-Werror'
+ '-Wall', '-Wextra', '-Werror'
]
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
self.cxx.addWarningFlagIfSupported('-Wno-attributes')
self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
@@ -525,6 +582,8 @@ class Configuration(object):
# compiles clean with them.
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
self.cxx.addWarningFlagIfSupported('-Wno-unused-variable')
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-parameter')
+ self.cxx.addWarningFlagIfSupported('-Wno-sign-compare')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode
@@ -551,6 +610,9 @@ class Configuration(object):
self.cxx.flags += ['-fsanitize=address']
if llvm_symbolizer is not None:
self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
+ # FIXME: Turn ODR violation back on after PR28391 is resolved
+ # https://llvm.org/bugs/show_bug.cgi?id=28391
+ self.env['ASAN_OPTIONS'] = 'detect_odr_violation=0'
self.config.available_features.add('asan')
self.config.available_features.add('sanitizer-new-delete')
elif san == 'Memory' or san == 'MemoryWithOrigins':
@@ -563,9 +625,12 @@ class Configuration(object):
self.config.available_features.add('msan')
self.config.available_features.add('sanitizer-new-delete')
elif san == 'Undefined':
+ blacklist = os.path.join(self.libcxx_src_root,
+ 'test/ubsan_blacklist.txt')
self.cxx.flags += ['-fsanitize=undefined',
- '-fno-sanitize=vptr,function',
- '-fno-sanitize-recover']
+ '-fno-sanitize=vptr,function,float-divide-by-zero',
+ '-fno-sanitize-recover=all',
+ '-fsanitize-blacklist=' + blacklist]
self.cxx.compile_flags += ['-O3']
self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1'
self.config.available_features.add('ubsan')