llvm-project/compiler-rt/test/lit.common.configured.in

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
3.9 KiB
Plaintext
Raw Normal View History

@LIT_SITE_CFG_IN_HEADER@
# Set attribute value if it is unset.
def set_default(attr, value):
if not getattr(config, attr, None):
setattr(config, attr, value)
# Generic config options for all compiler-rt lit tests.
set_default("target_triple", "@COMPILER_RT_DEFAULT_TARGET_TRIPLE@")
set_default("target_cflags", "@COMPILER_RT_TEST_COMPILER_CFLAGS@")
set_default("host_arch", "@HOST_ARCH@")
set_default("target_arch", "@COMPILER_RT_DEFAULT_TARGET_ARCH@")
set_default("host_os", "@HOST_OS@")
set_default("llvm_build_mode", "@LLVM_BUILD_MODE@")
set_default("llvm_src_root", "@LLVM_MAIN_SRC_DIR@")
set_default("llvm_obj_root", "@LLVM_BINARY_DIR@")
set_default("compiler_rt_src_root", "@COMPILER_RT_SOURCE_DIR@")
set_default("compiler_rt_obj_root", "@COMPILER_RT_BINARY_DIR@")
set_default("enable_per_target_runtime_dir", @LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_PYBOOL@)
set_default("llvm_tools_dir", "@LLVM_TOOLS_DIR@")
set_default("llvm_shlib_dir", "@LLVM_LIBRARY_OUTPUT_INTDIR@")
set_default("gnu_ld_executable", "@GNU_LD_EXECUTABLE@")
set_default("gold_executable", "@GOLD_EXECUTABLE@")
set_default("clang", "@COMPILER_RT_RESOLVED_TEST_COMPILER@")
set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
set_default("python_executable", "@Python3_EXECUTABLE@")
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
set_default("compiler_rt_intercept_libdispatch", @COMPILER_RT_INTERCEPT_LIBDISPATCH_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("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("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@)
set_default("has_lld", @COMPILER_RT_HAS_LLD_PYBOOL@)
set_default("can_symbolize", @CAN_SYMBOLIZE@)
set_default("use_lld", @COMPILER_RT_TEST_USE_LLD_PYBOOL@)
set_default("use_thinlto", False)
set_default("use_lto", config.use_thinlto)
set_default("android", @ANDROID_PYBOOL@)
set_default("android_api_level", "@ANDROID_API_LEVEL@")
set_default("android_serial", "@ANDROID_SERIAL_FOR_TESTING@")
set_default("android_files_to_push", [])
set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
set_default("gwp_asan", @COMPILER_RT_HAS_GWP_ASAN_PYBOOL@)
set_default("expensive_checks", @LLVM_ENABLE_EXPENSIVE_CHECKS_PYBOOL@)
[Compiler-rt] Distinguish between testing just built runtime libraries and the libraries shipped with the compiler. The path to the runtime libraries used by the compiler under test is normally identical to the path where just built libraries are created. However, this is not necessarily the case when doing standalone builds. This is because the external compiler used by tests may choose to get its runtime libraries from somewhere else. When doing standalone builds there are two types of testing we could be doing: * Test the just built runtime libraries. * Test the runtime libraries shipped with the compile under test. Both types of testing are valid but it confusingly turns out compiler-rt actually did a mixture of these types of testing. * The `test/builtins/Unit/` test suite always tested the just built runtime libraries. * All other testsuites implicitly use whatever runtime library the compiler decides to link. There is no way for us to infer which type of testing the developer wants so this patch introduces a new `COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` CMake option which explicitly declares which runtime libraries should be tested. If it is `ON` then the just built libraries should be tested, otherwise the libraries in the external compiler should be tested. When testing starts the lit test suite queries the compiler used for testing to see where it will get its runtime libraries from. If these paths are identical no action is taken (the common case). If the paths are not identical then we check the value of `COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` (progated into the config as `test_standalone_build_libs`) and check if the test suite supports testing in the requested configuration. * If we want to test just built libs and the test suite supports it (currently only `test/builtins/Unit`) then testing proceeds without any changes. * If we want to test the just built libs and the test suite doesn't support it we emit a fatal error to prevent the developer from testing the wrong runtime libraries. * If we are testing the compiler's built libs then we adjust `config.compiler_rt_libdir` to point at the compiler's runtime directory. This makes the `test/builtins/Unit` tests use the compiler's builtin library. No other changes are required because all other testsuites implicitly use the compiler's built libs. To make the above work the `test_suite_supports_overriding_runtime_lib_path` test suite config option has been introduced so we can identify what each test suite supports. Note all of these checks **have to be performed** when lit runs. We cannot run the checks at CMake generation time because multi-configuration build systems prevent us from knowing what the paths will be. We could perhaps support `COMPILER_RT_TEST_STANDALONE_BUILD_LIBS` being `ON` for most test suites (when the runtime library paths differs) in the future by specifiying a custom compiler resource directory path. Doing so is out of scope for this patch. rdar://77182297 Differential Revision: https://reviews.llvm.org/D101681
2021-05-01 07:24:33 +08:00
set_default("test_standalone_build_libs", @COMPILER_RT_TEST_STANDALONE_BUILD_LIBS_PYBOOL@)
# True iff the test suite supports ignoring the test compiler's runtime library path
# and using `config.compiler_rt_libdir` instead. This only matters when the runtime
# library paths differ.
set_default("test_suite_supports_overriding_runtime_lib_path", False)
[sanitizers] Make it possible to XFAIL on the effective target, not just the default. Summary: The triple is not the right thing to XFAIL on since LIT only sees the default triple and not the effective triple chosen by any -target option in the RUN directives. This discrepancy is shown in the table below: Default Triple | Options | XFAIL | LIT's expected result | Desired expectation =================+===================================+========+=======================+==================== mips-linux-gnu | -target mips-linux-gnu | | Pass | Pass mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | | Pass | Pass mips-linux-gnu | -target mips-linux-gnu | mips | Fail | Fail mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips | Fail | Fail/Pass* (debatable**) mips-linux-gnu | -target mips-linux-gnu | mips- | Fail | Fail mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips- | Fail | Pass* mips-linux-gnu | -target mips-linux-gnu | mips64 | Pass | Pass mips-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips64 | Pass | Fail* mips64-linux-gnu | -target mips-linux-gnu | | Pass | Pass mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | | Pass | Pass mips64-linux-gnu | -target mips-linux-gnu | mips | Fail | Fail* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips | Fail | Fail/Pass (debatable**) mips64-linux-gnu | -target mips-linux-gnu | mips- | Pass | Fail* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips- | Pass | Pass mips64-linux-gnu | -target mips-linux-gnu | mips64 | Fail | Pass* mips64-linux-gnu | -target mips64-linux-gnu -mabi=64 | mips64 | Fail | Fail x64_64-linux-gnu | -target i386-linux-gnu | | Pass | Pass x64_64-linux-gnu | -target x86_64-linux-gnu | | Pass | Pass x64_64-linux-gnu | -target i386-linux-gnu | i386 | Pass | Fail* x64_64-linux-gnu | -target x86_64-linux-gnu | i386 | Pass | Pass x64_64-linux-gnu | -target i386-linux-gnu | x86_64 | Fail | Pass x64_64-linux-gnu | -target x86_64-linux-gnu | x86_64 | Fail | Fail* * These all differ from LIT's current behaviour. ** People's expectations vary depending on whether they know that LIT does a substring match on the default triple or think it's an exact match on an architecture. This patch adds "target-is-${target_arch}" to the available features list and updates the mips XFAIL's to use them. XFAIL'ing on these features will correctly account for the target being tested. Making the table: Options | XFAIL | LIT's expected result ==================================+==================+====================== -target mips-linux-gnu | | Pass -target mips64-linux-gnu -mabi=64 | | Pass -target mips-linux-gnu | target-is-mips | Fail -target mips64-linux-gnu -mabi=64 | target-is-mips | Pass -target mips-linux-gnu | target-is-mips64 | Pass -target mips64-linux-gnu -mabi=64 | target-is-mips64 | Fail -target i386-linux-gnu | | Pass -target x86_64-linux-gnu | | Pass -target i386-linux-gnu | target-is-i386 | Fail -target x86_64-linux-gnu | target-is-i386 | Pass -target i386-linux-gnu | target-is-x86_64 | Pass -target x86_64-linux-gnu | target-is-x86_64 | Fail Reviewers: probinson Subscribers: probinson, kubabrecka, llvm-commits, samsonov Differential Revision: https://reviews.llvm.org/D22802 llvm-svn: 278116
2016-08-09 19:50:53 +08:00
config.available_features.add('target-is-%s' % config.target_arch)
if config.enable_per_target_runtime_dir:
set_default("target_suffix", "")
elif config.android:
if config.target_arch == "i386":
set_default("target_suffix", "-i686-android")
else:
set_default("target_suffix", "-%s-android" % config.target_arch)
else:
set_default("target_suffix", "-%s" % config.target_arch)
set_default("have_zlib", "@LLVM_ENABLE_ZLIB@")
set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
# LLVM tools dir can be passed in lit parameters, so try to
# apply substitution.
config.llvm_tools_dir = lit_config.substitute(config.llvm_tools_dir)
config.clang = lit_config.substitute(config.clang)
config.compiler_rt_libdir = lit_config.substitute(config.compiler_rt_libdir)
if not os.path.exists(config.clang):
lit_config.fatal("Can't find compiler on path %r" % config.clang)
# Setup attributes common for all compiler-rt projects.
lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/test/lit.common.cfg.py")