Skip to content

Commit b525b9c

Browse files
committed
Merge tag 'swift-DEVELOPMENT-SNAPSHOT-2024-05-01-a' of github.com:apple/swift into cal--fix-70089
Tag build swift-DEVELOPMENT-SNAPSHOT-2024-05-01-a
2 parents 7d897fd + 84d3618 commit b525b9c

File tree

1,874 files changed

+54483
-26333
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,874 files changed

+54483
-26333
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!--
2+
In order for a pull request to be considered for inclusion in a release branch
3+
(release/x.y) after it has been cut, the pull request must have the following
4+
information filled out in its description.
5+
6+
To draft a pull request using this template, append '&template=release.md' to
7+
a pull request preview URL (the "Open a pull request" page), or use the
8+
following URL template:
9+
10+
https://github.com/apple/swift/compare/main...<username>:swift:<my-branch>?expand=1&template=release.md
11+
-->
12+
13+
* Explanation:
14+
<!--
15+
A description of the change. This can be brief, but it should be clear.
16+
-->
17+
* Scope:
18+
<!--
19+
An assessment of the impact/importance of the change. For example, is the
20+
change a source-breaking language change?
21+
-->
22+
* Issues:
23+
<!--
24+
References to issues the change resolves, if any.
25+
-->
26+
* Original PR:
27+
<!--
28+
Link to the main branch version of this pull request.
29+
-->
30+
* Risk:
31+
<!--
32+
What is the (specific) risk to the release for taking this change?
33+
-->
34+
* Testing:
35+
<!--
36+
What specific testing has been done or needs to be done to further validate
37+
any impact of this change?
38+
-->
39+
* Reviewers:
40+
<!--
41+
The code owners that reviewed the original PR. One or more code owners of
42+
the impacted components should review the change. Technical review can be
43+
delegated by a code owner or otherwise requested as deemed appropriate or
44+
useful.
45+
-->
46+
File renamed without changes.

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
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

CMakeLists.txt

Lines changed: 49 additions & 19 deletions
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

@@ -119,7 +125,7 @@ set(SWIFT_DARWIN_EMBEDDED_VARIANTS "^(iphoneos|iphonesimulator|appletvos|appletv
119125
# if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
120126
# ...
121127
# endif()
122-
set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX")
128+
set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX" "XROS" "XROS_SIMULATOR")
123129

124130
set(SWIFT_APPLE_PLATFORMS ${SWIFT_DARWIN_PLATFORMS})
125131
if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")
@@ -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)
@@ -530,6 +532,12 @@ set(SWIFT_DARWIN_STDLIB_INSTALL_NAME_DIR "/usr/lib/swift" CACHE STRING
530532
set(SWIFT_DARWIN_STDLIB_PRIVATE_INSTALL_NAME_DIR "@rpath" CACHE STRING
531533
"The directory of the install_name for the private standard library dylibs")
532534

535+
option(SWIFT_ALLOW_LINKING_SWIFT_CONTENT_IN_DARWIN_TOOLCHAIN
536+
"Adds search paths for libraries in the toolchain
537+
when building Swift programs.
538+
This is needed to support Apple internal configurations."
539+
FALSE)
540+
533541
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX "10.13" CACHE STRING
534542
"Minimum deployment target version for OS X")
535543

@@ -542,6 +550,9 @@ set(SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS "11.0" CACHE STRING
542550
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS "4.0" CACHE STRING
543551
"Minimum deployment target version for watchOS")
544552

553+
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_XROS "1.0" CACHE STRING
554+
"Minimum deployment target version for xrOS")
555+
545556
#
546557
# Compatibility library deployment versions
547558
#
@@ -550,6 +561,7 @@ set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX "10.9")
550561
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS "7.0")
551562
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS "9.0")
552563
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS "2.0")
564+
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS "1.0")
553565
set(COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_MACCATALYST "13.1")
554566

555567
#
@@ -595,7 +607,7 @@ option(SWIFT_REPORT_STATISTICS
595607
FALSE)
596608

