Skip to content

Commit 6f4d55a

Browse files
authored
Merge branch 'release/6.2' into cdecl-6.2
2 parents f0db19d + 5ba72f2 commit 6f4d55a

File tree

307 files changed

+7168
-4097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+7168
-4097
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ option(SWIFT_STDLIB_ASSERTIONS
464464
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
465465
"${SWIFT_STDLIB_ASSERTIONS_default}")
466466

467+
option(SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY
468+
"Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code"
469+
FALSE)
470+
467471
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
468472
"Use the host compiler and not the internal clang to build the swift runtime"
469473
FALSE)
@@ -1406,8 +1410,9 @@ endif()
14061410

14071411
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
14081412
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
1409-
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1410-
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1413+
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1414+
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1415+
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
14111416
message(STATUS "")
14121417

14131418
message(STATUS "Building Swift runtime with:")

Runtimes/Core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ set(SwiftCore_VENDOR_MODULE_DIR "${SwiftCore_CMAKE_MODULES_DIR}/vendor"
7878
include(GNUInstallDirs)
7979
include(CheckSymbolExists)
8080
include(CheckIncludeFileCXX)
81-
include(AvailabilityMacros)
8281
include(CompilerSettings)
8382
include(DefaultSettings)
8483
include(EmitSwiftInterface)
8584
include(PlatformInfo)
8685
include(gyb)
8786
include(ResourceEmbedding)
8887
include(CatalystSupport)
88+
include(AvailabilityMacros)
8989

9090
check_symbol_exists("asl_log" "asl.h" SwiftCore_HAS_ASL)
9191
check_symbol_exists("dladdr" "dlfcn.h" SwiftCore_HAS_DLADDR)
@@ -125,6 +125,7 @@ defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime suppor
125125
defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer")
126126
defaulted_option(SwiftCore_ENABLE_FATALERROR_BACKTRACE "Build stdlib fatalError with backtrace output")
127127
defaulted_option(SwiftCore_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization")
128+
defaulted_option(SwiftCore_ENABLE_STRICT_AVAILABILITY "Enable strict availability; this will cause things to break at desk or in CI if the host OS is a lower version than some `@availability` annotations in the runtime code")
128129

129130
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
130131
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)

Runtimes/Core/cmake/caches/Vendors/Apple/apple-common.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(SwiftCore_ENABLE_VECTOR_TYPES ON CACHE BOOL "")
1212
set(SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS ON CACHE BOOL "")
1313
set(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT ON CACHE BOOL "")
1414
set(SwiftCore_ENABLE_FILESYSTEM_SUPPORT ON CACHE BOOL "")
15+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY ON CACHE BOOL "")
16+
1517
set(SwiftCore_OPTIMIZATION_REMARKS "bitstream" CACHE STRING "")
1618

1719
set(SwiftCore_INSTALL_NESTED_SUBDIR OFF CACHE BOOL "")

