| 1 | # -*- Python -*- |
| 2 | |
| 3 | from lit import Test |
| 4 | import lit.formats |
| 5 | import lit.util |
| 6 | import subprocess |
| 7 | |
| 8 | def getSysrootFlagsOnDarwin(config, lit_config): |
| 9 | # On Darwin, support relocatable SDKs by providing Clang with a |
| 10 | # default system root path. |
| 11 | if 'darwin' in config.target_triple: |
| 12 | try: |
| 13 | out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip() |
| 14 | res = 0 |
| 15 | except OSError: |
| 16 | res = -1 |
| 17 | if res == 0 and out: |
| 18 | sdk_path = out |
| 19 | lit_config.note('using SDKROOT: %r' % sdk_path) |
| 20 | return '-isysroot %s' % sdk_path |
| 21 | return '' |
| 22 | |
| 23 | sysroot_flags = getSysrootFlagsOnDarwin(config, lit_config) |
| 24 | |
| 25 | config.clang = lit.util.which('clang', config.clang_tools_dir).replace('\\', '/') |
| 26 | |
| 27 | config.name = 'Clang Perf Training' |
| 28 | config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap'] |
| 29 | |
| 30 | cc1_wrapper = '%s %s/perf-helper.py cc1' % (config.python_exe, config.test_source_root) |
| 31 | |
| 32 | use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") |
| 33 | config.test_format = lit.formats.ShTest(use_lit_shell == "0") |
| 34 | config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags))) |
| 35 | config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % (config.clang, sysroot_flags))) |
| 36 | config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags))) |
| 37 | config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) ) |
| 38 | config.substitutions.append( ('%test_root', config.test_exec_root ) ) |
| 39 | |
| 40 | config.environment['LLVM_PROFILE_FILE'] = 'perf-training-%p.profraw' |
| 41 | |
| 42 | |