Index: test/asan/CMakeLists.txt =================================================================== --- test/asan/CMakeLists.txt +++ test/asan/CMakeLists.txt @@ -51,10 +51,7 @@ set(ASAN_TEST_TARGET_ARCH ${arch}) endif() - set(ASAN_TEST_IOS "0") - pythonize_bool(ASAN_TEST_IOS) - set(ASAN_TEST_IOSSIM "0") - pythonize_bool(ASAN_TEST_IOSSIM) + set(ASAN_TEST_APPLE_PLATFORM "osx") string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX) get_bits_for_arch(${arch} ASAN_TEST_BITS) @@ -93,16 +90,13 @@ set(EXCLUDE_FROM_ALL ON) set(ASAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(ASAN_TEST_IOS "1") - pythonize_bool(ASAN_TEST_IOS) set(ASAN_TEST_DYNAMIC True) foreach(arch ${DARWIN_iossim_ARCHS}) - set(ASAN_TEST_IOSSIM "1") - pythonize_bool(ASAN_TEST_IOSSIM) + set(ASAN_TEST_APPLE_PLATFORM "iossim") set(ASAN_TEST_TARGET_ARCH ${arch}) set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") - set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") + set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}") get_bits_for_arch(${arch} ASAN_TEST_BITS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") @@ -116,11 +110,10 @@ endforeach() foreach (arch ${DARWIN_ios_ARCHS}) - set(ASAN_TEST_IOSSIM "0") - pythonize_bool(ASAN_TEST_IOSSIM) + set(ASAN_TEST_APPLE_PLATFORM "ios") set(ASAN_TEST_TARGET_ARCH ${arch}) set(ASAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") - set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-ios") + set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${ASAN_TEST_APPLE_PLATFORM}") get_bits_for_arch(${arch} ASAN_TEST_BITS) string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") Index: test/asan/lit.cfg =================================================================== --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -214,5 +214,5 @@ if config.host_os == 'Darwin': if config.target_arch in ["x86_64", "x86_64h"]: config.parallelism_group = "darwin-64bit-sanitizer" - elif config.ios and not config.iossim: + elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"): config.parallelism_group = "darwin-ios-device-sanitizer" Index: test/asan/lit.site.cfg.in =================================================================== --- test/asan/lit.site.cfg.in +++ test/asan/lit.site.cfg.in @@ -5,8 +5,7 @@ config.target_cflags = "@ASAN_TEST_TARGET_CFLAGS@" config.clang = "@ASAN_TEST_TARGET_CC@" config.bits = "@ASAN_TEST_BITS@" -config.ios = @ASAN_TEST_IOS_PYBOOL@ -config.iossim = @ASAN_TEST_IOSSIM_PYBOOL@ +config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@" config.asan_dynamic = @ASAN_TEST_DYNAMIC@ config.target_arch = "@ASAN_TEST_TARGET_ARCH@" Index: test/fuzzer/CMakeLists.txt =================================================================== --- test/fuzzer/CMakeLists.txt +++ test/fuzzer/CMakeLists.txt @@ -10,8 +10,6 @@ set(EXCLUDE_FROM_ALL ON) add_custom_target(check-fuzzer) -set(LIBFUZZER_TEST_IOS "0") -pythonize_bool(LIBFUZZER_TEST_IOS) if(COMPILER_RT_INCLUDE_TESTS) # libFuzzer unit tests. @@ -40,6 +38,8 @@ set(LIBFUZZER_TEST_COMPILER ${COMPILER_RT_TEST_COMPILER}) get_test_cc_for_arch(${arch} LIBFUZZER_TEST_COMPILER LIBFUZZER_TEST_FLAGS) + set(LIBFUZZER_TEST_APPLE_PLATFORM "osx") + set(LIBFUZZER_TEST_STDLIB ${stdlib}) string(TOUPPER ${arch} ARCH_UPPER_CASE) @@ -78,11 +78,10 @@ set(EXCLUDE_FROM_ALL ON) foreach(arch ${DARWIN_ios_ARCHS}) - set(LIBFUZZER_TEST_IOS "1") - pythonize_bool(LIBFUZZER_TEST_IOS) + set(LIBFUZZER_TEST_APPLE_PLATFORM "ios") set(LIBFUZZER_TEST_TARGET_ARCH ${arch}) set(LIBFUZZER_TEST_FLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") - set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-ios") + set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${LIBFUZZER_TEST_APPLE_PLATFORM}") string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( Index: test/fuzzer/lit.cfg =================================================================== --- test/fuzzer/lit.cfg +++ test/fuzzer/lit.cfg @@ -96,5 +96,5 @@ if config.host_os == 'Darwin': if config.target_arch in ["x86_64", "x86_64h"]: config.parallelism_group = "darwin-64bit-sanitizer" - elif config.ios and not config.iossim: + elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"): config.parallelism_group = "darwin-ios-device-sanitizer" Index: test/fuzzer/lit.site.cfg.in =================================================================== --- test/fuzzer/lit.site.cfg.in +++ test/fuzzer/lit.site.cfg.in @@ -6,7 +6,7 @@ config.target_flags = "@LIBFUZZER_TEST_FLAGS@" config.c_compiler = "@LIBFUZZER_TEST_COMPILER@" config.stdlib = "@LIBFUZZER_TEST_STDLIB@" -config.ios = @LIBFUZZER_TEST_IOS_PYBOOL@ +config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@" config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@" config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@" Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -7,6 +7,7 @@ import platform import re import subprocess +import json import lit.formats import lit.util @@ -104,17 +105,31 @@ config.substitutions.append( ('%run', config.emulator) ) config.substitutions.append( ('%env ', "env ") ) config.compile_wrapper = "" -elif config.ios: +elif config.host_os == 'Darwin' and config.apple_platform != "osx": + ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios" + config.available_features.add('ios') - device_id_env = "SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER" if config.iossim else "SANITIZER_IOS_TEST_DEVICE_IDENTIFIER" - if device_id_env in os.environ: config.environment[device_id_env] = os.environ[device_id_env] + if ios_or_iossim == "iossim": + config.available_features.add('iossim') + if config.apple_platform != "ios": + config.available_features.add(config.apple_platform) + ios_commands_dir = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "ios_commands") - run_wrapper = os.path.join(ios_commands_dir, "iossim_run.py" if config.iossim else "ios_run.py") + + device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER" + run_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_run.py") + env_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_env.py") + compile_wrapper = os.path.join(ios_commands_dir, ios_or_iossim + "_compile.py") + prepare_script = os.path.join(ios_commands_dir, ios_or_iossim + "_prepare.py") + + if device_id_env in os.environ: config.environment[device_id_env] = os.environ[device_id_env] config.substitutions.append(('%run', run_wrapper)) - env_wrapper = os.path.join(ios_commands_dir, "iossim_env.py" if config.iossim else "ios_env.py") config.substitutions.append(('%env ', env_wrapper + " ")) - compile_wrapper = os.path.join(ios_commands_dir, "iossim_compile.py" if config.iossim else "ios_compile.py") config.compile_wrapper = compile_wrapper + + prepare_output_json = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip().split("\n")[-1] + prepare_output = json.loads(prepare_output_json) + config.environment.update(prepare_output["env"]) elif config.android: config.available_features.add('android') compile_wrapper = os.path.join(config.compiler_rt_src_root, "test", "sanitizer_common", "android_commands", "android_compile.py") + " " @@ -202,7 +217,7 @@ config.substitutions.append( ("%macos_min_target_10_11", "-mmacosx-version-min=10.11") ) - isIOS = getattr(config, 'ios', False) + isIOS = config.apple_platform != "osx" # rdar://problem/22207160 config.substitutions.append( ("%darwin_min_target_with_full_runtime_arc_support", "-miphoneos-version-min=9.0" if isIOS else "-mmacosx-version-min=10.11") ) @@ -304,7 +319,7 @@ # The current implementation of the tools in sanitizer_common/ios_comamnds # do not support parallel execution so force sequential execution of the # tests on iOS devices. -if config.host_os == 'Darwin' and config.ios and not config.iossim: +if config.host_os == 'Darwin' and config.apple_platform != "osx" and not config.apple_platform.endswith("sim"): lit_config.warning("iOS device test cases being run sequentially") lit_config.parallelism_groups["darwin-ios-device-sanitizer"] = 1 Index: test/lit.common.configured.in =================================================================== --- test/lit.common.configured.in +++ test/lit.common.configured.in @@ -26,8 +26,7 @@ set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@") set_default("emulator", "@COMPILER_RT_EMULATOR@") set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@") -set_default("ios", False) -set_default("iossim", False) +set_default("apple_platform", None) set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@) set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@) set_default("can_symbolize", @CAN_SYMBOLIZE@) Index: test/sanitizer_common/ios_commands/iossim_prepare.py =================================================================== --- test/sanitizer_common/ios_commands/iossim_prepare.py +++ test/sanitizer_common/ios_commands/iossim_prepare.py @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import os, sys, subprocess, json + +print(json.dumps({"env": {}})) Index: test/tsan/CMakeLists.txt =================================================================== --- test/tsan/CMakeLists.txt +++ test/tsan/CMakeLists.txt @@ -24,10 +24,7 @@ endif() foreach(arch ${TSAN_TEST_ARCH}) - set(TSAN_TEST_IOS "0") - pythonize_bool(TSAN_TEST_IOS) - set(TSAN_TEST_IOSSIM "0") - pythonize_bool(TSAN_TEST_IOSSIM) + set(TSAN_TEST_APPLE_PLATFORM "osx") set(TSAN_TEST_TARGET_ARCH ${arch}) string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX) @@ -51,15 +48,12 @@ set(EXCLUDE_FROM_ALL ON) set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER}) - set(TSAN_TEST_IOS "1") - pythonize_bool(TSAN_TEST_IOS) + set(TSAN_TEST_APPLE_PLATFORM "iossim") set(arch "x86_64") - set(TSAN_TEST_IOSSIM "1") - pythonize_bool(TSAN_TEST_IOSSIM) set(TSAN_TEST_TARGET_ARCH ${arch}) set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_iossim_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") - set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-iossim") + set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}") string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOSSim${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( @@ -70,12 +64,11 @@ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/ DEPENDS ${TSAN_TEST_DEPS}) + set(TSAN_TEST_APPLE_PLATFORM "ios") set(arch "arm64") - set(TSAN_TEST_IOSSIM "0") - pythonize_bool(TSAN_TEST_IOSSIM) set(TSAN_TEST_TARGET_ARCH ${arch}) set(TSAN_TEST_TARGET_CFLAGS "-arch ${arch} -isysroot ${DARWIN_ios_SYSROOT} ${COMPILER_RT_TEST_COMPILER_CFLAGS}") - set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-ios") + set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${TSAN_TEST_APPLE_PLATFORM}") string(TOUPPER ${arch} ARCH_UPPER_CASE) set(CONFIG_NAME "IOS${ARCH_UPPER_CASE}Config") configure_lit_site_cfg( Index: test/tsan/lit.cfg =================================================================== --- test/tsan/lit.cfg +++ test/tsan/lit.cfg @@ -88,5 +88,5 @@ if config.host_os == 'Darwin': if config.target_arch in ["x86_64", "x86_64h"]: config.parallelism_group = "darwin-64bit-sanitizer" - elif config.ios and not config.iossim: + elif config.apple_platform != "osx" and not config.apple_platform.endswith("sim"): config.parallelism_group = "darwin-ios-device-sanitizer" Index: test/tsan/lit.site.cfg.in =================================================================== --- test/tsan/lit.site.cfg.in +++ test/tsan/lit.site.cfg.in @@ -3,8 +3,7 @@ config.name_suffix = "@TSAN_TEST_CONFIG_SUFFIX@" config.tsan_lit_source_dir = "@TSAN_LIT_SOURCE_DIR@" config.has_libcxx = @TSAN_HAS_LIBCXX@ -config.ios = @TSAN_TEST_IOS_PYBOOL@ -config.iossim = @TSAN_TEST_IOSSIM_PYBOOL@ +config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@" config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@" config.target_arch = "@TSAN_TEST_TARGET_ARCH@"