Skip to content

Commit 2dd41f5

Browse files
authored
Merge branch 'main' into maxd/bump-wasmkit
2 parents f14d47f + 1380a3e commit 2dd41f5

File tree

4,282 files changed

+136702
-64826
lines changed

Some content is hidden

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

4,282 files changed

+136702
-64826
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ root = true
66
indent_style = space
77
indent_size = 2
88
insert_final_newline = true
9+
10+
[*.py]
11+
indent_size = 4

.github/CODEOWNERS

Lines changed: 70 additions & 54 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ Runtimes/**/*.inc
9797
Runtimes/**/*.json
9898
Runtimes/**/*.modulemap
9999
Runtimes/**/*.in
100+
!Runtimes/**/*.cmake.in
101+
!Runtimes/**/CMakeConfig.h.in

Brewfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
brew "cmake"
21
brew "ninja"
32
brew "sccache"

CHANGELOG.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,125 @@
55

66
## Swift 6.2
77

8+
* [SE-0472][]:
9+
Introduced new `Task.immediate` and `taskGroup.addImmediateTask` APIs, which allow a task to run "immediately" in the
10+
calling context if its isolation is compatible with the enclosing one. This can be used to create tasks which execute
11+
without additional scheduling overhead, and allow for finer-grained control over where a task begins running.
12+
13+
The canonical example for using this new API is using an unstructured immediate task like this:
14+
15+
```swift
16+
func synchronous() { // synchronous function
17+
// executor / thread: "T1"
18+
let task: Task<Void, Never> = Task.immediate {
19+
// executor / thread: "T1"
20+
guard keepRunning() else { return } // synchronous call (1)
21+
22+
// executor / thread: "T1"
23+
await noSuspension() // potential suspension point #1 // (2)
24+
25+
// executor / thread: "T1"
26+
await suspend() // potential suspension point #2 // (3), suspend, (5)
27+
// executor / thread: "other"
28+
}
29+
30+
// (4) continue execution
31+
// executor / thread: "T1"
32+
}
33+
```
34+
35+
* [SE-0471][]:
36+
Actor and global actor annotated types may now declare a synchronous `isolated deinit`, which allows such deinitializer
37+
to access actor isolated state while deinitializing the actor. This enables actor deinitializers to safely access
38+
and shut down or close resources during an actors deinitialization, without explicitly resorting to unstructured
39+
concurrency tasks.
40+
41+
```swift
42+
class NonSendableAhmed {
43+
var state: Int = 0
44+
}
45+
46+
@MainActor
47+
class Maria {
48+
let friend: NonSendableAhmed
49+
50+
init() {
51+
self.friend = NonSendableAhmed()
52+
}
53+
54+
init(sharingFriendOf otherMaria: Maria) {
55+
// While the friend is non-Sendable, this initializer and
56+
// and the otherMaria are isolated to the MainActor. That is,
57+
// they share the same executor. So, it's OK for the non-Sendable value
58+
// to cross between otherMaria and self.
59+
self.friend = otherMaria.friend
60+
}
61+
62+
isolated deinit {
63+
// Used to be a potential data race. Now, deinit is also
64+
// isolated on the MainActor, so this code is perfectly
65+
// correct.
66+
friend.state += 1
67+
}
68+
}
69+
70+
func example() async {
71+
let m1 = await Maria()
72+
let m2 = await Maria(sharingFriendOf: m1)
73+
doSomething(m1, m2)
74+
}
75+
```
76+
77+
* [SE-0469][]:
78+
Swift concurrency tasks (both unstructured and structured, via the TaskGroup `addTask` APIs) may now be given
79+
human-readable names, which can be used to support debugging and identifying tasks.
80+
81+
```swift
82+
let getUsers = Task("Get Users for \(accountID)") {
83+
await users.get(accountID)
84+
}
85+
```
86+
87+
* [SE-0462][]:
88+
Task priority escalation may now be explicitly caused to a `Task`, as well as reacted to using the new task priority escalation handlers:
89+
90+
```swift
91+
// priority: low
92+
// priority: high!
93+
await withTaskPriorityEscalationHandler {
94+
await work()
95+
} onPriorityEscalated: { newPriority in // may not be triggered if ->high escalation happened before handler was installed
96+
// do something
97+
}
98+
```
99+
* [SE-0461][]:
100+
Nonisolated asynchronous functions may now execute on the calling actor, when the upcoming feature `NonisolatedNonsendingByDefault`
101+
is enabled, or when explicitly opted-into using the `nonisolated(nonsending)` keywords. This allows for fine grained control
102+
over where nonisolated asynchronous functions execute, and allows for the default behavior of their execution to be changed
103+
from always executing on the global concurrent pool, to the calling actor, which can yield noticeable performance improvements
104+
thanks to less executor hopping when nonisolated and isolated code is invoked in sequence.
105+
106+
This also allows for safely using asynchronous functions on non-sendable types from actors, like so:
107+
108+
```swift
109+
class NotSendable {
110+
func performSync() { ... }
111+
112+
nonisolated(nonsending)
113+
func performAsync() async { ... }
114+
}
115+
116+
actor MyActor {
117+
let x: NotSendable
118+
119+
func call() async {
120+
x.performSync() // okay
121+
122+
await x.performAsync() // okay
123+
}
124+
}
125+
```
126+
8127
* The Swift compiler no longer diagnoses references to declarations that are
9128
potentially unavailable because the platform version might not be new enough
10129
when those references occur inside of contexts that are also unavailable to
@@ -10787,7 +10906,12 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1078710906
[SE-0442]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0442-allow-taskgroup-childtaskresult-type-to-be-inferred.md
1078810907
[SE-0444]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
1078910908
[SE-0458]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md
10909+
[SE-0461]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0461-async-function-isolation.md
10910+
[SE-0462]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0462-task-priority-escalation-apis.md
10911+
[SE-0469]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0469-task-names.md
1079010912
[SE-0470]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0470-isolated-conformances.md
10913+
[SE-0471]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md
10914+
[SE-0472]: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0472-task-start-synchronously-on-caller-context.md
1079110915
[#64927]: <https://github.com/apple/swift/issues/64927>
1079210916
[#42697]: <https://github.com/apple/swift/issues/42697>
1079310917
[#42728]: <https://github.com/apple/swift/issues/42728>

CMakeLists.txt

Lines changed: 76 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
336336
"The internal version of the Swift compiler")
337337
set(CLANG_COMPILER_VERSION "" CACHE STRING
338338
"The internal version of the Clang compiler")
339+
set(SWIFT_TOOLCHAIN_VERSION "" CACHE STRING
340+
"The Swift compiler tag")
339341

340342
option(SWIFT_DISABLE_DEAD_STRIPPING
341343
"Turn off Darwin-specific dead stripping for Swift host tools." FALSE)
@@ -462,6 +464,10 @@ option(SWIFT_STDLIB_ASSERTIONS
462464
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
463465
"${SWIFT_STDLIB_ASSERTIONS_default}")
464466

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+
465471
option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
466472
"Use the host compiler and not the internal clang to build the swift runtime"
467473
FALSE)
@@ -624,6 +630,17 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
624630
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS "1.0")
625631
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1")
626632

