mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward deployment of binaries that dynamically check for protocol conformances on conditionally-available tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887; however, that doesn't do much good for running binaries on older OSes that don't have that fix. In order for binaries built with a newer Swift compiler to run successfully on older OSes, introduce a compatibility hook that replaces the conformance cache implementation in the original OS runtime with a version based on the current implementation that has the fix for the protocol conformance bug. Fixes rdar://problem/59460603
68 lines
2.1 KiB
CMake
68 lines
2.1 KiB
CMake
# Toolchain-only build products
|
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake/modules)
|
|
include(AddSwiftStdlib)
|
|
|
|
set(CXX_COMPILE_FLAGS)
|
|
set(CXX_LINK_FLAGS)
|
|
|
|
|
|
set(compile_flags
|
|
# Build the runtime with -Wall to catch, e.g., uninitialized variables
|
|
# warnings.
|
|
"-Wall"
|
|
|
|
# C++ code in the runtime and standard library should generally avoid
|
|
# introducing static constructors or destructors.
|
|
"-Wglobal-constructors"
|
|
"-Wexit-time-destructors"
|
|
|
|
# We don't want runtime C++ code to export symbols we didn't explicitly
|
|
# choose to.
|
|
"-fvisibility=hidden")
|
|
|
|
|
|
# Build the runtime with -Wall to catch, e.g., uninitialized variables
|
|
# warnings.
|
|
if(SWIFT_COMPILER_IS_MSVC_LIKE)
|
|
list(APPEND compile_flags "/W3")
|
|
else()
|
|
list(APPEND compile_flags "-Wall")
|
|
endif()
|
|
|
|
|
|
foreach(flag ${compile_flags})
|
|
check_cxx_compiler_flag("${flag}" is_supported)
|
|
if(is_supported)
|
|
list(APPEND CXX_COMPILE_FLAGS "${flag}")
|
|
endif()
|
|
endforeach()
|
|
unset(compile_flags)
|
|
|
|
|
|
if("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS)
|
|
list(APPEND CXX_LINK_FLAGS "-fsanitize=thread")
|
|
endif()
|
|
|
|
# Do not enforce checks for LLVM's ABI-breaking build settings.
|
|
# The Swift runtime uses some header-only code from LLVM's ADT classes,
|
|
# but we do not want to link libSupport into the runtime. These checks rely
|
|
# on the presence of symbols in libSupport to identify how the code was
|
|
# built and cause link failures for mismatches. Without linking that library,
|
|
# we get link failures regardless, so instead, this just disables the checks.
|
|
if(CMAKE_VERSION VERSION_LESS 3.12)
|
|
append("-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
|
else()
|
|
add_compile_definitions(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1)
|
|
endif()
|
|
|
|
# Compatibility libraries build in a special alternate universe that can't
|
|
# directly link to most OS runtime libraries, and have to access the
|
|
# runtime being patched only through public ABI.
|
|
list(APPEND CXX_COMPILE_FLAGS "-DSWIFT_COMPATIBILITY_LIBRARY=1")
|
|
|
|
add_subdirectory(legacy_layouts)
|
|
add_subdirectory(Compatibility50)
|
|
add_subdirectory(Compatibility51)
|
|
add_subdirectory(CompatibilityDynamicReplacements)
|