Skip to content

Commit 9edcb10

Browse files
committed
Merge branch 'master' into tbkka-SR12486-Any.Protocol-cast
2 parents c402872 + 71dbe2b commit 9edcb10

File tree

2,690 files changed

+92194
-70409
lines changed

Some content is hidden

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

2,690 files changed

+92194
-70409
lines changed

CMakeLists.txt

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ if(POLICY CMP0067)
1212
cmake_policy(SET CMP0067 NEW)
1313
endif()
1414

15+
# Convert relative paths to absolute for subdirectory `target_sources`
16+
if(POLICY CMP0076)
17+
cmake_policy(SET CMP0076 NEW)
18+
endif()
19+
1520
# Add path for custom CMake modules.
1621
list(APPEND CMAKE_MODULE_PATH
1722
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -142,14 +147,20 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
142147
set(CLANG_COMPILER_VERSION "" CACHE STRING
143148
"The internal version of the Clang compiler")
144149

145-
# Indicate whether Swift should attempt to use the lld linker.
146-
set(SWIFT_ENABLE_LLD_LINKER TRUE CACHE BOOL
147-
"Enable using the lld linker when available")
148-
149-
# Indicate whether Swift should attempt to use the gold linker.
150-
# This is not used on Darwin.
151-
set(SWIFT_ENABLE_GOLD_LINKER TRUE CACHE BOOL
152-
"Enable using the gold linker when available")
150+
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
151+
# our own defaults. This should only be possible in a unified (not stand alone)
152+
# build environment.
153+
if(LLVM_USE_LINKER)
154+
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
155+
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
156+
set(SWIFT_USE_LINKER_default "lld")
157+
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
158+
set(SWIFT_USE_LINKER_default "")
159+
else()
160+
set(SWIFT_USE_LINKER_default "gold")
161+
endif()
162+
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
163+
"Build Swift with a non-default linker")
153164

154165
set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
155166
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
@@ -261,11 +272,11 @@ set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
261272
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
262273

263274
#
264-
# User-configurable ICU specific options for Android, FreeBSD, Linux and Haiku.
275+
# User-configurable ICU specific options for Android, FreeBSD, Linux, Haiku, and WASI.
265276
#
266277

