Hi danalbert, jroelofs,

This patch refactors the structure for configuring all compiler flags to make 
it easier to run the test suite against non-standard configurations. It does so 
using the following LIT options:
1. `--param=no_default_flags`: Disable ALL flags other than those explicitly 
specified with `--param=compile_flags` and `--param=link_flags`.
2. `--param=no_library_flags`: Disable only the flags related to configuring 
the test suite for the just built libc++. This disables adding the include 
paths to the libc++ headers as well as the link flags relating to linking 
libc++ and the abi library.

The rational for these changes is:
1. To fix a bug where `no_default_flags` currently doesn't disable *all* flags.
2. To allow a user to run the test suite without having to manually define a 
bunch of flags that are always required (ex `-Ipath/to/libcxx/test/support`)

An example use case for these changes is running the test-suite against 
libstdc++. Previously you would have to use an invocation that looked something 
like:
```
lit -sv --param=no_default_flags=True 
--param=compile_flags='-I/path/to/libcxx/test/support -std=c++11' path/to/tests
```
Now you can simply use:
lit -sv --param=no_library_flags=True path/to/tests

This patch is useful to me when running the benchmarks against libstdc++.

http://reviews.llvm.org/D8459

Files:
  test/libcxx/test/config.py

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: test/libcxx/test/config.py
===================================================================
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -91,13 +91,8 @@
         self.configure_use_clang_verify()
         self.configure_execute_external()
         self.configure_ccache()
-        self.configure_compile_flags()
-        self.configure_link_flags()
+        self.configure_compiler_flags()
         self.configure_env()
-        self.configure_color_diagnostics()
-        self.configure_debug_mode()
-        self.configure_warnings()
-        self.configure_sanitizer()
         self.configure_substitutions()
         self.configure_features()
 
@@ -323,24 +318,41 @@
         if self.long_tests:
             self.config.available_features.add('long_tests')
 
-    def configure_compile_flags(self):
+    def configure_compiler_flags(self):
         no_default_flags = self.get_lit_bool('no_default_flags', False)
         if not no_default_flags:
-            self.configure_default_compile_flags()
-        # Configure extra flags
+            self.configure_compile_flags()
         compile_flags_str = self.get_lit_conf('compile_flags', '')
         self.cxx.compile_flags += shlex.split(compile_flags_str)
+        if not no_default_flags:
+            self.configure_link_flags()
+        link_flags_str = self.get_lit_conf('link_flags', '')
+        self.cxx.link_flags += shlex.split(link_flags_str)
+        if not no_default_flags:
+            self.configure_color_diagnostics()
+            self.configure_debug_mode()
+            self.configure_warnings()
+            self.configure_sanitizer()
 
-    def configure_default_compile_flags(self):
+    def configure_compile_flags(self):
+        no_library_flags = self.get_lit_bool('no_library_flags', False)
+        if not no_library_flags:
+            self.configure_library_include_paths()
+        self.configure_test_include_paths()
+        if not no_library_flags:
+            self.configure_library_compile_flags()
+        self.configure_test_compile_flags()
+
+    def configure_library_compile_flags(self):
+        pass
+
+    def configure_test_compile_flags(self):
         # Try and get the std version from the command line. Fall back to
         # default given in lit.site.cfg is not present. If default is not
         # present then force c++11.
         std = self.get_lit_conf('std', 'c++11')
         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()
         if self.target_info.platform() == 'linux':
             self.cxx.compile_flags += ['-D__STDC_FORMAT_MACROS',
                                        '-D__STDC_LIMIT_MACROS',
@@ -374,10 +386,8 @@
         if self.use_target:
             self.cxx.flags += ['-target', self.config.target_triple]
 
-    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')]
+    def configure_library_include_paths(self):
+        self.cxx.compile_flags += ['-nostdinc++']
         libcxx_headers = self.get_lit_conf(
             'libcxx_headers', os.path.join(self.libcxx_src_root, 'include'))
         if not os.path.isdir(libcxx_headers):
@@ -385,6 +395,11 @@
                                   % libcxx_headers)
         self.cxx.compile_flags += ['-I' + libcxx_headers]
 
+    def configure_test_include_paths(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')]
+
     def configure_compile_flags_exceptions(self):
         enable_exceptions = self.get_lit_bool('enable_exceptions', True)
         if not enable_exceptions:
@@ -415,8 +430,8 @@
         self.config.available_features.add('libcpp-has-no-monotonic-clock')
 
     def configure_link_flags(self):
-        no_default_flags = self.get_lit_bool('no_default_flags', False)
-        if not no_default_flags:
+        no_library_flags = self.get_lit_bool('no_library_flags', False)
+        if not no_library_flags:
             self.cxx.link_flags += ['-nodefaultlibs']
 
             # Configure library path
@@ -428,8 +443,6 @@
             self.configure_link_flags_abi_library()
             self.configure_extra_library_flags()
 
-        link_flags_str = self.get_lit_conf('link_flags', '')
-        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')
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to