Skip to content

Commit 26996d4

Browse files
author
ematejska
authored
Merge pull request #32077 from apple/tensorflow-merge
Merge swift-DEVELOPMENT-SNAPSHOT-2020-05-26-a into tensorflow
2 parents d2873b6 + 23d077e commit 26996d4

File tree

467 files changed

+8893
-3439
lines changed

Some content is hidden

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

467 files changed

+8893
-3439
lines changed

CMakeLists.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,22 @@ set(CLANG_COMPILER_VERSION "" CACHE STRING
154154
"The internal version of the Clang compiler")
155155

156156
# Indicate whether Swift should attempt to use the lld linker.
157-
set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
157+
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
158+
set(SWIFT_ENABLE_LLD_LINKER_default TRUE)
159+
else()
160+
set(SWIFT_ENABLE_LLD_LINKER_default FALSE)
161+
endif()
162+
set(SWIFT_ENABLE_LLD_LINKER ${SWIFT_ENABLE_LLD_LINKER_default} CACHE BOOL
158163
"Enable using the lld linker when available")
159164

160165
# Indicate whether Swift should attempt to use the gold linker.
161166
# This is not used on Darwin.
162-
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
167+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL Windows)
168+
set(SWIFT_ENABLE_GOLD_LINKER_default FALSE)
169+
else()
170+
set(SWIFT_ENABLE_GOLD_LINKER_default TRUE)
171+
endif()
172+
set(SWIFT_ENABLE_GOLD_LINKER ${SWIFT_ENABLE_GOLD_LINKER_default} CACHE BOOL
163173
"Enable using the gold linker when available")
164174

165175
set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
@@ -579,9 +589,6 @@ if(XCODE)
579589
swift_common_xcode_cxx_config()
580590
endif()
581591