633+
set(SWIFT_DARWIN_TEST_DEPLOYMENT_VERSION_OSX "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}" CACHE STRING
634+
"Deployment target version for building macOS tests")
635+
set(SWIFT_DARWIN_TEST_DEPLOYMENT_VERSION_IOS "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}" CACHE STRING
636+
"Deployment target version for building iOS tests")
637+
set(SWIFT_DARWIN_TEST_DEPLOYMENT_VERSION_TVOS "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}" CACHE STRING
638+
"Deployment target version for building tvOS tests")
639+
set(SWIFT_DARWIN_TEST_DEPLOYMENT_VERSION_WATCHOS "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}" CACHE STRING
640+
"Deployment target version for building watchOS tests")
641+
set(SWIFT_DARWIN_TEST_DEPLOYMENT_VERSION_XROS "${SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS}" CACHE STRING
642+
"Deployment target version for building visionOS tests")
643+
627644
#
628645
# User-configurable debugging options.
629646
#
@@ -818,6 +835,9 @@ elseif(UNIX)
818835
include(UnixCompileRules)
819836
endif()
820837

838+
# Add any extra C++ compilation options that were passed down.
839+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${SWIFT_EXTRA_CXX_FLAGS}>)
840+
821841
if(CMAKE_C_COMPILER_ID MATCHES Clang)
822842
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
823843
endif()
@@ -828,6 +848,19 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
828848
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=c++98-compat-extra-semi>)
829849
endif()
830850

