[libcxx] r174997 - [tests] Add support for a link_flags lit parameter.

Daniel Dunbar daniel at zuster.org
Tue Feb 12 11:28:51 PST 2013


Author: ddunbar
Date: Tue Feb 12 13:28:51 2013
New Revision: 174997

URL: http://llvm.org/viewvc/llvm-project?rev=174997&view=rev
Log:
[tests] Add support for a link_flags lit parameter.
 - This is useful for testing with custom ABI libraries.
 - Patch by Michael van der Westhuizen.

Modified:
    libcxx/trunk/test/lit.cfg

Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=174997&r1=174996&r2=174997&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Tue Feb 12 13:28:51 2013
@@ -1,4 +1,4 @@
-# -*- Python -*-
+# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
 
 # Configuration file for the 'lit' test runner.
 
@@ -10,6 +10,7 @@ import signal
 import subprocess
 import errno
 import time
+import shlex
 
 # FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a
 # dependency there. What we more ideally would like to do is lift the "xfail"
@@ -96,8 +97,8 @@ class LibcxxTestFormat(lit.formats.FileB
         #
         # FIXME: For now, this is cribbed from lit.TestRunner, to avoid
         # introducing a dependency there. What we more ideally would like to do
-        # is lift the "xfail" and "requires" handling to be a core lit framework
-        # feature.
+        # is lift the "xfail" and "requires" handling to be a core lit
+        # framework feature.
         missing_required_features = [f for f in requires
                                      if f not in test.config.available_features]
         if missing_required_features:
@@ -178,10 +179,10 @@ class LibcxxTestFormat(lit.formats.FileB
                     cmd = lit_config.valgrindArgs + cmd
                 out, err, exitCode = self.execute_command(cmd, source_dir)
                 if exitCode != 0:
-                    report = """Compiled With: %s\n""" % ' '.join(["'%s'" % a
-                                                                   for a in compile_cmd])
-                    report += """Command: %s\n""" % ' '.join(["'%s'" % a
-                                                             for a in cmd])
+                    report = """Compiled With: %s\n""" % \
+                        ' '.join(["'%s'" % a for a in compile_cmd])
+                    report += """Command: %s\n""" % \
+                        ' '.join(["'%s'" % a for a in cmd])
                     report += """Exit Code: %d\n""" % exitCode
                     if out:
                         report += """Standard Output:\n--\n%s--""" % out
@@ -258,32 +259,47 @@ else:
     use_system_lib = False
     lit.note("inferred use_system_lib as: %r" % (use_system_lib,))
 
+link_flags = []
+link_flags_str = lit.params.get('link_flags', None)
+if link_flags_str is None:
+    link_flags_str = getattr(config, 'link_flags', None)
+    if link_flags_str is None:
+        if sys.platform == 'darwin':
+            link_flags += ['-lSystem']
+        elif sys.platform == 'linux2':
+            link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread',
+                '-lrt', '-lgcc_s']
+        else:
+            lit.fatal("unrecognized system")
+        lit.note("inferred link_flags as: %r" % (link_flags,))
+if not link_flags_str is None:
+    link_flags += shlex.split(link_flags_str)
+
 # Configure extra compiler flags.
-include_paths = ['-I' + libcxx_src_root + '/include', '-I' + libcxx_src_root + '/test/support']
+include_paths = ['-I' + libcxx_src_root + '/include',
+    '-I' + libcxx_src_root + '/test/support']
 library_paths = ['-L' + libcxx_obj_root + '/lib']
 compile_flags = []
 if cxx_has_stdcxx0x_flag:
     compile_flags += ['-std=c++0x']
 
-# Configure extra libraries.
+# Configure extra linker parameters.
 exec_env = {}
-libraries = []
 if sys.platform == 'darwin':
-    libraries += ['-lSystem']
     if not use_system_lib:
         exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib')
 elif sys.platform == 'linux2':
-    libraries += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s']
     if not use_system_lib:
-        libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
-    compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS']
+        link_flags += ['-Wl,-R', libcxx_obj_root + '/lib']
+    compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
+        '-D__STDC_CONSTANT_MACROS']
 else:
     lit.fatal("unrecognized system")
 
 config.test_format = LibcxxTestFormat(
     cxx_under_test,
     cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
-    ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries,
+    ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + link_flags,
     exec_env = exec_env)
 
 # Get or infer the target triple.





More information about the cfe-commits mailing list