Skip to content

Commit 01fa6dc

Browse files
committed
merge branch 'main' into function-in-constructor
2 parents 6c73952 + 1d7d282 commit 01fa6dc

File tree

1,022 files changed

+40048
-16753
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,022 files changed

+40048
-16753
lines changed

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Ankit Aggarwal <[email protected]> <[email protected]>
99
Argyrios Kyrtzidis <[email protected]> <[email protected]>
1010
1111
12+
1213
Ben Cohen <[email protected]>
1314
1415
1516
16-
Brent Royal-Gordon <[email protected]> <[email protected]>
1717
1818
1919

CHANGELOG.md

Lines changed: 255 additions & 255 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
147147
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
148148
# can be reused when a new version of Swift comes out (assuming the user hasn't
149149
# manually set it as part of their own CMake configuration).
150-
set(SWIFT_VERSION "5.3")
150+
set(SWIFT_VERSION "5.4")
151151

152152
set(SWIFT_VENDOR "" CACHE STRING
153153
"The vendor name of the Swift compiler")
@@ -481,10 +481,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
481481
endif()
482482
message(STATUS "")
483483

484-
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
485-
set(SWIFT_CROSS_COMPILING FALSE)
484+
# Check if a prebuilt clang path was passed in, as this variable will be
485+
# assigned if not, in SwiftSharedCMakeConfig.
486+
if("${SWIFT_NATIVE_CLANG_TOOLS_PATH}" STREQUAL "")
487+
set(SWIFT_PREBUILT_CLANG FALSE)
486488
else()
487-
set(SWIFT_CROSS_COMPILING TRUE)
489+
set(SWIFT_PREBUILT_CLANG TRUE)
488490
endif()
489491

490492
include(SwiftSharedCMakeConfig)
@@ -605,8 +607,12 @@ if(SWIFT_HOST_VARIANT_ARCH)
605607
else()
606608
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
607609
set(SWIFT_HOST_VARIANT_ARCH_default "x86_64")
608-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64")
609-
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
610+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64")
611+
if(SWIFT_HOST_VARIANT_SDK_default STREQUAL OSX)
612+
set(SWIFT_HOST_VARIANT_ARCH_default "arm64")
613+
else()
614+
set(SWIFT_HOST_VARIANT_ARCH_default "aarch64")
615+
endif()
610616
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64")
611617
set(SWIFT_HOST_VARIANT_ARCH_default "powerpc64")
612618
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64le")
@@ -649,9 +655,10 @@ endif()
649655
#
650656

651657
if(XCODE)
652-
# FIXME: Cannot cross-compile the standard library using Xcode. Xcode
653-
# insists on passing -mmacosx-version-min to the compiler, and we need
654-
# to pass -mios-version-min. Clang sees both options and complains.
658+
# FIXME: It used to be the case that Xcode would force
659+
# -m${platform}-version-min flags that would conflict with those computed
660+
# by build-script. version-min flags are deprecated in favor of -target since
661+
# clang-11, so we might be able to undo this.
655662
set(SWIFT_SDKS "OSX")
656663
endif()
657664

@@ -772,7 +779,7 @@ elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "(OSX|IOS*|TVOS*|WATCHOS*)")
772779
#
773780
# Primary variant is always OSX; even on iOS hosts.
774781
set(SWIFT_PRIMARY_VARIANT_SDK_default "OSX")
775-
set(SWIFT_PRIMARY_VARIANT_ARCH_default "x86_64")
782+
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${CMAKE_HOST_SYSTEM_PROCESSOR}")
776783