582-
include(SwiftCheckCXXNativeRegex)
583-
check_cxx_native_regex(SWIFT_HAVE_WORKING_STD_REGEX)
584-
585592
# If SWIFT_HOST_VARIANT_SDK not given, try to detect from the CMAKE_SYSTEM_NAME.
586593
if(SWIFT_HOST_VARIANT_SDK)
587594
set(SWIFT_HOST_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")

benchmark/single-source/DataBenchmarks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import TestsUtils
1414
import Foundation
1515

16-
let d: [BenchmarkCategory] = [.validation, .api, .Data]
16+
let d: [BenchmarkCategory] = [.validation, .api, .Data, .cpubench]
1717

1818
public let DataBenchmarks = [
1919
BenchmarkInfo(name: "DataCreateEmpty",

benchmark/single-source/DictionarySwap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let numberMap = Dictionary(uniqueKeysWithValues: zip(1...size, 1...size))
1919
let boxedNums = (1...size).lazy.map { Box($0) }
2020
let boxedNumMap = Dictionary(uniqueKeysWithValues: zip(boxedNums, boxedNums))
2121

22-
let t: [BenchmarkCategory] = [.validation, .api, .Dictionary]
22+
let t: [BenchmarkCategory] = [.validation, .api, .Dictionary, .cpubench]
2323

2424
public let DictionarySwap = [
2525
BenchmarkInfo(name: "DictionarySwap",

benchmark/single-source/NIOChannelPipeline.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TestsUtils
1414

1515
// Mini benchmark implementing the gist of SwiftNIO's ChannelPipeline as
1616
// implemented by NIO 1 and NIO 2.[01]
17-
let t: [BenchmarkCategory] = [.runtime, .refcount]
17+
let t: [BenchmarkCategory] = [.runtime, .refcount, .cpubench]
1818
let N = 100
1919

2020
public let NIOChannelPipeline = [

benchmark/single-source/ObjectiveCNoBridgingStubs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Foundation
2121
import ObjectiveCTests
2222
#endif
2323

24-
let t: [BenchmarkCategory] = [.validation, .bridging]
24+
let t: [BenchmarkCategory] = [.validation, .bridging, .cpubench]
2525

2626
public let ObjectiveCNoBridgingStubs = [
2727
BenchmarkInfo(name: "ObjectiveCBridgeStubToNSStringRef",

benchmark/single-source/ReversedCollections.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public let ReversedCollections = [
1616
BenchmarkInfo(name: "ReversedArray2", runFunction: run_ReversedArray, tags: [.validation, .api, .Array],
1717
setUpFunction: { blackHole(arrayInput) },
1818
tearDownFunction: { arrayInput = nil }),
19-
BenchmarkInfo(name: "ReversedBidirectional", runFunction: run_ReversedBidirectional, tags: [.validation, .api]),
19+
BenchmarkInfo(name: "ReversedBidirectional", runFunction: run_ReversedBidirectional, tags: [.validation, .api, .cpubench]),
2020
BenchmarkInfo(name: "ReversedDictionary2", runFunction: run_ReversedDictionary, tags: [.validation, .api, .Dictionary],
2121
setUpFunction: { blackHole(dictionaryInput) },
2222
tearDownFunction: { dictionaryInput = nil })

benchmark/single-source/SortLargeExistentials.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import TestsUtils
1717
public let SortLargeExistentials = BenchmarkInfo(
1818
name: "SortLargeExistentials",
1919
runFunction: run_SortLargeExistentials,
20-
tags: [.validation, .api, .algorithm],
20+
tags: [.validation, .api, .algorithm, .cpubench],
2121
legacyFactor: 100)
2222

2323
protocol LetterKind {

benchmark/single-source/StackPromo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import TestsUtils
1414
public let StackPromo = BenchmarkInfo(
1515
name: "StackPromo",
1616
runFunction: run_StackPromo,
17-
tags: [.regression],
17+
tags: [.regression, .cpubench],
1818
legacyFactor: 100)
1919

2020
protocol Proto {

benchmark/single-source/StringReplaceSubrange.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import TestsUtils
1414

15-
let tags: [BenchmarkCategory] = [.validation, .api, .String]
15+
let tags: [BenchmarkCategory] = [.validation, .api, .String, .cpubench]
1616

1717
public let StringReplaceSubrange = [
1818
BenchmarkInfo(

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,12 @@ function(_add_host_variant_link_flags target)
368368
endif()
369369

370370
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
371-
# FIXME: On Apple platforms, find_program needs to look for "ld64.lld"
372-
find_program(LDLLD_PATH "ld.lld")
373-
if((SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE) OR
374-
(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS AND NOT CMAKE_SYSTEM_NAME STREQUAL WINDOWS))
375-
target_link_options(${target} PRIVATE -fuse-ld=lld)
376-
elseif(SWIFT_ENABLE_GOLD_LINKER AND
377-
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
378-
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
379-
target_link_options(${target} PRIVATE -fuse-ld=gold.exe)
380-
else()
381-
target_link_options(${target} PRIVATE -fuse-ld=gold)
382-
endif()
371+
if(SWIFT_ENABLE_LLD_LINKER)
372+
target_link_options(${target} PRIVATE
373+
-fuse-ld=lld$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
374+
elseif(SWIFT_ENABLE_GOLD_LINKER)
375+
target_link_options(${target} PRIVATE
376+
-fuse-ld=gold$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
383377
endif()
384378
endif()
385379

cmake/modules/SwiftCheckCXXNativeRegex.cmake

Lines changed: 0 additions & 32 deletions
This file was deleted.

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ macro(configure_sdk_unix name architectures)
374374

375375
# If the module triple wasn't set explicitly, it's the same as the triple.
376376
if(NOT SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE)
377-
set(SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE "${SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE}")
377+
set(SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE "${SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE}")
378378
endif()
379379
endforeach()
380380

@@ -407,7 +407,7 @@ macro(configure_sdk_windows name environment architectures)
407407
"${arch}-unknown-windows-${environment}")
408408
endif()
409409

410-
set(SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE "${SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE}")
410+
set(SWIFT_SDK_${prefix}_ARCH_${arch}_MODULE "${SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE}")
411411

412412
# NOTE: set the path to / to avoid a spurious `--sysroot` from being passed
413413
# to the driver -- rely on the `INCLUDE` AND `LIB` environment variables

docs/Lexicon.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ and *zero* protocols; the latter is the `Any` type).
167167
Describes a type or function where making changes will break binary
168168
compatibility. See [LibraryEvolution.rst](LibraryEvolution.rst).
169169

170+
## gardening
171+
172+
Describes contributions which fix code that is not executed
173+
(such as in a manifesto or README) and written text
174+
(correcting typos and grammatical errors).
175+
170176
## generic environment
171177

172178
Provides context for interpreting a type that may have generic parameters

docs/Testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ uses an iOS 10.3 simulator configuration named "iPhone 5" for 32-bit testing.
3838
window, or with the command line:
3939

4040
```sh
41-
xcrun simctl create 'iPhone 5' 'com.apple.CoreSimulator.SimDeviceType.iPhone-5'
41+
xcrun simctl create 'iPhone 5' com.apple.CoreSimulator.SimDeviceType.iPhone-5 com.apple.CoreSimulator.SimRuntime.iOS-10-3
4242
```
4343

4444
3. Append `--ios` to the `utils/build-script` command line (see below).

docs/WindowsBuild.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
# Building Swift on Windows
22

3-
Visual Studio 2017 or newer is needed to build swift on Windows.
3+
Visual Studio 2017 or newer is needed to build Swift on Windows.
44

5-
The following must take place in the **developer command prompt** (provided by Visual Studio). This shows up as "x64 Native Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu.
5+
The commands below (with the exception of installing Visual Studio) must be entered in the "**x64 Native** Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to select the correct target platform.
66

77
## Install dependencies
88

9-
- Install the latest version of [Visual Studio](https://www.visualstudio.com/downloads/)
10-
- Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The following components are required:
9+
### Visual Studio
1110

12-
1. Microsoft.VisualStudio.Component.Windows10SDK
13-
2. Microsoft.VisualStudio.Component.Windows10SDK.17763
14-
3. Microsoft.VisualStudio.Component.VC.Tools.x86.x64
11+
An easy way to get most of the tools to build Swift is using the [Visual Studio installer](https://www.visualstudio.com/downloads/). This command installs all needed Visual Studio components as well as Python and Git:
12+
13+
```
14+
vs_community ^
15+
--add Component.CPython2.x86 ^
16+
--add Component.CPython3.x64 ^
17+
--add Microsoft.VisualStudio.Component.Git ^
18+
--add Microsoft.VisualStudio.Component.VC.ATL ^
19+
--add Microsoft.VisualStudio.Component.VC.CMake.Project ^
20+
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
21+
--add Microsoft.VisualStudio.Component.Windows10SDK ^
22+
--add Microsoft.VisualStudio.Component.Windows10SDK.17763
23+
```
24+
25+
If you prefer you can install everything by hand, but make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation. The components listed above are required.
1526

1627
The following [link](https://docs.microsoft.com/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019) helps in finding the component name given its ID for Visual Studio 2019.
1728

1829
### Python
1930

20-
In the Visual Studio installation program, under *Individual Components*
31+
The command above already installs Python 2 and 3. Alternatively, in the Visual Studio installation program, under *Individual Components*
2132

2233
1. Install *Python 2*, either the 32-bit version (C:\Python27\\) or the 64-bit version (C:\Python27amd64\\)
2334

include/swift/ABI/Metadata.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,9 +1012,12 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
10121012

10131013
constexpr TargetAnyClassMetadata(TargetClassMetadata<Runtime> *superclass)
10141014
: TargetHeapMetadata<Runtime>(MetadataKind::Class),
1015-
Superclass(superclass),
1016-
CacheData{nullptr, nullptr},
1017-
Data(SWIFT_CLASS_IS_SWIFT_MASK) {}
1015+
Superclass(superclass)
1016+
#if SWIFT_OBJC_INTEROP
1017+
, CacheData{nullptr, nullptr},
1018+
Data(SWIFT_CLASS_IS_SWIFT_MASK)
1019+
#endif
1020+
{}
10181021

10191022
#if SWIFT_OBJC_INTEROP
10201023
// Allow setting the metadata kind to a class ISA on class metadata.
@@ -1027,8 +1030,7 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
10271030
/// The metadata for the superclass. This is null for the root class.
10281031
ConstTargetMetadataPointer<Runtime, swift::TargetClassMetadata> Superclass;
10291032

1030-
// TODO: remove the CacheData and Data fields in non-ObjC-interop builds.
1031-
1033+
#if SWIFT_OBJC_INTEROP
10321034
/// The cache data is used for certain dynamic lookups; it is owned
10331035
/// by the runtime and generally needs to interoperate with
10341036
/// Objective-C's use.
@@ -1043,11 +1045,16 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
10431045
static constexpr StoredPointer offsetToData() {
10441046
return offsetof(TargetAnyClassMetadata, Data);
10451047
}
1048+
#endif
10461049

10471050
/// Is this object a valid swift type metadata? That is, can it be
10481051
/// safely downcast to ClassMetadata?
10491052
bool isTypeMetadata() const {
1053+
#if SWIFT_OBJC_INTEROP
10501054
return (Data & SWIFT_CLASS_IS_SWIFT_MASK);
1055+
#else
1056+
return true;
1057+
#endif
10511058
}
10521059
/// A different perspective on the same bit
10531060
bool isPureObjC() const {
@@ -1270,6 +1277,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
12701277
return bounds;
12711278
}
12721279

1280+
#if SWIFT_OBJC_INTEROP
12731281
/// Given a statically-emitted metadata template, this sets the correct
12741282
/// "is Swift" bit for the current runtime. Depending on the deployment
12751283
/// target a binary was compiled for, statically emitted metadata templates
@@ -1294,6 +1302,7 @@ struct TargetClassMetadata : public TargetAnyClassMetadata<Runtime> {
12941302

12951303
assert(isTypeMetadata());
12961304
}
1305+
#endif
12971306

12981307
bool isCanonicalStaticallySpecializedGenericMetadata() const {
12991308
auto *description = getDescription();

include/swift/AST/ASTContext.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ namespace swift {
111111
class SourceManager;
112112
class ValueDecl;
113113
class DiagnosticEngine;
114-
class TypeCheckerDebugConsumer;
115114
struct RawComment;
116115
class DocComment;
117116
class SILBoxType;
@@ -276,9 +275,6 @@ class ASTContext final {
276275
#define IDENTIFIER_WITH_NAME(Name, IdStr) Identifier Id_##Name;
277276
#include "swift/AST/KnownIdentifiers.def"
278277

279-
/// A consumer of type checker debug output.
280-
std::unique_ptr<TypeCheckerDebugConsumer> TypeCheckerDebug;
281-
282278
/// Cache for names of canonical GenericTypeParamTypes.
283279
mutable llvm::DenseMap<unsigned, Identifier>
284280
CanonicalGenericTypeParamTypeNames;
@@ -784,11 +780,13 @@ class ASTContext final {
784780
/// \param methods The list of @objc methods in this class that have this
785781
/// selector and are instance/class methods as requested. This list will be
786782
/// extended with any methods found in subsequent generations.
787-
void loadObjCMethods(ClassDecl *classDecl,
788-
ObjCSelector selector,
789-
bool isInstanceMethod,
790-
unsigned previousGeneration,
791-
llvm::TinyPtrVector<AbstractFunctionDecl *> &methods);
783+
///
784+
/// \param swiftOnly If true, only loads methods from imported Swift modules,
785+
/// skipping the Clang importer.
786+
void loadObjCMethods(ClassDecl *classDecl, ObjCSelector selector,
787+
bool isInstanceMethod, unsigned previousGeneration,
788+
llvm::TinyPtrVector<AbstractFunctionDecl *> &methods,
789+
bool swiftOnly = false);
792790

793791
/// Load derivative function configurations for the given
794792
/// AbstractFunctionDecl.

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ SWIFT_TYPEID_NAMED(PatternBindingEntry *, PatternBindingEntry)
5757
SWIFT_TYPEID_NAMED(PostfixOperatorDecl *, PostfixOperatorDecl)
5858
SWIFT_TYPEID_NAMED(PrecedenceGroupDecl *, PrecedenceGroupDecl)
5959
SWIFT_TYPEID_NAMED(PrefixOperatorDecl *, PrefixOperatorDecl)
60+
SWIFT_TYPEID_NAMED(ProtocolConformance *, ProtocolConformance)
6061
SWIFT_TYPEID_NAMED(ProtocolDecl *, ProtocolDecl)
6162
SWIFT_TYPEID_NAMED(SourceFile *, SourceFile)
6263
SWIFT_TYPEID_NAMED(TypeAliasDecl *, TypeAliasDecl)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct PropertyWrapperTypeInfo;
5252
enum class CtorInitializerKind;
5353
struct PropertyWrapperLValueness;
5454
struct PropertyWrapperMutability;
55+
class ProtocolConformance;
5556
class ProtocolDecl;
5657
class Requirement;
5758
enum class ResilienceExpansion : unsigned;

0 commit comments

Comments
 (0)