]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/profile/lit.cfg
New upstream version 1.12.0+dfsg1
[rustc.git] / src / compiler-rt / test / profile / lit.cfg
CommitLineData
1a4d82fc
JJ
1# -*- Python -*-
2
3import os
4
5bcae85e
SL
5def get_required_attr(config, attr_name):
6 attr_value = getattr(config, attr_name, None)
7 if attr_value == None:
8 lit_config.fatal(
9 "No attribute %r in test configuration! You may need to run "
10 "tests from your build directory or add this attribute "
11 "to lit.site.cfg " % attr_name)
12 return attr_value
13
1a4d82fc 14# Setup config name.
5bcae85e 15config.name = 'Profile-' + config.target_arch
1a4d82fc
JJ
16
17# Setup source root.
18config.test_source_root = os.path.dirname(__file__)
19
20# Setup executable root.
21if hasattr(config, 'profile_lit_binary_dir') and \
22 config.profile_lit_binary_dir is not None:
5bcae85e 23 config.test_exec_root = os.path.join(config.profile_lit_binary_dir, config.name)
1a4d82fc
JJ
24
25# If the above check didn't work, we're probably in the source tree. Use some
26# magic to re-execute from the build tree.
27if config.test_exec_root is None:
28 # The magic relies on knowing compilerrt_site_basedir.
29 compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None)
30 if compilerrt_basedir:
31 site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg')
32 if os.path.exists(site_cfg):
33 lit_config.load_config(config, site_cfg)
34 raise SystemExit
35
92a42be0
SL
36if config.host_os in ['Linux']:
37 extra_linkflags = ["-ldl"]
38else:
39 extra_linkflags = []
40
1a4d82fc
JJ
41# Test suffixes.
42config.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test']
43
92a42be0
SL
44# What to exclude.
45config.excludes = ['Inputs']
46
1a4d82fc 47# Clang flags.
5bcae85e
SL
48target_cflags=[get_required_attr(config, "target_cflags")]
49clang_cflags = target_cflags + extra_linkflags
50clang_cxxflags = config.cxx_mode_flags + clang_cflags
1a4d82fc
JJ
51
52def build_invocation(compile_flags):
53 return " " + " ".join([config.clang] + compile_flags) + " "
54
55# Add clang substitutions.
92a42be0 56config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
5bcae85e 57config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
1a4d82fc 58config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
5bcae85e 59config.substitutions.append( ("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=") )
1a4d82fc 60config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
5bcae85e
SL
61config.substitutions.append( ("%clangxx_profgen ", build_invocation(clang_cxxflags) + " -fprofile-instr-generate ") )
62config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") )
92a42be0
SL
63config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") )
64config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") )
65
66if config.host_os not in ['Darwin', 'FreeBSD', 'Linux']:
67 config.unsupported = True
1a4d82fc 68
92a42be0 69if config.target_arch in ['armv7l']:
1a4d82fc 70 config.unsupported = True