Skip to content

Commit 2c15456

Browse files
authored
Merge branch 'main' into curl
2 parents dd5d6fa + c531f29 commit 2c15456

File tree

2,629 files changed

+87570
-38239
lines changed

Some content is hidden

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

2,629 files changed

+87570
-38239
lines changed

CHANGELOG.md

+92-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,93 @@
11
# CHANGELOG
22

3-
> **Note**\
3+
> [!NOTE]
44
> This is in reverse chronological order, so newer entries are added to the top.
55
66
## Swift 6.0
7+
8+
* Swift 5.10 missed a semantic check from [SE-0309][]. In type context, a reference to a
9+
protocol `P` that has associated types or `Self` requirements should use
10+
the `any` keyword, but this was not enforced in nested generic argument positions.
11+
This is now an error as required by the proposal:
12+
13+
```swift
14+
protocol P { associatedtype A }
15+
struct Outer<T> { struct Inner<U> { } }
16+
let x = Outer<P>.Inner<P>() // error
17+
```
18+
To correct the error, add `any` where appropriate, for example
19+
`Outer<any P>.Inner<any P>`.
20+
21+
* Swift 5.10 accepted certain invalid opaque return types from [SE-0346][].
22+
If a generic argument of a constrained opaque return type did not
23+
satisfy the requirements on the primary associated type, the generic
24+
argument was silently ignored and type checking would proceed as if it
25+
weren't stated. This now results in a diagnostic:
26+
27+
```swift
28+
protocol P<A> { associatedtype A: Sequence }
29+
struct G<A: Sequence>: P {}
30+
31+
func f() -> some P<Int> { return G<Array<Int>>() } // error
32+
```
33+
34+
The return type above should be written as `some P<Array<Int>>` to match
35+
the return statement. The old broken behavior in this situation can also
36+
be restored, by removing the erroneous constraint and using the more general
37+
upper bound `some P`.
38+
39+
* [SE-0408][]:
40+
A `for`-`in` loop statement can now accept a pack expansion expression,
41+
enabling iteration over the elements of its respective value pack. This form
42+
supports pattern matching, control transfer statements, and other features
43+
available to a `Sequence`-driven `for`-`in` loop, except for the `where`
44+
clause. Below is an example implementation of the equality operator for
45+
tuples of arbitrary length using pack iteration:
46+
47+
```swift
48+
func == <each Element: Equatable>(lhs: (repeat each Element),
49+
rhs: (repeat each Element)) -> Bool {
50+
51+
for (left, right) in repeat (each lhs, each rhs) {
52+
guard left == right else { return false }
53+
}
54+
return true
55+
}
56+
```
57+
58+
The elements of the value pack corresponding to the pack expansion expression
59+
are evaluated on demand, meaning the i<sup>th</sup> element is evaluated on
60+
the i<sup>th</sup> iteration:
61+
62+
```swift
63+
func doSomething(_: some Any) {}
64+
65+
func evaluateFirst<each T>(_ t: repeat each T) {
66+
for _ in repeat doSomething(each t) {
67+
break
68+
}
69+
}
70+
71+
evaluateFirst(1, 2, 3)
72+
// 'doSomething' will be called only on the first element of the pack.
73+
```
74+
75+
* [SE-0352][]:
76+
The Swift 6 language mode will open existential values with
77+
"self-conforming" types (such as `any Error` or `@objc` protocols)
78+
passed to generic functions. For example:
79+
80+
```swift
81+
func takeError<E: Error>(_ error: E) { }
82+
83+
func passError(error: any Error) {
84+
takeError(error) // Swift 5 does not open `any Error`, Swift 6 does
85+
}
86+
```
87+
88+
This behavior can be enabled prior to the Swift 6 language mode
89+
using the upcoming language feature `ImplicitOpenExistentials`.
90+
791
* [SE-0422][]:
892
Non-built-in expression macros can now be used as default arguments that
993
expand at each call site. For example, a custom `#CurrentFile` macro used as
@@ -146,7 +230,9 @@
146230

147231
## Swift 5.10
148232

