6 config.name = 'Profile'
9 config.test_source_root = os.path.dirname(__file__)
11 # Setup executable root.
12 if hasattr(config, 'profile_lit_binary_dir') and \
13 config.profile_lit_binary_dir is not None:
14 config.test_exec_root = config.profile_lit_binary_dir
16 # If the above check didn't work, we're probably in the source tree. Use some
17 # magic to re-execute from the build tree.
18 if config.test_exec_root is None:
19 # The magic relies on knowing compilerrt_site_basedir.
20 compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None)
21 if compilerrt_basedir:
22 site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg')
23 if os.path.exists(site_cfg):
24 lit_config.load_config(config, site_cfg)
28 config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
31 config.excludes = ['Inputs']
34 clang_cflags = [config.target_cflags]
36 def build_invocation(compile_flags):
37 return " " + " ".join([config.clang] + compile_flags) + " "
39 # Add clang substitutions.
40 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
41 config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
42 config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
44 # Profile tests are currently supported on Linux and Darwin only.
45 if config.host_os not in ['Linux', 'Darwin']:
46 config.unsupported = True