Runtimes/Core/cmake/modules/AvailabilityMacros.cmake

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,39 @@ configure_file("${SwiftCore_SWIFTC_SOURCE_DIR}/utils/availability-macros.def"
44
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.def" availability_defs)
55
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
66
foreach(def ${availability_defs})
7-
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")
7+
list(APPEND availability_definitions "-Xfrontend -define-availability -Xfrontend \"${def}\"")
8+
9+
if("${def}" MATCHES "SwiftStdlib .*")
10+
# For each SwiftStdlib x.y, also define StdlibDeploymentTarget x.y, which,
11+
# will expand to the current `-target` platform if the macro defines a
12+
# newer platform as its availability.
13+
#
14+
# There is a setting, SwiftCore_ENABLE_STRICT_AVAILABILITY, which if set
15+
# ON will cause us to use the "proper" availability instead.
16+
string(REPLACE "SwiftStdlib" "StdlibDeploymentTarget" current "${def}")
17+
if(NOT SwiftCore_ENABLE_STRICT_AVAILABILITY AND SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
18+
if("${SwiftCore_SWIFT_AVAILABILITY_PLATFORM}" STREQUAL "macOS" AND "${SwiftCore_VARIANT_AVAILABILITY_PLATFORM}" STREQUAL "iOS")
19+
string(REGEX MATCH "iOS ([0-9]+(\.[0-9]+)+)" ios_platform_version "${def}")
20+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" ios_version "${ios_platform_version}")
21+
string(REGEX MATCH "macOS ([0-9]+(\.[0-9]+)+)" macos_platform_version "${def}")
22+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" macos_version "${macos_platform_version}")
23+
if((NOT macos_version STREQUAL "9999" OR NOT ios_version STREQUAL "9999") AND (macos_version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET OR ios_version VERSION_GREATER SwiftCore_VARIANT_DEPLOYMENT_VERSION))
24+
string(REGEX REPLACE ":.*" ": macOS ${CMAKE_OSX_DEPLOYMENT_VERSION}, iOS ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}" current "${current}")
25+
endif()
26+
else()
27+
string(REGEX MATCH "${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ([0-9]+(\.[0-9]+)+)" platform_version "${def}")
28+
string(REGEX MATCH "[0-9]+(\.[0-9]+)+" version "${platform_version}")
29+
if(NOT version STREQUAL "9999" AND version VERSION_GREATER CMAKE_OSX_DEPLOYMENT_TARGET)
30+
string(REGEX REPLACE ":.*" ":${SwiftCore_SWIFT_AVAILABILITY_PLATFORM} ${CMAKE_OSX_DEPLOYMENT_TARGET}" current "${current}")
31+
endif()
32+
endif()
33+
endif()
34+
list(APPEND availability_definitions "-Xfrontend -define-availability -Xfrontend \"${current}\"")
35+
endif()
836
endforeach()
37+
38+
list(JOIN availability_definitions "\n" availability_definitions)
39+
file(GENERATE
40+
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/availability-macros.rsp"
41+
CONTENT "${availability_definitions}")
42+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:${CMAKE_Swift_RESPONSE_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/availability-macros.rsp>")

Runtimes/Core/cmake/modules/CatalystSupport.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ if(SwiftCore_COMPILER_VARIANT_TARGET)
3434
set(SwiftCore_VARIANT_MODULE_TRIPLE "${module_triple}" CACHE STRING "Triple used for installed swift{module,interface} files for the target variant")
3535
mark_as_advanced(SwiftCore_VARIANT_MODULE_TRIPLE)
3636
message(CONFIGURE_LOG "Swift target variant module triple: ${module_triple}")
37+
38+
string(JSON triple GET "${target_info_json}" "target" "triple")
39+
if(triple MATCHES "apple-([a-zA-Z]+)([0-9]+[.0-9]*)-macabi")
40+
set(SwiftCore_VARIANT_DEPLOYMENT_VERSION "${CMAKE_MATCH_2}")
41+
mark_as_advanced(SwiftCore_VARIANT_DEPLOYMENT_VERSION)
42+
message(CONFIGURE_LOG "Swift target variant deployment version: ${SwiftCore_VARIANT_DEPLOYMENT_VERSION}")
43+
endif()
3744
endif()
3845
endif()

Runtimes/Core/cmake/modules/DefaultSettings.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set(SwiftCore_ENABLE_COMMANDLINE_SUPPORT_default OFF) # TODO: enable this by def
1111
set(SwiftCore_ENABLE_STDIN_default ON)
1212
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)
1313

14+
set(SwiftCore_ENABLE_STRICT_AVAILABILITY_default OFF)
15+
1416
set(SwiftCore_BACKTRACER_PATH_default "")
1517

1618
# Provide a boolean option that a user can optionally enable.
@@ -20,7 +22,7 @@ macro(defaulted_option variable helptext)
2022
if(NOT DEFINED ${variable}_default)
2123
set(${variable}_default OFF)
2224
endif()
23-
option(${variable} ${helptext} ${${variable}_default})
25+
option(${variable} "${helptext}" ${${variable}_default})
2426
endmacro()
2527

2628
# Create a defaulted cache entry

Runtimes/Core/cmake/modules/PlatformInfo.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,47 @@ if(NOT SwiftCore_ARCH_SUBDIR)
3636

3737
message(CONFIGURE_LOG "Swift Arch: ${arch}")
3838
endif()
39+
40+
# Note: *moduleTriple* doesn't have an "x" on the end of "macos"; just to be
41+
# safe, we support both cases here.
42+
set(availability_platform_macos "macOS")
43+
set(availaiblity_platform_macosx "macOS")
44+
set(availability_platform_ios "iOS")
45+
set(availability_platform_watchos "watchOS")
46+
set(availability_platform_tvos "tvOS")
47+
set(availability_platform_xros "visionOS")
48+
set(availability_platform_bridgeos "bridgeOS")
49+
50+
if(NOT SwiftCore_SWIFT_AVAILABILITY_PLATFORM)
51+
if(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-simulator$")
52+
set(platform "${CMAKE_MATCH_1}")
53+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)-msvc$")
54+
set(platform "${CMAKE_MATCH_1}")
55+
elseif(SwiftCore_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
56+
set(platform "${CMAKE_MATCH_1}")
57+
else()
58+
message(WARNING "Unable to extract platform name from triple ${SwiftCore_MODULE_TRIPLE}")
59+
endif()
60+
61+
if(availability_platform_${platform})
62+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
63+
else()
64+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM "unknown")
65+
message(WARNING "Unknown platform ${platform} for availability")
66+
endif()
67+
endif()
68+
69+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "none")
70+
if(SwiftCore_VARIANT_MODULE_TRIPLE)
71+
if(SwiftCore_VARIANT_MODULE_TRIPLE MATCHES ".*-([^-]+)$")
72+
set(platform "${CMAKE_MATCH_1}")
73+
else()
74+
message(FATAL_ERROR "Unable to extract platform name from triple ${SwiftCore_VARIANT_MODULE_TRIPLE}")
75+
endif()
76+
77+
if(availability_platform_${platform})
78+
set(SwiftCore_VARIANT_AVAILABILITY_PLATFORM "${availability_platform_${platform}}")
79+
else()
80+
message(WARNING "Unknown platform ${platform} for variant availability")
81+
endif()
82+
endif()

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/LetPropertyLowering.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ private func insertEndInitInstructions(
122122
use.set(to: ssaUpdater.getValue(atEndOf: use.instruction.parentBlock), context)
123123
}
124124
}
125+
// This peephole optimization is required to avoid ownership errors.
126+
replacePhisWithIncomingValues(phis: ssaUpdater.insertedPhis, context)
125127
}
126128