851+
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
852+
include(CheckCXXCompilerFlag)
853+
# Check for '-fsized-deallocation', which we need in IRGen. Clang presumably
854+
# adds this flag as a requirement for C++14+ to avoid a potential source
855+
# compatibility issue with C++11 where the 2-parameter `operator delete` was
856+
# used for placement deletion.
857+
check_cxx_compiler_flag("-fsized-deallocation"
858+
CXX_SUPPORTS_FSIZED_DEALLOCATION)
859+
if(CXX_SUPPORTS_FSIZED_DEALLOCATION)
860+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fsized-deallocation>)
861+
endif()
862+
endif()
863+
831864
option(SWIFT_BUILD_SWIFT_SYNTAX
832865
"Enable building swift syntax"
833866
FALSE)
@@ -868,12 +901,7 @@ include(CMakePushCheckState)
868901

869902
# Print out path and version of any installed commands
870903
message(STATUS "CMake (${CMAKE_COMMAND}) Version: ${CMAKE_VERSION}")
871-
if(XCODE)
872-
set(version_flag -version)
873-
else()
874-
set(version_flag --version)
875-
endif()
876-
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} ${version_flag}
904+
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
877905
OUTPUT_VARIABLE _CMAKE_MAKE_PROGRAM_VERSION
878906
OUTPUT_STRIP_TRAILING_WHITESPACE)
879907
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")
@@ -1070,6 +1098,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
10701098
set(SWIFT_USE_LINKER_default "")
10711099
elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023")
10721100
set(SWIFT_USE_LINKER_default "lld")
1101+
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
1102+
set(SWIFT_USE_LINKER_default "lld")
10731103
else()
10741104
get_gold_version(gold_version)
10751105
if(NOT gold_version)
@@ -1141,14 +1171,6 @@ endif()
11411171
# Configure SDKs.
11421172
#
11431173

1144-
if(XCODE)
1145-
# FIXME: It used to be the case that Xcode would force
1146-
# -m${platform}-version-min flags that would conflict with those computed
1147-
# by build-script. version-min flags are deprecated in favor of -target since
1148-
# clang-11, so we might be able to undo this.
1149-
set(SWIFT_SDKS "OSX")
1150-
endif()
1151-
11521174
# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
11531175
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
11541176
# and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately.
@@ -1404,8 +1426,9 @@ endif()
14041426

14051427
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
14061428
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
1407-
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1408-
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1429+
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
1430+
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
1431+
message(STATUS " Strict availability: ${SWIFT_STDLIB_ENABLE_STRICT_AVAILABILITY}")
14091432
message(STATUS "")
14101433

14111434
message(STATUS "Building Swift runtime with:")
@@ -1590,22 +1613,6 @@ swift_install_in_component(FILES "LICENSE.txt"
15901613
DESTINATION "share/swift"
15911614
COMPONENT license)
15921615

