[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / lit.cfg.py
blob8fdb1a216ee262b1646bac0153aaf6fdf12a1cf3
1 # -*- Python -*-
3 import os
4 import platform
6 import lit.formats
8 def get_required_attr(config, attr_name):
9 attr_value = getattr(config, attr_name, None)
10 if attr_value == None:
11 lit_config.fatal(
12 "No attribute %r in test configuration! You may need to run "
13 "tests from your build directory or add this attribute "
14 "to lit.site.cfg.py " % attr_name)
15 return attr_value
17 # Setup config name.
18 config.name = 'Builtins' + config.name_suffix
20 # Platform-specific default Builtins_OPTIONS for lit tests.
21 default_builtins_opts = ''
23 # Setup source root.
24 config.test_source_root = os.path.dirname(__file__)
26 # Path to the static library
27 is_msvc = get_required_attr(config, "is_msvc")
28 if is_msvc:
29 base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins%s.lib "
30 % config.target_suffix)
31 config.substitutions.append( ("%librt ", base_lib) )
32 elif config.host_os == 'Darwin':
33 base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.osx.a ")
34 config.substitutions.append( ("%librt ", base_lib + ' -lSystem ') )
35 else:
36 base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins%s.a"
37 % config.target_suffix)
38 config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') )
40 builtins_source_dir = os.path.join(
41 get_required_attr(config, "compiler_rt_src_root"), "lib", "builtins")
42 builtins_lit_source_dir = get_required_attr(config, "builtins_lit_source_dir")
44 extra_link_flags = ["-nodefaultlibs"]
46 target_cflags = [get_required_attr(config, "target_cflags")]
47 target_cflags += ['-fno-builtin', '-I', builtins_source_dir]
48 target_cflags += extra_link_flags
49 target_cxxflags = config.cxx_mode_flags + target_cflags
50 clang_builtins_static_cflags = ([""] +
51 config.debug_info_flags + target_cflags)
52 clang_builtins_static_cxxflags = config.cxx_mode_flags + \
53 clang_builtins_static_cflags
55 clang_builtins_cflags = clang_builtins_static_cflags
56 clang_builtins_cxxflags = clang_builtins_static_cxxflags
58 # FIXME: Right now we don't compile the C99 complex builtins when using
59 # clang-cl. Fix that.
60 if not is_msvc:
61 config.available_features.add('c99-complex')
63 builtins_is_msvc = get_required_attr(config, "builtins_is_msvc")
64 if not builtins_is_msvc:
65 config.available_features.add('int128')
67 clang_wrapper = ""
69 def build_invocation(compile_flags):
70 return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
73 target_arch = config.target_arch
74 if (target_arch == "arm"):
75 target_arch = "armv7"
77 config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
78 config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
79 config.substitutions.append( ("%clang_builtins ", \
80 build_invocation(clang_builtins_cflags)))
81 config.substitutions.append( ("%clangxx_builtins ", \
82 build_invocation(clang_builtins_cxxflags)))
84 # FIXME: move the call_apsr.s into call_apsr.h as inline-asm.
85 # some ARM tests needs call_apsr.s
86 call_apsr_source = os.path.join(builtins_lit_source_dir, 'arm', 'call_apsr.S')
87 march_flag = '-march=' + target_arch
88 call_apsr_flags = ['-c', march_flag, call_apsr_source]
89 config.substitutions.append( ("%arm_call_apsr ", \
90 build_invocation(call_apsr_flags)) )
92 # Default test suffixes.
93 config.suffixes = ['.c', '.cpp']
95 if not config.emulator:
96 config.available_features.add('native-run')
98 # Add features for available sources
99 builtins_source_features = config.builtins_lit_source_features.split(';')
100 # Sanity checks
101 if not builtins_source_features:
102 lit_config.fatal('builtins_source_features cannot be empty')
103 builtins_source_features_set = set()
104 builtins_source_feature_duplicates = []
105 for builtin_source_feature in builtins_source_features:
106 if len(builtin_source_feature) == 0:
107 lit_config.fatal('builtins_source_feature cannot contain empty features')
108 if builtin_source_feature not in builtins_source_features_set:
109 builtins_source_features_set.add(builtin_source_feature)
110 else:
111 builtins_source_feature_duplicates.append(builtin_source_feature)
113 if len(builtins_source_feature_duplicates) > 0:
114 lit_config.fatal(
115 'builtins_source_features contains duplicates: {}'.format(
116 builtins_source_feature_duplicates)
118 config.available_features.update(builtins_source_features)