[NFCI] [Darwin] Add APPLE_TARGET_IS_HOST lit option to compiler-rt#174522
[NFCI] [Darwin] Add APPLE_TARGET_IS_HOST lit option to compiler-rt#174522
Conversation
Darwin supports running tests on targets other than the host machine e.g. simulators. In such configurations, tests are run via a wrapper script (e.g. iossim_run.py). This refactors the lit test config to use a dedicated option to distinguish test suites that run on the host from those that run in any other configuration. This will allow the test suites to distinguish a local osx configuration from a "remote" one. rdar://167591463
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Andrew Haberlandt (ndrewh) ChangesDarwin supports running tests on targets other than the host machine e.g. simulators. In such configurations, tests are run via a wrapper script (e.g. iossim_run.py). This refactors the lit test config to use a dedicated option to distinguish test suites that run on the host from those that run in any other configuration. This will allow the test suites to distinguish a local osx configuration from a "remote" one. rdar://167591463 Full diff: https://github.com/llvm/llvm-project/pull/174522.diff 14 Files Affected:
diff --git a/compiler-rt/test/asan/CMakeLists.txt b/compiler-rt/test/asan/CMakeLists.txt
index 414a6cc9496ed..98fb3fd5ae5fc 100644
--- a/compiler-rt/test/asan/CMakeLists.txt
+++ b/compiler-rt/test/asan/CMakeLists.txt
@@ -45,6 +45,8 @@ foreach(arch ${ASAN_TEST_ARCH})
set(ASAN_TEST_TARGET_ARCH ${arch})
set(ASAN_TEST_APPLE_PLATFORM "osx")
set(ASAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
+ set(ASAN_TEST_APPLE_TARGET_IS_HOST ON)
+ pythonize_bool(ASAN_TEST_APPLE_TARGET_IS_HOST)
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_TEST_CONFIG_SUFFIX)
get_bits_for_arch(${arch} ASAN_TEST_BITS)
get_test_cc_for_arch(${arch} ASAN_TEST_TARGET_CC ASAN_TEST_TARGET_CFLAGS)
@@ -113,6 +115,8 @@ if(APPLE)
get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED)
set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
set(ASAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
+ set(ASAN_TEST_APPLE_TARGET_IS_HOST OFF)
+ pythonize_bool(ASAN_TEST_APPLE_TARGET_IS_HOST)
set(ASAN_TEST_APPLE_PLATFORM "${platform}")
set(ASAN_TEST_TARGET_ARCH "${arch}")
set(ASAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
diff --git a/compiler-rt/test/asan/lit.site.cfg.py.in b/compiler-rt/test/asan/lit.site.cfg.py.in
index afecfafeb99f9..6726df61eef74 100644
--- a/compiler-rt/test/asan/lit.site.cfg.py.in
+++ b/compiler-rt/test/asan/lit.site.cfg.py.in
@@ -8,6 +8,7 @@ config.bits = "@ASAN_TEST_BITS@"
config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
config.apple_platform = "@ASAN_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@ASAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @ASAN_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
config.asan_dynamic = @ASAN_TEST_DYNAMIC@
config.target_arch = "@ASAN_TEST_TARGET_ARCH@"
diff --git a/compiler-rt/test/asan_abi/CMakeLists.txt b/compiler-rt/test/asan_abi/CMakeLists.txt
index 51c7980459113..1df86c683af5f 100644
--- a/compiler-rt/test/asan_abi/CMakeLists.txt
+++ b/compiler-rt/test/asan_abi/CMakeLists.txt
@@ -20,6 +20,8 @@ foreach(arch ${ASAN_ABI_TEST_ARCH})
set(ASAN_ABI_TEST_TARGET_ARCH ${arch})
set(ASAN_ABI_TEST_APPLE_PLATFORM "osx")
set(ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
+ set(ASAN_ABI_TEST_APPLE_TARGET_IS_HOST ON)
+ pythonize_bool(ASAN_ABI_TEST_APPLE_TARGET_IS_HOST)
string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC ASAN_ABI_TEST_TARGET_CFLAGS)
@@ -61,6 +63,8 @@ if(APPLE)
set(ASAN_ABI_TEST_APPLE_PLATFORM "${platform}")
set(ASAN_ABI_TEST_TARGET_ARCH "${arch}")
set(ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
+ set(ASAN_ABI_TEST_APPLE_TARGET_IS_HOST OFF)
+ pythonize_bool(ASAN_ABI_TEST_APPLE_TARGET_IS_HOST)
get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
diff --git a/compiler-rt/test/asan_abi/lit.site.cfg.py.in b/compiler-rt/test/asan_abi/lit.site.cfg.py.in
index 0261159b664a2..33ab08c24d250 100644
--- a/compiler-rt/test/asan_abi/lit.site.cfg.py.in
+++ b/compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -8,6 +8,7 @@ config.bits = "@ASAN_ABI_TEST_BITS@"
config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @ASAN_ABI_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
# Load common config for all compiler-rt lit tests.
diff --git a/compiler-rt/test/fuzzer/CMakeLists.txt b/compiler-rt/test/fuzzer/CMakeLists.txt
index 51021e2dc2d99..8228743816ce1 100644
--- a/compiler-rt/test/fuzzer/CMakeLists.txt
+++ b/compiler-rt/test/fuzzer/CMakeLists.txt
@@ -50,6 +50,8 @@ macro(test_fuzzer stdlib)
set(LIBFUZZER_TEST_TARGET_ARCH ${arch})
set(LIBFUZZER_TEST_APPLE_PLATFORM "osx")
+ set(LIBFUZZER_TEST_APPLE_TARGET_IS_HOST ON)
+ pythonize_bool(LIBFUZZER_TEST_APPLE_TARGET_IS_HOST)
set(LIBFUZZER_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
set(LIBFUZZER_TEST_STDLIB ${stdlib})
@@ -111,6 +113,8 @@ if (APPLE)
set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
set(LIBFUZZER_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
set(LIBFUZZER_TEST_APPLE_PLATFORM "${platform}")
+ set(LIBFUZZER_TEST_APPLE_TARGET_IS_HOST OFF)
+ pythonize_bool(LIBFUZZER_TEST_APPLE_TARGET_IS_HOST)
set(LIBFUZZER_TEST_TARGET_ARCH "${arch}")
set(LIBFUZZER_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
configure_lit_site_cfg(
diff --git a/compiler-rt/test/fuzzer/lit.site.cfg.py.in b/compiler-rt/test/fuzzer/lit.site.cfg.py.in
index 8c403a2719a77..3521b051b89df 100644
--- a/compiler-rt/test/fuzzer/lit.site.cfg.py.in
+++ b/compiler-rt/test/fuzzer/lit.site.cfg.py.in
@@ -6,6 +6,7 @@ config.c_compiler = "@LIBFUZZER_TEST_COMPILER@"
config.stdlib = "@LIBFUZZER_TEST_STDLIB@"
config.apple_platform = "@LIBFUZZER_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@LIBFUZZER_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @LIBFUZZER_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
config.name_suffix = "@LIBFUZZER_TEST_CONFIG_SUFFIX@"
config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
diff --git a/compiler-rt/test/lit.common.cfg.py b/compiler-rt/test/lit.common.cfg.py
index fa74408383638..a6913318591c9 100644
--- a/compiler-rt/test/lit.common.cfg.py
+++ b/compiler-rt/test/lit.common.cfg.py
@@ -411,7 +411,7 @@ def get_ios_commands_dir():
lit_config.warning("%device_rm is not implemented")
config.substitutions.append(("%device_rm", "echo "))
config.compile_wrapper = ""
-elif config.target_os == "Darwin" and config.apple_platform != "osx":
+elif config.target_os == "Darwin" and not config.apple_target_is_host:
# 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.
@@ -428,9 +428,12 @@ def get_ios_commands_dir():
# watchOS simulator | darwin, ios, iossim, watchos, watchossim
# =========================================================================
+ # All non-OSX targets have the ios feature (see the above table)
+ if config.apple_platform != "osx":
+ config.available_features.add("ios")
+
ios_or_iossim = "iossim" if config.apple_platform.endswith("sim") else "ios"
- config.available_features.add("ios")
device_id_env = "SANITIZER_" + ios_or_iossim.upper() + "_TEST_DEVICE_IDENTIFIER"
if ios_or_iossim == "iossim":
config.available_features.add("iossim")
diff --git a/compiler-rt/test/lit.common.configured.in b/compiler-rt/test/lit.common.configured.in
index 2b4b72bc895c5..ea3bb9b08d05f 100644
--- a/compiler-rt/test/lit.common.configured.in
+++ b/compiler-rt/test/lit.common.configured.in
@@ -35,6 +35,7 @@ set_default("asan_shadow_scale", "@COMPILER_RT_ASAN_SHADOW_SCALE@")
set_default("memprof_shadow_scale", "@COMPILER_RT_MEMPROF_SHADOW_SCALE@")
set_default("apple_platform", "osx")
set_default("apple_platform_min_deployment_target_flag", "-mmacosx-version-min")
+set_default("apple_target_is_host", True)
set_default("sanitizer_can_use_cxxabi", @SANITIZER_CAN_USE_CXXABI_PYBOOL@)
set_default("sanitizer_uses_static_cxxabi", @SANITIZER_USE_STATIC_CXX_ABI_PYBOOL@)
set_default("sanitizer_uses_static_unwind", @SANITIZER_USE_STATIC_LLVM_UNWINDER_PYBOOL@)
diff --git a/compiler-rt/test/sanitizer_common/CMakeLists.txt b/compiler-rt/test/sanitizer_common/CMakeLists.txt
index c8c9b73875918..739879d961248 100644
--- a/compiler-rt/test/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/test/sanitizer_common/CMakeLists.txt
@@ -82,6 +82,9 @@ foreach(tool ${SUPPORTED_TOOLS})
"${SANITIZER_COMMON_TEST_TARGET_CFLAGS}")
endif()
+ set(SANITIZER_COMMON_TEST_APPLE_TARGET_IS_HOST ON)
+ pythonize_bool(SANITIZER_COMMON_TEST_APPLE_TARGET_IS_HOST)
+
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
@@ -131,6 +134,8 @@ if(APPLE)
set(CONFIG_NAME "${tool}-${arch}-${platform}")
set(SANITIZER_COMMON_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
set(SANITIZER_COMMON_TEST_APPLE_PLATFORM "${platform}")
+ set(SANITIZER_COMMON_TEST_APPLE_TARGET_IS_HOST OFF)
+ pythonize_bool(SANITIZER_COMMON_TEST_APPLE_TARGET_IS_HOST)
set(SANITIZER_COMMON_TEST_TARGET_ARCH "${arch}")
set(SANITIZER_COMMON_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
configure_lit_site_cfg(
diff --git a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
index 0daadb2879ef9..753bb8d1c68a4 100644
--- a/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
+++ b/compiler-rt/test/sanitizer_common/lit.site.cfg.py.in
@@ -6,6 +6,7 @@ config.tool_name = "@SANITIZER_COMMON_LIT_TEST_MODE@"
config.target_cflags = "@SANITIZER_COMMON_TEST_TARGET_CFLAGS@"
config.apple_platform = "@SANITIZER_COMMON_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@SANITIZER_COMMON_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @SANITIZER_COMMON_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
config.target_arch = "@SANITIZER_COMMON_TEST_TARGET_ARCH@"
config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
diff --git a/compiler-rt/test/tsan/CMakeLists.txt b/compiler-rt/test/tsan/CMakeLists.txt
index 163355d68ebc2..4cd88507a2baf 100644
--- a/compiler-rt/test/tsan/CMakeLists.txt
+++ b/compiler-rt/test/tsan/CMakeLists.txt
@@ -31,6 +31,8 @@ endif()
foreach(arch ${TSAN_TEST_ARCH})
set(TSAN_TEST_APPLE_PLATFORM "osx")
set(TSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
+ set(TSAN_TEST_APPLE_TARGET_IS_HOST ON)
+ pythonize_bool(TSAN_TEST_APPLE_TARGET_IS_HOST)
set(TSAN_TEST_TARGET_ARCH ${arch})
string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
@@ -97,6 +99,8 @@ if(APPLE)
set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
set(TSAN_TEST_APPLE_PLATFORM "${platform}")
+ set(TSAN_TEST_APPLE_TARGET_IS_HOST OFF)
+ pythonize_bool(TSAN_TEST_APPLE_TARGET_IS_HOST)
set(TSAN_TEST_TARGET_ARCH "${arch}")
set(TSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
configure_lit_site_cfg(
diff --git a/compiler-rt/test/tsan/lit.site.cfg.py.in b/compiler-rt/test/tsan/lit.site.cfg.py.in
index c6d453aaee26f..458da18a17147 100644
--- a/compiler-rt/test/tsan/lit.site.cfg.py.in
+++ b/compiler-rt/test/tsan/lit.site.cfg.py.in
@@ -5,6 +5,7 @@ config.tsan_lit_source_dir = "@TSAN_LIT_SOURCE_DIR@"
config.has_libcxx = @TSAN_HAS_LIBCXX@
config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@TSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @TSAN_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
config.deflake_threshold = "@TSAN_TEST_DEFLAKE_THRESHOLD@"
diff --git a/compiler-rt/test/ubsan/CMakeLists.txt b/compiler-rt/test/ubsan/CMakeLists.txt
index f0b84f431472a..a83215d82d57e 100644
--- a/compiler-rt/test/ubsan/CMakeLists.txt
+++ b/compiler-rt/test/ubsan/CMakeLists.txt
@@ -44,7 +44,9 @@ foreach(arch ${UBSAN_TEST_ARCH})
if (APPLE)
set(UBSAN_TEST_APPLE_PLATFORM "osx")
set(UBSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
+ set(UBSAN_TEST_APPLE_TARGET_IS_HOST ON)
endif()
+ pythonize_bool(UBSAN_TEST_APPLE_TARGET_IS_HOST)
get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS)
add_ubsan_testsuites("Standalone" ubsan ${arch})
@@ -77,10 +79,12 @@ macro(add_ubsan_device_testsuite test_mode sanitizer platform arch)
if (APPLE)
set(UBSAN_TEST_APPLE_PLATFORM "${platform}")
set(UBSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
+ set(UBSAN_TEST_APPLE_TARGET_IS_HOST OFF)
else()
unset(UBSAN_TEST_APPLE_PLATFORM)
unset(UBSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG)
endif()
+ pythonize_bool(UBSAN_TEST_APPLE_TARGET_IS_HOST)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
diff --git a/compiler-rt/test/ubsan/lit.site.cfg.py.in b/compiler-rt/test/ubsan/lit.site.cfg.py.in
index 4dfd5c5b5c1a9..b5468b195be11 100644
--- a/compiler-rt/test/ubsan/lit.site.cfg.py.in
+++ b/compiler-rt/test/ubsan/lit.site.cfg.py.in
@@ -9,6 +9,7 @@ config.use_lld = @UBSAN_TEST_USE_LLD@
config.use_thinlto = @UBSAN_TEST_USE_THINLTO@
config.apple_platform = "@UBSAN_TEST_APPLE_PLATFORM@"
config.apple_platform_min_deployment_target_flag = "@UBSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.apple_target_is_host = @UBSAN_TEST_APPLE_TARGET_IS_HOST_PYBOOL@
# Load common config for all compiler-rt lit tests.
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
|
…174522) (#174642) The option added in #174522 breaks simulator tests, since `set_default` overrides `False` values with the default. Since these options are either string or boolean, this patches set_default to override only un-set or empty string values (empty string is not truth-y and therefore would be overwritten by defaults currently, so this is NFCI)
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/19665 Here is the relevant piece of the build log for the reference |
…lvm#174522) Darwin supports running tests on targets other than the host machine e.g. simulators. In such configurations, tests are run via a wrapper script (e.g. iossim_run.py). This refactors the lit test config to use a dedicated option to distinguish test suites that run on the host from those that run in any other configuration. This will allow the test suites to distinguish a local osx configuration from a "remote" one. rdar://167591463 (cherry picked from commit 305c413)
…lvm#174522) (llvm#174642) The option added in llvm#174522 breaks simulator tests, since `set_default` overrides `False` values with the default. Since these options are either string or boolean, this patches set_default to override only un-set or empty string values (empty string is not truth-y and therefore would be overwritten by defaults currently, so this is NFCI) (cherry picked from commit 0aea22f)
…lvm#174522) Darwin supports running tests on targets other than the host machine e.g. simulators. In such configurations, tests are run via a wrapper script (e.g. iossim_run.py). This refactors the lit test config to use a dedicated option to distinguish test suites that run on the host from those that run in any other configuration. This will allow the test suites to distinguish a local osx configuration from a "remote" one. rdar://167591463 (cherry picked from commit 305c413)
…lvm#174522) (llvm#174642) The option added in llvm#174522 breaks simulator tests, since `set_default` overrides `False` values with the default. Since these options are either string or boolean, this patches set_default to override only un-set or empty string values (empty string is not truth-y and therefore would be overwritten by defaults currently, so this is NFCI) (cherry picked from commit 0aea22f)
Darwin supports running tests on targets other than the host machine e.g. simulators. In such configurations, tests are run via a wrapper script (e.g. iossim_run.py).
This refactors the lit test config to use a dedicated option to distinguish test suites that run on the host from those that run in any other configuration. This will allow the test suites to distinguish a local osx configuration from a "remote" one.
rdar://167591463