[compiler-rt] CRT builtins tests should not run on mac/windows under LLVM_ENABLE_RUNTIMES (#187835)

#171941 got the builtins tests running under LLVM_ENABLE_RUNTIMES by
testing the builtins as part of the runtimes build.

As a consequence, CMake in `lib/builtins/` is no longer visible when
configuring the tests (but `test/builtins/` is). This means that the
`cmake_dependent_option` from `lib/builtins/` is not accounted for by
the tests, allowing COMPILER_RT_BUILD_CRT to be YES when
COMPILER_RT_HAS_CRT is NO. As a consequence, the CRT tests are running
on platforms where COMPILER_RT_HAS_CRT is false (#176892).


367da15a11/compiler-rt/lib/builtins/CMakeLists.txt (L1106-L1108)

Although the long-term solution could be to split both the builtins (and
their tests) out of compiler-rt into a top-level directory with shared
options, this works around the issue for the moment by checking both
COMPILER_RT_HAS_CRT and COMPILER_RT_BUILD_CRT before enabling the "crt"
feature.

Fixes #176892
This commit is contained in:
Andrew Haberlandt 2026-03-24 23:49:14 -07:00 committed by GitHub
parent acbbe5c145
commit a5a7f6266e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View File

@ -23,10 +23,13 @@ configure_lit_site_cfg(
include(builtin-config-ix)
if (COMPILER_RT_BUILD_CRT AND TARGET crt)
list(APPEND BUILTINS_TEST_DEPS crt)
if (COMPILER_RT_BUILD_CRT AND COMPILER_RT_HAS_CRT)
if (TARGET crt)
list(APPEND BUILTINS_TEST_DEPS crt)
endif()
set(COMPILER_RT_TEST_CRT ON)
endif()
pythonize_bool(COMPILER_RT_BUILD_CRT)
pythonize_bool(COMPILER_RT_TEST_CRT)
# Indicate if this is an MSVC environment.
pythonize_bool(MSVC)

View File

@ -109,8 +109,8 @@ else:
else:
config.substitutions.append(("%librt ", base_lib + " -lc -lm "))
builtins_build_crt = get_required_attr(config, "builtins_build_crt")
if builtins_build_crt:
builtins_test_crt = get_required_attr(config, "builtins_test_crt")
if builtins_test_crt:
base_obj = os.path.join(
config.compiler_rt_libdir, "clang_rt.%%s%s.o" % config.target_suffix
)

View File

@ -5,7 +5,7 @@ config.builtins_lit_source_dir = "@BUILTINS_LIT_SOURCE_DIR@/Unit"
config.target_cflags = "@BUILTINS_TEST_TARGET_CFLAGS@"
config.target_arch = "@BUILTINS_TEST_TARGET_ARCH@"
config.sanitizer_cxx_lib = "@SANITIZER_TEST_CXX_LIBNAME@"
config.builtins_build_crt = @COMPILER_RT_BUILD_CRT_PYBOOL@
config.builtins_test_crt = @COMPILER_RT_TEST_CRT_PYBOOL@
config.is_msvc = @MSVC_PYBOOL@
config.builtins_is_msvc = @BUILTINS_IS_MSVC_PYBOOL@
config.builtins_lit_source_features = "@BUILTINS_LIT_SOURCE_FEATURES@"