10084fce4Sjoerg# -*- Python -*- 20084fce4Sjoerg 30084fce4Sjoergimport os 40084fce4Sjoerg 50084fce4Sjoerg# Setup config name. 60084fce4Sjoergconfig.name = 'Profile' 70084fce4Sjoerg 80084fce4Sjoerg# Setup source root. 90084fce4Sjoergconfig.test_source_root = os.path.dirname(__file__) 100084fce4Sjoerg 110084fce4Sjoerg# Setup executable root. 120084fce4Sjoergif hasattr(config, 'profile_lit_binary_dir') and \ 130084fce4Sjoerg config.profile_lit_binary_dir is not None: 140084fce4Sjoerg config.test_exec_root = config.profile_lit_binary_dir 150084fce4Sjoerg 160084fce4Sjoerg# If the above check didn't work, we're probably in the source tree. Use some 170084fce4Sjoerg# magic to re-execute from the build tree. 180084fce4Sjoergif config.test_exec_root is None: 190084fce4Sjoerg # The magic relies on knowing compilerrt_site_basedir. 200084fce4Sjoerg compilerrt_basedir = lit_config.params.get('compilerrt_site_basedir', None) 210084fce4Sjoerg if compilerrt_basedir: 220084fce4Sjoerg site_cfg = os.path.join(compilerrt_basedir, 'profile', 'lit.site.cfg') 230084fce4Sjoerg if os.path.exists(site_cfg): 240084fce4Sjoerg lit_config.load_config(config, site_cfg) 250084fce4Sjoerg raise SystemExit 260084fce4Sjoerg 27*40cf9698Sjoergif config.host_os in ['Linux']: 28*40cf9698Sjoerg extra_linkflags = ["-ldl"] 29*40cf9698Sjoergelse: 30*40cf9698Sjoerg extra_linkflags = [] 31*40cf9698Sjoerg 320084fce4Sjoerg# Test suffixes. 330084fce4Sjoergconfig.suffixes = ['.c', '.cc', '.cpp', '.m', '.mm', '.ll', '.test'] 340084fce4Sjoerg 35c91bae03Sjoerg# What to exclude. 36c91bae03Sjoergconfig.excludes = ['Inputs'] 37c91bae03Sjoerg 380084fce4Sjoerg# Clang flags. 39*40cf9698Sjoergclang_cflags = [config.target_cflags] + extra_linkflags 400084fce4Sjoerg 410084fce4Sjoergdef build_invocation(compile_flags): 420084fce4Sjoerg return " " + " ".join([config.clang] + compile_flags) + " " 430084fce4Sjoerg 440084fce4Sjoerg# Add clang substitutions. 4561e3637bSjoergconfig.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) 460084fce4Sjoergconfig.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") ) 470084fce4Sjoergconfig.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") ) 48*40cf9698Sjoergconfig.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") ) 49*40cf9698Sjoergconfig.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") ) 500084fce4Sjoerg 51*40cf9698Sjoergif config.host_os not in ['Darwin', 'FreeBSD', 'Linux']: 52*40cf9698Sjoerg config.unsupported = True 53*40cf9698Sjoerg 54*40cf9698Sjoergif config.target_arch in ['armv7l']: 550084fce4Sjoerg config.unsupported = True 56