Skip to content

Commit e1371d7

Browse files
Merge remote-tracking branch 'apple/release/5.6' into swiftwasm-release/5.6
2 parents 4673f6b + ce25df6 commit e1371d7

File tree

539 files changed

+108798
-30680
lines changed

Some content is hidden

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

539 files changed

+108798
-30680
lines changed

CHANGELOG.md

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,109 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66
Swift 5.6
77
---------
88

9+
* Actor isolation checking now understands that `defer` bodies share the isolation of their enclosing function.
10+
11+
```swift
12+
// Works on global actors
13+
@MainActor
14+
func runAnimation(controller: MyViewController) async {
15+
controller.hasActiveAnimation = true
16+
defer { controller.hasActiveAnimation = false }
17+
18+
// do the animation here...
19+
}
20+
21+
// Works on actor instances
22+
actor OperationCounter {
23+
var activeOperationCount = 0
24+
25+
func operate() async {
26+
activeOperationCount += 1
27+
defer { activeOperationCount -= 1 }
28+
29+
// do work here...
30+
}
31+
}
32+
```
33+
34+
* [SE-0335][]:
35+
36+
Swift now allows existential types to be explicitly written with the `any`
37+
keyword, creating a syntactic distinction between existential types and
38+
protocol conformance constraints. For example:
39+
40+
```swift
41+
protocol P {}
42+
43+
func generic<T>(value: T) where T: P {
44+
...
45+
}
46+
47+
func existential(value: any P) {
48+
...
49+
}
50+
```
51+
52+
* [SE-0337][]:
53+
54+
Swift now provides an incremental migration path to data race safety, allowing
55+
APIs to adopt concurrency without breaking their clients that themselves have
56+
not adopted concurrency. An existing declaration can introduce
57+
concurrency-related annotations (such as making its closure parameters
58+
`@Sendable`) and use the `@preconcurrency` attribute to maintain its behavior
59+
for clients who have not themselves adopted concurrency:
60+
61+
```swift
62+
// module A
63+
@preconcurrency func runOnSeparateTask(_ workItem: @Sendable () -> Void)
64+
65+
// module B
66+
import A
67+
68+
class MyCounter {
69+
var value = 0
70+
}
71+
72+
func doesNotUseConcurrency(counter: MyCounter) {
73+
runOnSeparateTask {
74+
counter.value += 1 // no warning, because this code hasn't adopted concurrency
75+
}
76+
}
77+
78+
func usesConcurrency(counter: MyCounter) async {
79+
runOnSeparateTask {
80+
counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
81+
}
82+
}
83+
```
84+
85+
One can enable warnings about data race safety within a module with the
86+
`-warn-concurrency` compiler option. When using a module that does not yet
87+
provide `Sendable` annotations, one can suppress warnings for types from that
88+
module by marking the import with `@preconcurrency`:
89+
90+
```swift
91+
/// module C
92+
public struct Point {
93+
public var x, y: Double
94+
}
95+
96+
// module D
97+
@preconcurrency import C
98+
99+
func centerView(at location: Point) {
100+
Task {
101+
await mainView.center(at: location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
102+
}
103+
}
104+
```
105+
106+
* [SE-0331][]:
107+
108+
The conformance of the unsafe pointer types (e.g., `UnsafePointer`,
109+
`UnsafeMutableBufferPointer`) to the `Sendable` protocols has been removed,
110+
because pointers cannot safely be transferred across task or actor boundaries.
111+
9112
* References to `Self` or so-called "`Self` requirements" in the type signatures
10113
of protocol members are now correctly detected in the parent of a nested type.
11114
As a result, protocol members that fall under this overlooked case are no longer
@@ -26,7 +129,7 @@ Swift 5.6
26129
// protocol type (use a generic constraint instead).
27130
_ = p.method
28131
}
29-
```
132+
```
30133

31134
* [SE-0324][]:
32135