777784
endif()
778785

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
| | **Architecture** | **main** | **Package** |
77
|---|:---:|:---:|:---:|
8-
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-osx)|[![Build Status](https://ci.swift.org/job/oss-swift-package-osx/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-osx)|
8+
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-macos)|[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
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)|
@@ -67,7 +67,7 @@ diligently to make the Swift community welcoming to everyone.
6767
To give clarity of what is expected of our members, Swift has adopted the
6868
code of conduct defined by the Contributor Covenant. This document is used
6969
across many open source communities, and we think it articulates our values
70-
well. For more, see the [Code of Conduct](https://swift.org/community/#code-of-conduct).
70+
well. For more, see the [Code of Conduct](https://swift.org/code-of-conduct/).
7171

7272
## Getting Started
7373

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ set(SWIFT_BENCH_MODULES
179179
single-source/StringMatch
180180
single-source/StringRemoveDupes
181181
single-source/StringReplaceSubrange
182+
single-source/StringSwitch
182183
single-source/StringTests
183184
single-source/StringWalk
184185
single-source/Substring

benchmark/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ The following build options are available:
7474
The following build targets are available:
7575

7676
* `swift-benchmark-macosx-x86_64`
77+
* `swift-benchmark-macosx-arm64`
7778
* `swift-benchmark-iphoneos-arm64e`
7879
* `swift-benchmark-iphoneos-arm64`
7980
* `swift-benchmark-iphoneos-armv7`
@@ -84,7 +85,7 @@ Build steps (with example options):
8485

8586
1. `$ mkdir build; cd build`
8687
2. `$ cmake [path to swift src]/benchmark -G Ninja -DSWIFT_EXEC=[path to built swiftc]`
87-
3. `$ ninja swift-benchmark-macosx-x86_64`
88+
3. `$ ninja swift-benchmark-macosx-$(uname -m)`
8889

8990
Benchmark binaries are placed in `bin`.
9091

@@ -98,7 +99,7 @@ relative to the benchmark binary at the time it was executed
9899
For example, to benchmark against a locally built `swiftc`, including
99100
any standard library changes in that build, you might configure using:
100101

101-
cmake <src>/benchmark -G Ninja -DSWIFT_EXEC=<build>/swift-macosx-x86_64/bin/swiftc
102+
cmake <src>/benchmark -G Ninja -DSWIFT_EXEC=<build>/swift-macosx-$(uname -m)/bin/swiftc
102103
ninja swift-benchmark-iphoneos-arm64
103104

104105
To build against the installed Xcode, simply omit SWIFT_EXEC:
@@ -139,7 +140,7 @@ The benchmark suite can be built with swiftpm/llbuild without needing any help
139140
from build-script by invoking swift build in the benchmark directory:
140141

141142
```
142-
swift-source/swift/benchmark$ swift build -configuration release
143+
swift-source/swift/benchmark$ swift build --configuration release
143144
swift-source/swift/benchmark$ .build/release/SwiftBench
144145
#,TEST,SAMPLES,MIN(μs),MAX(μs),MEAN(μs),SD(μs),MEDIAN(μs)
145146
1,Ackermann,1,169,169,169,0,169
@@ -319,12 +320,12 @@ swift-source$ ./swift/utils/build-script -R -B
319320
````
320321
you can rebuild just the benchmarks:
321322
````
322-
swift-source$ export SWIFT_BUILD_DIR=`pwd`/build/Ninja-ReleaseAssert/swift-macosx-x86_64
323-
swift-source$ ninja -C ${SWIFT_BUILD_DIR} swift-benchmark-macosx-x86_64
323+
swift-source$ export SWIFT_BUILD_DIR=`pwd`/build/Ninja-ReleaseAssert/swift-macosx-$(uname -m)
324+
swift-source$ ninja -C ${SWIFT_BUILD_DIR} swift-benchmark-macosx-$(uname -m)
324325
````
325326

326327
When modifying the testing infrastructure, you should verify that your changes
327328
pass all the tests:
328329
````
329-
swift-source$ ./llvm/utils/lit/lit.py -sv ${SWIFT_BUILD_DIR}/test-macosx-x86_64/benchmark
330+
swift-source$ ./llvm/utils/lit/lit.py -sv ${SWIFT_BUILD_DIR}/test-macosx-$(uname -m)/benchmark
330331
````
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
//===--- StringSwitch.swift -------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 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+
import TestsUtils
14+
15+
public let StringSwitch = [
16+
BenchmarkInfo(
17+
name: "StringSwitch",
18+
runFunction: run_StringSwitch,
19+
tags: [.validation, .api])
20+
]
21+
22+
@inline(never)
23+
func getIndex(_ s: String) -> Int {
24+
switch s {
25+
case "Swift": return 0
26+
case "is": return 1
27+
case "a": return 2
28+
case "general-purpose": return 3
29+
case "programming language": return 4
30+
case "built": return 5
31+
case "using": return 6
32+
case "modern": return 7
33+
case "approach": return 8
34+
case "to": return 9
35+
case "safety,": return 10
36+
case "performance,": return 11
37+
case "and": return 12
38+
case "software": return 13
39+
case "design": return 14
40+
case "patterns.": return 15
41+
case "": return 16
42+
case "The": return 17
43+
case "goal": return 18
44+
case "of": return 19
45+
case "the": return 20
46+
case "project": return 21
47+
case "create": return 22
48+
case "best": return 23
49+
case "available": return 24
50+
case "for": return 25
51+
case "uses": return 26
52+
case "ranging": return 27
53+
case "from": return 28
54+
case "systems": return 29
55+
case "mobile": return 30
56+
case "desktop": return 31
57+
case "apps,": return 32
58+
case "scaling": return 33
59+
case "up": return 34
60+
case "cloud": return 35
61+
case "services.": return 36
62+
case "Most": return 37
63+
case "importantly,": return 38
64+
case "designed": return 39
65+
case "make": return 40
66+
case "writing": return 41
67+
case "maintaining": return 42
68+
case "correct": return 43
69+
case "programs": return 44
70+
case "easier": return 45
71+
case "developer.": return 46
72+
case "To": return 47
73+
case "achieve": return 48
74+
case "this": return 49
75+
case "goal,": return 50
76+
case "we": return 51
77+
case "believe": return 52
78+
case "that": return 53
79+
case "most": return 54
80+
case "obvious": return 55
81+
case "way": return 56
82+
case "write": return 57
83+
case "code": return 58
84+
case "must": return 59
85+
case "also": return 60
86+
case "be:": return 61
87+
case "Safe.": return 62
88+
case "should": return 63
89+
case "behave": return 64
90+
case "in": return 65
91+
case "safe": return 66
92+
case "manner.": return 67
93+
case "Undefined": return 68
94+
case "behavior": return 69
95+
case "enemy": return 70
96+
case "developer": return 71
97+
case "mistakes": return 72
98+
case "be": return 73
99+
case "caught": return 74
100+
case "before": return 75
101+
case "production.": return 76
102+
case "Opting": return 77
103+
case "safety": return 78
104+
case "sometimes": return 79
105+
case "means": return 80
106+
case "will": return 81
107+
case "feel": return 82
108+
case "strict,": return 83
109+
case "but": return 84
110+
case "clarity": return 85
111+
case "saves": return 86
112+
case "time": return 87
113+
case "long": return 88
114+
case "run.": return 89
115+
case "Fast.": return 90
116+
case "intended": return 91
117+
case "as": return 92
118+
case "replacement": return 93
119+
case "C-based": return 94
120+
case "languages": return 95
121+
case "(C, C++, Objective-C).": return 96
122+
case "As": return 97
123+
case "such,": return 98
124+
case "comparable": return 99
125+
case "those": return 100
126+
case "performance": return 101
127+
case "tasks.": return 102
128+
case "Performance": return 103
129+
case "predictable": return 104
130+
case "consistent,": return 105
131+
case "not": return 106
132+
case "just": return 107
133+
case "fast": return 108
134+
case "short": return 109
135+
case "bursts": return 110
136+
case "require": return 111
137+
case "clean-up": return 112
138+
case "later.": return 113
139+
case "There": return 114
140+
case "are": return 115
141+
case "lots": return 116
142+
case "with": return 117
143+
case "novel": return 118
144+
case "features": return 119
145+
case "x": return 120
146+
case "being": return 121
147+
case "rare.": return 122
148+
case "Expressive.": return 123
149+
case "benefits": return 124
150+
case "decades": return 125
151+
case "advancement": return 126
152+
case "computer": return 127
153+
case "science": return 128
154+
case "offer": return 129
155+
case "syntax": return 130
156+
case "joy": return 131
157+
case "use,": return 132
158+
case "developers": return 133
159+
case "expect.": return 134
160+
case "But": return 135
161+
case "never": return 136
162+
case "done.": return 137
163+
case "We": return 138
164+
case "monitor": return 139
165+
case "advancements": return 140
166+
case "embrace": return 141
167+
case "what": return 142
168+
case "works,": return 143
169+
case "continually": return 144
170+
case "evolving": return 145
171+
case "even": return 146
172+
case "better.": return 147
173+
case "Tools": return 148
174+
case "critical": return 149
175+
case "part": return 150
176+
case "ecosystem.": return 151
177+
case "strive": return 152
178+
case "integrate": return 153
179+
case "well": return 154
180+
case "within": return 155
181+
case "developerss": return 156
182+
case "toolset,": return 157
183+
case "build": return 158
184+
case "quickly,": return 159
185+
case "present": return 160
186+
case "excellent": return 161
187+
case "diagnostics,": return 162
188+
case "enable": return 163
189+
case "interactive": return 164
190+
case "development": return 165
191+
case "experiences.": return 166
192+
case "can": return 167
193+
case "so": return 168
194+
case "much": return 169
195+
case "more": return 170
196+
case "powerful,": return 171
197+
case "like": return 172
198+
case "Swift-based": return 173
199+
case "playgrounds": return 174
200+
case "do": return 175
201+
case "Xcode,": return 176
202+
case "or": return 177
203+
case "web-based": return 178
204+
case "REPL": return 179
205+
case "when": return 180
206+
case "working": return 181
207+
case "Linux": return 182
208+
case "server-side": return 183
209+
case "code.": return 184
210+
default: return -1
211+
}
212+
}
213+
214+
@inline(never)
215+
func test(_ s: String) {
216+
blackHole(getIndex(s))
217+
}
218+
219+
@inline(never)
220+
public func run_StringSwitch(N: Int) {
221+
let first = "Swift"
222+
let short = "To"
223+
let long = "(C, C++, Objective-C)."
224+
let last = "code."
225+
let none = "non existent string"
226+
for _ in 1...100*N {
227+
test(first)
228+
test(short)
229+
test(long)
230+
test(last)
231+
test(none)
232+
}
233+
}
234+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#ifndef BENCHMARK_CREATE_OBJECTS_H
2+
#define BENCHMARK_CREATE_OBJECTS_H
3+
14
struct CxxLoadableIntWrapper {
25
int value;
36
};
7+
8+
#endif // BENCHMARK_CREATE_OBJECTS_H

0 commit comments

Comments
 (0)