Skip to content

Commit 335a50b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into explicit_true
2 parents c556b00 + de3af89 commit 335a50b

File tree

159 files changed

+18913
-2987
lines changed

Some content is hidden

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

159 files changed

+18913
-2987
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
458458
endif()
459459
message(STATUS "")
460460

461+
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
462+
set(SWIFT_CROSS_COMPILING FALSE)
463+
else()
464+
set(SWIFT_CROSS_COMPILING TRUE)
465+
endif()
466+
461467
include(SwiftSharedCMakeConfig)
462468

463469
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ various products. These incremental builds are a big timesaver when developing
241241
and debugging.
242242

243243
cd ${SWIFT_BUILD_DIR}
244-
ninja swift
244+
ninja swift-frontend
245245

246246
This will build the Swift compiler, but will not rebuild the standard library or
247247
any other target. Building the `swift-stdlib` target as an additional layer of
@@ -258,7 +258,7 @@ To open the Swift project in Xcode, open `${SWIFT_BUILD_DIR}/Swift.xcodeproj`.
258258
It will auto-create a *lot* of schemes for all of the available targets. A
259259
common debug flow would involve:
260260

261-
- Select the 'swift' scheme.
261+
- Select the 'swift-frontend' scheme.
262262
- Pull up the scheme editor (⌘⇧<).
263263
- Select the 'Arguments' tab and click the '+'.
264264
- Add the command line options.

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ macro(configure_build)
105105
endmacro()
106106

107107
macro(configure_sdks_darwin)
108-
set(macosx_arch "x86_64")
108+
set(macosx_arch "x86_64" "arm64")
109109
set(iphoneos_arch "arm64" "arm64e" "armv7")
110110
set(appletvos_arch "arm64")
111111
set(watchos_arch "armv7k")
@@ -609,11 +609,7 @@ function (swift_benchmark_compile_archopts)
609609

610610
if(is_darwin)
611611
# If host == target.
612-
if("${BENCH_COMPILE_ARCHOPTS_PLATFORM}" STREQUAL "macosx")
613-
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")
614-
else()
615-
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
616-
endif()
612+
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
617613
else()
618614
# If we are on Linux, we do not support cross compiling.
619615
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")

benchmark/scripts/Benchmark_Driver

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,25 @@ class BenchmarkDriver(object):
7373
def test_harness(self):
7474
"""Full path to test harness binary."""
7575
suffix = self.args.optimization if hasattr(self.args, "optimization") else "O"
76-
return os.path.join(self.args.tests, "Benchmark_" + suffix)
76+
if hasattr(self.args, "architecture") and self.args.architecture:
77+
suffix += "-" + self.args.architecture + "*"
78+
pattern = os.path.join(self.args.tests, "Benchmark_" + suffix)
79+
executables = []
80+
if hasattr(self._subprocess, "test_mode") and self._subprocess.test_mode:
81+
executables = [pattern]
82+
else:
83+
executables = glob.glob(pattern)
84+
if len(executables) == 0:
85+
raise ValueError(
86+
"No benchmark executable for file name pattern " +
87+
pattern + " found")
88+
if len(executables) > 1:
89+
raise ValueError(
90+
"Multiple benchmark executables for file name pattern " +
91+
pattern + " found\n" +
92+
str(executables) +
93+
"\nSpecify the architecture to select the right benchmark executable")
94+
return executables[0]
7795

7896
def _git(self, cmd):
7997
"""Execute the Git command in the `swift-repo`."""

benchmark/scripts/run_smoke_bench

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ VERBOSE = False
4848
class DriverArgs(object):
4949
"""Arguments for BenchmarkDriver."""
5050

51-
def __init__(self, tests, optimization="O"):
51+
def __init__(self, tests, optimization="O", architecture=None):
5252
"""Initialize with path to the build-dir and optimization level."""
5353
self.benchmarks = None
5454
self.filters = None
5555
self.tests = os.path.join(tests, "bin")
5656
self.optimization = optimization
57+
self.architecture = architecture
5758

5859

5960
def log(msg):
@@ -126,6 +127,12 @@ def main():
126127
help="The number of re-runs until it's assumed to be a real change",
127128
default=8,
128129
)
130+
argparser.add_argument(
131+
"-arch",
132+
type=str,
133+
help="The architecture. The default is x86_64",
134+
default="x86_64",
135+
)
129136
argparser.add_argument(
130137
"-platform", type=str, help="The benchmark build platform", default="macosx"
131138
)
@@ -158,6 +165,7 @@ def test_opt_levels(args):
158165
args.num_samples,
159166
args.num_reruns,
160167
output_file,
168+
args.arch
161169
):
162170
changes = True
163171