149-
* Swift 5.10 closes all known static data-race safey holes in complete strict
233+
### 2024-03-05 (Xcode 15.3)
234+
235+
* Swift 5.10 closes all known static data-race safety holes in complete strict
150236
concurrency checking.
151237

152238
When writing code against `-strict-concurrency=complete`, Swift 5.10 will
@@ -285,6 +371,8 @@ concurrency checking.
285371

286372
## Swift 5.9.2
287373

374+
### 2023-12-11 (Xcode 15.1)
375+
288376
* [SE-0407][]:
289377

290378
Member macros can specify a list of protocols via the `conformances` argument to the macro role. The macro implementation will be provided with those protocols that are listed but have not already been implemented by the type to which the member macro is attached, in the same manner as extension macros.
@@ -10129,10 +10217,12 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1012910217
[SE-0394]: https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md
1013010218
[SE-0397]: https://github.com/apple/swift-evolution/blob/main/proposals/0397-freestanding-declaration-macros.md
1013110219
[SE-0407]: https://github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
10220+
[SE-0408]: https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
1013210221
[SE-0411]: https://github.com/apple/swift-evolution/blob/main/proposals/0411-isolated-default-values.md
1013310222
[SE-0417]: https://github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md
1013410223
[SE-0412]: https://github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md
1013510224
[SE-0413]: https://github.com/apple/swift-evolution/blob/main/proposals/0413-typed-throws.md
10225+
[SE-0422]: https://github.com/apple/swift-evolution/blob/main/proposals/0422-caller-side-default-argument-macro-expression.md
1013610226
[#64927]: <https://github.com/apple/swift/issues/64927>
1013710227
[#42697]: <https://github.com/apple/swift/issues/42697>
1013810228
[#42728]: <https://github.com/apple/swift/issues/42728>

CMakeLists.txt

+44-23
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ include(FetchContent)
100100
# optional until we have a bootstrap story.
101101
check_language(Swift)
102102
if(CMAKE_Swift_COMPILER)
103+
# we are not interested in logging any Swift module used
104+
# when configuring the build system -- those are not useful
105+
# since they will not contribute to the build of the compiler itself
106+
unset(ENV{SWIFT_LOADED_MODULE_TRACE_FILE})
107+
103108
enable_language(Swift)
104109
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION "${CMAKE_Swift_COMPILER_VERSION}")
105110
else()
106-
message(STATUS "WARNING! Did not find a host compiler swift?! Can not build
107-
any compiler host sources written in Swift")
111+
message(WARNING "Swift compiler not found on path.
112+
Cannot build compiler sources written in Swift.
113+
If this is unexpected, please pass the path to the swiftc binary by defining the `CMAKE_Swift_COMPILER` variable.")
108114
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION)
109115
endif()
110116

@@ -217,10 +223,6 @@ option(SWIFT_BUILD_REMOTE_MIRROR
217223
"Build the Swift Remote Mirror Library"
218224
TRUE)
219225

220-
option(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER
221-
"Build the Swift External Generic Metadata Builder Library"
222-
TRUE)
223-
224226
option(SWIFT_BUILD_DYNAMIC_STDLIB
225227
"Build dynamic variants of the Swift standard library"
226228
TRUE)
@@ -238,6 +240,10 @@ option(SWIFT_STDLIB_ENABLE_UNICODE_DATA
238240
NOTE: Disabling this will cause many String methods to crash."
239241
TRUE)
240242

243+
option(SWIFT_BUILD_CLANG_OVERLAYS
244+
"Build Swift overlays for the clang builtin modules"
245+
TRUE)
246+
241247
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
242248
"Build dynamic variants of the Swift SDK overlay"
243249
TRUE)
@@ -356,9 +362,11 @@ How swift-C++ bridging code is compiled:
356362
]=] DEFAULT)
357363

