Skip to content

Commit 61b19c8

Browse files
authored
Merge branch 'main' into import-extension-visibility
2 parents fa88348 + ffa8c9a commit 61b19c8

File tree

1,765 files changed

+54310
-27400
lines changed

Some content is hidden

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

1,765 files changed

+54310
-27400
lines changed

CHANGELOG.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,38 @@
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+
739
* [SE-0408][]:
840
A `for`-`in` loop statement can now accept a pack expansion expression,
941
enabling iteration over the elements of its respective value pack. This form
@@ -198,7 +230,9 @@
198230

199231
## Swift 5.10
200232

201-
* 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
202236
concurrency checking.
203237

204238
When writing code against `-strict-concurrency=complete`, Swift 5.10 will

CMakeLists.txt

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ 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()
@@ -217,10 +222,6 @@ option(SWIFT_BUILD_REMOTE_MIRROR
217222
"Build the Swift Remote Mirror Library"
218223
TRUE)
219224

220-
option(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER
221-
"Build the Swift External Generic Metadata Builder Library"
222-
TRUE)
223-
224225
option(SWIFT_BUILD_DYNAMIC_STDLIB
225226
"Build dynamic variants of the Swift standard library"
226227
TRUE)
@@ -360,9 +361,11 @@ How swift-C++ bridging code is compiled:
360361
]=] DEFAULT)
361362

362363
option(SWIFT_USE_SYMLINKS "Use symlinks instead of copying binaries" ${CMAKE_HOST_UNIX})
363-
set(SWIFT_COPY_OR_SYMLINK "copy")
364+
set(SWIFT_COPY_OR_SYMLINK "copy_if_different")
365+
set(SWIFT_COPY_OR_SYMLINK_DIR "copy_directory")
364366
if(SWIFT_USE_SYMLINKS)
365367
set(SWIFT_COPY_OR_SYMLINK "create_symlink")
368+
set(SWIFT_COPY_OR_SYMLINK_DIR "create_symlink")
366369
endif()
367370

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

493+
#
494+
# User-configurable WebAssembly specific options.
495+
#
496+
497+
option(SWIFT_ENABLE_WASI_THREADS
498+
"Build the Standard Library with WASI threads support"
499+
FALSE)
500+
490501
#
491502
# User-configurable Darwin-specific options.
492503
#
@@ -653,8 +664,8 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
653664
"Enable experimental distributed actors and functions"
654665
FALSE)
655666

656-
option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
657-
"Enable experimental NoncopyableGenerics"
667+
option(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES
668+
"Enable experimental NonescapableTypes"
658669
FALSE)
659670

660671
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
@@ -965,6 +976,18 @@ endif()
965976
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
966977
"Build Swift with a non-default linker")
967978

979+
include(CheckLinkerFlag)
980+
981+
# Apple's linker complains about duplicate libraries, which CMake likes to do
982+
# to support ELF platforms. To silence that warning, we can use
983+
# -no_warn_duplicate_libraries, but only in versions of the linker that
984+
# support that flag.
985+
if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
986+
check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
987+
else()
988+
set(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
989+
endif()
990+
968991
#
969992
# Enable additional warnings.
970993
#
@@ -1252,7 +1275,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12521275
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
12531276
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12541277
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1255-
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
1278+
message(STATUS "NonEscapableTypes Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES}")
12561279
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12571280
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
12581281
message(STATUS "Unicode Support: ${SWIFT_STDLIB_ENABLE_UNICODE_DATA}")
@@ -1274,11 +1297,6 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
12741297
message(STATUS "")
12751298
endif()
12761299

1277-
if(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER)
1278-
message(STATUS "Building Swift External Generic Metadata Builder for SDKs: ${SWIFT_SDKS}")
1279-
message(STATUS "")
1280-
endif()
1281-
12821300
#
12831301
# Find required dependencies.
12841302
#

README.md

Lines changed: 6 additions & 1 deletion
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

Lines changed: 12 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ struct InstructionRange : CustomStringConvertible, NoReflectionChildren {
6060
}
6161

6262
init(for value: Value, _ context: some Context) {
63-
var begin: Instruction
63+
self = InstructionRange(begin: InstructionRange.beginningInstruction(for: value), context)
64+
}
65+
66+
static func beginningInstruction(for value: Value) -> Instruction {
6467
if let def = value.definingInstruction {
65-
begin = def
68+
return def
6669
} 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!
70+
return result.terminator
7171
}
72-
self = InstructionRange(begin: begin, context)
72+
assert(Phi(value) != nil || value is FunctionArgument)
73+
return value.parentBlock.instructions.first!
7374
}
7475