267-
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU)
268-
foreach(arch aarch64;armv6;armv7;i686;powerpc64;powerpc64le;s390x;x86_64)
278+
foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS;HAIKU;WASI)
279+
foreach(arch aarch64;armv6;armv7;i686;powerpc64;powerpc64le;s390x;wasm32;x86_64)
269280
set(SWIFT_${sdk}_${arch}_ICU_UC "" CACHE STRING
270281
"Path to a directory containing the icuuc library for ${sdk}")
271282
set(SWIFT_${sdk}_${arch}_ICU_UC_INCLUDE "" CACHE STRING
@@ -402,6 +413,8 @@ endif()
402413

403414
if(MSVC OR "${CMAKE_SIMULATE_ID}" STREQUAL MSVC)
404415
include(ClangClCompileRules)
416+
elseif(UNIX)
417+
include(UnixCompileRules)
405418
endif()
406419

407420
if(CMAKE_C_COMPILER_ID MATCHES Clang)
@@ -421,19 +434,6 @@ if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
421434
endif()
422435
endif()
423436

424-
#
425-
# Assume a new enough ar to generate the index at construction time. This avoids
426-
# having to invoke ranlib as a secondary command.
427-
#
428-
429-
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
430-
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
431-
set(CMAKE_C_ARCHIVE_FINISH "")
432-
433-
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <LINK_FLAGS> <OBJECTS>")
434-
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qs <TARGET> <LINK_FLAGS> <OBJECTS>")
435-
set(CMAKE_CXX_ARCHIVE_FINISH "")
436-
437437
#
438438
# Include CMake modules
439439
#
@@ -487,16 +487,6 @@ if(NOT SWIFT_LIPO)
487487
find_toolchain_tool(SWIFT_LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
488488
endif()
489489

490-
# Reset CMAKE_SYSTEM_PROCESSOR if not cross-compiling.
491-
# CMake refuses to use `uname -m` on OS X
492-
# http://public.kitware.com/Bug/view.php?id=10326
493-
if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
494-
execute_process(
495-
COMMAND "uname" "-m"
496-
OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
497-
OUTPUT_STRIP_TRAILING_WHITESPACE)
498-
endif()
499-
500490
get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
501491
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
502492
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -555,9 +545,6 @@ if(XCODE)
555545
swift_common_xcode_cxx_config()
556546
endif()
557547

558-
include(SwiftCheckCXXNativeRegex)
559-
check_cxx_native_regex(SWIFT_HAVE_WORKING_STD_REGEX)
560-
561548
# If SWIFT_HOST_VARIANT_SDK not given, try to detect from the CMAKE_SYSTEM_NAME.
562549
if(SWIFT_HOST_VARIANT_SDK)
563550
set(SWIFT_HOST_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
@@ -606,6 +593,8 @@ else()
606593
set(SWIFT_HOST_VARIANT_ARCH_default "itanium")
607594
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86|i686)")
608595
set(SWIFT_HOST_VARIANT_ARCH_default "i686")
596+
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "wasm32")
597+
set(SWIFT_HOST_VARIANT_ARCH_default "wasm32")
609598
else()
610599
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
611600
endif()
@@ -790,6 +779,12 @@ if(swift_build_windows AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
790779
configure_sdk_windows("Windows" "msvc" "${SWIFT_SDK_WINDOWS_ARCHITECTURES}")
791780
endif()
792781

782+
# Should we cross-compile the standard library for WASI?
783+
is_sdk_requested(WASI swift_build_wasm)
784+
if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASI")
785+
configure_sdk_unix(WASI wasm32)
786+
endif()
787+
793788
if("${SWIFT_SDKS}" STREQUAL "")
794789
set(SWIFT_SDKS "${SWIFT_CONFIGURED_SDKS}")
795790
endif()

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| **Ubuntu 16.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-16_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-16_04)|
1010
| **Ubuntu 18.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-linux-ubuntu-18_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04)|
1111
| **Ubuntu 20.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|
12-
| **CentOS 8** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|[![Build Status](https://ci.swift.org/job/oss-swift-package-linux-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|
12+
| **CentOS 8** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|
1313
| **Amazon Linux 2** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|
1414

1515
**Swift Community-Hosted CI Platforms**
@@ -85,6 +85,9 @@ Once you are able to build things successfully and have a compile-test-debug
8585
loop going, check out the [development tips](docs/DevelopmentTips.md) for
8686
better productivity while working on the compiler.
8787

88+
You can also skim [docs/README.md](/docs/README.md) to understand what
89+
high-level documentation is available.
90+
8891
### System Requirements
8992

9093
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are currently
@@ -94,7 +97,7 @@ Please make sure you use Python 2.x. Python 3.x is not supported currently.
9497

9598
#### macOS
9699

97-
To build for macOS, you need [Xcode 11.4](https://developer.apple.com/xcode/resources/).
100+
To build for macOS, you need [Xcode 12 beta](https://developer.apple.com/xcode/resources/).
98101
The required version of Xcode changes frequently, and is often a beta release.
99102
Check this document or the host information on <https://ci.swift.org> for the
100103
current required version.
@@ -151,8 +154,6 @@ with version 2 shipped with Ubuntu.
151154

152155
**Note:** For Ubuntu 20.04, use `libpython2-dev` in place of the libpython-dev package above.
153156

154-
Build instructions for Ubuntu 14.04 LTS can be found [here](docs/Ubuntu14.md).
155-
156157
### Getting Sources for Swift and Related Projects
157158

158159
First create a directory for all of the Swift sources:

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ set(SWIFT_BENCH_MODULES
108108
single-source/LuhnAlgoLazy
109109
single-source/MapReduce
110110
single-source/Memset
111+
single-source/Mirror
111112
single-source/MonteCarloE
112113
single-source/MonteCarloPi
113114
single-source/NSDictionaryCastToSwift

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,11 @@ function (swift_benchmark_compile_archopts)
660660
"-m${triple_platform}-version-min=${ver}"
661661
"-lobjc"
662662
"-L${SWIFT_LIBRARY_PATH}/${BENCH_COMPILE_ARCHOPTS_PLATFORM}"
663+
"-L${sdk}/usr/lib/swift"
663664
"-Xlinker" "-rpath"
664665
"-Xlinker" "${SWIFT_LINK_RPATH}"
666+
"-Xlinker" "-rpath"
667+
"-Xlinker" "/usr/lib/swift"
665668
${bench_library_objects}
666669
${bench_driver_objects}
667670
${ld64_add_ast_path_opts}
@@ -694,7 +697,7 @@ function(swift_benchmark_compile)
694697
cmake_parse_arguments(SWIFT_BENCHMARK_COMPILE "" "PLATFORM" "" ${ARGN})
695698

696699
if(NOT SWIFT_BENCHMARK_BUILT_STANDALONE)
697-
set(stdlib_dependencies "swift")
700+
set(stdlib_dependencies "swift-frontend")
698701
foreach(stdlib_dependency ${UNIVERSAL_LIBRARY_NAMES_${SWIFT_BENCHMARK_COMPILE_PLATFORM}})
699702
string(FIND "${stdlib_dependency}" "Unittest" find_output)
700703
if("${find_output}" STREQUAL "-1")

benchmark/scripts/run_smoke_bench

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ def report_code_size(opt_level, old_dir, new_dir, platform, output_file):
272272
old_lines = ""
273273
new_lines = ""
274274
for oldfile in files:
275+
new_dir = os.path.join(new_dir, '')
275276
newfile = oldfile.replace(old_dir, new_dir, 1)
276277
if os.path.isfile(newfile):
277278
oldsize = get_codesize(oldfile)

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/Mirror.swift

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//===--- Mirror.swift ------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
// This test measures performance of Mirror and related things.
14+
import TestsUtils
15+
16+
public let TypeName = BenchmarkInfo(
17+
name: "TypeName",
18+
runFunction: run_TypeName,
19+
tags: [.api, .String])
20+
21+
public let MirrorDefault = BenchmarkInfo(
22+
name: "MirrorDefault",
23+
runFunction: run_MirrorDefault,
24+
tags: [.api, .String])
25+
26+
struct S1 { var s: String; var d: Double }
27+
struct S2 { var i: Int; var a: [Range<Int>] }
28+
29+
class C { var i: Int = 0 }
30+
class D: C { var s: String = "" }
31+
32+
enum E {
33+
case a,b(Int)
34+
}
35+
36+
struct G<T> { var t: T }
37+
class H<T>: C { var t: T; init(_ t: T) { self.t = t }}
38+
39+
public func run_MirrorDefault(scale: Int) {
40+
let N = 100*scale
41+
42+
let s1 = S1(s: "foo", d: 3.14)
43+
let s2 = S2(i: 42, a: [0..<4])
44+
let c = C()
45+
let d = D()
46+
let e = E.a
47+
let f = E.b(99)
48+
let g = G(t: 12.3)
49+
let h = H<[Int]>([1,2,3])
50+
51+
var str = ""
52+
53+
for _ in 0..<N {
54+
str = "\(s1),\(s2),\(c),\(d),\(e),\(f),\(g),\(h)"
55+
blackHole(str)
56+
}
57+
58+
CheckResults(str ==
59+
"S1(s: \"foo\", d: 3.14),S2(i: 42, a: [Range(0..<4)]),Mirror.C,Mirror.D,a,b(99),G<Double>(t: 12.3),Mirror.H<Swift.Array<Swift.Int>>")
60+
}
61+
62+
func typename<T>(of: T.Type) -> String {
63+
"\(T.self)"
64+
}
65+
66+
public func run_TypeName(scale: Int) {
67+
let N = 1_000*scale
68+
var a: [String] = []
69+
a.reserveCapacity(16)
70+
71+
for _ in 0..<N {
72+
a = []
73+
a.removeAll(keepingCapacity: true)
74+
a.append(typename(of: S1.self))
75+
a.append(typename(of: S2.self))
76+
a.append(typename(of: C.self))
77+
a.append(typename(of: D.self))
78+
a.append(typename(of: G<S1>.self))
79+
a.append(typename(of: G<C>.self))
80+
a.append(typename(of: G<String>.self))
81+
a.append(typename(of: H<Int>.self))
82+
a.append(typename(of: [S1].self))
83+
a.append(typename(of: [G<Int>].self))
84+
a.append(typename(of: [H<S1>].self))
85+
a.append(typename(of: S1?.self))
86+
a.append(typename(of: C?.self))
87+
blackHole(a)
88+
}
89+
90+
let expected = ["S1",
91+
"S2",
92+
"C",
93+
"D",
94+
"G<S1>",
95+
"G<C>",
96+
"G<String>",
97+
"H<Int>",
98+
"Array<S1>",
99+
"Array<G<Int>>",
100+
"Array<H<S1>>",
101+
"Optional<S1>",
102+
"Optional<C>",
103+
]
104+
CheckResults(a == expected)
105+
}

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(

0 commit comments

Comments
 (0)