summaryrefslogtreecommitdiff
path: root/test/xray/lit.cfg
blob: 0dc2108ba1870583165a5d04f5d4783c5c4a408e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- Python -*-

import os

# Setup config name.
config.name = 'XRay' + config.name_suffix

# Setup source root.
config.test_source_root = os.path.dirname(__file__)

# Setup default compiler flags use with -fxray-instrument option.
clang_xray_cflags = (['-fxray-instrument', config.target_cflags])
clang_xray_cxxflags = config.cxx_mode_flags + clang_xray_cflags


def build_invocation(compile_flags):
  return ' ' + ' '.join([config.clang] + compile_flags) + ' '

# Assume that llvm-xray is in the config.llvm_tools_dir.
llvm_xray = os.path.join(config.llvm_tools_dir, 'llvm-xray')

# Setup substitutions.
if config.host_os == "Linux":
  libdl_flag = "-ldl"
else:
  libdl_flag = ""

config.substitutions.append(
    ('%clang ', build_invocation([config.target_cflags])))
config.substitutions.append(
    ('%clangxx ',
     build_invocation(config.cxx_mode_flags + [config.target_cflags])))
config.substitutions.append(
    ('%clang_xray ', build_invocation(clang_xray_cflags)))
config.substitutions.append(
    ('%clangxx_xray', build_invocation(clang_xray_cxxflags)))
config.substitutions.append(
    ('%llvm_xray', llvm_xray))
config.substitutions.append(
    ('%xraylib',
        ('-lm -lpthread %s -lrt -L%s '
         '-Wl,-whole-archive -lclang_rt.xray%s -Wl,-no-whole-archive')
        % (libdl_flag, config.compiler_rt_libdir, config.target_suffix)))

# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']

if config.host_os not in ['FreeBSD', 'Linux', 'NetBSD', 'OpenBSD']:
  config.unsupported = True
elif '64' not in config.host_arch:
  if 'arm' in config.host_arch:
    if '-mthumb' in config.target_cflags:
      config.unsupported = True
  else:
    config.unsupported = True