Skip to content

Commit 44f3915

Browse files
committed
Don't set attribute as invalid
2 parents f899f2e + 22c6f9f commit 44f3915

File tree

3,020 files changed

+303499
-48680
lines changed

Some content is hidden

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

3,020 files changed

+303499
-48680
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.swift.gyb linguist-language=Swift
22
*.cpp.gyb linguist-language=C++
3+
*.bat text eol=crlf

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ docs/_build
4040
# Visual Studio metadata
4141
.vs
4242

43+
# Visual Studio Code Configurations
44+
.vscode
45+
4346
# clangd
4447
.cache
4548
.clangd

CHANGELOG.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,66 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
Swift 5.6
77
---------
8+
9+
* References to `Self` or so-called "`Self` requirements" in the type signatures
10+
of protocol members are now correctly detected in the parent of a nested type.
11+
As a result, protocol members that fall under this overlooked case are no longer
12+
available on values of protocol type:
13+
14+
```swift
15+
struct Outer<T> {
16+
struct Inner {}
17+
}
18+
19+
protocol P {}
20+
extension P {
21+
func method(arg: Outer<Self>.Inner) {}
22+
}
23+
24+
func test(p: P) {
25+
// error: 'method' has a 'Self' requirement and cannot be used on a value of
26+
// protocol type (use a generic constraint instead).
27+
_ = p.method
28+
}
29+
```
30+
31+
* [SE-0324][]:
32+
33+
Relax diagnostics for pointer arguments to C functions. The Swift
34+
compiler now accepts limited pointer type mismatches when directly
35+
calling functions imported from C as long as the C language allows
36+
those pointer types to alias. Consequently, any Swift
37+
`Unsafe[Mutable]Pointer<T>` or `Unsafe[Mutable]RawPointer` may be
38+
passed to C function arguments declared as `[signed|unsigned] char
39+
*`. Swift `Unsafe[Mutable]Pointer<T>` can also be passed to C
40+
function arguments with an integer type that differs from `T` only
41+
in its signedness.
42+
43+
For example, after importing a C function declaration:
44+
```c
45+
long long decode_int64(const char *ptr_to_int64);
46+
```
47+
Swift can now directly pass a raw pointer as the function argument:
48+
```swift
49+
func decodeAsInt64(data: Data) -> Int64 {
50+
data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
51+
decode_int64(bytes.baseAddress!)
52+
}
53+
}
54+
```
55+
56+
* [SE-0315][]:
57+
58+
Type expressions and annotations can now include "type placeholders" which
59+
directs the compiler to fill in that portion of the type according to the usual
60+
type inference rules. Type placeholders are spelled as an underscore ("`_`") in
61+
a type name. For instance:
62+
63+
```swift
64+
// This is OK--the compiler can infer the key type as `Int`.
65+
let dict: [_: String] = [0: "zero", 1: "one", 2: "two"]
66+
```
67+
868
* [SE-0290][]:
969

1070
It is now possible to write inverted availability conditions by using the new `#unavailable` keyword:
@@ -22,6 +82,23 @@ Swift 5.6
2282
Swift 5.5
2383
---------
2484

85+
### 2021-09-20 (Xcode 13.0)
86+
87+
* [SE-0323][]:
88+
89+
The main function is executed with `MainActor` isolation applied, so functions
90+
and variables with `MainActor` isolation may be called and modified
91+
synchronously from the main function. If the main function is annotated with a
92+
global actor explicitly, it must be the main actor or an error is emitted. If
93+
no global actor annotation is present, the main function is implicitly run on
94+
the main actor.
95+
96+
The main function is executed synchronously up to the first suspension point.
97+
Any tasks enqueued by initializers in Objective-C or C++ will run after the
98+
main function runs to the first suspension point. At the suspension point, the
99+
main function suspends and the tasks are executed according to the Swift
100+
concurrency mechanisms.
101+
25102
* [SE-0313][]:
26103

27104
Parameters of actor type can be declared as `isolated`, which means that they
@@ -57,7 +134,8 @@ Swift 5.5
57134
// previously interpreted as a return type of Box<T>, ignoring the <Int> part;
58135
// now we diagnose an error with a fix-it suggesting replacing `Self` with `Box`
59136
static func makeBox() -> Self<Int> {...}
60-
}```
137+
}
138+
```
61139

