Skip to content

Commit fcf6550

Browse files
committed
Merge branch 'master' into numist/diffing
2 parents 4f783fb + ea85726 commit fcf6550

File tree

1,769 files changed

+69498
-23918
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,769 files changed

+69498
-23918
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,33 @@ CHANGELOG
2121

2222
</details>
2323

24+
Swift 5.1
25+
---------
26+
27+
* Key path expressions can now include references to tuple elements.
28+
2429
Swift 5.0
2530
---------
2631

32+
* [SE-0235][]:
33+
34+
The standard library now contains a `Result` type for manually propagating errors.
35+
36+
```swift
37+
enum Result<Success, Failure: Error> {
38+
case success(Success)
39+
case failure(Failure)
40+
}
41+
```
42+
43+
This type serves a complementary role to that of throwing functions and initializers.
44+
Use `Result` in situations where automatic error propagation or `try`-`catch`
45+
blocks are undesirable, such as in asynchronous code or when accumulating the
46+
results of successive error-producing operations.
47+
48+
* `Error` now conforms to itself. This allows for the use of `Error` itself as
49+
the argument for a generic parameter constrained to `Error`.
50+
2751
* Swift 3 mode has been removed. Supported values for the `-swift-version`
2852
flag are `4`, `4.2`, and `5`.
2953

@@ -7406,6 +7430,7 @@ Swift 1.0
74067430
[SE-0227]: <https://github.com/apple/swift-evolution/blob/master/proposals/0227-identity-keypath.md>
74077431
[SE-0228]: <https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md>
74087432
[SE-0230]: <https://github.com/apple/swift-evolution/blob/master/proposals/0230-flatten-optional-try.md>
7433+
[SE-0235]: <https://github.com/apple/swift-evolution/blob/master/proposals/0235-add-result.md>
74097434

74107435
[SR-106]: <https://bugs.swift.org/browse/SR-106>
74117436
[SR-419]: <https://bugs.swift.org/browse/SR-419>

CMakeLists.txt

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
180180
"Generate .swiftinterface files alongside .swiftmodule files"
181181
TRUE)
182182

183+
# Allow building Swift with Clang's Profile Guided Optimization
184+
if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
185+
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
186+
message(FATAL_ERROR "SWIFT_PROFDATA_FILE can only be specified when compiling with clang")
187+
endif()
188+
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
189+
endif()
190+
183191
#
184192
# User-configurable Android specific options.
185193
#
@@ -311,10 +319,6 @@ option(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP
311319
"Build the standard libraries and overlays with sil ownership enabled."
312320
FALSE)
313321

314-
option(SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS
315-
"Build the standard libraries, overlays, and runtime with normal arguments at +0"
316-
TRUE)
317-
318322
option(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS
319323
"Enable runtime function counters and expose the API."
320324
FALSE)
@@ -409,13 +413,24 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
409413
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
410414
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
411415
endif()
416+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
417+
if(EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE} AND
418+
CMAKE_CXX_COMPILER_ID STREQUAL Clang)
419+
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
420+
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
421+
else()
422+
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
423+
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
424+
endif()
412425
else()
413426
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
414427
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
415428
endif()
416429
option(SWIFT_BUILD_SYNTAXPARSERLIB
417430
"Build the Swift Syntax Parser library"
418431
${SWIFT_BUILD_SYNTAXPARSERLIB_default})
432+
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
433+
"Only build the Swift Syntax Parser library" FALSE)
419434
option(SWIFT_BUILD_SOURCEKIT
420435
"Build SourceKit"
421436
${SWIFT_BUILD_SOURCEKIT_default})
@@ -492,15 +507,11 @@ include(SwiftSharedCMakeConfig)
492507
# Support building Swift as a standalone project, using LLVM as an
493508
# external library.
494509
if(SWIFT_BUILT_STANDALONE)
495-
swift_common_standalone_build_config(SWIFT SWIFT_CROSS_COMPILING)
510+
swift_common_standalone_build_config(SWIFT)
496511
else()
497512
swift_common_unified_build_config(SWIFT)
498513
endif()
499514