@@ -53,6 +156,13 @@ Swift 5.6
53156
}
54157
```
55158

159+
* [SE-0322][]:
160+
161+
The standard library now provides a new operation
162+
`withUnsafeTemporaryAllocation` which provides an efficient temporarily
163+
allocation within a limited scope, which will be optimized to use stack
164+
allocation when possible.
165+
56166
* [SE-0315][]:
57167

58168
Type expressions and annotations can now include "type placeholders" which
@@ -8753,14 +8863,19 @@ Swift 1.0
87538863
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
87548864
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
87558865
[SE-0300]: <https://github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
8866+
[SE-0302]: <https://github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md>
87568867
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
87578868
[SE-0310]: <https://github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
87588869
[SE-0311]: <https://github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
87598870
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
87608871
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
87618872
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8873+
[SE-0322]: <https://github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
87628874
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87638875
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
8876+
[SE-0331]: <https://github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
8877+
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
8878+
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
87648879

87658880
[SR-75]: <https://bugs.swift.org/browse/SR-75>
87668881
[SR-106]: <https://bugs.swift.org/browse/SR-106>

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,6 @@ set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.8" CACHE STRING
304304
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
305305
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
306306

307-
#
308-
# User-configurable ICU specific options for Android, FreeBSD, Linux, Haiku, and WASI.
309-
#
310-
311-
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU;WASI)
312-
foreach(arch aarch64;armv6;armv7;i686;powerpc64;powerpc64le;s390x;wasm32;x86_64)
313-
set(SWIFT_${sdk}_${arch}_ICU_UC "" CACHE STRING
314-
"Path to a directory containing the icuuc library for ${sdk}")
315-
set(SWIFT_${sdk}_${arch}_ICU_UC_INCLUDE "" CACHE STRING
316-
"Path to a directory containing headers for icuuc for ${sdk}")
317-
set(SWIFT_${sdk}_${arch}_ICU_I18N "" CACHE STRING
318-
"Path to a directory containing the icui18n library for ${sdk}")
319-
set(SWIFT_${sdk}_${arch}_ICU_I18N_INCLUDE "" CACHE STRING
320-
"Path to a directory containing headers icui18n for ${sdk}")
321-
endforeach()
322-
endforeach()
323-
324307
#
325308
# User-configurable Darwin-specific options.
326309
#

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @apple/swift5-branch-managers

cmake/modules/StandaloneOverlay.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# In some configurations (e.g. back deploy concurrency) we
2+
# configure the build from the root of the Swift repo but we skip
3+
# stdlib/CMakeLists.txt, with the risk of missing important parameters.
4+
# To account for this scenario, we include the stdlib options
5+
# before the guard
6+
include(${CMAKE_CURRENT_LIST_DIR}/../../stdlib/cmake/modules/StdlibOptions.cmake)
7+
18
# CMAKE_SOURCE_DIR is the directory that cmake got initially invoked on.
29
# CMAKE_CURRENT_SOURCE_DIR is the current directory. If these are equal, it's
310
# a top-level build of the CMAKE_SOURCE_DIR. Otherwise, define a guard variable
@@ -85,10 +92,6 @@ set(SWIFT_DARWIN_MODULE_ARCHS "" CACHE STRING
8592
targets on Darwin platforms. These targets are in addition to the full \
8693
library targets.")
8794

88-
option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
89-
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
90-
TRUE)
91-
9295
# -----------------------------------------------------------------------------
9396
# Constants
9497

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function(_report_sdk prefix)
6363
if(NOT prefix IN_LIST SWIFT_DARWIN_PLATFORMS)
6464
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
6565
message(STATUS " ${arch} libc header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}")
66-
message(STATUS " ${arch} libc architecture specific header path: ${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY}")
6766
endforeach()
6867
endif()
6968

@@ -288,7 +287,6 @@ macro(configure_sdk_unix name architectures)
288287
swift_android_sysroot(android_sysroot)
289288
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${android_sysroot}")
290289
set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library headers")
291-
set(SWIFT_SDK_ANDROID_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${android_sysroot}/usr/include" CACHE STRING "Path to C library architecture headers")
292290

293291
if("${arch}" STREQUAL "armv7")
294292
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
@@ -320,10 +318,8 @@ macro(configure_sdk_unix name architectures)
320318

321319
if("${prefix}" STREQUAL "HAIKU")
322320
set(SWIFT_SDK_HAIKU_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "/system/develop/headers/posix" CACHE STRING "Path to C library headers")
323-
set(SWIFT_SDK_HAIKU_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "/system/develop/headers" CACHE STRING "Path to C library architecture headers")
324321
else()
325322
set(SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY "/usr/include" CACHE STRING "Path to C library headers")
326-
set(SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_SDK_${prefix}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY}/${CMAKE_LIBRARY_ARCHITECTURE}" CACHE STRING "Path to C library architecture headers")
327323
endif()
328324

329325
if("${prefix}" STREQUAL "LINUX")
@@ -373,7 +369,6 @@ macro(configure_sdk_unix name architectures)
373369
set(SWIFT_SDK_WASI_ARCH_wasm32_PATH "${SWIFT_WASI_SYSROOT_PATH}")
374370
set(SWIFT_SDK_WASI_ARCH_wasm32_TRIPLE "wasm32-unknown-wasi")
375371
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASI_SYSROOT_PATH}/include")
376-
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASI_SYSROOT_PATH}/include")
377372
else()
378373
message(FATAL_ERROR "unknown Unix OS: ${prefix}")
379374
endif()

docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ Types
619619
type-list ::= empty-list
620620

621621
// FIXME: Consider replacing 'h' with a two-char code
622-
list-type ::= type identifier? 'Yk'? 'z'? 'h'? 'n'? 'Yi'? 'd'? // type with optional label, '@noDerivative', inout convention, shared convention, owned convention, actor 'isolated', and variadic specifier
622+
list-type ::= type identifier? 'Yk'? 'z'? 'h'? 'n'? 'Yi'? 'd'? 'Yt'? // type with optional label, '@noDerivative', inout convention, shared convention, owned convention, actor 'isolated', variadic specifier, and compile-time constant
623623

624624
METATYPE-REPR ::= 't' // Thin metatype representation
625625
METATYPE-REPR ::= 'T' // Thick metatype representation

docs/Android.md

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,22 @@ To follow along with this guide, you'll need:
4343

4444
## "Hello, world" on Android
4545

46-
### 1. Downloading (or building) the Swift Android stdlib dependencies
46+
### 1. Building the Swift stdlib for Android
4747

48-
You may have noticed that, in order to build the Swift stdlib for Linux, you
49-
needed to `apt-get install libicu-dev icu-devtools`. Similarly, building
50-
the Swift stdlib for Android requires the libiconv and libicu libraries.
51-
However, you'll need versions of these libraries that work on Android devices.
52-
53-
The steps are as follows:
54-
55-
1. Ensure you have `curl`, `autoconf`, `automake`, `libtool`, and
56-
`git` installed.
57-
2. Clone the [SwiftAndroid/libiconv-libicu-android](https://github.com/SwiftAndroid/libiconv-libicu-android)
58-
project. From the command-line, run the following command:
59-
`git clone https://github.com/SwiftAndroid/libiconv-libicu-android.git`.
60-
3. From the command-line, run `which ndk-build`. Confirm that the path to
61-
the `ndk-build` executable in the Android NDK you downloaded is displayed.
62-
If not, you may need to add the Android NDK directory to your `PATH`.
63-
4. Change directories into `libiconv-libicu-android`: `cd libiconv-libicu-android`
64-
5. Run the Swift build script: `./build-swift.sh`
65-
6. Confirm that the various `libicuXYZswift.so` libraries are located in the
66-
`armeabi-v7a` directory.
67-
68-
### 2. Building the Swift stdlib for Android
69-
70-
Enter your Swift directory, then run the build script, passing paths to the
71-
Android NDK, as well as the directories that contain the `libicuucswift.so` and
72-
`libicui18nswift.so` you downloaded or built in step one:
48+
Enter your Swift directory, then run the build script, passing the path to the
49+
Android NDK:
7350