597609
# Only Darwin platforms enable ObjC interop by default.
598-
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
610+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)")
599611
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE)
600612
else()
601613
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE)
@@ -663,10 +675,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
663675
"Enable experimental distributed actors and functions"
664676
FALSE)
665677

666-
option(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS
667-
"Enable experimental NoncopyableGenerics"
668-
FALSE)
669-
670678
option(SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES
671679
"Enable experimental NonescapableTypes"
672680
FALSE)
@@ -695,6 +703,10 @@ option(SWIFT_ENABLE_GLOBAL_ISEL_ARM64
695703
"Enable global isel on arm64"
696704
FALSE)
697705

706+
option(SWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION
707+
"Enable experimental SwiftParser validation by default"
708+
FALSE)
709+
698710
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
699711
"Build SourceKit" TRUE
700712
"SWIFT_ENABLE_DISPATCH" FALSE)
@@ -724,6 +736,18 @@ option(SWIFT_ENABLE_BACKTRACING
724736
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST "14.5" CACHE STRING
725737
"Minimum deployment target version for macCatalyst")
726738

739+
# A tempoarary hack: force enabling HOSTTOOLS mode on Windows.
740+
# Right now, SwiftCompilerSources cannot be enabled for lldb because on Windows
741+
# swift and lldb are built in a unified build and there is a missing dependency
742+
# on swiftrt.
743+
# Swift and lldb are configured with the same cmake invocation and therefore
744+
# enabling bootstrapping for swift and disabling it for lldb only works by
745+
# hardcoding the bootstrapping mode in the cmake file.
746+
# https://github.com/apple/swift/issues/73322
747+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
748+
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
749+
endif()
750+
727751
#
728752
# End of user-configurable options.
729753
#
@@ -892,6 +916,10 @@ if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
892916
# This is the normal case. We are not cross-compiling.
893917
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
894918
set(SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER}")
919+
if(NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
920+
message(WARNING "BOOSTRAPPING set to OFF because no Swift compiler is defined")
921+
set(BOOTSTRAPPING_MODE "OFF")
922+
endif()
895923
elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
896924
# If cross-compiling, we don't have to bootstrap. We can just use the previously
897925
# built native swiftc to build the swift compiler modules.
@@ -962,6 +990,12 @@ if(XCODE)
962990
swift_common_xcode_cxx_config()
963991
endif()
964992

993+
# Check what linux distribution is being used.
994+
# This can be used to determine the default linker to use.
995+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22")
996+
cmake_host_system_information(RESULT DISTRO_NAME QUERY DISTRIB_PRETTY_NAME)
997+
endif()
998+
965999
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
9661000
# our own defaults. This should only be possible in a unified (not stand alone)
9671001
# build environment.
@@ -973,6 +1007,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT CMAKE_HOST_SYSTEM_NAME STREQ
9731007
set(SWIFT_USE_LINKER_default "lld")
9741008
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
9751009
set(SWIFT_USE_LINKER_default "")
1010+
elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023")
1011+
set(SWIFT_USE_LINKER_default "lld")
9761012
else()
9771013
set(SWIFT_USE_LINKER_default "gold")
9781014
endif()
@@ -1139,7 +1175,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
11391175
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
11401176
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
11411177

1142-
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
1178+
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*|XROS*)")
11431179

11441180
set(SWIFT_HOST_VARIANT "macosx" CACHE STRING
11451181
"Deployment OS for Swift host tools (the compiler) [macosx, iphoneos].")
@@ -1278,7 +1314,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
12781314
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
12791315
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
12801316
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1281-
message(STATUS "NoncopyableGenerics Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS}")
12821317
message(STATUS "NonEscapableTypes Support: ${SWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES}")
12831318
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
12841319
message(STATUS "Backtracing Support: ${SWIFT_ENABLE_BACKTRACING}")
@@ -1301,11 +1336,6 @@ if(SWIFT_BUILD_REMOTE_MIRROR)
13011336
message(STATUS "")
13021337
endif()
13031338

1304-
if(SWIFT_BUILD_EXTERNAL_GENERIC_METADATA_BUILDER)
1305-
message(STATUS "Building Swift External Generic Metadata Builder for SDKs: ${SWIFT_SDKS}")
1306-
message(STATUS "")
1307-
endif()
1308-
13091339
#
13101340
# Find required dependencies.
13111341
#