500-
if(NOT EXISTS "${CLANG_MAIN_INCLUDE_DIR}/clang/AST/Decl.h")
501-
message(FATAL_ERROR "Clang is missing from llvm/tools subdirectory.")
502-
endif()
503-
504515
set(SWIFT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
505516
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
506517
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -803,20 +814,17 @@ message(STATUS "Building host Swift tools for ${SWIFT_HOST_VARIANT_SDK} ${SWIFT_
803814
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
804815
message(STATUS " Assertions: ${LLVM_ENABLE_ASSERTIONS}")
805816
message(STATUS " LTO: ${SWIFT_TOOLS_ENABLE_LTO}")
806-
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
807817
message(STATUS "")
808818

809819
if (SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
810820

811821
message(STATUS "Building Swift standard library and overlays for SDKs: ${SWIFT_SDKS}")
812822
message(STATUS " Build type: ${SWIFT_STDLIB_BUILD_TYPE}")
813823
message(STATUS " Assertions: ${SWIFT_STDLIB_ASSERTIONS}")
814-
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
815824
message(STATUS "")
816825

817826
message(STATUS "Building Swift runtime with:")
818827
message(STATUS " Leak Detection Checker Entrypoints: ${SWIFT_RUNTIME_ENABLE_LEAK_CHECKER}")
819-
message(STATUS " +0 Normal Args: ${SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS}")
820828
message(STATUS "")
821829

822830
else()
@@ -901,8 +909,18 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
901909
set(SWIFT_LIBDISPATCH_C_COMPILER ${CMAKE_C_COMPILER})
902910
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
903911
elseif(${CMAKE_SYSTEM_NAME} STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
904-
set(SWIFT_LIBDISPATCH_C_COMPILER ${PATH_TO_CLANG_BUILD}/bin/clang)
905-
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${PATH_TO_CLANG_BUILD}/bin/clang++)
912+
get_target_property(CLANG_LOCATION clang LOCATION)
913+
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)
914+
915+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
916+
set(SWIFT_LIBDISPATCH_C_COMPILER
917+
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
918+
set(SWIFT_LIBDISPATCH_CXX_COMPILER
919+
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
920+
else()
921+
set(SWIFT_LIBDISPATCH_C_COMPILER ${CLANG_LOCATION}/clang)
922+
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CLANG_LOCATION}/clang++)
923+
endif()
906924
else()
907925
message(SEND_ERROR "libdispatch requires a newer clang compiler (${CMAKE_C_COMPILER_VERSION} < 3.9)")
908926
endif()
@@ -977,12 +995,24 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
977995
add_dependencies(dispatch libdispatch-install)
978996
add_dependencies(BlocksRuntime libdispatch-install)
979997

998+
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)
999+
set(SOURCEKIT_RUNTIME_DIR bin)
1000+
else()
1001+
set(SOURCEKIT_RUNTIME_DIR lib)
1002+
endif()
9801003
swift_install_in_component(sourcekit-inproc
9811004
FILES
9821005
$<TARGET_FILE:dispatch>
9831006
$<TARGET_FILE:BlocksRuntime>
984-
DESTINATION
985-
lib${LLVM_LIBDIR_SUFFIX})
1007+
DESTINATION ${SOURCEKIT_RUNTIME_DIR})
1008+
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)
1009+
swift_install_in_component(sourcekit-inproc
1010+
FILES
1011+
$<TARGET_LINKER_FILE:dispatch>
1012+
$<TARGET_LINKER_FILE:BlocksRuntime>
1013+
DESTINATION lib)
1014+
endif()
1015+
9861016

