xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/test/profile/lit.cfg (revision ef84fd3bd8895f4e6be1e38baf19e6dc3255bc64)
161f2f256Sjoerg# -*- Python -*-
261f2f256Sjoerg
361f2f256Sjoergimport os
461f2f256Sjoerg
561f2f256Sjoerg# Setup config name.
661f2f256Sjoergconfig.name = 'Profile'
761f2f256Sjoerg
861f2f256Sjoerg# Setup source root.
961f2f256Sjoergconfig.test_source_root = os.path.dirname(__file__)
1061f2f256Sjoerg
1161f2f256Sjoerg# Setup executable root.
1261f2f256Sjoergif hasattr(config, 'profile_lit_binary_dir') and \
1361f2f256Sjoerg        config.profile_lit_binary_dir is not None:
1461f2f256Sjoerg    config.test_exec_root = config.profile_lit_binary_dir
1561f2f256Sjoerg
1661f2f256Sjoerg# If the above check didn't work, we're probably in the source tree.  Use some
1761f2f256Sjoerg# magic to re-execute from the build tree.
1861f2f256Sjoergif config.test_exec_root is None:
1961f2f256Sjoerg    # The magic relies on knowing compilerrt_site_basedir.
2061f2f256Sjoerg    compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None)
2161f2f256Sjoerg    if compilerrt_basedir:
2261f2f256Sjoerg        site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg')
2361f2f256Sjoerg        if os.path.exists(site_cfg):
2461f2f256Sjoerg            lit_config.load_config(config, site_cfg)
2561f2f256Sjoerg            raise SystemExit
2661f2f256Sjoerg
27*ef84fd3bSjoergif config.host_os in ['Linux']:
28*ef84fd3bSjoerg  extra_linkflags = ["-ldl"]
29*ef84fd3bSjoergelse:
30*ef84fd3bSjoerg  extra_linkflags = []
31*ef84fd3bSjoerg
3261f2f256Sjoerg# Test suffixes.
3361f2f256Sjoergconfig.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
3461f2f256Sjoerg
3530308f42Sjoerg# What to exclude.
3630308f42Sjoergconfig.excludes = ['Inputs']
3730308f42Sjoerg
3861f2f256Sjoerg# Clang flags.
39*ef84fd3bSjoergclang_cflags = [config.target_cflags] + extra_linkflags
4061f2f256Sjoerg
4161f2f256Sjoergdef build_invocation(compile_flags):
4261f2f256Sjoerg  return " " + " ".join([config.clang] + compile_flags) + " "
4361f2f256Sjoerg
4461f2f256Sjoerg# Add clang substitutions.
45190e92d8Sjoergconfig.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
4661f2f256Sjoergconfig.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
4761f2f256Sjoergconfig.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
48*ef84fd3bSjoergconfig.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") )
49*ef84fd3bSjoergconfig.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") )
5061f2f256Sjoerg
51*ef84fd3bSjoergif config.host_os not in ['Darwin', 'FreeBSD', 'Linux']:
52*ef84fd3bSjoerg  config.unsupported = True
53*ef84fd3bSjoerg
54*ef84fd3bSjoergif config.target_arch in ['armv7l']:
5561f2f256Sjoerg  config.unsupported = True
56