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