Skip to content

Commit 35607ed

Browse files
committed
Merge remote-tracking branch 'apple/master' into callables
2 parents e213836 + 529d784 commit 35607ed

File tree

1,247 files changed

+34523
-18364
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,247 files changed

+34523
-18364
lines changed

CHANGELOG.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,24 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29-
* [SR-8974][]:
29+
* [SR-4206][]:
3030

31-
Duplicate tuple element labels are no longer allowed, because it leads
32-
to incorrect behavior. For example:
31+
A method override is no longer allowed to have a generic signature with
32+
requirements not imposed by the base method. For example:
3333

3434
```
35-
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
36-
37-
enum Foo { case bar(x: Int, x: Int) }
38-
let f: Foo = .bar(x: 0, x: 1)
35+
protocol P {}
36+
37+
class Base {
38+
func foo<T>(arg: T) {}
39+
}
40+
41+
class Derived: Base {
42+
override func foo<T: P>(arg: T) {}
43+
}
3944
```
4045

41-
will now be diagnosed as an error.
42-
43-
Note: You can still use duplicate labels when declaring functions and
44-
subscripts, as long as the internal labels are different. For example:
45-
46-
```
47-
func foo(bar x: Int, bar y: Int) {}
48-
subscript(a x: Int, a y: Int) -> Int {}
49-
```
46+
will now be diagnosed as an error.
5047

5148
* [SR-6118][]:
5249

@@ -68,6 +65,28 @@ Swift Next
6865
Swift 5.1
6966
---------
7067

68+
* [SR-8974][]:
69+
70+
Duplicate tuple element labels are no longer allowed, because it leads
71+
to incorrect behavior. For example:
72+
73+
```
74+
let dupLabels: (foo: Int, foo: Int) = (foo: 1, foo: 2)
75+
76+
enum Foo { case bar(x: Int, x: Int) }
77+
let f: Foo = .bar(x: 0, x: 1)
78+
```
79+
80+
will now be diagnosed as an error.
81+
82+
Note: You can still use duplicate argument labels when declaring functions and
83+
subscripts, as long as the internal parameter names are different. For example:
84+
85+
```
86+
func foo(bar x: Int, bar y: Int) {}
87+
subscript(a x: Int, a y: Int) -> Int {}
88+
```
89+
7190
* [SE-0244][]:
7291

7392
Functions can now hide their concrete return type by declaring what protocols
@@ -7708,6 +7727,7 @@ Swift 1.0
77087727
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
77097728
[SR-2672]: <https://bugs.swift.org/browse/SR-2672>
77107729
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
7730+
[SR-4206]: <https://bugs.swift.org/browse/SR-4206>
77117731
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
77127732
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
77137733
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>

CMakeLists.txt

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ option(SWIFT_BUILD_STATIC_SDK_OVERLAY
6161
"Build static variants of the Swift SDK overlay"
6262
FALSE)
6363

64+
option(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT
65+
"If not building stdlib, controls whether to build 'stdlib/toolchain' content"
66+
TRUE)
67+
6468
# In many cases, the CMake build system needs to determine whether to include
6569
# a directory, or perform other actions, based on whether the stdlib or SDK is
6670
# being built at all -- statically or dynamically. Please note that these
@@ -599,7 +603,13 @@ if(SWIFT_HOST_VARIANT_SDK)
599603
set(SWIFT_HOST_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
600604
else()
601605
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
602-
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
606+
# CMake on an Android host sets this to Linux, so check for the ANDROID_DATA
607+
# environment variable to see if we're building on Android.
608+
if(NOT "$ENV{ANDROID_DATA}" STREQUAL "")
609+
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
610+
else()
611+
set(SWIFT_HOST_VARIANT_SDK_default "LINUX")
612+
endif()
603613
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
604614
set(SWIFT_HOST_VARIANT_SDK_default "FREEBSD")
605615
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
@@ -609,6 +619,7 @@ else()
609619
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku")
610620
set(SWIFT_HOST_VARIANT_SDK_default "HAIKU")
611621
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
622+
# CMAKE_SYSTEM_NAME might be set this way when cross-compiling to Android.
612623
set(SWIFT_HOST_VARIANT_SDK_default "ANDROID")
613624
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
614625
set(SWIFT_HOST_VARIANT_SDK_default "OSX")
@@ -673,7 +684,7 @@ endif()
673684

674685
# FIXME: the parameters we specify in SWIFT_SDKS are lacking architecture specifics,
675686
# so we need to hard-code it. For example, the SDK for Android is just 'ANDROID',
676-
# which we assume below to be armv7.
687+
# and we have to specify SWIFT_SDK_ANDROID_ARCHITECTURES separately.
677688
# The iOS SDKs all have their architectures hardcoded because they are just specified by name (e.g. 'IOS' or 'WATCHOS').
678689
# We can't cross-compile the standard library for another linux architecture,
679690
# because the SDK list would just be 'LINUX' and we couldn't disambiguate it from the host.
@@ -735,9 +746,16 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "HAIKU")
735746
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "ANDROID")
736747