@@ -167,6 +175,7 @@ def test_opt_levels(args):
167175
opt_level,
168176
args.oldbuilddir[0],
169177
args.newbuilddir[0],
178+
args.arch,
170179
args.platform,
171180
output_file,
172181
):
@@ -177,6 +186,7 @@ def test_opt_levels(args):
177186
"swiftlibs",
178187
args.oldbuilddir[0],
179188
args.newbuilddir[0],
189+
args.arch,
180190
args.platform,
181191
output_file,
182192
):
@@ -221,7 +231,8 @@ def merge(results, other_results):
221231

222232

223233
def test_performance(
224-
opt_level, old_dir, new_dir, threshold, num_samples, num_reruns, output_file
234+
opt_level, old_dir, new_dir, threshold, num_samples, num_reruns,
235+
output_file, arch
225236
):
226237
"""Detect performance changes in benchmarks.
227238
@@ -231,7 +242,7 @@ def test_performance(
231242

232243
i, unchanged_length_count = 0, 0
233244
old, new = [
234-
BenchmarkDriver(DriverArgs(dir, optimization=opt_level))
245+
BenchmarkDriver(DriverArgs(dir, optimization=opt_level, architecture=arch))
235246
for dir in [old_dir, new_dir]
236247
]
237248
results = [measure(driver, driver.tests, i) for driver in [old, new]]
@@ -260,12 +271,13 @@ def test_performance(
260271
)
261272

262273

263-
def report_code_size(opt_level, old_dir, new_dir, platform, output_file):
274+
def report_code_size(opt_level, old_dir, new_dir, architecture, platform, output_file):
264275
if opt_level == "swiftlibs":
265276
files = glob.glob(os.path.join(old_dir, "lib", "swift", platform, "*.dylib"))
266277
else:
267278
files = glob.glob(
268-
os.path.join(old_dir, opt_level + "-*" + platform + "*", "*.o")
279+
os.path.join(old_dir, opt_level + "-" + architecture + "*" +
280+
platform + "*", "*.o")
269281
)
270282

271283
idx = 1
@@ -370,8 +382,8 @@ performance team (@eeckstein).
370382

371383

372384
def check_added(args, output_file=None):
373-
old = BenchmarkDriver(DriverArgs(args.oldbuilddir[0]))
374-
new = BenchmarkDriver(DriverArgs(args.newbuilddir[0]))
385+
old = BenchmarkDriver(DriverArgs(args.oldbuilddir[0], architecture=args.arch))
386+
new = BenchmarkDriver(DriverArgs(args.newbuilddir[0], architecture=args.arch))
375387
added = set(new.tests).difference(set(old.tests))
376388
new.tests = list(added)
377389
doctor = BenchmarkDoctor(args, driver=new)

benchmark/scripts/test_Benchmark_Driver.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def record_and_respond(self, args, stdin, stdout, stderr, shell):
198198
self.calls.append(args)
199199
return self.respond.get(args, "")
200200

201+
def test_mode():
202+
return True
203+
201204

202205
class TestBenchmarkDriverInitialization(unittest.TestCase):
203206
def setUp(self):
@@ -206,13 +209,19 @@ def setUp(self):
206209

207210
def test_test_harness(self):
208211
self.assertEqual(
209-
BenchmarkDriver(self.args, tests=["ignored"]).test_harness,
212+
BenchmarkDriver(
213+
self.args,
214+
tests=["ignored"],
215+
_subprocess=self.subprocess_mock).test_harness,
210216
"/benchmarks/Benchmark_O",
211217
)
212218
self.args.tests = "/path"
213219
self.args.optimization = "Suffix"
214220
self.assertEqual(
215-
BenchmarkDriver(self.args, tests=["ignored"]).test_harness,
221+
BenchmarkDriver(
222+
self.args,
223+
tests=["ignored"],
224+
_subprocess=self.subprocess_mock).test_harness,
216225
"/path/Benchmark_Suffix",
217226
)
218227

@@ -271,6 +280,7 @@ def test_log_file(self):
271280
swift_repo=None,
272281
),
273282
tests=["ignored"],
283+
_subprocess=self.subprocess_mock
274284
)
275285
self.assertEqual(driver.log_file, "/path/Benchmark_Suffix-" + now + ".log")
276286

cmake/modules/DarwinSDKs.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ option(SWIFT_ENABLE_IOS32
44

55
if(SWIFT_ENABLE_IOS32)
66
set(SUPPORTED_IOS_ARCHS "armv7;armv7s;arm64;arm64e")
7-
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64")
7+
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
88
else()
99
set(SUPPORTED_IOS_ARCHS "arm64;arm64e")
10-
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64")
10+
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64;arm64")
1111
endif()
1212

1313
set(SUPPORTED_TVOS_ARCHS "arm64")
14-
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64")
14+
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
1515
set(SUPPORTED_WATCHOS_ARCHS "armv7k")
16-
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386")
17-
set(SUPPORTED_OSX_ARCHS "x86_64")
16+
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
17+
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")
1818

1919
is_sdk_requested(OSX swift_build_osx)
2020
if(swift_build_osx)

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ function(_report_sdk prefix)
8585
message(STATUS "")
8686
endfunction()
8787

88+
# Remove architectures not supported by the SDK from the given list.
89+
function(remove_sdk_unsupported_archs name os sdk_path architectures_var)
90+
execute_process(COMMAND
91+
/usr/libexec/PlistBuddy -c "Print :SupportedTargets:${os}:Archs" ${sdk_path}/SDKSettings.plist
92+
OUTPUT_VARIABLE sdk_supported_archs
93+
RESULT_VARIABLE plist_error)
94+
95+
if (NOT plist_error EQUAL 0)
96+
message(STATUS "${os} SDK at ${sdk_path} does not publish its supported architectures")
97+
return()
98+
endif()
99+
100+
set(architectures)
101+
foreach(arch ${${architectures_var}})
102+
if(sdk_supported_archs MATCHES "${arch}\n")
103+
list(APPEND architectures ${arch})
104+
elseif(arch MATCHES "^armv7(s)?$" AND os STREQUAL "iphoneos")
105+
# 32-bit iOS is not listed explicitly in SDK settings.
106+
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
107+
list(APPEND architectures ${arch})
108+
elseif(arch STREQUAL "i386" AND os STREQUAL "iphonesimulator")
109+
# 32-bit iOS simulatoris not listed explicitly in SDK settings.
110+
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
111+
list(APPEND architectures ${arch})
112+
else()
113+
message(STATUS "${name} SDK at ${sdk_path} does not support architecture ${arch}")
114+
endif()
115+
endforeach()
116+
117+
set("${architectures_var}" ${architectures} PARENT_SCOPE)
118+
endfunction()
119+
88120
# Configure an SDK
89121
#
90122
# Usage:
@@ -164,6 +196,9 @@ macro(configure_sdk_darwin
164196
SWIFT_SDK_${prefix}_ARCHITECTURES) # result
165197
endif()
166198

199+
# Remove any architectures not supported by the SDK.
200+
remove_sdk_unsupported_archs(${name} ${xcrun_name} ${SWIFT_SDK_${prefix}_PATH} SWIFT_SDK_${prefix}_ARCHITECTURES)
201+
167202
list_intersect(
168203
"${SWIFT_DARWIN_MODULE_ARCHS}" # lhs
169204
"${architectures}" # rhs

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
5858
fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}")
5959
endif()
6060

61-
if(NOT CMAKE_CROSSCOMPILING)
61+
if(NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING)
6262
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
6363
endif()
6464

include/swift/AST/AvailabilitySpec.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,33 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
6868
SourceLoc PlatformLoc;
6969

7070
llvm::VersionTuple Version;
71+
72+
// For macOS Big Sur, we canonicalize 10.16 to 11.0 for compile-time
73+
// checking since clang canonicalizes availability markup. However, to
74+
// support Beta versions of macOS Big Sur where the OS
75+
// reports 10.16 at run time, we need to compare against 10.16,
76+
//
77+
// This means for:
78+
//
79+
// if #available(macOS 10.16, *) { ... }
80+
//
81+
// we need to keep around both a canonical version for use in compile-time
82+
// checks and an uncanonicalized version for the version to actually codegen
83+
// with.
84+
llvm::VersionTuple RuntimeVersion;
85+
7186
SourceRange VersionSrcRange;
7287

7388
public:
7489
PlatformVersionConstraintAvailabilitySpec(PlatformKind Platform,
7590
SourceLoc PlatformLoc,
7691
llvm::VersionTuple Version,
92+
llvm::VersionTuple RuntimeVersion,
7793
SourceRange VersionSrcRange)
7894
: AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint),
7995
Platform(Platform),
8096
PlatformLoc(PlatformLoc), Version(Version),
97+
RuntimeVersion(RuntimeVersion),
8198
VersionSrcRange(VersionSrcRange) {}
8299

83100
/// The required platform.
@@ -93,6 +110,11 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
93110
llvm::VersionTuple getVersion() const { return Version; }
94111
SourceRange getVersionSrcRange() const { return VersionSrcRange; }
95112

113+
// The version to be used in codegen for version comparisons at run time.
114+
// This is required to support beta versions of macOS Big Sur that
115+
// report 10.16 at run time.
116+
llvm::VersionTuple getRuntimeVersion() const { return RuntimeVersion; }
117+
96118
SourceRange getSourceRange() const;
97119

98120
void print(raw_ostream &OS, unsigned Indent) const;

0 commit comments

Comments
 (0)