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