737748
set(SWIFT_HOST_VARIANT "android" CACHE STRING
738-
"Deployment OS for Swift host tools (the compiler) [android].")
749+
"Deployment OS for Swift host tools (the compiler) [android]")
750+
751+
set(SWIFT_ANDROID_NATIVE_SYSROOT "/data/data/com.termux/files" CACHE STRING
752+
"Path to Android sysroot, default initialized to the Termux app's layout")
739753

740-
configure_sdk_unix("Android" "${SWIFT_HOST_VARIANT_ARCH}")
754+
if("${SWIFT_SDK_ANDROID_ARCHITECTURES}" STREQUAL "")
755+
set(SWIFT_SDK_ANDROID_ARCHITECTURES ${SWIFT_HOST_VARIANT_ARCH})
756+
endif()
757+
758+
configure_sdk_unix("Android" "${SWIFT_SDK_ANDROID_ARCHITECTURES}")
741759
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
742760
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
743761

@@ -1065,8 +1083,7 @@ endif()
10651083
#
10661084
# We must include stdlib/ before tools/ because stdlib/CMakeLists.txt
10671085
# declares the swift-stdlib-* set of targets. These targets will then
1068-
# implicitly depend on any targets declared with IS_STDLIB or
1069-
# TARGET_LIBRARY.
1086+
# implicitly depend on any targets declared with IS_STDLIB.
10701087
#
10711088
# One such library that declares IS_STDLIB is SwiftSyntax, living in
10721089
# tools/SwiftSyntax. If we include stdlib/ after tools/,
@@ -1078,7 +1095,9 @@ endif()
10781095
if(SWIFT_BUILD_STDLIB)
10791096
add_subdirectory(stdlib)
10801097
else()
1081-
add_subdirectory(stdlib/public/legacy_layouts)
1098+
if(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT)
1099+
add_subdirectory(stdlib/toolchain)
1100+
endif()
10821101

10831102
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10841103
# ensure we build that when building tools.

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
|**[Debian 9.1 (Raspberry Pi)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/armv7_debian_stretch.json)** | ARMv7 | [![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-debian-9_1/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-debian-9_1)|
1818
|**[Fedora 27](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_fedora_27.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-fedora-27)|
1919
|**[Ubuntu 16.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04)|
20-
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-4.1-RA-linux-ubuntu-16.04-ppc64le)|
20+
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le)|
2121
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
2222
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/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)|
2323
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/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)|
@@ -42,6 +42,17 @@ modules, eliminating the need for headers and the code duplication they entail.
4242

