Skip to content

[compiler-rt] [test] Fix using toolchains that rely on Clang default configs #113491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ include(CompilerRTUtils)
include(CMakeDependentOption)
include(GetDarwinLinkerVersion)

include(CheckCXXCompilerFlag)

# Check if we can compile with --no-default-config, or if that omits a config
# file that is essential for the toolchain to work properly.
#
# Using CMAKE_REQUIRED_FLAGS to make sure the flag is used both for compilation
# and for linking.
#
# Doing this test early on, to see if the flag works on the toolchain
# out of the box. Later on, we end up adding -nostdlib and similar flags
# to all test compiles, which easily can give false positives on this test.
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --no-default-config")
check_cxx_compiler_flag("" COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")

option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versioning support" OFF)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pythonize_bool(COMPILER_RT_ENABLE_INTERNAL_SYMBOLIZER)

pythonize_bool(COMPILER_RT_HAS_AARCH64_SME)

pythonize_bool(COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)

configure_compiler_rt_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.common.configured.in
${CMAKE_CURRENT_BINARY_DIR}/lit.common.configured)
Expand Down
6 changes: 5 additions & 1 deletion compiler-rt/test/lit.common.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,11 @@ def is_windows_lto_supported():
# default configs for the test runs. In particular, anything hardening
# related is likely to cause issues with sanitizer tests, because it may
# preempt something we're looking to trap (e.g. _FORTIFY_SOURCE vs our ASAN).
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"
#
# Only set this if we know we can still build for the target while disabling
# default configs.
if config.has_no_default_config_flag:
config.environment["CLANG_NO_DEFAULT_CONFIG"] = "1"

if config.has_compiler_rt_libatomic:
base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.atomic%s.so"
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/lit.common.configured.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set_default("test_standalone_build_libs", @COMPILER_RT_TEST_STANDALONE_BUILD_LIB
set_default("has_compiler_rt_libatomic", @COMPILER_RT_BUILD_STANDALONE_LIBATOMIC_PYBOOL@)
set_default("aarch64_sme", @COMPILER_RT_HAS_AARCH64_SME_PYBOOL@)
set_default("darwin_linker_version", "@COMPILER_RT_DARWIN_LINKER_VERSION@")
set_default("has_no_default_config_flag", @COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG_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.
Expand Down
Loading