Skip to content

Commit

Permalink
Merge branch 'master' into Self-fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
johnno1962 authored Mar 14, 2019
2 parents 32fd355 + 1e0414d commit d3e2550
Show file tree
Hide file tree
Showing 723 changed files with 21,950 additions and 9,069 deletions.
97 changes: 97 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG

| Contents |
| :--------------------- |
| [Swift 5.1](#swift-51) |
| [Swift 5.0](#swift-50) |
| [Swift 4.2](#swift-42) |
| [Swift 4.1](#swift-41) |
Expand All @@ -28,9 +29,100 @@ Swift 5.1

`Self` can now be used inside member functions and for function arguments of structs and enums to refer to the containing type.

* [SR-7799][]:

Enum cases can now be matched against an optional enum without
requiring a '?' at the end of the pattern.

```swift
enum Foo { case zero, one }

let foo: Foo? = .zero

switch foo {
case .zero: break
case .one: break
case .none: break
}
```

* `weak` and `unowned` variables can now be used inside types that
declare `Equatable` or `Hashable` conformance.

* [SR-2688][]:

An `@autoclosure` closure can now be a typealias.

```swift
class Foo {
typealias FooClosure = () -> String
func fooFunction(closure: @autoclosure FooClosure) {}
}
```

* [SR-7601][]:

Functions marked with `@objc` can now return `Self`

```swift
@objc func returnDynamicSelf() -> Self { return self }
```

* [SR-2176][]:

Assigning '.none' to an optional enum which also has a 'none' case
or comparing such an enum with '.none' will now warn. Such expressions
create an ambiguity because the compiler chooses Optional.none
over Foo.none.

```swift
enum Foo { case none }

// Assigned Optional.none instead of Foo.none
let foo: Foo? = .none
// Comparing with Optional.none instead of Foo.none
let isEqual = foo == .none
```

The compiler will provide a warning along with a fix-it to
replace '.none' with 'Optional.none' or 'Foo.none' to resolve
the ambiguity.

* Key path expressions can now include references to tuple elements.

* Single-parameter functions accepting values of type `Any` are no
longer preferred over other functions.

```swift
func foo(_: Any) { print("Any") }
func foo<T>(_: T) { print("T") }
foo(0) // prints "Any" in Swift < 5.1, "T" in Swift 5.1
```

**Add new entries to the top of this section, not here!**

Swift 5.0
---------

* [SE-0235][]:

The standard library now contains a `Result` type for manually propagating errors.

```swift
enum Result<Success, Failure: Error> {
case success(Success)
case failure(Failure)
}
```

This type serves a complementary role to that of throwing functions and initializers.
Use `Result` in situations where automatic error propagation or `try`-`catch`
blocks are undesirable, such as in asynchronous code or when accumulating the
results of successive error-producing operations.

* `Error` now conforms to itself. This allows for the use of `Error` itself as
the argument for a generic parameter constrained to `Error`.

* Swift 3 mode has been removed. Supported values for the `-swift-version`
flag are `4`, `4.2`, and `5`.

Expand Down Expand Up @@ -7413,6 +7505,7 @@ Swift 1.0
[SE-0227]: <https://github.com/apple/swift-evolution/blob/master/proposals/0227-identity-keypath.md>
[SE-0228]: <https://github.com/apple/swift-evolution/blob/master/proposals/0228-fix-expressiblebystringinterpolation.md>
[SE-0230]: <https://github.com/apple/swift-evolution/blob/master/proposals/0230-flatten-optional-try.md>
[SE-0235]: <https://github.com/apple/swift-evolution/blob/master/proposals/0235-add-result.md>

[SR-106]: <https://bugs.swift.org/browse/SR-106>
[SR-419]: <https://bugs.swift.org/browse/SR-419>
Expand All @@ -7422,12 +7515,16 @@ Swift 1.0
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
[SR-2176]: <https://bugs.swift.org/browse/SR-2176>
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>
[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
[SR-2688]: <https://bugs.swift.org/browse/SR-2688>
[SR-4248]: <https://bugs.swift.org/browse/SR-4248>
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>
[SR-7799]: <https://bugs.swift.org/browse/SR-7799>
[SR-8109]: <https://bugs.swift.org/browse/SR-8109>
137 changes: 87 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ endif()
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

# Make a job pool for things that can't yet be distributed
cmake_host_system_information(
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
# Put linking in that category
set_property(GLOBAL PROPERTY JOB_POOL_LINK local_jobs)
if(DEFINED CMAKE_JOB_POOLS)
# CMake < 3.11 doesn't support CMAKE_JOB_POOLS. Manually set the property.
set_property(GLOBAL PROPERTY JOB_POOLS "${CMAKE_JOB_POOLS}")
else()
# Make a job pool for things that can't yet be distributed
cmake_host_system_information(
RESULT localhost_logical_cores QUERY NUMBER_OF_LOGICAL_CORES)
set_property(GLOBAL PROPERTY JOB_POOLS local_jobs=${localhost_logical_cores})
# Put linking in that category
set(CMAKE_JOB_POOL_LINK local_jobs)
endif()

ENABLE_LANGUAGE(C)

Expand Down Expand Up @@ -101,25 +106,6 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type was specified, will default to ${CMAKE_BUILD_TYPE}")
endif()

set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")

is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
if(swift_optimized)
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
else()
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
endif()
option(SWIFT_STDLIB_ASSERTIONS
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
"${SWIFT_STDLIB_ASSERTIONS_default}")

option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
"Use the host compiler and not the internal clang to build the swift runtime"
FALSE)

set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
Expand All @@ -146,23 +132,6 @@ set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
"Enable using the gold linker when available")

set(SWIFT_SDKS "" CACHE STRING
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")

set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
"Primary SDK for target binaries")
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
"Primary arch for target binaries")

set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains LLVM tools that are executable on the build machine")

set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains Clang tools that are executable on the build machine")

set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains Swift tools that are executable on the build machine")

set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
option only affects the tools that run on the host (the compiler), and has
Expand All @@ -176,10 +145,6 @@ option(SWIFT_FORCE_OPTIMIZED_TYPECHECKER "Override the optimization setting of
the type checker so that it always compiles with optimization. This eases
debugging after type checking occurs by speeding up type checking" FALSE)

option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
"Generate .swiftinterface files alongside .swiftmodule files"
TRUE)

# Allow building Swift with Clang's Profile Guided Optimization
if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
if(NOT CMAKE_C_COMPILER_ID MATCHES Clang)
Expand All @@ -188,6 +153,57 @@ if(SWIFT_PROFDATA_FILE AND EXISTS ${SWIFT_PROFDATA_FILE})
add_definitions("-fprofile-instr-use=${SWIFT_PROFDATA_FILE}")
endif()

#
# User-configurable Swift Standard Library specific options.
#
# TODO: Once the stdlib/compiler builds are split, this should be sunk into the
# stdlib cmake.
#

set(SWIFT_STDLIB_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Build type for the Swift standard library and SDK overlays [Debug, RelWithDebInfo, Release, MinSizeRel]")
set_property(CACHE SWIFT_STDLIB_BUILD_TYPE PROPERTY
STRINGS "Debug" "RelWithDebInfo" "Release" "MinSizeRel")

is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" swift_optimized)
if(swift_optimized)
set(SWIFT_STDLIB_ASSERTIONS_default FALSE)
else()
set(SWIFT_STDLIB_ASSERTIONS_default TRUE)
endif()
option(SWIFT_STDLIB_ASSERTIONS
"Enable internal checks for the Swift standard library (useful for debugging the library itself, does not affect checks required for safety)"
"${SWIFT_STDLIB_ASSERTIONS_default}")

option(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER
"Use the host compiler and not the internal clang to build the swift runtime"
FALSE)

set(SWIFT_SDKS "" CACHE STRING
"If non-empty, limits building target binaries only to specified SDKs (despite other SDKs being available)")

set(SWIFT_PRIMARY_VARIANT_SDK "" CACHE STRING
"Primary SDK for target binaries")
set(SWIFT_PRIMARY_VARIANT_ARCH "" CACHE STRING
"Primary arch for target binaries")

set(SWIFT_NATIVE_LLVM_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains LLVM tools that are executable on the build machine")

set(SWIFT_NATIVE_CLANG_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains Clang tools that are executable on the build machine")

set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "" CACHE STRING
"Path to the directory that contains Swift tools that are executable on the build machine")

option(SWIFT_ENABLE_PARSEABLE_MODULE_INTERFACES
"Generate .swiftinterface files alongside .swiftmodule files"
TRUE)

option(SWIFT_STDLIB_ENABLE_SIB_TARGETS
"Should we generate sib targets for the stdlib or not?"
FALSE)

#
# User-configurable Android specific options.
#
Expand Down Expand Up @@ -235,8 +251,8 @@ option(SWIFT_RUNTIME_CRASH_REPORTER_CLIENT
FALSE)

option(SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT
"Enable the Swift stable ABI's class marker bit"
FALSE)
"Enable the Swift stable ABI's class marker bit for new deployment targets"
TRUE)

set(SWIFT_DARWIN_XCRUN_TOOLCHAIN "XcodeDefault" CACHE STRING
"The name of the toolchain to pass to 'xcrun'")
Expand Down Expand Up @@ -413,13 +429,24 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(EXISTS ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE} AND
CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(SWIFT_BUILD_SYNTAXPARSERLIB_default TRUE)
set(SWIFT_BUILD_SOURCEKIT_default TRUE)
else()
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
endif()
else()
set(SWIFT_BUILD_SYNTAXPARSERLIB_default FALSE)
set(SWIFT_BUILD_SOURCEKIT_default FALSE)
endif()
option(SWIFT_BUILD_SYNTAXPARSERLIB
"Build the Swift Syntax Parser library"
${SWIFT_BUILD_SYNTAXPARSERLIB_default})
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
"Only build the Swift Syntax Parser library" FALSE)
option(SWIFT_BUILD_SOURCEKIT
"Build SourceKit"
${SWIFT_BUILD_SOURCEKIT_default})
Expand Down Expand Up @@ -898,8 +925,18 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
set(SWIFT_LIBDISPATCH_C_COMPILER ${CMAKE_C_COMPILER})
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CMAKE_CXX_COMPILER})
elseif(${CMAKE_SYSTEM_NAME} STREQUAL ${CMAKE_HOST_SYSTEM_NAME})
set(SWIFT_LIBDISPATCH_C_COMPILER $<TARGET_PROPERTY:clang,LOCATION>)
set(SWIFT_LIBDISPATCH_CXX_COMPILER $<TARGET_PROPERTY:clang,LOCATION>)
get_target_property(CLANG_LOCATION clang LOCATION)
get_filename_component(CLANG_LOCATION ${CLANG_LOCATION} DIRECTORY)

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_LIBDISPATCH_C_COMPILER
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
set(SWIFT_LIBDISPATCH_CXX_COMPILER
${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
else()
set(SWIFT_LIBDISPATCH_C_COMPILER ${CLANG_LOCATION}/clang)
set(SWIFT_LIBDISPATCH_CXX_COMPILER ${CLANG_LOCATION}/clang++)
endif()
else()
message(SEND_ERROR "libdispatch requires a newer clang compiler (${CMAKE_C_COMPILER_VERSION} < 3.9)")
endif()
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
|**[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)|
|**[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)|
|**[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)|
|**[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)|
|**[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)|
|**[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)|
|**[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)|
|**[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)|
|**[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)|
Expand Down
1 change: 0 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ set(SWIFT_BENCH_MODULES
single-source/DictionaryRemove
single-source/DictionarySubscriptDefault
single-source/DictionarySwap
single-source/DoubleWidthDivision
single-source/DropFirst
single-source/DropLast
single-source/DropWhile
Expand Down
5 changes: 5 additions & 0 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ macro(configure_sdks_darwin)
set(appletvos_ver "9.1")
set(watchos_ver "2.0")

set(macosx_vendor "apple")
set(iphoneos_vendor "apple")
set(appletvos_vendor "apple")
set(watchos_vendor "apple")

set(macosx_triple_platform "macosx")
set(iphoneos_triple_platform "ios")
set(appletvos_triple_platform "tvos")
Expand Down
9 changes: 5 additions & 4 deletions benchmark/single-source/ArrayInClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public let ArrayInClass = [
runFunction: run_ArrayInClass,
tags: [.validation, .api, .Array],
setUpFunction: { ac = ArrayContainer() },
tearDownFunction: { ac = nil }),
tearDownFunction: { ac = nil },
legacyFactor: 5),
BenchmarkInfo(name: "DistinctClassFieldAccesses",
runFunction: run_DistinctClassFieldAccesses,
tags: [.unstable, .api, .Array],
setUpFunction: { workload = ClassWithArrs(N: 100_000) },
tags: [.validation, .api, .Array],
setUpFunction: { workload = ClassWithArrs(N: 10_000) },
tearDownFunction: { workload = nil }),
]

Expand All @@ -31,7 +32,7 @@ class ArrayContainer {
final var arr : [Int]

init() {
arr = [Int] (repeating: 0, count: 100_000)
arr = [Int] (repeating: 0, count: 20_000)
}

func runLoop(_ N: Int) {
Expand Down
Loading

0 comments on commit d3e2550

Please sign in to comment.