127129
private func constructLetInitRegion(

SwiftCompilerSources/Sources/Optimizer/ModulePasses/MandatoryPerformanceOptimizations.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private func optimize(function: Function, _ context: FunctionPassContext, _ modu
122122
}
123123
}
124124
case let metatype as MetatypeInst:
125-
if context.options.enableEmbeddedSwift {
125+
if context.options.enableEmbeddedSwift,
126+
metatype.type.representationOfMetatype == .thick {
126127
let instanceType = metatype.type.loweredInstanceTypeOfMetatype(in: function)
127128
if instanceType.isClass {
128129
specializeVTable(forClassType: instanceType, errorLocation: metatype.location, moduleContext) {

SwiftCompilerSources/Sources/Optimizer/Utilities/AddressUtils.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,10 @@ extension AddressOwnershipLiveRange {
648648
let addressOwnershipLiveRangeTest = FunctionTest("address_ownership_live_range") {
649649
function, arguments, context in
650650
let address = arguments.takeValue()
651+
let begin = arguments.takeInstruction()
651652
print("Address: \(address)")
652653
print("Base: \(address.accessBase)")
653-
let begin = address.definingInstructionOrTerminator ?? {
654-
assert(address is FunctionArgument)
655-
return function.instructions.first!
656-
}()
654+
print("Begin: \(begin)")
657655
let localReachabilityCache = LocalVariableReachabilityCache()
658656
guard var ownershipRange = AddressOwnershipLiveRange.compute(for: address, at: begin,
659657
localReachabilityCache, context) else {

0 commit comments

Comments
 (0)