7451
```
75-
$ ARM_DIR=path/to/libiconv-libicu-android/armeabi-v7a
7652
$ NDK_PATH=path/to/android-ndk-r23b
7753
$ utils/build-script \
7854
-R \ # Build in ReleaseAssert mode.
7955
--android \ # Build for Android.
8056
--android-ndk $NDK_PATH \ # Path to an Android NDK.
8157
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64 or x86_64
82-
--android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater.
83-
--android-icu-uc ${ARM_DIR}/libicuucswift.so \
84-
--android-icu-uc-include ${ARM_DIR}/icu/source/common \
85-
--android-icu-i18n ${ARM_DIR}/libicui18nswift.so \
86-
--android-icu-i18n-include ${ARM_DIR}/icu/source/i18n \
87-
--android-icu-data ${ARM_DIR}/libicudataswift.so
58+
--android-api-level 21 # The Android API level to target. Swift only supports 21 or greater.
8859
```
8960

90-
### 3. Compiling `hello.swift` to run on an Android device
61+
### 2. Compiling `hello.swift` to run on an Android device
9162

9263
Create a simple Swift file named `hello.swift`:
9364

@@ -121,7 +92,7 @@ This is exactly the error we want: the executable is built to run on an
12192
Android device--it does not run on Linux. Next, let's deploy it to an Android
12293
device in order to execute it.
12394

124-
### 4. Deploying the build products to the device
95+
### 3. Deploying the build products to the device
12596