1593-
# Add a documentation target so that documentation shows up in the
1594-
# Xcode project.
1595-
if(XCODE)
1596-
add_custom_target(Documentation
1597-
SOURCES
1598-
README.md
1599-
docs)
1600-
1601-
file(GLOB SWIFT_TOPLEVEL_HEADERS
1602-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.h
1603-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.td
1604-
${CMAKE_CURRENT_SOURCE_DIR}/include/swift${dir}/*.def)
1605-
add_custom_target(Miscellaneous
1606-
SOURCES ${SWIFT_TOPLEVEL_HEADERS})
1607-
endif()
1608-
16091616
# New standard library build
16101617
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
16111618
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
@@ -1633,13 +1640,21 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16331640
set(stdlib_deployment_version_flag -DCMAKE_OSX_DEPLOYMENT_TARGET=${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION})
16341641
endif()
16351642

1643+
if(sdk STREQUAL "OSX" AND SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION VERSION_LESS "10.15")
1644+
set(build_concurrency NO)
1645+
else()
1646+
set(build_concurrency YES)
1647+
endif()
1648+
16361649
ExternalProject_Add("${stdlib_target}-core"
16371650
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Core"
16381651
# TODO: Add this once we're ready to start swapping out the libraries
16391652
# for testing
16401653
# INSTALL_DIR "${CMAKE_BINARY_DIR}/"
16411654

16421655
DEPENDS PopulateRuntimeSourceDir
1656+
# To ensure incremental builds work as expected
1657+
BUILD_ALWAYS 1
16431658
CMAKE_ARGS
16441659
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib
16451660
# Compiler will see mismatched swift modules and fail initial checks
@@ -1658,21 +1673,45 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16581673
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
16591674
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
16601675
-DSwiftCore_INSTALL_NESTED_SUBDIR=YES
1661-
-DSwiftCore_ENABLE_CONCURRENCY=YES)
1676+
-DSwiftCore_ENABLE_CONCURRENCY=${build_concurrency})
16621677
if(NOT ${CMAKE_CROSSCOMPILING})
16631678
add_dependencies("${stdlib_target}-core" swift-frontend)
16641679
endif()
16651680

16661681
ExternalProject_Get_Property("${stdlib_target}-core" INSTALL_DIR)
16671682

1683+
ExternalProject_Add("${stdlib_target}-Overlay"
1684+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Overlay"
1685+
DEPENDS "${stdlib_target}-core"
1686+
INSTALL_DIR "${INSTALL_DIR}"
1687+
LIST_SEPARATOR "|"
1688+
# To ensure incremental builds work as expected
1689+
BUILD_ALWAYS 1
1690+
CMAKE_ARGS
1691+
-DBUILD_SHARED_LIBS=YES
1692+
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
1693+
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
1694+
-DCMAKE_INSTALL_PREFIX:FILEPATH=${INSTALL_DIR}
1695+
-DCMAKE_Swift_COMPILER:FILEPATH=$<IF:$<BOOL:${CMAKE_CROSSCOMPILING}>,${CMAKE_Swift_COMPILER},$<PATH:REPLACE_FILENAME,$<TARGET_FILE:swift-frontend>,swiftc>>
1696+
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1697+
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1698+
-DCMAKE_Swift_COMPILER_TARGET:STRING=${stdlib_target_triple}
1699+
-DCMAKE_C_COMPILER_TARGET:STRING=${stdlib_target_triple}
1700+
-DCMAKE_CXX_COMPILER_TARGET:STRING=${stdlib_target_triple}
1701+
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
1702+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
1703+
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE)
1704+
16681705
ExternalProject_Add("${stdlib_target}-Supplemental"
16691706
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Supplemental"
1670-
DEPENDS "${stdlib_target}-core"
1707+
DEPENDS "${stdlib_target}-core" "${stdlib_target}-Overlay"
16711708
INSTALL_DIR "${INSTALL_DIR}"
16721709
INSTALL_COMMAND ""
16731710
LIST_SEPARATOR "|"
1711+
# To ensure incremental builds work as expected
1712+
BUILD_ALWAYS 1
16741713
CMAKE_ARGS
1675-
-DSwift_ENABLE_RUNTIMES=StringProcessing
1714+
-DSwift_ENABLE_RUNTIMES=StringProcessing|Synchronization|Distributed|Observation
16761715
-DBUILD_SHARED_LIBS=YES
16771716
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
16781717
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
@@ -1684,7 +1723,8 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
16841723
-DCMAKE_C_COMPILER_TARGET:STRING=${stdlib_target_triple}
16851724
-DCMAKE_CXX_COMPILER_TARGET:STRING=${stdlib_target_triple}
16861725
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS}
1687-
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM})
1726+
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
1727+
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE)
16881728
endforeach()
16891729
endforeach()
16901730
endif()

0 commit comments

Comments
 (0)