Skip to content

Commit b48e148

Browse files
authored
Merge pull request #40204 from kubamracek/swift_stdlib_support_back_deployment
Rename SWIFT_ENABLE_COMPATIBILITY_OVERRIDES -> SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT and avoid building more back-deployment stdlib parts when not set
2 parents a32396b + d441f85 commit b48e148

File tree

11 files changed

+33
-22
lines changed

11 files changed

+33
-22
lines changed

stdlib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ option(SWIFT_ENABLE_MODULE_INTERFACES
8989
"Generate .swiftinterface files alongside .swiftmodule files"
9090
"${SWIFT_STDLIB_STABLE_ABI}")
9191

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

9696
option(SWIFT_STDLIB_HAS_DLADDR

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ function(_add_target_variant_c_compile_flags)
310310
list(APPEND result "-DSWIFT_LIBRARY_EVOLUTION=0")
311311
endif()
312312

313-
if(NOT SWIFT_ENABLE_COMPATIBILITY_OVERRIDES)
314-
list(APPEND result "-DSWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES")
313+
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
314+
list(APPEND result "-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT")
315315
endif()
316316

317317
if(SWIFT_ENABLE_REFLECTION)

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ function(_compile_swift_files
850850
#
851851
# See stdlib/CMakeLists.txt and TypeConverter::TypeConverter() in
852852
# lib/IRGen/GenType.cpp.
853-
if(SWIFTFILE_IS_STDLIB_CORE)
853+
if(SWIFTFILE_IS_STDLIB_CORE AND SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
854854
set(SWIFTFILE_PLATFORM "${SWIFT_SDK_${SWIFTFILE_SDK}_LIB_SUBDIR}")
855855
set(copy_legacy_layouts_dep
856856
"copy-legacy-layouts-${SWIFTFILE_PLATFORM}-${SWIFTFILE_ARCHITECTURE}${target_suffix}")

stdlib/linker-support/magic-symbols-for-install-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//
1818
//===----------------------------------------------------------------------===//
1919

20-
#if defined(__APPLE__) && defined(__MACH__)
20+
#if defined(__APPLE__) && defined(__MACH__) && SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
2121

2222
#include <Availability.h>
2323
#include <TargetConditionals.h>

stdlib/public/CompatibilityOverride/CompatibilityOverride.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include "CompatibilityOverride.h"
1818

19-
#ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
19+
#ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
2020

2121
#include "../runtime/ImageInspection.h"
2222
#include "swift/Runtime/Once.h"
@@ -91,4 +91,4 @@ static OverrideSection *getOverrideSectionPtr() {
9191
}
9292
#include COMPATIBILITY_OVERRIDE_INCLUDE_PATH
9393

94-
#endif // #ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
94+
#endif // #ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT

stdlib/public/CompatibilityOverride/CompatibilityOverride.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ namespace swift {
6868
SWIFT_TARGET_LIBRARY_NAME)
6969

7070
// Compatibility overrides are only supported on Darwin.
71-
#ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
71+
#ifdef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
7272
#if !(defined(__APPLE__) && defined(__MACH__))
73-
#define SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
73+
#undef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
7474
#endif
7575
#endif
7676

77-
#ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
77+
#ifndef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
7878

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

87-
#else // #ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
87+
#else // #ifndef SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
8888

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

132-
#endif // #else SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
132+
#endif // #else SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
133133

134134
} /* end namespace swift */
135135

stdlib/toolchain/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
5050
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
5151
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
5252

53-
add_subdirectory(legacy_layouts)
54-
add_subdirectory(Compatibility50)
55-
add_subdirectory(Compatibility51)
56-
add_subdirectory(CompatibilityDynamicReplacements)
57-
add_subdirectory(CompatibilityConcurrency)
53+
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
54+
add_subdirectory(legacy_layouts)
55+
add_subdirectory(Compatibility50)
56+
add_subdirectory(Compatibility51)
57+
add_subdirectory(CompatibilityDynamicReplacements)
58+
add_subdirectory(CompatibilityConcurrency)
59+
endif()

test/lit.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,10 @@ if run_vendor == 'apple':
958958
swift_execution_tests_extra_flags += \
959959
' -Xfrontend -disable-implicit-concurrency-module-import'
960960

961+
# Freestanding doesn't back deploy.
962+
swift_execution_tests_extra_flags += \
963+
' -Xfrontend -disable-autolinking-runtime-compatibility-concurrency'
964+
961965
# To have visible references from symbolic manglings
962966
swift_execution_tests_extra_flags += \
963967
' -Xfrontend -disable-standard-substitutions-in-reflection-mangling'

unittests/runtime/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# We can't currently build the runtime tests under ASAN
2-
# The problem is that we want to use the just-build compiler (just like the
2+
# The problem is that we want to use the just\build compiler (just like the
33
# runtime) but ASAN will complain if we link against libgtest and LLVMSupport
44
# libraries because they were compiled with the host compiler.
55
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
@@ -133,6 +133,11 @@ if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
133133
swiftCore_EXPORTS
134134
SWIFT_INLINE_NAMESPACE=__runtime)
135135

136+
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
137+
target_compile_definitions(SwiftRuntimeTests
138+
PRIVATE SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
139+
endif()
140+
136141
target_include_directories(SwiftRuntimeTests BEFORE PRIVATE
137142
${SWIFT_SOURCE_DIR}/stdlib/include)
138143

utils/build-presets.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,7 @@ build-swift-static-stdlib=1
25212521
swift-objc-interop=0
25222522
swift-enable-dispatch=0
25232523
swift-implicit-concurrency-import=0
2524-
swift-enable-compatibility-overrides=0
2524+
swift-stdlib-support-back-deployment=0
25252525
swift-enable-reflection=0
25262526
swift-stdlib-stable-abi=0
25272527
swift-stdlib-has-dladdr=0

utils/build-script-impl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ KNOWN_SETTINGS=(
205205
swift-objc-interop "" "whether to enable interoperability with Objective-C, default is 1 on Darwin platforms, 0 otherwise"
206206
swift-enable-dispatch "1" "whether to enable use of libdispatch"
207207
swift-implicit-concurrency-import "1" "whether to implicitly import the Swift concurrency module"
208-
swift-enable-compatibility-overrides "1" "whether to support back-deploying compatibility fixes for newer apps running on older runtimes"
208+
swift-stdlib-support-back-deployment "1" "whether to support back-deployment of built binaries to older OS versions"
209209
swift-enable-reflection "1" "whether to support reflection and mirrors"
210210
swift-stdlib-has-dladdr "1" "whether to build stdlib assuming the runtime environment provides dladdr API"
211211
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"
@@ -1997,7 +1997,7 @@ for host in "${ALL_HOSTS[@]}"; do
19971997
-DSWIFT_STDLIB_ASSERTIONS:BOOL=$(true_false "${SWIFT_STDLIB_ENABLE_ASSERTIONS}")
19981998
-DSWIFT_ENABLE_DISPATCH:BOOL=$(true_false "${SWIFT_ENABLE_DISPATCH}")
19991999
-DSWIFT_IMPLICIT_CONCURRENCY_IMPORT:BOOL=$(true_false "${SWIFT_IMPLICIT_CONCURRENCY_IMPORT}")
2000-
-DSWIFT_ENABLE_COMPATIBILITY_OVERRIDES:BOOL=$(true_false "${SWIFT_ENABLE_COMPATIBILITY_OVERRIDES}")
2000+
-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT:BOOL=$(true_false "${SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT}")
20012001
-DSWIFT_STDLIB_SINGLE_THREADED_RUNTIME:BOOL=$(true_false "${SWIFT_STDLIB_SINGLE_THREADED_RUNTIME}")
20022002
-DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS:BOOL=$(true_false "${SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS}")
20032003
-DSWIFT_STDLIB_HAS_DLADDR:BOOL=$(true_false "${SWIFT_STDLIB_HAS_DLADDR}")

0 commit comments

Comments
 (0)