diff options
Diffstat (limited to 'test/libcxx/test')
-rw-r--r-- | test/libcxx/test/config.py | 117 | ||||
-rw-r--r-- | test/libcxx/test/format.py | 11 | ||||
-rw-r--r-- | test/libcxx/test/target_info.py | 22 |
3 files changed, 117 insertions, 33 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') diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py index aaa9a1845ae4..b9ec2ba2aa7b 100644 --- a/test/libcxx/test/format.py +++ b/test/libcxx/test/format.py @@ -161,12 +161,19 @@ class LibcxxTestFormat(object): 'expected-error', 'expected-no-diagnostics'] use_verify = self.use_verify_for_fail and \ any([tag in contents for tag in verify_tags]) - extra_flags = ['-fsyntax-only'] + # FIXME(EricWF): GCC 5 does not evaluate static assertions that + # are dependant on a template parameter when '-fsyntax-only' is passed. + # This is fixed in GCC 6. However for now we only pass "-fsyntax-only" + # when using Clang. + extra_flags = [] + if self.cxx.type != 'gcc': + extra_flags += ['-fsyntax-only'] if use_verify: extra_flags += ['-Xclang', '-verify', '-Xclang', '-verify-ignore-unexpected=note'] cmd, out, err, rc = self.cxx.compile(source_path, out=os.devnull, - flags=extra_flags) + flags=extra_flags, + disable_ccache=True) expected_rc = 0 if use_verify else 1 if rc == expected_rc: return lit.Test.PASS, '' diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py index 7ca08bea193a..a743595a1046 100644 --- a/test/libcxx/test/target_info.py +++ b/test/libcxx/test/target_info.py @@ -90,13 +90,10 @@ class DarwinLocalTI(DefaultTargetInfo): def configure_env(self, env): library_paths = [] # Configure the library path for libc++ - libcxx_library = self.full_config.get_lit_conf('libcxx_library') if self.full_config.use_system_cxx_lib: pass - elif libcxx_library: - library_paths += [os.path.dirname(libcxx_library)] - elif self.full_config.cxx_library_root: - library_paths += [self.full_config.cxx_library_root] + elif self.full_config.cxx_runtime_root: + library_paths += [self.full_config.cxx_runtime_root] # Configure the abi library path if self.full_config.abi_library_root: library_paths += [self.full_config.abi_library_root] @@ -104,6 +101,15 @@ class DarwinLocalTI(DefaultTargetInfo): env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) def allow_cxxabi_link(self): + # FIXME: PR27405 + # libc++ *should* export all of the symbols found in libc++abi on OS X. + # For this reason LibcxxConfiguration will not link libc++abi in OS X. + # However __cxa_throw_bad_new_array_length doesn't get exported into + # libc++ yet so we still need to explicitly link libc++abi when testing + # libc++abi + # See PR22654. + if(self.full_config.get_lit_conf('name', '') == 'libc++abi'): + return True # Don't link libc++abi explicitly on OS X because the symbols # should be available in libc++ directly. return False @@ -162,16 +168,22 @@ class LinuxLocalTI(DefaultTargetInfo): enable_threads = ('libcpp-has-no-threads' not in self.full_config.config.available_features) llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) + shared_libcxx = self.full_config.get_lit_bool('enable_shared', True) flags += ['-lm'] if not llvm_unwinder: flags += ['-lgcc_s', '-lgcc'] if enable_threads: flags += ['-lpthread'] + if not shared_libcxx: + flags += ['-lrt'] flags += ['-lc'] if llvm_unwinder: flags += ['-lunwind', '-ldl'] else: flags += ['-lgcc_s', '-lgcc'] + use_libatomic = self.full_config.get_lit_bool('use_libatomic', False) + if use_libatomic: + flags += ['-latomic'] san = self.full_config.get_lit_conf('use_sanitizer', '').strip() if san: # The libraries and their order are taken from the |