[libcxx] r283958 - Make it easier to run the libc++ test suite against libstdc++

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 17:00:38 PDT 2016


Author: ericwf
Date: Tue Oct 11 19:00:37 2016
New Revision: 283958

URL: http://llvm.org/viewvc/llvm-project?rev=283958&view=rev
Log:
Make it easier to run the libc++ test suite against libstdc++

Modified:
    libcxx/trunk/docs/TestingLibcxx.rst
    libcxx/trunk/test/libcxx/test/config.py
    libcxx/trunk/test/lit.cfg

Modified: libcxx/trunk/docs/TestingLibcxx.rst
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/TestingLibcxx.rst?rev=283958&r1=283957&r2=283958&view=diff
==============================================================================
--- libcxx/trunk/docs/TestingLibcxx.rst (original)
+++ libcxx/trunk/docs/TestingLibcxx.rst Tue Oct 11 19:00:37 2016
@@ -102,6 +102,12 @@ configuration. Passing the option on the
 
   Specify the compiler used to build the tests.
 
+.. option:: --cxx_stdlib_under_test=[libc++, libstdc++, cxx_default]
+
+  Specify the C++ standard library being tested. Unless otherwise specified
+  libc++ is used. This option is intended to allow running the libc++ test
+  suite against other standard library implementations.
+
 .. option:: std=<standard version>
 
   **Values**: c++98, c++03, c++11, c++14, c++1z
@@ -113,10 +119,10 @@ configuration. Passing the option on the
   Specify the site configuration to use when running the tests.  This option
   overrides the enviroment variable LIBCXX_SITE_CONFIG.
 
-.. option:: --libcxx_headers=<path/to/headers>
+.. option:: --cxx_headers=<path/to/headers>
 
-  Specify the libc++ headers that are tested. By default the headers in the
-  source tree are used.
+  Specify the c++ standard library headers that are tested. By default the
+  headers in the source tree are used.
 
 .. option:: --cxx_library_root=<path/to/lib/>
 

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=283958&r1=283957&r2=283958&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Oct 11 19:00:37 2016
@@ -57,6 +57,7 @@ class Configuration(object):
         self.lit_config = lit_config
         self.config = config
         self.cxx = None
+        self.cxx_stdlib_under_test = None
         self.project_obj_root = None
         self.libcxx_src_root = None
         self.libcxx_obj_root = None
@@ -96,6 +97,7 @@ class Configuration(object):
         self.configure_triple()
         self.configure_src_root()
         self.configure_obj_root()
+        self.configure_cxx_stdlib_under_test()
         self.configure_cxx_library_root()
         self.configure_use_system_cxx_lib()
         self.configure_use_clang_verify()
@@ -215,6 +217,15 @@ class Configuration(object):
             self.lit_config.note(
                 "inferred use_system_cxx_lib as: %r" % self.use_system_cxx_lib)
 
+    def configure_cxx_stdlib_under_test(self):
+        self.cxx_stdlib_under_test = self.get_lit_conf(
+            'cxx_stdlib_under_test', 'libc++')
+        if self.cxx_stdlib_under_test not in \
+                ['libc++', 'libstdc++', 'cxx_default']:
+            self.lit_config.fatal(
+                'unsupported value for "cxx_stdlib_under_test": %s'
+                % self.cxx_stdlib_under_test)
+
     def configure_use_clang_verify(self):
         '''If set, run clang with -verify on failing tests.'''
         self.use_clang_verify = self.get_lit_bool('use_clang_verify')
@@ -329,7 +340,6 @@ class Configuration(object):
         self.cxx.compile_flags += ['-std={0}'.format(std)]
         self.config.available_features.add(std)
         # Configure include paths
-        self.cxx.compile_flags += ['-nostdinc++']
         self.configure_compile_flags_header_includes()
         self.target_info.add_cxx_compile_flags(self.cxx.compile_flags)
         # Configure feature flags.
@@ -352,14 +362,22 @@ 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 += ['-include', os.path.join(support_path, 'nasty_macros.hpp')]
+        if self.cxx_stdlib_under_test != 'libstdc++':
+            self.cxx.compile_flags += [
+                '-include', os.path.join(support_path, 'nasty_macros.hpp')]
         self.configure_config_site_header()
