[sanitizer] Unify and generalize Apple platforms in CMake and lit test configs
There's more platforms than just "ios" and "iossim" that we should support, and adding more lit config variables for each platform isn't great. Let's generalize and have a single value that determines what the platform under test is. Differential Revision: https://reviews.llvm.org/D48309 llvm-svn: 335123
This commit is contained in:
parent
eae99120b0
commit
badaa15c88
|
|
@ -51,10 +51,7 @@ foreach(arch ${ASAN_TEST_ARCH})
|
|||
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 @@ if(APPLE)
|
|||
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 @@ if(APPLE)
|
|||
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")
|
||||
|
|
|
|||
|
|
@ -214,5 +214,5 @@ if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'SunOS', 'Windows', 'Net
|
|||
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"
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ config.name_suffix = "@ASAN_TEST_CONFIG_SUFFIX@"
|
|||
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@"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ endif()
|
|||
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 @@ macro(test_fuzzer stdlib)
|
|||
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 @@ if (APPLE)
|
|||
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(
|
||||
|
|
|
|||
|
|
@ -96,5 +96,5 @@ config.substitutions.append(('%no_fuzzer_c_compiler',
|
|||
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"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@"
|
|||
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@"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import os
|
|||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
import lit.formats
|
||||
import lit.util
|
||||
|
|
@ -104,17 +105,50 @@ if config.emulator:
|
|||
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":
|
||||
# Darwin tests can be targetting macOS, a device or a simulator. All devices
|
||||
# are declared as "ios", even for iOS derivatives (tvOS, watchOS). Similarly,
|
||||
# all simulators are "iossim". See the table below.
|
||||
#
|
||||
# =========================================================================
|
||||
# Target | Feature set
|
||||
# =========================================================================
|
||||
# macOS | darwin
|
||||
# iOS device | darwin, ios
|
||||
# iOS simulator | darwin, ios, iossim
|
||||
# tvOS device | darwin, ios, tvos
|
||||
# tvOS simulator | darwin, ios, iossim, tvos, tvossim
|
||||
# watchOS device | darwin, ios, watchos
|
||||
# watchOS simulator | darwin, ios, iossim, watchos, watchossim
|
||||
# =========================================================================
|
||||
|
||||
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" and config.apple_platform != "iossim":
|
||||
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 = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip()
|
||||
if len(prepare_output) > 0: print(prepare_output)
|
||||
prepare_output_json = prepare_output.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 +236,7 @@ if config.host_os == 'Darwin':
|
|||
|
||||
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 +338,7 @@ if platform.system() == 'Darwin':
|
|||
# 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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
|
|||
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@)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os, sys, subprocess, json
|
||||
|
||||
print(json.dumps({"env": {}}))
|
||||
|
|
@ -24,10 +24,7 @@ if(APPLE)
|
|||
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 @@ if(APPLE)
|
|||
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 @@ if(APPLE)
|
|||
${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(
|
||||
|
|
|
|||
|
|
@ -88,5 +88,5 @@ if config.android:
|
|||
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"
|
||||
|
|
|
|||
|
|
@ -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@"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue