Skip to content

Commit ae23892

Browse files
authored
Merge branch 'main' into wip-prevent-async-overloads-dist
2 parents 6b8642c + 7054460 commit ae23892

File tree

2,774 files changed

+106372
-40323
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,774 files changed

+106372
-40323
lines changed

.dir-locals.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
(add-to-list 'load-path
1212
(concat this-directory "utils")
1313
:append)
14+
(defvar swift-project-directory)
1415
(let ((swift-project-directory this-directory))
1516
(require 'swift-project-settings)))
1617
(set (make-local-variable 'swift-project-directory)

.flake8

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ ignore =
5151
# compliant (https://github.com/psf/black#slices).
5252
E203,
5353

54-
# FIXME: We should not have trailing whitespace.
55-
W291,
56-
5754
# Line breaks before binary operators are not explicitly disallowed in
5855
# PEP8, rather it should be consistent throughout the project. The black
5956
# tool puts them on new lines which is to be considered a best practice

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ assignees: ''
1010
**Describe the bug**
1111
A clear and concise description of what the bug is.
1212

13-
**To Reproduce**
13+
**Steps To Reproduce**
1414
Steps to reproduce the behavior:
1515
1.
1616
2.
@@ -22,7 +22,7 @@ A clear and concise description of what you expected to happen.
2222
**Screenshots**
2323
If applicable, add screenshots to help explain your problem.
2424

25-
**Environment (please complete the following information):**
25+
**Environment (please fill out the following information)**
2626
- OS: [e.g. macOS 11.0]
2727
- Xcode Version/Tag/Branch:
2828

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Resolves SR-NNNN.
77
<!--
88
Before merging this pull request, you must run the Swift continuous integration tests.
99
For information about triggering CI builds via @swift-ci, see:
10-
https://github.com/apple/swift/blob/master/docs/ContinuousIntegration.md#swift-ci
10+
https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci
1111
1212
Thank you for your contribution to Swift!
1313
-->

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,56 @@ CHANGELOG
33

44
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
55

6+
## Swift 5.8
7+
8+
* [SE-0362][]:
9+
10+
The compiler flag `-enable-upcoming-feature X` can now be used to enable a specific feature `X` that has been accepted by the evolution process, but whose introduction into the language is waiting for the next major version (e.g., version 6). The `X` is specified by any proposal that falls into this category:
11+
* `ConciseMagicFile` enables the new `#file` semantics in [SE-0274][].
12+
* `ForwardTrailingClosures` disables the "backward" scanning behavior of [SE-0286][].
13+
* `BareSlashRegexLiterals` enables the regex literal syntax of [SE-0354][].
14+
15+
Features can be detected in source code with `#if hasFeature(X)`.
16+
617
## Swift 5.7
718

19+
* [SE-0327][]:
20+
21+
There are a few notable changes in Swift 5.7 with respect to SE-0327.
22+
23+
First, the deinitializer and most kinds of initializers for `actor` types, and types constrained by a global actor like the `@MainActor`, have revised rules about what expressions are permitted in their body. The goal of these revisions has been to improve language expressivity and safety. In particular, many more programming patterns are now permitted in these initializers.
24+
25+
For example, a non-async initializer of an `actor` prior to Swift 5.7 would raise a diagnostic any time `self` escapes the initializer before returning. That diagnostic's purpose was to protect against a possible data race when accessing isolated stored proeprties. But, that diagnostic was emitted even if there was no dangerous racy access.
26+
27+
In Swift 5.7, the compiler now checks these initializers for dangerous accesses to isolated stored properties that occur after an escape of `self`:
28+
29+
```swift
30+
actor Database {
31+
// ... other properties ...
32+
var rows: Int = 0
33+
34+
init(_ world: DataUser) {
35+
defer {
36+
print("last = \(self.rows)") // ❌ this access to 'rows' is illegal.
37+
}
38+
39+
print("before = \(self.rows)") // ✅ this access to 'rows' is OK
40+
world.publishDatabase(self) // ✅ passing 'self' is OK in Swift 5.7+
41+
print("after = \(self.rows)") // ❌ this access to 'rows' is illegal.
42+
43+
Task { [weak self] in // ✅ capturing 'self' is OK in Swift 5.7+
44+
while let db = self { await db.prune() }
45+
}
46+
}
47+
}
48+
```
49+
50+
This is a control-flow sensitive check, meaning an illegal access does not necessarily appear on a source line after an escape of `self` (in the example above, consider _when_ the `defer` is executed). The compiler will always point out one of the escapes of `self` that is causing an access to become illegal.
51+
52+
Next, delegating initializers of an actor are no longer always non-isolated. This means an `async` delegating initializer can do the same things as a non-delegating one.
53+
54+
Finally, the diagnostic about non-isolated default-value expressions introduced for Swift 5.6 in the Xcode 13.3 release has been removed. The proposed rule was not precise enough to avoid flagging an innocuous yet common pattern in SwiftUI code involving `@StateObject` properties and `@MainActor`.
55+
856
* The Swift compiler no longer warns about redundant requirements in generic declarations. For example,
957
the following code diagnosed a warning in Swift 5.6 about the `T.Iterator : IteratorProtocol`
1058
requirement being redundant, because it is implied by `T : Sequence`:
@@ -9459,6 +9507,7 @@ Swift 1.0
94599507
[SE-0267]: <https://github.com/apple/swift-evolution/blob/main/proposals/0267-where-on-contextually-generic.md>
94609508
[SE-0268]: <https://github.com/apple/swift-evolution/blob/main/proposals/0268-didset-semantics.md>
94619509
[SE-0269]: <https://github.com/apple/swift-evolution/blob/main/proposals/0269-implicit-self-explicit-capture.md>
9510+
[SE-0274]: <https://github.com/apple/swift-evolution/blob/main/proposals/0274-magic-file.md>
94629511
[SE-0276]: <https://github.com/apple/swift-evolution/blob/main/proposals/0276-multi-pattern-catch-clauses.md>
94639512
[SE-0279]: <https://github.com/apple/swift-evolution/blob/main/proposals/0279-multiple-trailing-closures.md>
94649513
[SE-0280]: <https://github.com/apple/swift-evolution/blob/main/proposals/0280-enum-cases-as-protocol-witnesses.md>
@@ -9509,6 +9558,7 @@ Swift 1.0
95099558
[SE-0355]: <https://github.com/apple/swift-evolution/blob/main/proposals/0355-regex-syntax-run-time-construction.md>
95109559
[SE-0357]: <https://github.com/apple/swift-evolution/blob/main/proposals/0357-regex-string-processing-algorithms.md>
95119560
[SE-0358]: <https://github.com/apple/swift-evolution/blob/main/proposals/0358-primary-associated-types-in-stdlib.md>
9561+
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
95129562

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

CMakeLists.txt

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ option(SWIFT_STDLIB_ENABLE_UNICODE_DATA
192192
NOTE: Disabling this will cause many String methods to crash."
193193
TRUE)
194194

195-
include(Threading)
196-
197-
threading_package_default("${SWIFT_HOST_VARIANT_SDK}"
198-
SWIFT_THREADING_PACKAGE_default)
199-
200-
set(SWIFT_THREADING_PACKAGE "${SWIFT_THREADING_PACKAGE_default}"
201-
CACHE STRING
202-
"The threading package to use. Must be one of 'none', 'pthreads',
203-
'darwin', 'linux', 'win32', 'c11'.")
204-
205195
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
206196
"Build dynamic variants of the Swift SDK overlay"
207197
TRUE)
@@ -464,6 +454,15 @@ set(SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS "9.0" CACHE STRING
464454
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS "2.0" CACHE STRING
465455
"Minimum deployment target version for watchOS")
466456

457+
#
458+
# Compatibility library deployment versions
459+
#
460+
461+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9")
462+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
463+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
464+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
465+
467466
#
468467
# User-configurable debugging options.
469468
#
@@ -589,6 +588,12 @@ cmake_dependent_option(SWIFT_ENABLE_SOURCEKIT_TESTS
589588
"Enable running SourceKit tests" TRUE
590589
"SWIFT_BUILD_SOURCEKIT" FALSE)
591590

591+
option(SWIFT_THREADING_PACKAGE
592+
"Override the threading package used for the build. This can either be a
593+
single package name, or a semicolon separated sequence of sdk:package pairs.
594+
Valid package names are 'pthreads', 'darwin', 'linux', 'win32', 'c11', 'none'
595+
or the empty string for the SDK default.")
596+
592597
#
593598
# End of user-configurable options.
594599
#
@@ -618,6 +623,11 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
618623
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=c++98-compat-extra-semi>)
619624
endif()
620625

626+
# Make sure we know where swift-syntax is because we need it to build the parser.
627+
if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
628+
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
629+
endif()
630+
621631
# Use dispatch as the system scheduler by default.
622632
# For convenience, we set this to false when concurrency is disabled.
623633
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
@@ -725,6 +735,7 @@ get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
725735
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
726736
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
727737
set(SWIFT_MAIN_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/include")
738+
set(SWIFT_SHIMS_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/stdlib/public/SwiftShims")
728739
set(SWIFT_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
729740

730741
set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
@@ -745,7 +756,7 @@ elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
745756
else()
746757
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
747758
endif()
748-
elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
759+
elseif(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" OR SWIFT_SWIFT_PARSER)
749760
# We are building using a pre-installed host toolchain but not bootstrapping
750761
# the Swift modules. This happens when building using 'build-tooling-libs'
751762
# where we haven't built a new Swift compiler. Use the Swift compiler from the
@@ -775,6 +786,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
775786
include_directories(BEFORE
776787
${SWIFT_MAIN_INCLUDE_DIR}
777788
${SWIFT_INCLUDE_DIR}
789+
${SWIFT_SHIMS_INCLUDE_DIR}
778790
)
779791

780792
# Configuration flags passed to all of our invocations of gyb. Try to
@@ -820,6 +832,32 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQU
820832
set(SWIFT_COMPILER_IS_MSVC_LIKE TRUE)
821833
endif()
822834

835+
#
836+
# Display a message if the threading package has been overridden
837+
#
838+
839+
if(SWIFT_THREADING_PACKAGE)
840+
message(STATUS "")
841+
message(STATUS "Threading package override enabled")
842+
foreach(elt ${SWIFT_THREADING_PACKAGE})
843+
string(REPLACE ":" ";" elt_list "${elt}")
844+
list(LENGTH elt_list elt_list_len)
845+
if(elt_list_len EQUAL 1)
846+
set(elt_sdk "Global")
847+
list(GET elt_list 0 elt_package)
848+
elseif(elt_list_len EQUAL 2)
849+
list(GET elt_list 0 elt_sdk)
850+
list(GET elt_list 1 elt_package)
851+
string(TOUPPER "${elt_sdk}" elt_sdk)
852+
else()
853+
message(FATAL_ERROR "Bad threading override \"${elt}\" - SWIFT_THREADING_PACKAGE must be a semicolon separated list of package or sdk:package pairs.")
854+
endif()
855+
string(TOLOWER "${elt_package}" elt_package)
856+
message(STATUS " ${elt_sdk}: ${elt_package}")
857+
endforeach()
858+
message(STATUS "")
859+
endif()
860+
823861
#
824862
# Configure SDKs.
825863
#
@@ -832,6 +870,19 @@ if(XCODE)
832870
set(SWIFT_SDKS "OSX")
833871
endif()
834872

873+
# When we have the early SwiftSyntax build, we can include its parser.
874+
if(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR)
875+
set(SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS
876+
${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_BUILD_DIR}/cmake/SwiftSyntaxTargets.cmake)
877+
if(NOT EXISTS "${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS}")
878+
message(STATUS "Skipping Swift Swift parser integration due to missing early SwiftSyntax")
879+
else()
880+
set(SWIFT_SWIFT_PARSER TRUE)
881+
include(${SWIFT_PATH_TO_EARLYSWIFTSYNTAX_TARGETS})
882+
endif()
883+
endif()
884+
885+
835886
# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
836887
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
837888
# and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately.
@@ -1038,6 +1089,7 @@ if(SWIFT_INCLUDE_TOOLS)
10381089
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
10391090
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
10401091
message(STATUS " Bootstrapping: ${BOOTSTRAPPING_MODE}")
1092+
message(STATUS " Swift parser: ${SWIFT_SWIFT_PARSER}")
10411093
message(STATUS "")
10421094
else()
10431095
message(STATUS "Not building host Swift tools")
@@ -1054,7 +1106,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
10541106
message(STATUS " Leak Detection Checker Entrypoints: ${SWIFT_RUNTIME_ENABLE_LEAK_CHECKER}")
10551107
message(STATUS "")
10561108

1057-
message(STATUS "Threading Package: ${SWIFT_THREADING_PACKAGE}")
10581109
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
10591110
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
10601111
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
@@ -1133,6 +1184,7 @@ endif()
11331184
if(SWIFT_BUILD_STDLIB)
11341185
add_subdirectory(stdlib)
11351186
else()
1187+
set(SWIFT_STDLIB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/stdlib")
11361188
# Some of the things below depend on the threading library
11371189
add_subdirectory(stdlib/public/Threading)
11381190

@@ -1148,7 +1200,7 @@ else()
11481200
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
11491201
# ensure we build that when building tools.
11501202
if(SWIFT_INCLUDE_TOOLS)
1151-
add_subdirectory(stdlib/public/SwiftShims)
1203+
add_subdirectory(stdlib/public/SwiftShims/swift/shims)
11521204
endif()
11531205
endif()
11541206

0 commit comments

Comments
 (0)