Skip to content

Rename SWIFT_ENABLE_COMPATIBILITY_OVERRIDES -> SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT and avoid building more back-deployment stdlib parts when not set #40204

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
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
4 changes: 2 additions & 2 deletions stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ option(SWIFT_ENABLE_MODULE_INTERFACES
"Generate .swiftinterface files alongside .swiftmodule files"
"${SWIFT_STDLIB_STABLE_ABI}")

option(SWIFT_ENABLE_COMPATIBILITY_OVERRIDES
"Support back-deploying compatibility fixes for newer apps running on older runtimes."
option(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
"Support back-deployment of built binaries to older OS versions."
TRUE)

option(SWIFT_STDLIB_HAS_DLADDR
Expand Down
4 changes: 2 additions & 2 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ function(_add_target_variant_c_compile_flags)
list(APPEND result "-DSWIFT_LIBRARY_EVOLUTION=0")
endif()

if(NOT SWIFT_ENABLE_COMPATIBILITY_OVERRIDES)
list(APPEND result "-DSWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES")
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
list(APPEND result "-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT")
endif()

if(SWIFT_ENABLE_REFLECTION)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ function(_compile_swift_files
#
# See stdlib/CMakeLists.txt and TypeConverter::TypeConverter() in
# lib/IRGen/GenType.cpp.
if(SWIFTFILE_IS_STDLIB_CORE)
if(SWIFTFILE_IS_STDLIB_CORE AND SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
set(SWIFTFILE_PLATFORM "${SWIFT_SDK_${SWIFTFILE_SDK}_LIB_SUBDIR}")
set(copy_legacy_layouts_dep
"copy-legacy-layouts-${SWIFTFILE_PLATFORM}-${SWIFTFILE_ARCHITECTURE}${target_suffix}")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/linker-support/magic-symbols-for-install-name.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//
//===----------------------------------------------------------------------===//

#if defined(__APPLE__) && defined(__MACH__)
#if defined(__APPLE__) && defined(__MACH__) && SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

#include <Availability.h>
#include <TargetConditionals.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "CompatibilityOverride.h"

#ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

#include "../runtime/ImageInspection.h"
#include "swift/Runtime/Once.h"
Expand Down Expand Up @@ -91,4 +91,4 @@ static OverrideSection *getOverrideSectionPtr() {
}
#include COMPATIBILITY_OVERRIDE_INCLUDE_PATH

#endif // #ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#endif // #ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
10 changes: 5 additions & 5 deletions stdlib/public/CompatibilityOverride/CompatibilityOverride.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ namespace swift {
SWIFT_TARGET_LIBRARY_NAME)

// Compatibility overrides are only supported on Darwin.
#ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
#if !(defined(__APPLE__) && defined(__MACH__))
#define SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#undef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
#endif
#endif

#ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#ifndef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

// Call directly through to the original implementation when we don't support
// overrides.
Expand All @@ -84,7 +84,7 @@ namespace swift {
return swift_##name##Impl COMPATIBILITY_PAREN(namedArgs); \
}

#else // #ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#else // #ifndef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

// Override section name computation. `COMPATIBILITY_OVERRIDE_SECTION_NAME` will
// resolve to string literal containing the appropriate section name for the
Expand Down Expand Up @@ -129,7 +129,7 @@ namespace swift {
return swift_##name##Impl COMPATIBILITY_PAREN(namedArgs); \
}

#endif // #else SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
#endif // #else SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

} /* end namespace swift */

Expand Down
12 changes: 7 additions & 5 deletions stdlib/toolchain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")

add_subdirectory(legacy_layouts)
add_subdirectory(Compatibility50)
add_subdirectory(Compatibility51)
add_subdirectory(CompatibilityDynamicReplacements)
add_subdirectory(CompatibilityConcurrency)
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
add_subdirectory(legacy_layouts)
add_subdirectory(Compatibility50)
add_subdirectory(Compatibility51)
add_subdirectory(CompatibilityDynamicReplacements)
add_subdirectory(CompatibilityConcurrency)
endif()
4 changes: 4 additions & 0 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,10 @@ if run_vendor == 'apple':
swift_execution_tests_extra_flags += \
' -Xfrontend -disable-implicit-concurrency-module-import'

# Freestanding doesn't back deploy.
swift_execution_tests_extra_flags += \
' -Xfrontend -disable-autolinking-runtime-compatibility-concurrency'

# To have visible references from symbolic manglings
swift_execution_tests_extra_flags += \
' -Xfrontend -disable-standard-substitutions-in-reflection-mangling'
Expand Down
7 changes: 6 additions & 1 deletion unittests/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# We can't currently build the runtime tests under ASAN
# The problem is that we want to use the just-build compiler (just like the
# The problem is that we want to use the just\build compiler (just like the
# runtime) but ASAN will complain if we link against libgtest and LLVMSupport
# libraries because they were compiled with the host compiler.
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
Expand Down Expand Up @@ -133,6 +133,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
swiftCore_EXPORTS
SWIFT_INLINE_NAMESPACE=__runtime)

if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
target_compile_definitions(SwiftRuntimeTests
PRIVATE SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
endif()

target_include_directories(SwiftRuntimeTests BEFORE PRIVATE
${SWIFT_SOURCE_DIR}/stdlib/include)

Expand Down
2 changes: 1 addition & 1 deletion utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2521,7 +2521,7 @@ build-swift-static-stdlib=1
swift-objc-interop=0
swift-enable-dispatch=0
swift-implicit-concurrency-import=0
swift-enable-compatibility-overrides=0
swift-stdlib-support-back-deployment=0
swift-enable-reflection=0
swift-stdlib-stable-abi=0
swift-stdlib-has-dladdr=0
Expand Down
4 changes: 2 additions & 2 deletions utils/build-script-impl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ KNOWN_SETTINGS=(
swift-objc-interop "" "whether to enable interoperability with Objective-C, default is 1 on Darwin platforms, 0 otherwise"
swift-enable-dispatch "1" "whether to enable use of libdispatch"
swift-implicit-concurrency-import "1" "whether to implicitly import the Swift concurrency module"
swift-enable-compatibility-overrides "1" "whether to support back-deploying compatibility fixes for newer apps running on older runtimes"
swift-stdlib-support-back-deployment "1" "whether to support back-deployment of built binaries to older OS versions"
swift-enable-reflection "1" "whether to support reflection and mirrors"
swift-stdlib-has-dladdr "1" "whether to build stdlib assuming the runtime environment provides dladdr API"
swift-stdlib-supports-backtrace-reporting "" "whether to build stdlib assuming the runtime environment provides the backtrace(3) API, if not set defaults to true on all platforms except for Cygwin, Haiku and wasm"
Expand Down Expand Up @@ -1997,7 +1997,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DSWIFT_STDLIB_ASSERTIONS:BOOL=$(true_false "${SWIFT_STDLIB_ENABLE_ASSERTIONS}")
-DSWIFT_ENABLE_DISPATCH:BOOL=$(true_false "${SWIFT_ENABLE_DISPATCH}")
-DSWIFT_IMPLICIT_CONCURRENCY_IMPORT:BOOL=$(true_false "${SWIFT_IMPLICIT_CONCURRENCY_IMPORT}")
-DSWIFT_ENABLE_COMPATIBILITY_OVERRIDES:BOOL=$(true_false "${SWIFT_ENABLE_COMPATIBILITY_OVERRIDES}")
-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT:BOOL=$(true_false "${SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT}")
-DSWIFT_STDLIB_SINGLE_THREADED_RUNTIME:BOOL=$(true_false "${SWIFT_STDLIB_SINGLE_THREADED_RUNTIME}")
-DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS:BOOL=$(true_false "${SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS}")
-DSWIFT_STDLIB_HAS_DLADDR:BOOL=$(true_false "${SWIFT_STDLIB_HAS_DLADDR}")
Expand Down