62140
* [SR-14878][]:
63141

@@ -8679,7 +8757,10 @@ Swift 1.0
86798757
[SE-0310]: <https://github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
86808758
[SE-0311]: <https://github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
86818759
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
8760+
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
86828761
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8762+
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
8763+
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
86838764

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

CMakeLists.txt

Lines changed: 110 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required(VERSION 3.19.6)
22

3+
4+
# set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
5+
36
# TODO: Fix RPATH usage to be CMP0068 compliant
47
# Disable Policy CMP0068 for CMake 3.9
58
# rdar://37725888
@@ -90,6 +93,10 @@ option(SWIFT_BUILD_DYNAMIC_STDLIB
9093
option(SWIFT_BUILD_STATIC_STDLIB
9194
"Build static variants of the Swift standard library"
9295
FALSE)
96+
97+
option(SWIFT_STDLIB_STATIC_PRINT
98+
"Build compile-time evaluated vprintf()"
99+
FALSE)
93100

94101
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
95102
"Build dynamic variants of the Swift SDK overlay"
@@ -127,6 +134,10 @@ option(SWIFT_BUILD_PERF_TESTSUITE
127134

128135
option(SWIFT_INCLUDE_TESTS "Create targets for building/running tests." TRUE)
129136

137+
option(SWIFT_INCLUDE_TEST_BINARIES
138+
"Create targets for building/running test binaries even if SWIFT_INCLUDE_TESTS is disabled"
139+
TRUE)
140+
130141
option(SWIFT_INCLUDE_DOCS
131142
"Create targets for building docs."
132143
TRUE)
@@ -168,21 +179,6 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
168179
set(CLANG_COMPILER_VERSION "" CACHE STRING
169180
"The internal version of the Clang compiler")
170181

171-
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
172-
# our own defaults. This should only be possible in a unified (not stand alone)
173-
# build environment.
174-
if(LLVM_USE_LINKER)
175-
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
176-
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
177-
set(SWIFT_USE_LINKER_default "lld")
178-
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
179-
set(SWIFT_USE_LINKER_default "")
180-
else()
181-
set(SWIFT_USE_LINKER_default "gold")
182-
endif()
183-
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
184-
"Build Swift with a non-default linker")
185-
186182
option(SWIFT_DISABLE_DEAD_STRIPPING
187183
"Turn off Darwin-specific dead stripping for Swift host tools." FALSE)
188184

@@ -192,9 +188,15 @@ set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
192188
no effect on the target libraries (the standard library and the runtime).")
193189

194190
# NOTE: We do not currently support building libswift with the Xcode generator.
195-
cmake_dependent_option(SWIFT_TOOLS_ENABLE_LIBSWIFT
196-
"Enable building libswift and linking libswift into the compiler itself." FALSE
197-
"NOT CMAKE_GENERATOR STREQUAL \"Xcode\"" FALSE)
191+
cmake_dependent_option(LIBSWIFT_BUILD_MODE "How to build libswift. Possible values are
192+
OFF: the compiler is built without libswift
193+
HOSTTOOLS: libswift is built with a pre-installed toolchain
194+
BOOTSTRAPPING: libswift is built with a 2-stage bootstrapping process
195+
BOOTSTRAPPING-WITH-HOSTLIBS: libswift is built with a 2-stage bootstrapping process,
196+
but the compiler links against the host system swift libs (macOS only)
197+
CROSSCOMPILE-WITH-HOSTLIBS: libswift is built with a bootstrapping-with-hostlibs compiled
198+
compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`"
199+
OFF "NOT CMAKE_GENERATOR STREQUAL \"Xcode\"" OFF)
198200

199201
# The following only works with the Ninja generator in CMake >= 3.0.
200202
set(SWIFT_PARALLEL_LINK_JOBS "" CACHE STRING
@@ -295,8 +297,8 @@ set(SWIFT_ANDROID_API_LEVEL "" CACHE STRING
295297

296298
set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
297299
"Path to the directory that contains the Android NDK tools that are executable on the build machine")
298-
set(SWIFT_ANDROID_NDK_GCC_VERSION "" CACHE STRING
299-
"The GCC version to use when building for Android. Currently only 4.9 is supported.")
300+
set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.8" CACHE STRING
301+
"The Clang version to use when building for Android.")
300302
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
301303
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
302304

@@ -386,13 +388,25 @@ option(SWIFT_CHECK_INCREMENTAL_COMPILATION
386388
"Check if incremental compilation works when compiling the Swift libraries"
387389
FALSE)
388390

391+
option(SWIFT_ENABLE_ARRAY_COW_CHECKS
392+
"Compile the stdlib with Array COW checks enabled (only relevant for assert builds)"
393+
FALSE)
394+
389395
option(SWIFT_REPORT_STATISTICS
390396
"Create json files which contain internal compilation statistics"
391397
FALSE)
392398

393-
option(SWIFT_DISABLE_OBJC_INTEROP
394-
"Disable Objective-C interoperability even on platforms what would normally have it"
395-
FALSE)
399+
# Only Darwin platforms enable ObjC interop by default.
400+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
401+
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default TRUE)
402+
else()
403+
set(SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default FALSE)
404+
endif()
405+
406+
# Used by stdlib/toolchain as well, so this cannot be in stdlib/CMakeLists.txt
407+
option(SWIFT_STDLIB_ENABLE_OBJC_INTEROP
408+
"Should stdlib be built with Obj-C interop."
409+
"${SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default}")
396410

397411
#
398412
# User-configurable experimental options. Do not use in production builds.
@@ -435,10 +449,18 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
435449
"Enable experimental distributed actors and functions"
436450
FALSE)
437451

452+
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
453+
"Enable experimental string processing"
454+
FALSE)
455+
438456
option(SWIFT_ENABLE_DISPATCH
439457
"Enable use of libdispatch"
440458
TRUE)
441459

460+
option(SWIFT_ENABLE_GLOBAL_ISEL_ARM64
461+
"Enable global isel on arm64"
462+
FALSE)
463+
442464
cmake_dependent_option(SWIFT_BUILD_SYNTAXPARSERLIB
443465
"Build the Swift Syntax Parser library" TRUE
444466
"SWIFT_ENABLE_DISPATCH" FALSE)
@@ -476,10 +498,16 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
476498
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
477499
endif()
478500

501+
# Make some warnings errors as they are commonly occurring and flood the build
502+
# with unnecessary noise.
503+
if(CMAKE_C_COMPILER_ID MATCHES Clang)
504+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=c++98-compat-extra-semi>)
505+
endif()
506+
479507
# Use dispatch as the system scheduler by default.
480508
# For convenience, we set this to false when concurrency is disabled.
481509
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
482-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND NOT SWIFT_STDLIB_SINGLE_THREADED_RUNTIME)
510+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
483511
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
484512
endif()
485513

@@ -498,6 +526,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
498526
endif()
499527
endif()
500528

529+
file(STRINGS "utils/availability-macros.def" SWIFT_STDLIB_AVAILABILITY_DEFINITIONS)
530+
list(FILTER SWIFT_STDLIB_AVAILABILITY_DEFINITIONS EXCLUDE REGEX "^\\s*(#.*)?$")
531+
501532
#
502533
# Include CMake modules
503534
#
@@ -581,6 +612,24 @@ set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
581612
set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
582613
if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
583614
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
615+
set(SWIFT_EXEC_FOR_LIBSWIFT "${CMAKE_Swift_COMPILER}")
616+
elseif(LIBSWIFT_BUILD_MODE MATCHES "BOOTSTRAPPING.*")
617+
# If cross-compiling we don't have to bootstrap. We can just use the previously
618+
# built native swiftc to build libswift.
619+
message(STATUS "Building libswift with previously built tools instead of bootstrapping")
620+
set(SWIFT_EXEC_FOR_LIBSWIFT "${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc")
621+
if(LIBSWIFT_BUILD_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
622+
set(LIBSWIFT_BUILD_MODE "CROSSCOMPILE-WITH-HOSTLIBS")
623+
else()
624+
set(LIBSWIFT_BUILD_MODE "HOSTTOOLS")
625+
endif()
626+
endif()
627+
628+
if(LIBSWIFT_BUILD_MODE MATCHES "HOSTTOOLS|.*-WITH-HOSTLIBS")
629+
if(SWIFT_ENABLE_ARRAY_COW_CHECKS)
630+
message(STATUS "array COW checks disabled when building libswift with host libraries")
631+
set(SWIFT_ENABLE_ARRAY_COW_CHECKS FALSE)
632+
endif()
584633
endif()
585634

586635
# This setting causes all CMakeLists.txt to automatically have
@@ -608,10 +657,15 @@ set(SWIFT_DARWIN_VARIANTS "^(macosx|iphoneos|iphonesimulator|appletvos|appletvsi
608657
set(SWIFT_DARWIN_EMBEDDED_VARIANTS "^(iphoneos|iphonesimulator|appletvos|appletvsimulator|watchos|watchsimulator)")
609658

610659
# A convenient list to match Darwin SDKs. Example:
611-
# if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_APPLE_PLATFORMS)
660+
# if("${SWIFT_HOST_VARIANT_SDK}" IN_LIST SWIFT_DARWIN_PLATFORMS)
612661
# ...
613662
# endif()
614-
set(SWIFT_APPLE_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX")
663+
set(SWIFT_DARWIN_PLATFORMS "IOS" "IOS_SIMULATOR" "TVOS" "TVOS_SIMULATOR" "WATCHOS" "WATCHOS_SIMULATOR" "OSX")
664+
665+
set(SWIFT_APPLE_PLATFORMS ${SWIFT_DARWIN_PLATFORMS})
666+
if(SWIFT_FREESTANDING_FLAVOR STREQUAL "apple")
667+
list(APPEND SWIFT_APPLE_PLATFORMS "FREESTANDING")
668+
endif()
615669

616670
# Configuration flags passed to all of our invocations of gyb. Try to
617671
# avoid making up new variable names here if you can find a CMake
@@ -693,6 +747,23 @@ set(SWIFT_HOST_VARIANT_SDK "${SWIFT_HOST_VARIANT_SDK_default}" CACHE STRING
693747
set(SWIFT_HOST_VARIANT_ARCH "${SWIFT_HOST_VARIANT_ARCH_default}" CACHE STRING
694748
"Deployment arch for Swift host tools (the compiler).")
695749

750+
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
751+
# our own defaults. This should only be possible in a unified (not stand alone)
752+
# build environment.
753+
if(LLVM_USE_LINKER)
754+
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
755+
elseif(${SWIFT_HOST_VARIANT_SDK} STREQUAL ANDROID)
756+
set(SWIFT_USE_LINKER_default "lld")
757+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
758+
set(SWIFT_USE_LINKER_default "lld")
759+
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
760+
set(SWIFT_USE_LINKER_default "")
761+
else()
762+
set(SWIFT_USE_LINKER_default "gold")
763+
endif()
764+
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
765+
"Build Swift with a non-default linker")
766+
696767
#
697768
# Enable additional warnings.
698769
#
@@ -740,6 +811,12 @@ if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
740811
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
741812
endif()
742813

814+
is_sdk_requested(FREESTANDING swift_build_freestanding)
815+
if(swift_build_freestanding AND (SWIFT_FREESTANDING_FLAVOR STREQUAL "linux"))
816+
# TODO
817+
# configure_sdk_unix("FREESTANDING" "${SWIFT_HOST_VARIANT_ARCH}")
818+
endif()
819+
743820
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "FREEBSD")
744821

745822
set(SWIFT_HOST_VARIANT "freebsd" CACHE STRING
@@ -914,7 +991,7 @@ if(SWIFT_INCLUDE_TOOLS)
914991
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
915992
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
916993
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
917-
message(STATUS " libswift: ${SWIFT_TOOLS_ENABLE_LIBSWIFT}")
994+
message(STATUS " libswift: ${LIBSWIFT_BUILD_MODE}")
918995
message(STATUS "")
919996
else()
920997
message(STATUS "Not building host Swift tools")
@@ -934,6 +1011,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
9341011
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
9351012
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
9361013
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1014+
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
9371015
message(STATUS "")
9381016
else()
9391017
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
@@ -1042,6 +1120,11 @@ else()
10421120
add_subdirectory(stdlib/toolchain)
10431121
endif()
10441122

1123+
if (BUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES)
1124+
# Build the back-deployed concurrency library.
1125+
add_subdirectory(stdlib/public/BackDeployConcurrency)
1126+
endif()
1127+
10451128
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10461129
# ensure we build that when building tools.
10471130
if(SWIFT_INCLUDE_TOOLS)

0 commit comments

Comments
 (0)