9871017
# FIXME(compnerd) this should be taken care of by the
9881018
# INTERFACE_INCLUDE_DIRECTORIES above

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
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)|
2020
|**[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)|
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)|
22-
|**[Ubuntu 16.04 (Android)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | x86_64 |[![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)|
22+
|**[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)|
23+
|**[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)|
2324
|**[Ubuntu 16.04 (TensorFlow)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow)|
2425
|**[macOS 10.13 (TensorFlow)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_macos_high_sierra_tensorflow.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-macOS-tensorflow/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-macOS-tensorflow)|
2526
|**[Ubuntu 16.04 (TensorFlow with GPU)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_tensorflow_gpu.json)** | x86_64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow-gpu/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-tensorflow-gpu)|
@@ -72,7 +73,7 @@ supported host development operating systems.
7273

7374
#### macOS
7475

75-
To build for macOS, you need [Xcode 10.0](https://developer.apple.com/xcode/downloads/).
76+
To build for macOS, you need [Xcode 10.2 beta](https://developer.apple.com/xcode/downloads/).
7677
The required version of Xcode changes frequently, and is often a beta release.
7778
Check this document or the host information on <https://ci.swift.org> for the
7879
current required version.

apinotes/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ add_custom_target("copy_apinotes"
2828
COMMENT "Copying API notes to ${output_dir}"
2929
SOURCES "${sources}")
3030

31+
# This is treated as an OPTIONAL target because if we don't build the SDK
32+
# overlay, the files will be missing anyway. It also allows us to build
33+
# single overlays without installing the API notes.
3134
swift_install_in_component(sdk-overlay
32-
FILES ${sources}
33-
DESTINATION "lib/swift/apinotes")
35+
DIRECTORY "${output_dir}"
36+
DESTINATION "lib/swift/"
37+
OPTIONAL)

benchmark/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ set(SWIFT_BENCH_MODULES
5858
single-source/ClassArrayGetter
5959
single-source/Codable
6060
single-source/Combos
61-
single-source/CountAlgo
6261
single-source/DataBenchmarks
6362
single-source/DeadArray
6463
single-source/DictOfArraysToArrayOfDicts
@@ -78,7 +77,6 @@ set(SWIFT_BENCH_MODULES
7877
single-source/DictionaryRemove
7978
single-source/DictionarySubscriptDefault
8079
single-source/DictionarySwap
81-
single-source/DoubleWidthDivision
8280
single-source/DropFirst
8381
single-source/DropLast
8482
single-source/DropWhile
@@ -90,7 +88,6 @@ set(SWIFT_BENCH_MODULES
9088
single-source/FloatingPointPrinting
9189
single-source/Hanoi
9290
single-source/Hash
93-
single-source/HashQuadratic
9491
single-source/Histogram
9592
single-source/InsertCharacter
9693
single-source/Integrate

benchmark/Naming.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ benchmark is testing individual method on a concrete type.
2828
````
2929
⛔️ Dictionary2
3030
✅ AngryPhonebook
31-
✅ Dictionary.AnyHashable.String.update
3231
✅ Array.append.Array.Int
32+
✅ Dictionary.AnyHashable.String.update
3333
````
3434

3535
Benchmark names are used to run individual tests when passed as command line
@@ -42,8 +42,8 @@ optional chaining etc.
4242

4343
````
4444
✅ Array.append.Array.Int?
45-
✅ Flatten.Array.Tuple4.for-in.reserved
4645
✅ Bridging.NSArray.as!.Array.NSString
46+
✅ Flatten.Array.Tuple4.for-in.Reserve
4747
````
4848

4949
Note: Special characters that could be interpreted by the shell require escaping

benchmark/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,17 @@ Adding New Benchmarks
132132

133133
The harness generator supports both single and multiple file tests.
134134

135-
To add a new single file test:
135+
To add a new single file test, execute the following script with the new of the benchmark:
136136

137+
```
138+
swift-source$ ./swift/benchmark/scripts/create_benchmark.py YourTestNameHere
139+
```
140+
141+
The script will automatically:
137142
1. Add a new Swift file (`YourTestNameHere.swift`), built according to
138143
the template below, to the `single-source` directory.
139-
2. Add the filename of the new Swift file to CMakeLists.txt
140-
3. Edit `main.swift`. Import and register your new Swift module.
144+
2. Add the filename of the new Swift file to `CMakeLists.txt`.
145+
3. Edit `main.swift` by importing and registering your new Swift module.
141146

142147
To add a new multiple file test:
143148

benchmark/multi-source/PrimsSplit/Prims_main.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import TestsUtils
1515
public let PrimsSplit = BenchmarkInfo(
1616
name: "PrimsSplit",
1717
runFunction: run_PrimsSplit,
18-
tags: [.validation, .algorithm])
18+
tags: [.validation, .algorithm],
19+
legacyFactor: 5)
1920

2021
@inline(never)
2122
public func run_PrimsSplit(_ N: Int) {
22-
for _ in 1...5*N {
23+
for _ in 1...N {
2324
let nodes : [Int] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
2425
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
2526
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,

benchmark/scripts/Benchmark_Driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class BenchmarkDriver(object):
200200
with open(log_file, 'w') as f:
201201
f.write(output)
202202

203-
RESULT = '{:>3} {:<25} {:>7} {:>7} {:>6} {:>10} {:>6} {:>7} {:>10}'
203+
RESULT = '{:>3} {:<40} {:>7} {:>7} {:>6} {:>10} {:>6} {:>7} {:>10}'
204204

205205
def run_and_log(self, csv_console=True):
206206
"""Run benchmarks and continuously log results to the console.
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
//===--- StringVariant.swift - Common operations on String storage views -===//
1+
//===--- {name}.swift -------------------------------------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
99
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import TestsUtils
14+
15+
public let {name} = [
16+
BenchmarkInfo(name: "{name}", runFunction: run_{name}, tags: [.validation, .api]),
17+
]
18+
19+
@inline(never)
20+
public func run_{name}(N: Int) {{
21+
// TODO
22+
}}

benchmark/scripts/compare_perf_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ def _reset(self):
363363
# Parse lines like this
364364
# #,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
365365
results_re = re.compile(
366-
r'( *\d+[, \t]+[\w.]+[, \t]+' + # #,TEST
367-
r'[, \t]+'.join([r'\d+'] * 2) + # at least 2...
368-
r'(?:[, \t]+\d*)*)') # ...or more numeric columns
366+
r'( *\d+[, \t]+[\w.\-\?!]+[, \t]+' + # #,TEST
367+
r'[, \t]+'.join([r'\d+'] * 2) + # at least 2...
368+
r'(?:[, \t]+\d*)*)') # ...or more numeric columns
369369

370370
def _append_result(self, result):
371371
columns = result.split(',') if ',' in result else result.split()

0 commit comments

Comments
 (0)