1# -*- Python -*- 2 3# Configuration file for 'lit' test runner. 4# This file contains common rules for various compiler-rt testsuites. 5# It is mostly copied from lit.cfg.py used by Clang. 6import os 7import platform 8import re 9import subprocess 10import json 11 12import lit.formats 13import lit.util 14 15# Choose between lit's internal shell pipeline runner and a real shell. If 16# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. 17use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") 18if use_lit_shell: 19 # 0 is external, "" is default, and everything else is internal. 20 execute_external = (use_lit_shell == "0") 21else: 22 # Otherwise we default to internal on Windows and external elsewhere, as 23 # bash on Windows is usually very slow. 24 execute_external = (not sys.platform in ['win32']) 25 26# Setup test format. 27config.test_format = lit.formats.ShTest(execute_external) 28if execute_external: 29 config.available_features.add('shell') 30 31compiler_id = getattr(config, 'compiler_id', None) 32if compiler_id == "Clang": 33 if platform.system() != 'Windows': 34 config.cxx_mode_flags = ["--driver-mode=g++"] 35 else: 36 config.cxx_mode_flags = [] 37 # We assume that sanitizers should provide good enough error 38 # reports and stack traces even with minimal debug info. 39 config.debug_info_flags = ["-gline-tables-only"] 40 if platform.system() == 'Windows': 41 # On Windows, use CodeView with column info instead of DWARF. Both VS and 42 # windbg do not behave well when column info is enabled, but users have 43 # requested it because it makes ASan reports more precise. 44 config.debug_info_flags.append("-gcodeview") 45 config.debug_info_flags.append("-gcolumn-info") 46elif compiler_id == 'GNU': 47 config.cxx_mode_flags = ["-x c++"] 48 config.debug_info_flags = ["-g"] 49else: 50 lit_config.fatal("Unsupported compiler id: %r" % compiler_id) 51# Add compiler ID to the list of available features. 52config.available_features.add(compiler_id) 53 54# If needed, add cflag for shadow scale. 55if config.asan_shadow_scale != '': 56 config.target_cflags += " -mllvm -asan-mapping-scale=" + config.asan_shadow_scale 57 58# BFD linker in 64-bit android toolchains fails to find libc++_shared.so, which 59# is a transitive shared library dependency (via asan runtime). 60if config.android: 61 # Prepend the flag so that it can be overridden. 62 config.target_cflags = "-pie -fuse-ld=gold " + config.target_cflags 63 if config.android_ndk_version < 19: 64 # With a new compiler and NDK < r19 this flag ends up meaning "link against 65 # libc++", but NDK r19 makes this mean "link against the stub libstdc++ that 66 # just contains a handful of ABI functions", which makes most C++ code fail 67 # to link. In r19 and later we just use the default which is libc++. 68 config.cxx_mode_flags.append('-stdlib=libstdc++') 69 70# Clear some environment variables that might affect Clang. 71possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS', 72 'MSAN_OPTIONS', 'UBSAN_OPTIONS', 73 'COMPILER_PATH', 'RC_DEBUG_OPTIONS', 74 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH', 75 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH', 76 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH', 77 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING', 78 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX', 79 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS', 80 'LIBCLANG_RESOURCE_USAGE', 81 'LIBCLANG_CODE_COMPLETION_LOGGING', 82 'XRAY_OPTIONS'] 83# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it. 84if platform.system() != 'Windows': 85 possibly_dangerous_env_vars.append('INCLUDE') 86for name in possibly_dangerous_env_vars: 87 if name in config.environment: 88 del config.environment[name] 89 90# Tweak PATH to include llvm tools dir. 91if (not config.llvm_tools_dir) or (not os.path.exists(config.llvm_tools_dir)): 92 lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % config.llvm_tools_dir) 93path = os.path.pathsep.join((config.llvm_tools_dir, config.environment['PATH'])) 94config.environment['PATH'] = path 95 96# Help MSVS link.exe find the standard libraries. 97# Make sure we only try to use it when targetting Windows. 98if platform.system() == 'Windows' and '-win' in config.target_triple: 99 config.environment['LIB'] = os.environ['LIB'] 100 101config.available_features.add(config.host_os.lower()) 102 103if re.match(r'^x86_64.*-linux', config.target_triple): 104 config.available_features.add("x86_64-linux") 105 106if config.have_zlib == "1": 107 config.available_features.add("zlib") 108 109# Use ugly construction to explicitly prohibit "clang", "clang++" etc. 110# in RUN lines. 111config.substitutions.append( 112 (' clang', """\n\n*** Do not use 'clangXXX' in tests, 113 instead define '%clangXXX' substitution in lit config. ***\n\n""") ) 114 115if config.host_os == 'NetBSD': 116 nb_commands_dir = os.path.join(config.compiler_rt_src_root, 117 "test", "sanitizer_common", "netbsd_commands") 118 config.netbsd_noaslr_prefix = ('sh ' + 119 os.path.join(nb_commands_dir, 'run_noaslr.sh')) 120 config.netbsd_nomprotect_prefix = ('sh ' + 121 os.path.join(nb_commands_dir, 122 'run_nomprotect.sh')) 123 config.substitutions.append( ('%run_nomprotect', 124 config.netbsd_nomprotect_prefix) ) 125else: 126 config.substitutions.append( ('%run_nomprotect', '%run') ) 127 128# Allow tests to be executed on a simulator or remotely. 129if config.emulator: 130 config.substitutions.append( ('%run', config.emulator) ) 131 config.substitutions.append( ('%env ', "env ") ) 132 # TODO: Implement `%device_rm` to perform removal of files in the emulator. 133 # For now just make it a no-op. 134 lit_config.warning('%device_rm is not implemented') 135 config.substitutions.append( ('%device_rm', 'echo ') ) 136 config.compile_wrapper = "" 137elif config.host_os == 'Darwin' and config.apple_platform != "osx": 138 # Darwin tests can be targetting macOS, a device or a simulator. All devices 139 # are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly, 140 # all simulators are "iossim". See the table below. 141 # 142 # ========================================================================= 143 # Target | Feature set 144 # ========================================================================= 145 # macOS | darwin 146 # iOS device | darwin, ios 147 # iOS simulator | darwin, ios, iossim 148 # tvOS device | darwin, ios, tvos 149 # tvOS simulator | darwin, ios, iossim, tvos, tvossim 150 # watchOS device | darwin, ios, watchos 151 # watchOS simulator | darwin, ios, iossim, watchos, watchossim 152 # ========================================================================= 153 154 ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios" 155 156 config.available_features.add('ios') 157 device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER" 158 if ios_or_iossim == "iossim": 159 config.available_features.add('iossim') 160 if device_id_env not in os.environ: 161 lit_config.fatal( 162 '{} must be set in the environment when running iossim tests'.format( 163 device_id_env)) 164 if config.apple_platform != "ios" and config.apple_platform != "iossim": 165 config.available_features.add(config.apple_platform) 166 167 ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands") 168 169 run_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_run.py") 170 env_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_env.py") 171 compile_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_compile.py") 172 prepare_script = os.path.join(ios_commands_dir, ios_or_iossim + "_prepare.py") 173 174 if device_id_env in os.environ: 175 config.environment[device_id_env] = os.environ[device_id_env] 176 config.substitutions.append(('%run', run_wrapper)) 177 config.substitutions.append(('%env ', env_wrapper + " ")) 178 # Current implementation of %device_rm uses the run_wrapper to do 179 # the work. 180 config.substitutions.append(('%device_rm', '{} rm '.format(run_wrapper))) 181 config.compile_wrapper = compile_wrapper 182 183 try: 184 prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).decode().strip() 185 except subprocess.CalledProcessError as e: 186 print("Command failed:") 187 print(e.output) 188 raise e 189 if len(prepare_output) > 0: print(prepare_output) 190 prepare_output_json = prepare_output.split("\n")[-1] 191 prepare_output = json.loads(prepare_output_json) 192 config.environment.update(prepare_output["env"]) 193elif config.android: 194 config.available_features.add('android') 195 compile_wrapper = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "android_commands", "android_compile.py") + " " 196 config.compile_wrapper = compile_wrapper 197 config.substitutions.append( ('%run', "") ) 198 config.substitutions.append( ('%env ', "env ") ) 199 # TODO: Implement `%device_rm` to perform removal of files on a device. For 200 # now just make it a no-op. 201 lit_config.warning('%device_rm is not implemented') 202 config.substitutions.append( ('%device_rm', 'echo ') ) 203else: 204 config.substitutions.append( ('%run', "") ) 205 config.substitutions.append( ('%env ', "env ") ) 206 # When running locally %device_rm is a no-op. 207 config.substitutions.append( ('%device_rm', 'echo ') ) 208 config.compile_wrapper = "" 209 210# Define CHECK-%os to check for OS-dependent output. 211config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os))) 212 213# Define %arch to check for architecture-dependent output. 214config.substitutions.append( ('%arch', (config.host_arch))) 215 216if config.host_os == 'Windows': 217 # FIXME: This isn't quite right. Specifically, it will succeed if the program 218 # does not crash but exits with a non-zero exit code. We ought to merge 219 # KillTheDoctor and not --crash to make the latter more useful and remove the 220 # need for this substitution. 221 config.expect_crash = "not KillTheDoctor " 222else: 223 config.expect_crash = "not --crash " 224 225config.substitutions.append( ("%expect_crash ", config.expect_crash) ) 226 227target_arch = getattr(config, 'target_arch', None) 228if target_arch: 229 config.available_features.add(target_arch + '-target-arch') 230 if target_arch in ['x86_64', 'i386']: 231 config.available_features.add('x86-target-arch') 232 config.available_features.add(target_arch + '-' + config.host_os.lower()) 233 234compiler_rt_debug = getattr(config, 'compiler_rt_debug', False) 235if not compiler_rt_debug: 236 config.available_features.add('compiler-rt-optimized') 237 238libdispatch = getattr(config, 'compiler_rt_intercept_libdispatch', False) 239if libdispatch: 240 config.available_features.add('libdispatch') 241 242sanitizer_can_use_cxxabi = getattr(config, 'sanitizer_can_use_cxxabi', True) 243if sanitizer_can_use_cxxabi: 244 config.available_features.add('cxxabi') 245 246if config.has_lld: 247 config.available_features.add('lld-available') 248 249if config.use_lld: 250 config.available_features.add('lld') 251 252if config.can_symbolize: 253 config.available_features.add('can-symbolize') 254 255if config.gwp_asan: 256 config.available_features.add('gwp_asan') 257 258lit.util.usePlatformSdkOnDarwin(config, lit_config) 259 260# Maps a lit substitution name for the minimum target OS flag 261# to the macOS version that first contained the relevant feature. 262darwin_min_deployment_target_substitutions = { 263 '%macos_min_target_10_11': '10.11', 264 # rdar://problem/22207160 265 '%darwin_min_target_with_full_runtime_arc_support': '10.11', 266 '%darwin_min_target_with_tls_support': '10.12', 267} 268 269if config.host_os == 'Darwin': 270 def get_apple_platform_version_aligned_with(macos_version, apple_platform): 271 """ 272 Given a macOS version (`macos_version`) returns the corresponding version for 273 the specified Apple platform if it exists. 274 275 `macos_version` - The macOS version as a string. 276 `apple_platform` - The Apple platform name as a string. 277 278 Returns the corresponding version as a string if it exists, otherwise 279 `None` is returned. 280 """ 281 m = re.match(r'^10\.(?P<min>\d+)(\.(?P<patch>\d+))?$', macos_version) 282 if not m: 283 raise Exception('Could not parse macOS version: "{}"'.format(macos_version)) 284 ver_min = int(m.group('min')) 285 ver_patch = m.group('patch') 286 if ver_patch: 287 ver_patch = int(ver_patch) 288 else: 289 ver_patch = 0 290 result_str = '' 291 if apple_platform == 'osx': 292 # Drop patch for now. 293 result_str = '10.{}'.format(ver_min) 294 elif apple_platform.startswith('ios') or apple_platform.startswith('tvos'): 295 result_maj = ver_min - 2 296 if result_maj < 1: 297 return None 298 result_str = '{}.{}'.format(result_maj, ver_patch) 299 elif apple_platform.startswith('watch'): 300 result_maj = ver_min - 9 301 if result_maj < 1: 302 return None 303 result_str = '{}.{}'.format(result_maj, ver_patch) 304 else: 305 raise Exception('Unsuported apple platform "{}"'.format(apple_platform)) 306 return result_str 307 308 osx_version = (10, 0, 0) 309 try: 310 osx_version = subprocess.check_output(["sw_vers", "-productVersion"], 311 universal_newlines=True) 312 osx_version = tuple(int(x) for x in osx_version.split('.')) 313 if len(osx_version) == 2: osx_version = (osx_version[0], osx_version[1], 0) 314 if osx_version >= (10, 11): 315 config.available_features.add('osx-autointerception') 316 config.available_features.add('osx-ld64-live_support') 317 else: 318 # The ASAN initialization-bug.cpp test should XFAIL on OS X systems 319 # older than El Capitan. By marking the test as being unsupported with 320 # this "feature", we can pass the test on newer OS X versions and other 321 # platforms. 322 config.available_features.add('osx-no-ld64-live_support') 323 except subprocess.CalledProcessError: 324 pass 325 326 config.darwin_osx_version = osx_version 327 328 # Detect x86_64h 329 try: 330 output = subprocess.check_output(["sysctl", "hw.cpusubtype"]) 331 output_re = re.match("^hw.cpusubtype: ([0-9]+)$", output) 332 if output_re: 333 cpu_subtype = int(output_re.group(1)) 334 if cpu_subtype == 8: # x86_64h 335 config.available_features.add('x86_64h') 336 except: 337 pass 338 339 def get_apple_min_deploy_target_flag_aligned_with_osx(version): 340 min_os_aligned_with_osx_v = get_apple_platform_version_aligned_with(version, config.apple_platform) 341 min_os_aligned_with_osx_v_flag = '' 342 if min_os_aligned_with_osx_v: 343 min_os_aligned_with_osx_v_flag = '{flag}={version}'.format( 344 flag=config.apple_platform_min_deployment_target_flag, 345 version=min_os_aligned_with_osx_v) 346 else: 347 lit_config.warning('Could not find a version of {} that corresponds with macOS {}'.format( 348 config.apple_platform, 349 version)) 350 return min_os_aligned_with_osx_v_flag 351 352 for substitution, osx_version in darwin_min_deployment_target_substitutions.items(): 353 config.substitutions.append( (substitution, get_apple_min_deploy_target_flag_aligned_with_osx(osx_version)) ) 354 355 # 32-bit iOS simulator is deprecated and removed in latest Xcode. 356 if config.apple_platform == "iossim": 357 if config.target_arch == "i386": 358 config.unsupported = True 359else: 360 for substitution in darwin_min_deployment_target_substitutions.keys(): 361 config.substitutions.append( (substitution, "") ) 362 363if config.android: 364 env = os.environ.copy() 365 if config.android_serial: 366 env['ANDROID_SERIAL'] = config.android_serial 367 config.environment['ANDROID_SERIAL'] = config.android_serial 368 369 adb = os.environ.get('ADB', 'adb') 370 try: 371 android_api_level_str = subprocess.check_output([adb, "shell", "getprop", "ro.build.version.sdk"], env=env).rstrip() 372 except (subprocess.CalledProcessError, OSError): 373 lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb)" % adb) 374 try: 375 android_api_level = int(android_api_level_str) 376 except ValueError: 377 lit_config.fatal("Failed to read ro.build.version.sdk (using '%s' as adb): got '%s'" % (adb, android_api_level_str)) 378 if android_api_level >= 26: 379 config.available_features.add('android-26') 380 if android_api_level >= 28: 381 config.available_features.add('android-28') 382 383 # Prepare the device. 384 android_tmpdir = '/data/local/tmp/Output' 385 subprocess.check_call([adb, "shell", "mkdir", "-p", android_tmpdir], env=env) 386 for file in config.android_files_to_push: 387 subprocess.check_call([adb, "push", file, android_tmpdir], env=env) 388 389if config.host_os == 'Linux': 390 # detect whether we are using glibc, and which version 391 # NB: 'ldd' is just one of the tools commonly installed as part of glibc 392 ldd_ver_cmd = subprocess.Popen(['ldd', '--version'], 393 stdout=subprocess.PIPE, 394 env={'LANG': 'C'}) 395 sout, _ = ldd_ver_cmd.communicate() 396 ver_line = sout.splitlines()[0] 397 if ver_line.startswith(b"ldd "): 398 from distutils.version import LooseVersion 399 ver = LooseVersion(ver_line.split()[-1].decode()) 400 # 2.27 introduced some incompatibilities 401 if ver >= LooseVersion("2.27"): 402 config.available_features.add("glibc-2.27") 403 404sancovcc_path = os.path.join(config.llvm_tools_dir, "sancov") 405if os.path.exists(sancovcc_path): 406 config.available_features.add("has_sancovcc") 407 config.substitutions.append( ("%sancovcc ", sancovcc_path) ) 408 409def is_darwin_lto_supported(): 410 return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) 411 412def is_linux_lto_supported(): 413 if config.use_lld: 414 return True 415 416 if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): 417 return False 418 419 ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE, env={'LANG': 'C'}) 420 ld_out = ld_cmd.stdout.read().decode() 421 ld_cmd.wait() 422 423 if not '-plugin' in ld_out: 424 return False 425 426 return True 427 428def is_windows_lto_supported(): 429 return os.path.exists(os.path.join(config.llvm_tools_dir, 'lld-link.exe')) 430 431if config.host_os == 'Darwin' and is_darwin_lto_supported(): 432 config.lto_supported = True 433 config.lto_launch = ["env", "DYLD_LIBRARY_PATH=" + config.llvm_shlib_dir] 434 config.lto_flags = [] 435elif config.host_os in ['Linux', 'FreeBSD', 'NetBSD'] and is_linux_lto_supported(): 436 config.lto_supported = True 437 config.lto_launch = [] 438 if config.use_lld: 439 config.lto_flags = ["-fuse-ld=lld"] 440 else: 441 config.lto_flags = ["-fuse-ld=gold"] 442elif config.host_os == 'Windows' and is_windows_lto_supported(): 443 config.lto_supported = True 444 config.lto_launch = [] 445 config.lto_flags = ["-fuse-ld=lld"] 446else: 447 config.lto_supported = False 448 449if config.lto_supported: 450 config.available_features.add('lto') 451 if config.use_thinlto: 452 config.available_features.add('thinlto') 453 config.lto_flags += ["-flto=thin"] 454 else: 455 config.lto_flags += ["-flto"] 456 if config.use_newpm: 457 config.lto_flags += ["-fexperimental-new-pass-manager"] 458 459if config.have_rpc_xdr_h: 460 config.available_features.add('sunrpc') 461 462# Ask llvm-config about assertion mode. 463try: 464 llvm_config_cmd = subprocess.Popen( 465 [os.path.join(config.llvm_tools_dir, 'llvm-config'), '--assertion-mode'], 466 stdout = subprocess.PIPE, 467 env=config.environment) 468except OSError as e: 469 print("Could not launch llvm-config in " + config.llvm_tools_dir) 470 print(" Failed with error #{0}: {1}".format(e.errno, e.strerror)) 471 exit(42) 472 473if re.search(r'ON', llvm_config_cmd.stdout.read().decode('ascii')): 474 config.available_features.add('asserts') 475llvm_config_cmd.wait() 476 477# Sanitizer tests tend to be flaky on Windows due to PR24554, so add some 478# retries. We don't do this on otther platforms because it's slower. 479if platform.system() == 'Windows': 480 config.test_retry_attempts = 2 481 482# No throttling on non-Darwin platforms. 483lit_config.parallelism_groups['shadow-memory'] = None 484 485if platform.system() == 'Darwin': 486 ios_device = config.apple_platform != 'osx' and not config.apple_platform.endswith('sim') 487 # Force sequential execution when running tests on iOS devices. 488 if ios_device: 489 lit_config.warning('Forcing sequential execution for iOS device tests') 490 lit_config.parallelism_groups['ios-device'] = 1 491 config.parallelism_group = 'ios-device' 492 493 # Only run up to 3 processes that require shadow memory simultaneously on 494 # 64-bit Darwin. Using more scales badly and hogs the system due to 495 # inefficient handling of large mmap'd regions (terabytes) by the kernel. 496 elif config.target_arch in ['x86_64', 'x86_64h']: 497 lit_config.warning('Throttling sanitizer tests that require shadow memory on Darwin 64bit') 498 lit_config.parallelism_groups['shadow-memory'] = 3 499 500# Multiple substitutions are necessary to support multiple shared objects used 501# at once. 502# Note that substitutions with numbers have to be defined first to avoid 503# being subsumed by substitutions with smaller postfix. 504for postfix in ["2", "1", ""]: 505 if config.host_os == 'Darwin': 506 config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, '-Wl,-rpath,@executable_path/ %dynamiclib' + postfix) ) 507 config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '-install_name @rpath/`basename %dynamiclib{}`'.format(postfix)) ) 508 elif config.host_os in ('FreeBSD', 'NetBSD', 'OpenBSD'): 509 config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-z,origin -Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) 510 config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) 511 elif config.host_os == 'Linux': 512 config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-rpath,\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) 513 config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) 514 elif config.host_os == 'SunOS': 515 config.substitutions.append( ("%ld_flags_rpath_exe" + postfix, "-Wl,-R\$ORIGIN -L%T -l%xdynamiclib_namespec" + postfix) ) 516 config.substitutions.append( ("%ld_flags_rpath_so" + postfix, '') ) 517 518 # Must be defined after the substitutions that use %dynamiclib. 519 config.substitutions.append( ("%dynamiclib" + postfix, '%T/%xdynamiclib_filename' + postfix) ) 520 config.substitutions.append( ("%xdynamiclib_filename" + postfix, 'lib%xdynamiclib_namespec{}.so'.format(postfix)) ) 521 config.substitutions.append( ("%xdynamiclib_namespec", '%basename_t.dynamic') ) 522 523# Provide a substituion that can be used to tell Clang to use a static libstdc++. 524# The substitution expands to nothing on non Linux platforms. 525# FIXME: This should check the target OS, not the host OS. 526if config.host_os == 'Linux': 527 config.substitutions.append( ("%linux_static_libstdcplusplus", "-stdlib=libstdc++ -static-libstdc++") ) 528else: 529 config.substitutions.append( ("%linux_static_libstdcplusplus", "") ) 530 531config.default_sanitizer_opts = [] 532if config.host_os == 'Darwin': 533 # On Darwin, we default to `abort_on_error=1`, which would make tests run 534 # much slower. Let's override this and run lit tests with 'abort_on_error=0'. 535 config.default_sanitizer_opts += ['abort_on_error=0'] 536 config.default_sanitizer_opts += ['log_to_syslog=0'] 537 if lit.util.which('log'): 538 # Querying the log can only done by a privileged user so 539 # so check if we can query the log. 540 exit_code = -1 541 with open('/dev/null', 'r') as f: 542 # Run a `log show` command the should finish fairly quickly and produce very little output. 543 exit_code = subprocess.call(['log', 'show', '--last', '1m', '--predicate', '1 == 0'], stdout=f, stderr=f) 544 if exit_code == 0: 545 config.available_features.add('darwin_log_cmd') 546 else: 547 lit_config.warning('log command found but cannot queried') 548 else: 549 lit_config.warning('log command not found. Some tests will be skipped.') 550elif config.android: 551 config.default_sanitizer_opts += ['abort_on_error=0'] 552 553# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL 554# because the test hangs or fails on one configuration and not the other. 555if config.android or (config.target_arch not in ['arm', 'armhf', 'aarch64']): 556 config.available_features.add('stable-runtime') 557 558if config.asan_shadow_scale: 559 config.available_features.add("shadow-scale-%s" % config.asan_shadow_scale) 560else: 561 config.available_features.add("shadow-scale-3") 562 563if config.expensive_checks: 564 config.available_features.add("expensive_checks") 565 566# Propagate the LLD/LTO into the clang config option, so nothing else is needed. 567run_wrapper = [] 568target_cflags = [getattr(config, 'target_cflags', None)] 569extra_cflags = [] 570 571if config.use_lto and config.lto_supported: 572 run_wrapper += config.lto_launch 573 extra_cflags += config.lto_flags 574elif config.use_lto and (not config.lto_supported): 575 config.unsupported = True 576 577if config.use_lld and config.has_lld and not config.use_lto: 578 extra_cflags += ["-fuse-ld=lld"] 579elif config.use_lld and (not config.has_lld): 580 config.unsupported = True 581 582config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " " 583config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " " 584