358364
option(SWIFT_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX})
359-
set(SWIFT_COPY_OR_SYMLINK "copy")
365+
set(SWIFT_COPY_OR_SYMLINK "copy_if_different")
366+
set(SWIFT_COPY_OR_SYMLINK_DIR "copy_directory")
360367
if(SWIFT_USE_SYMLINKS)
361368
set(SWIFT_COPY_OR_SYMLINK "create_symlink")
369+
set(SWIFT_COPY_OR_SYMLINK_DIR "create_symlink")
362370
endif()
363371

364372
# The following only works with the Ninja generator in CMake >= 3.0.
@@ -483,6 +491,14 @@ set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
483491
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
484492
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
485493

494+
#
495+
# User-configurable WebAssembly specific options.
496+
#
497+
498+
option(SWIFT_ENABLE_WASI_THREADS
499+
"Build the Standard Library with WASI threads support"
500+
FALSE)
501+
486502
#
487503
# User-configurable Darwin-specific options.
488504
#
@@ -649,8 +665,8 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
649665
"Enable experimental distributed actors and functions"
650666
FALSE)
651667

652-
option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
653-
"Enable experimental NoncopyableGenerics"
668+
option(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES
669+
"Enable experimental NonescapableTypes"
654670
FALSE)
655671

656672
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
@@ -944,6 +960,10 @@ if(XCODE)
944960
swift_common_xcode_cxx_config()
945961
endif()
946962

963+
# Check what linux distribution is being used.
964+
# This can be used to determine the default linker to use.
965+
cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME)
966+
947967
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
948968
# our own defaults. This should only be possible in a unified (not stand alone)
949969
# build environment.
@@ -955,12 +975,26 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQ
955975
set(SWIFT_USE_LINKER_default "lld")
956976
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
957977
set(SWIFT_USE_LINKER_default "")
978+
elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023")
979+
set(SWIFT_USE_LINKER_default "lld")
958980
else()
959981
set(SWIFT_USE_LINKER_default "gold")
960982
endif()
961983
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
962984
"Build Swift with a non-default linker")
963985

986+
include(CheckLinkerFlag)
987+
988+
# Apple's linker complains about duplicate libraries, which CMake likes to do
989+
# to support ELF platforms. To silence that warning, we can use
990+
# -no_warn_duplicate_libraries, but only in versions of the linker that
991+
# support that flag.
992+
if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
993+
check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
994+
else()
995+
set(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
996+
endif()
997+
964998
#
965999
# Enable additional warnings.
9661000
#
@@ -1248,7 +1282,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12481282
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
12491283
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12501284
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1251-
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
1285+
message(STATUS "NonEscapableTypes Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES}")
12521286
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12531287
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
12541288
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")
@@ -1270,11 +1304,6 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
12701304
message(STATUS "")
12711305
endif()
12721306

1273-
if(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER)
1274-
message(STATUS "Building Swift External Generic Metadata Builder for SDKs: ${SWIFT_SDKS}")
1275-
message(STATUS "")
1276-
endif()
1277-
12781307
#
12791308
# Find required dependencies.
12801309
#
@@ -1381,14 +1410,6 @@ endif()
13811410
add_subdirectory(include)
13821411

13831412
if(SWIFT_INCLUDE_TOOLS)
1384-
# TODO Remove this once release/5.9 is done and we can finish migrating Swift
1385-
# off of `llvm::None`/`llvm::Optional`, and `llvm::makeArrayRef`.
1386-
# This is to silence the avalanche of deprecation warnings from LLVM headers
1387-
# until we can actually do something about them. This is nasty, but it's
1388-
# better than losing context due to the sheer number in-actionable deprecation
1389-
# warnings or the massive number of merge-conflicts we would get otherwise.
1390-
add_definitions(-DSWIFT_TARGET)
1391-
13921413
add_subdirectory(lib)
13931414

13941415
add_subdirectory(SwiftCompilerSources)

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@
1919
| **Amazon Linux 2** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64)|
2020
| **Universal Base Image 9** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubi-9/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubi-9)|
2121