SwiftCompilerSources/CMakeLists.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ 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-
108101
set(swift_compile_options
109102
"-color-diagnostics"
110103
"-Xfrontend" "-validate-tbd-against-ir=none"
@@ -114,6 +107,13 @@ function(add_swift_compiler_modules_library name)
114107
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
115108
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
116109

110+
# Prior to 5.9, we have to use the experimental flag for C++ interop.
111+
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9)
112+
list(APPEND swift_compile_options "-Xfrontend" "-enable-experimental-cxx-interop")
113+
else()
114+
list(APPEND swift_compile_options "-cxx-interoperability-mode=default")
115+
endif()
116+
117117
if (NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
118118
if(SWIFT_MIN_RUNTIME_VERSION)
119119
list(APPEND swift_compile_options
@@ -129,7 +129,9 @@ function(add_swift_compiler_modules_library name)
129129
list(APPEND swift_compile_options "-O" "-cross-module-optimization")
130130
endif()
131131

132-
if(NOT LLVM_ENABLE_ASSERTIONS)
132+
if(LLVM_ENABLE_ASSERTIONS)
133+
list(APPEND swift_compile_options "-Xcc" "-UNDEBUG")
134+
else()
133135
list(APPEND swift_compile_options "-Xcc" "-DNDEBUG")
134136
endif()
135137

@@ -166,7 +168,17 @@ function(add_swift_compiler_modules_library name)
166168
# under `include/swift`. These are either located next to the compiler (in case of open source toolchains) or
167169
# in the SDK (in case a Swift compiler from Xcode)
168170
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
169-
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
171+
172+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
173+
list(APPEND swift_compile_options "-static")
174+
list(APPEND sdk_option "-sdk" "${SWIFT_PATH_TO_SWIFT_SDK}")
175+
176+
# Workaround a crash in the LoadableByAddress pass
177+
# https://github.com/apple/swift/issues/73254
178+
list(APPEND swift_compile_options "-Xllvm" "-sil-disable-pass=loadable-address")
179+
else()
180+
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
181+
endif()
170182

171183
set(all_obj_files)
172184
set(all_module_targets)
@@ -304,7 +316,7 @@ else()
304316

305317
elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
306318

307-
set(b0_deps swift-frontend-bootstrapping0 symlink-headers-bootstrapping0)
319+
set(b0_deps swift-frontend-bootstrapping0 symlink-headers-bootstrapping0 copy-legacy-layouts)
308320
set(b1_deps swift-frontend-bootstrapping1 symlink-headers-bootstrapping1)
309321
if(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
310322
list(APPEND b0_deps swiftCore-bootstrapping0)

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import BasicBridging
14-
import CxxStdlib
1514

1615
/// The assert function to be used in the compiler.
1716
///
@@ -52,6 +51,9 @@ public extension NoReflectionChildren {
5251
var customMirror: Mirror { Mirror(self, children: []) }
5352
}
5453

54+
#if !os(Windows)
55+
// TODO: https://github.com/apple/swift/issues/73252
56+
5557
public var standardError = CFileStream(fp: stderr)
5658

5759
#if os(Android) || canImport(Musl)
@@ -72,6 +74,8 @@ public struct CFileStream: TextOutputStream {
7274
}
7375
}
7476

77+
#endif
78+
7579
//===----------------------------------------------------------------------===//
7680
// StringRef
7781
//===----------------------------------------------------------------------===//

SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ struct InstructionRange : CustomStringConvertible, NoReflectionChildren {
6464
}
6565

6666
static func beginningInstruction(for value: Value) -> Instruction {
67-
if let def = value.definingInstruction {
67+
if let def = value.definingInstructionOrTerminator {
6868
return def
69-
} else if let result = TerminatorResult(value) {
70-
return result.terminator
7169
}
7270
assert(Phi(value) != nil || value is FunctionArgument)
7371
return value.parentBlock.instructions.first!

0 commit comments

Comments
 (0)