12697
You can use the `adb push` command to copy build products from your Linux
12798
environment to your Android device. If you haven't already installed `adb`,
@@ -142,14 +113,6 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
142113
$ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswiftRemoteMirror.so /data/local/tmp
143114
```
144115

145-
You will also need to push the icu libraries:
146-
147-
```
148-
adb push /path/to/libicu-android/armeabi-v7a/libicudataswift.so /data/local/tmp
149-
adb push /path/to/libicu-android/armeabi-v7a/libicui18nswift.so /data/local/tmp
150-
adb push /path/to/libicu-android/armeabi-v7a/libicuucswift.so /data/local/tmp
151-
```
152-
153116
In addition, you'll also need to copy the Android NDK's libc++:
154117

155118
```
@@ -162,7 +125,7 @@ previous step:
162125
$ adb push hello /data/local/tmp
163126
```
164127

165-
### 5. Running "Hello, world" on your Android device
128+
### 4. Running "Hello, world" on your Android device
166129

167130
You can use the `adb shell` command to execute the `hello` executable on
168131
the Android device:
@@ -182,7 +145,7 @@ Congratulations! You've just run your first Swift program on Android.
182145
## Running the Swift test suite hosted on an Android device
183146

184147
When running the test suite, build products are automatically pushed to your
185-
device. As in part four, you'll need to connect your Android device via USB:
148+
device. As in part three, you'll need to connect your Android device via USB:
186149

187150
1. Connect your Android device to your computer via USB. Ensure that remote
188151
debugging is enabled for that device by following the official instructions:
@@ -198,10 +161,5 @@ $ utils/build-script \
198161
--android \ # Build for Android.
199162
--android-ndk ~/android-ndk-r23b \ # Path to an Android NDK.
200163
--android-arch armv7 \ # Optionally specify Android architecture, alternately aarch64
201-
--android-ndk-version 21 \
202-
--android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
203-
--android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
204-
--android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
205-
--android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/ \
206-
--android-icu-data ~/libicu-android/armeabi-v7a/libicudata.so
164+
--android-ndk-version 21
207165
```

docs/AndroidBuild.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ cmake -C S:\swift-build\cmake\caches\android-armv7.cmake
7474
-DANDROID_ALTERNATE_TOOLCHAIN=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr ^
7575
-DLLVM_DIR=S:/b/a/llvm/lib/cmake/llvm ^
7676
-DSWIFT_NATIVE_SWIFT_TOOLS_PATH=S:/b/a/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain/usr/bin ^
77-
-DSWIFT_ANDROID_armv7_ICU_UC_INCLUDE=S:/b/a/Library/icu-64/usr/include/unicode ^
78-
-DSWIFT_ANDROID_armv7_ICU_UC=S:/b/a/Library/icu-64/usr/lib/libicuuc64.so ^
79-
-DSWIFT_ANDROID_armv7_ICU_I18N_INCLUDE=S:/b/a/Library/icu-64/usr/include ^
80-
-DSWIFT_ANDROID_armv7_ICU_I18N=S:/b/a/Library/icu-64/usr/lib/libicuin64.so ^
8177
S:/swift
8278
ninja
8379
ninja install

docs/WindowsBuild.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ structure should resemble:
9292
┕ usr/...
9393
```
9494

95-
Note that only ICU is required for building the toolchain, and SQLite is only
95+
Note that ICU is only required for building Foundation, and SQLite is only
9696
needed for building llbuild and onwards. The ICU project provides binaries,
9797
alternatively, see the ICU project for details on building ICU from source.
9898

@@ -134,10 +134,6 @@ cmake -B "S:\b\1" ^
134134
-D LLVM_EXTERNAL_CMARK_SOURCE_DIR=S:\cmark ^
135135
-D LLVM_EXTERNAL_SWIFT_SOURCE_DIR=S:\swift ^
136136
-D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=S:\swift-corelibs-libdispatch ^
137-
-D SWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE=S:\Library\icu-67\usr\include ^
138-
-D SWIFT_WINDOWS_x86_64_ICU_I18N=S:\Library\icu-67\usr\lib\icuin67.lib ^
139-
-D SWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE=S:\Library\icu-67\usr\include ^
140-
-D SWIFT_WINDOWS_x86_64_ICU_UC=S:\Library\icu-67\usr\lib\icuuc67.lib ^
141137
-G Ninja ^
142138
-S S:\llvm-project\llvm
143139

0 commit comments

Comments
 (0)