22+
**Cross-Compilation Targets**
23+
24+
| **Target** | **Build** |
25+
|:---:|:---:|
26+
| **wasm32-unknown-wasi** |[![Build Status](https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04)|
27+
2228
**Swift Community-Hosted CI Platforms**
2329

2430
| **OS** | **Architecture** | **Build** |
2531
|---|:---:|:---:|
26-
|**[Ubuntu 20.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/wasm32_ubuntu_20.04.json)** | wasm32 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly)|
2732
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
2833
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|
2934
|**[Windows 2019 (VS 2019)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_windows_2019_VS2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019)|

SwiftCompilerSources/CMakeLists.txt

+12-3
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ function(add_swift_compiler_modules_library name)
9898
"DEPENDS"
9999
${ARGN})
100100

101+
# Prior to 5.9, we have to use the experimental flag for C++ interop.
102+
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9)
103+
set(cxx_interop_flag "-enable-experimental-cxx-interop")
104+
else()
105+
set(cxx_interop_flag "-cxx-interoperability-mode=default")
106+
endif()
107+
101108
set(swift_compile_options
102109
"-color-diagnostics"
103110
"-Xfrontend" "-validate-tbd-against-ir=none"
104-
"-Xfrontend" "-enable-experimental-cxx-interop"
111+
"${cxx_interop_flag}"
105112
"-Xfrontend" "-disable-target-os-checking"
106113
"-Xcc" "-std=c++17"
107114
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
@@ -148,10 +155,9 @@ function(add_swift_compiler_modules_library name)
148155
list(APPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
149156
endif()
150157
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
151-
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
152158
# NOTE: prepending allows SWIFT_COMPILER_SOURCES_SDK_FLAGS to override the
153159
# resource directory if needed.
154-
list(PREPEND sdk_option "-resource-dir" "${swift_exec_bin_dir}/../lib/swift")
160+
list(PREPEND sdk_option "-resource-dir" "${SWIFTLIB_DIR}")
155161
endif()
156162
get_versioned_target_triple(target ${SWIFT_HOST_VARIANT_SDK}
157163
${SWIFT_HOST_VARIANT_ARCH} "${deployment_version}")
@@ -225,6 +231,9 @@ function(add_swift_compiler_modules_library name)
225231
importedHeaderDependencies
226232
COMMENT "Building swift module ${module}")
227233

234+
if(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
235+
add_dependencies(${dep_target} swift-stdlib-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
236+
endif()
228237
set("${module}_dep_target" ${dep_target})
229238
set(all_module_targets ${all_module_targets} ${dep_target})
230239
endforeach()

SwiftCompilerSources/Sources/Optimizer/Analysis/AliasAnalysis.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct AliasAnalysis {
6363
let path = SmallProjectionPath(.anyValueFields)
6464
if let apply = inst as? ApplySite {
6565
// Workaround for quadratic complexity in ARCSequenceOpts.
66-
// We need to use an ever lower budget to not get into noticable compile time troubles.
66+
// We need to use an ever lower budget to not get into noticeable compile time troubles.
6767
let budget = complexityBudget / 10
6868
let effect = getOwnershipEffect(of: apply, for: obj, path: path, complexityBudget: budget, context)
6969
return effect.destroy

SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift

+8-9
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,15 @@ struct InstructionRange : CustomStringConvertible, NoReflectionChildren {
6060
}
6161

6262
init(for value: Value, _ context: some Context) {
63-
var begin: Instruction
64-
if let def = value.definingInstruction {
65-
begin = def
66-
} else if let result = TerminatorResult(value) {
67-
begin = result.terminator
68-
} else {
69-
assert(Phi(value) != nil || value is FunctionArgument)
70-
begin = value.parentBlock.instructions.first!
63+
self = InstructionRange(begin: InstructionRange.beginningInstruction(for: value), context)
64+
}
65+
66+
static func beginningInstruction(for value: Value) -> Instruction {
67+
if let def = value.definingInstructionOrTerminator {
68+
return def
7169
}
72-
self = InstructionRange(begin: begin, context)
70+
assert(Phi(value) != nil || value is FunctionArgument)
71+
return value.parentBlock.instructions.first!
7372
}
7473

7574
/// Insert a potential end instruction.

0 commit comments

Comments
 (0)