7576
/// Insert a potential end instruction.

SwiftCompilerSources/Sources/Optimizer/DataStructures/Set.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,55 @@ struct InstructionSet : IntrusiveSet {
176176
context.freeNodeSet(bridged)
177177
}
178178
}
179+
180+
/// A set of operands.
181+
///
182+
/// This is an extremely efficient implementation which does not need memory
183+
/// allocations or hash lookups.
184+
///
185+
/// This type should be a move-only type, but unfortunately we don't have move-only
186+
/// types yet. Therefore it's needed to call `deinitialize()` explicitly to
187+
/// destruct this data structure, e.g. in a `defer {}` block.
188+
struct OperandSet : IntrusiveSet {
189+
190+
private let context: BridgedPassContext
191+
private let bridged: BridgedOperandSet
192+
193+
init(_ context: some Context) {
194+
self.context = context._bridged
195+
self.bridged = self.context.allocOperandSet()
196+
}
197+
198+
func contains(_ operand: Operand) -> Bool {
199+
bridged.contains(operand.bridged)
200+
}
201+
202+
/// Returns true if `inst` was not contained in the set before inserting.
203+
@discardableResult
204+
mutating func insert(_ operand: Operand) -> Bool {
205+
bridged.insert(operand.bridged)
206+
}
207+
208+
mutating func erase(_ operand: Operand) {
209+
bridged.erase(operand.bridged)
210+
}
211+
212+
var description: String {
213+
let function = bridged.getFunction().function
214+
var d = "{\n"
215+
for inst in function.instructions {
216+
for op in inst.operands {
217+
if contains(op) {
218+
d += op.description
219+
}
220+
}
221+
}
222+
d += "}\n"
223+
return d
224+
}
225+
226+
/// TODO: once we have move-only types, make this a real deinit.
227+
mutating func deinitialize() {
228+
context.freeOperandSet(bridged)
229+
}
230+
}

SwiftCompilerSources/Sources/Optimizer/DataStructures/Worklist.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ struct Worklist<Set: IntrusiveSet> : CustomStringConvertible, NoReflectionChildr
7575
typealias BasicBlockWorklist = Worklist<BasicBlockSet>
7676
typealias InstructionWorklist = Worklist<InstructionSet>
7777
typealias ValueWorklist = Worklist<ValueSet>
78+
typealias OperandWorklist = Worklist<OperandSet>

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/AllocVectorLowering.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ private struct ComputeNonEscapingLiferange : EscapeVisitorWithResult {
414414
if dominates {
415415
liferange.insert(user)
416416
}
417-
if !apply.type.isEscapable {
417+
if !apply.isEscapable {
418418
return .abort
419419
}
420420
return .ignore

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/InitializeStaticGlobals.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ private func getSequenceOfElementStores(firstStore: StoreInst) -> ([StoreInst],
113113
return nil
114114
}
115115
let structAddr = elementAddr.struct
116-
if structAddr.type.isMoveOnly {
116+
let structType = structAddr.type
117+
if structType.isMoveOnly {
117118
return nil
118119
}
119-
guard let fields = structAddr.type.getNominalFields(in: firstStore.parentFunction) else {
120+
if structType.nominal.isStructWithUnreferenceableStorage {
121+
return nil
122+
}
123+
guard let fields = structType.getNominalFields(in: firstStore.parentFunction) else {
120124
return nil
121125
}
122126
let numElements = fields.count

0 commit comments

Comments
 (0)