4343
To learn more about the programming language, visit [swift.org](https://swift.org/documentation/).
4444

45+
- [Contributing to Swift](#contributing-to-swift)
46+
- [Getting Started](#getting-started)
47+
- [System Requirements](#system-requirements)
48+
- [Getting Sources for Swift and Related Projects](#getting-sources-for-swift-and-related-projects)
49+
- [Building Swift](#building-swift)
50+
- [Swift Toolchains](#swift-toolchains)
51+
- [Build Failures](#build-failures)
52+
- [Testing Swift](#testing-swift)
53+
- [Learning More](#learning-more)
54+
- [Build Dependencies](#build-dependencies)
55+
4556
## Contributing to Swift
4657

4758
Contributions to Swift are welcomed and encouraged! Please see the
@@ -76,7 +87,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
7687

7788
#### macOS
7889

79-
To build for macOS, you need [Xcode 11 beta](https://developer.apple.com/xcode/downloads/).
90+
To build for macOS, you need [Xcode 11 beta 5](https://developer.apple.com/xcode/downloads/).
8091
The required version of Xcode changes frequently, and is often a beta release.
8192
Check this document or the host information on <https://ci.swift.org> for the
8293
current required version.

benchmark/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ set(SWIFT_BENCH_MODULES
7878
single-source/DictionaryRemove
7979
single-source/DictionarySubscriptDefault
8080
single-source/DictionarySwap
81+
single-source/Diffing
82+
single-source/DiffingMyers
8183
single-source/DropFirst
8284
single-source/DropLast
8385
single-source/DropWhile
@@ -164,6 +166,7 @@ set(SWIFT_BENCH_MODULES
164166
single-source/StringInterpolation
165167
single-source/StringMatch
166168
single-source/StringRemoveDupes
169+
single-source/StringReplaceSubrange
167170
single-source/StringTests
168171
single-source/StringWalk
169172
single-source/Substring

benchmark/Package.swift

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22

33
import PackageDescription
44
import Foundation
@@ -9,10 +9,15 @@ unsupportedTests.insert("ObjectiveCBridging")
99
unsupportedTests.insert("ObjectiveCBridgingStubs")
1010
#endif
1111

12-
// This is a stop gap hack so we can edit benchmarks in Xcode.
13-
let singleSourceLibraries: [String] = {
12+
//===---
13+
// Single Source Libraries
14+
//
15+
16+
/// Return the source files in subDirectory that we will translate into
17+
/// libraries. Each source library will be compiled as its own module.
18+
func getSingleSourceLibraries(subDirectory: String) -> [String] {
1419
let f = FileManager.`default`
15-
let dirURL = URL(fileURLWithPath: "single-source").absoluteURL
20+
let dirURL = URL(fileURLWithPath: subDirectory)
1621
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
1722
includingPropertiesForKeys: nil)
1823
return fileURLs.compactMap { (path: URL) -> String? in
@@ -25,27 +30,45 @@ let singleSourceLibraries: [String] = {
2530
return nil
2631
}
2732

28-
let s = String(c[0])
33+
let name = String(c[0])
2934

3035
// We do not support this test.
31-
if unsupportedTests.contains(s) {
36+
if unsupportedTests.contains(name) {
3237
return nil
3338
}
3439

35-
assert(s != "PrimsSplit")
36-
return s
40+
return name
3741
}
38-
}()
42+
}
43+
44+
var singleSourceLibraryDirs: [String] = []
45+
singleSourceLibraryDirs.append("single-source")
46+
47+
var singleSourceLibraries: [String] = singleSourceLibraryDirs.flatMap {
48+
getSingleSourceLibraries(subDirectory: $0)
49+
}
3950

40-
let multiSourceLibraries: [String] = {
51+
//===---
52+
// Multi Source Libraries
53+
//
54+
55+
func getMultiSourceLibraries(subDirectory: String) -> [(String, String)] {
4156
let f = FileManager.`default`
42-
let dirURL = URL(fileURLWithPath: "multi-source").absoluteURL
43-
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
44-
includingPropertiesForKeys: nil)
45-
return fileURLs.map { (path: URL) -> String in
46-
return path.lastPathComponent
47-
}
48-
}()
57+
let dirURL = URL(string: subDirectory)!
58+
let subDirs = try! f.contentsOfDirectory(at: dirURL, includingPropertiesForKeys: nil)
59+
return subDirs.map { (subDirectory, $0.lastPathComponent) }
60+
}
61+
62+
var multiSourceLibraryDirs: [String] = []
63+
multiSourceLibraryDirs.append("multi-source")
64+
65+
var multiSourceLibraries: [(parentSubDir: String, name: String)] = multiSourceLibraryDirs.flatMap {
66+
getMultiSourceLibraries(subDirectory: $0)
67+
}
68+
69+
//===---
70+
// Products
71+
//
4972

5073
var products: [Product] = []
5174
products.append(.library(name: "TestsUtils", type: .static, targets: ["TestsUtils"]))
@@ -54,9 +77,15 @@ products.append(.library(name: "DriverUtils", type: .static, targets: ["DriverUt
5477
products.append(.library(name: "ObjectiveCTests", type: .static, targets: ["ObjectiveCTests"]))
5578
#endif
5679
products.append(.executable(name: "SwiftBench", targets: ["SwiftBench"]))
57-
products.append(.library(name: "PrimsSplit", type: .static, targets: ["PrimsSplit"]))
80+
5881
products += singleSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
59-
products += multiSourceLibraries.map { .library(name: $0, type: .static, targets: [$0]) }
82+
products += multiSourceLibraries.map {
83+
return .library(name: $0.name, type: .static, targets: [$0.name])
84+
}
85+
86+
//===---
87+
// Targets
88+
//
6089

6190
var targets: [Target] = []
6291
targets.append(.target(name: "TestsUtils", path: "utils", sources: ["TestsUtils.swift"]))
@@ -73,7 +102,7 @@ swiftBenchDeps.append(.target(name: "ObjectiveCTests"))
73102
#endif
74103
swiftBenchDeps.append(.target(name: "DriverUtils"))
75104
swiftBenchDeps += singleSourceLibraries.map { .target(name: $0) }
76-
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0) }
105+
swiftBenchDeps += multiSourceLibraries.map { .target(name: $0.name) }
77106

78107
targets.append(
79108
.target(name: "SwiftBench",
@@ -92,20 +121,27 @@ var singleSourceDeps: [Target.Dependency] = [.target(name: "TestsUtils")]
92121
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
93122
singleSourceDeps.append(.target(name: "ObjectiveCTests"))
94123
#endif
95-
targets += singleSourceLibraries.map { x in
96-
return .target(name: x,
124+
125+
targets += singleSourceLibraries.map { name in
126+
return .target(name: name,
97127
dependencies: singleSourceDeps,
98128
path: "single-source",
99-
sources: ["\(x).swift"])
129+
sources: ["\(name).swift"])
100130
}
101-
targets += multiSourceLibraries.map { x in
102-
return .target(name: x,
131+
132+
targets += multiSourceLibraries.map { lib in
133+
return .target(
134+
name: lib.name,
103135
dependencies: [
104136
.target(name: "TestsUtils")
105137
],
106-
path: "multi-source/\(x)")
138+
path: lib.parentSubDir)
107139
}
108140

141+
//===---
142+
// Top Level Definition
143+
//
144+
109145
let p = Package(
110146
name: "swiftbench",
111147
products: products,

0 commit comments

Comments
 (0)