-        libcxx_headers = self.get_lit_conf(
-            'libcxx_headers', os.path.join(self.libcxx_src_root, 'include'))
-        if not os.path.isdir(libcxx_headers):
-            self.lit_config.fatal("libcxx_headers='%s' is not a directory."
-                                  % libcxx_headers)
-        self.cxx.compile_flags += ['-I' + libcxx_headers]
+        cxx_headers = self.get_lit_conf('cxx_headers')
+        if cxx_headers == '' or (cxx_headers is None
+                                 and self.cxx_stdlib_under_test != 'libc++'):
+            self.lit_config.note('using the system cxx headers')
+            return
+        self.cxx.compile_flags += ['-nostdinc++']
+        if cxx_headers is None:
+            cxx_headers = os.path.join(self.libcxx_src_root, 'include')
+        if not os.path.isdir(cxx_headers):
+            self.lit_config.fatal("cxx_headers='%s' is not a directory."
+                                  % cxx_headers)
+        self.cxx.compile_flags += ['-I' + cxx_headers]
 
     def configure_config_site_header(self):
         # Check for a possible __config_site in the build directory. We
@@ -468,16 +486,29 @@ class Configuration(object):
     def configure_link_flags(self):
         no_default_flags = self.get_lit_bool('no_default_flags', False)
         if not no_default_flags:
-            self.cxx.link_flags += ['-nodefaultlibs']
-
             # Configure library path
             self.configure_link_flags_cxx_library_path()
             self.configure_link_flags_abi_library_path()
 
             # Configure libraries
-            self.configure_link_flags_cxx_library()
-            self.configure_link_flags_abi_library()
-            self.configure_extra_library_flags()
+            if self.cxx_stdlib_under_test == 'libc++':
+                self.cxx.link_flags += ['-nodefaultlibs']
+                self.configure_link_flags_cxx_library()
+                self.configure_link_flags_abi_library()
+                self.configure_extra_library_flags()
+            elif self.cxx_stdlib_under_test == 'libstdc++':
+                enable_fs = self.get_lit_bool('enable_filesystem',
+                                              default=False)
+                if enable_fs:
+                    self.config.available_features.add('c++experimental')
+                    self.cxx.link_flags += ['-lstdc++fs']
+                self.cxx.link_flags += ['-lm', '-pthread']
+            elif self.cxx_stdlib_under_test == 'cxx_default':
+                self.cxx.link_flags += ['-pthread']
+            else:
+                self.lit_config.fatal(
+                    'unsupported value for "use_stdlib_type": %s'
+                    %  use_stdlib_type)
 
         link_flags_str = self.get_lit_conf('link_flags', '')
         self.cxx.link_flags += shlex.split(link_flags_str)

Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=283958&r1=283957&r2=283958&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Tue Oct 11 19:00:37 2016
@@ -20,20 +20,24 @@ config.suffixes = ['.pass.cpp', '.fail.c
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
 
+loaded_site_cfg = getattr(config, 'loaded_site_config', False)
+if not loaded_site_cfg:
+    import libcxx.test.config
+    libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config',
+                                      'LIBCXX_SITE_CONFIG')
+
 # Infer the test_exec_root from the libcxx_object root.
 obj_root = getattr(config, 'libcxx_obj_root', None)
 
 # Check that the test exec root is known.
 if obj_root is None:
-    import libcxx.test.config
-    libcxx.test.config.loadSiteConfig(lit_config, config, 'libcxx_site_config',
-                                      'LIBCXX_SITE_CONFIG')
     obj_root = getattr(config, 'libcxx_obj_root', None)
     if obj_root is None:
         import tempfile
         obj_root = tempfile.mkdtemp(prefix='libcxx-testsuite-')
         lit_config.warning('Creating temporary directory for object root: %s' %
                            obj_root)
+        config.libcxx_obj_root = obj_root
 
 config.test_exec_root = os.path.join(obj_root, 'test')
 




More information about the cfe-commits mailing list