Home | History | Annotate | Line # | Download | only in profile
      1      1.1  joerg # -*- Python -*-
      2      1.1  joerg 
      3      1.1  joerg import os
      4      1.1  joerg 
      5      1.1  joerg # Setup config name.
      6      1.1  joerg config.name = 'Profile'
      7      1.1  joerg 
      8      1.1  joerg # Setup source root.
      9      1.1  joerg config.test_source_root = os.path.dirname(__file__)
     10      1.1  joerg 
     11      1.1  joerg # Setup executable root.
     12      1.1  joerg if hasattr(config, 'profile_lit_binary_dir') and \
     13      1.1  joerg         config.profile_lit_binary_dir is not None:
     14      1.1  joerg     config.test_exec_root = config.profile_lit_binary_dir
     15      1.1  joerg 
     16      1.1  joerg # If the above check didn't work, we're probably in the source tree.  Use some
     17      1.1  joerg # magic to re-execute from the build tree.
     18      1.1  joerg if config.test_exec_root is None:
     19      1.1  joerg     # The magic relies on knowing compilerrt_site_basedir.
     20      1.1  joerg     compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None)
     21      1.1  joerg     if compilerrt_basedir:
     22      1.1  joerg         site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg')
     23      1.1  joerg         if os.path.exists(site_cfg):
     24      1.1  joerg             lit_config.load_config(config, site_cfg)
     25      1.1  joerg             raise SystemExit
     26      1.1  joerg 
     27  1.1.1.4  joerg if config.host_os in ['Linux']:
     28  1.1.1.4  joerg   extra_linkflags = ["-ldl"]
     29  1.1.1.4  joerg else:
     30  1.1.1.4  joerg   extra_linkflags = []
     31  1.1.1.4  joerg 
     32      1.1  joerg # Test suffixes.
     33      1.1  joerg config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
     34      1.1  joerg 
     35  1.1.1.2  joerg # What to exclude.
     36  1.1.1.2  joerg config.excludes = ['Inputs']
     37  1.1.1.2  joerg 
     38      1.1  joerg # Clang flags.
     39  1.1.1.4  joerg clang_cflags = [config.target_cflags] + extra_linkflags
     40      1.1  joerg 
     41      1.1  joerg def build_invocation(compile_flags):
     42      1.1  joerg   return " " + " ".join([config.clang] + compile_flags) + " "
     43      1.1  joerg 
     44      1.1  joerg # Add clang substitutions.
     45  1.1.1.3  joerg config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
     46      1.1  joerg config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
     47      1.1  joerg config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
     48  1.1.1.4  joerg config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") )
     49  1.1.1.4  joerg config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") )
     50  1.1.1.4  joerg 
     51  1.1.1.4  joerg if config.host_os not in ['Darwin', 'FreeBSD', 'Linux']:
     52  1.1.1.4  joerg   config.unsupported = True
     53      1.1  joerg 
     54  1.1.1.4  joerg if config.target_arch in ['armv7l']:
     55      1.1  joerg   config.unsupported = True
     56