Skip to content

Commit 749e05b

Browse files
authored
Merge pull request #8861 from tkremenek/ver-4-bump
Bump Swift version to 4.0
2 parents 946b776 + 42ea938 commit 749e05b

File tree

13 files changed

+39
-24
lines changed

13 files changed

+39
-24
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
105105
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
106106
STRINGS FALSE "NOT-MERGED" "MERGED")
107107

108-
set(SWIFT_VERSION "3.1" CACHE STRING
108+
set(SWIFT_VERSION "4.0" CACHE STRING
109109
"The user-visible version of the Swift compiler")
110110
set(SWIFT_VENDOR "" CACHE STRING
111111
"The vendor name of the Swift compiler")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function (swift_benchmark_compile_archopts)
4242
set(bench_flags "${${benchvar}}")
4343

4444
set(common_options
45+
"-swift-version" "3" # FIXME: Force Swift 3 version compatibility.
4546
"-c"
4647
"-sdk" "${sdk}"
4748
"-target" "${target}"

cmake/modules/SwiftSource.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ function(_compile_swift_files
268268
endif()
269269
endif()
270270

271+
# Force swift 3 compatibility mode for Standard Library and overlay.
272+
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
273+
list(APPEND swift_flags "-swift-version" "3")
274+
endif()
275+
271276
if(SWIFTFILE_IS_SDK_OVERLAY)
272277
list(APPEND swift_flags "-autolink-force-load")
273278
endif()

lib/Basic/Version.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,23 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
312312
return None;
313313
}
314314

315-
// FIXME: When we switch to Swift 4 by default, the "3" case should return
316-
// a version newer than any released 3.x compiler (probably "3.2"), and the
317-
// "4" case should start returning getCurrentLanguageVersion. We should
315+
// FIXME: When we switch to Swift 5 by default, the "4" case should return
316+
// a version newer than any released 4.x compiler, and the
317+
// "5" case should start returning getCurrentLanguageVersion. We should
318318
// also check for the presence of SWIFT_VERSION_PATCHLEVEL, and if that's
319319
// set apply it to the "3" case, so that Swift 4.0.1 will automatically
320320
// have a compatibility mode of 3.2.1.
321321
switch (Components[0]) {
322322
case 3:
323-
static_assert(SWIFT_VERSION_MAJOR == 3,
323+
#ifdef SWIFT_VERSION_PATCHLEVEL
324+
return Version{3, 2, SWIFT_VERSION_PATCHLEVEL};
325+
#else
326+
return Version{3, 2};
327+
#endif
328+
case 4:
329+
static_assert(SWIFT_VERSION_MAJOR == 4,
324330
"getCurrentLanguageVersion is no longer correct here");
325331
return Version::getCurrentLanguageVersion();
326-
case 4:
327-
return Version{4, 0};
328332
default:
329333
return None;
330334
}

test/Driver/swift-version-default.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jkl
1818
#endif
1919

2020
#if swift(>=4)
21-
aoeu
21+
aoeu // expected-error {{use of unresolved identifier}}
2222
#else
23-
htn // expected-error {{use of unresolved identifier}}
23+
htn
2424
#endif
2525

2626
#if swift(>=4.1)

test/IDE/local_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Tests lookup and mangling of local types
22

33
// RUN: rm -rf %t && mkdir -p %t
4-
// RUN: %target-swiftc_driver -v -emit-module -module-name LocalTypes -o %t/LocalTypes.swiftmodule %s
5-
// RUN: %target-swift-ide-test -print-local-types -I %t -module-to-print LocalTypes -source-filename %s | %FileCheck %s
4+
// RUN: %target-swiftc_driver -swift-version 3 -v -emit-module -module-name LocalTypes -o %t/LocalTypes.swiftmodule %s
5+
// RUN: %target-swift-ide-test -swift-version 3 -print-local-types -I %t -module-to-print LocalTypes -source-filename %s | %FileCheck %s
66

77
public func singleFunc() {
88
// CHECK-DAG: 10LocalTypes10singleFuncyyF06SingleD6StructL_V

test/IDE/merge_local_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// RUN: rm -rf %t && mkdir -p %t
44

55
// Create separate modules and merge them together
6-
// RUN: %target-swiftc_driver -v -emit-module -module-name LocalTypesMerged -o %t/LocalTypesMerged.swiftmodule %s %S/local_types.swift
6+
// RUN: %target-swiftc_driver -swift-version 3 -v -emit-module -module-name LocalTypesMerged -o %t/LocalTypesMerged.swiftmodule %s %S/local_types.swift
77

8-
// RUN: %target-swift-ide-test -print-local-types -I %t -module-to-print LocalTypesMerged -source-filename %s | %FileCheck %s
8+
// RUN: %target-swift-ide-test -swift-version 3 -print-local-types -I %t -module-to-print LocalTypesMerged -source-filename %s | %FileCheck %s
99

1010
public func toMerge() {
1111
// CHECK-DAG: 16LocalTypesMerged7toMergeyyF16SingleFuncStructL_V

test/Serialization/Recovery/crash-recovery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Sub: Base {
1414

1515
// CHECK-CRASH: error: fatal error encountered while reading from module 'Lib'; please file a bug report with your project and the crash log
1616
// CHECK-CRASH-3-NOT: note
17-
// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.1
17+
// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.2
1818
// CHECK-CRASH-LABEL: *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
1919
// CHECK-CRASH: could not find 'disappearingMethod()' in parent class
2020
// CHECK-CRASH: While loading members for 'Sub' in module 'Lib'

test/lit.cfg

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,9 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi
768768
% (config.swiftc, config.variant_triple, resource_dir_opt, mcp_opt,
769769
config.swift_test_options, swift_execution_tests_extra_flags))
770770
config.target_swift_frontend = (
771-
'%s -frontend -target %s %s %s'
772-
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt))
771+
'%s -frontend -target %s %s %s %s'
772+
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt,
773+
config.swift_test_options))
773774
subst_target_swift_frontend_mock_sdk = config.target_swift_frontend
774775
subst_target_swift_frontend_mock_sdk_after = ""
775776
config.target_run = ''
@@ -1019,10 +1020,11 @@ config.substitutions.append(('%target-sil-llvm-gen', config.target_sil_llvm_gen)
10191020
config.substitutions.append(('%target-sil-nm', config.target_sil_nm))
10201021
config.substitutions.append(
10211022
('%target-swift-ide-test\(mock-sdk:([^)]+)\)',
1022-
'%s \\1 %s' %
1023+
'%s \\1 %s -swift-version %s' %
10231024
(subst_target_swift_ide_test_mock_sdk,
1024-
subst_target_swift_ide_test_mock_sdk_after)))
1025-
config.substitutions.append(('%target-swift-ide-test', config.target_swift_ide_test))
1025+
subst_target_swift_ide_test_mock_sdk_after,
1026+
swift_version)))
1027+
config.substitutions.append(('%target-swift-ide-test', "%s -swift-version %s" % (config.target_swift_ide_test, swift_version)))
10261028
config.substitutions.append(('%target-swift-reflection-test', lit.util.which('swift-reflection-test{variant_suffix}'.format(variant_suffix=config.variant_suffix), config.environment['PATH'])))
10271029
config.substitutions.append(('%target-swift-reflection-dump', '{} {} {}'.format(config.swift_reflection_dump, '-arch', run_cpu)))
10281030
config.substitutions.append(('%target-swiftc_driver', config.target_swiftc_driver))

test/stdlib/NSStringAPI.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift
1+
// RUN: %target-run-simple-swift -swift-version 3
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop

test/stdlib/TestUUID.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class TestUUID : TestUUIDSuper {
7474
let valFromRef = ref as UUID
7575
var bytes: [UInt8] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
7676
let valFromBytes = bytes.withUnsafeMutableBufferPointer { buffer -> UUID in
77-
ref.getBytes(buffer.baseAddress)
77+
ref.getBytes(buffer.baseAddress!)
7878
return UUID(uuid: UnsafeRawPointer(buffer.baseAddress!).load(as: uuid_t.self))
7979
}
8080
let valFromStr = UUID(uuidString: ref.uuidString)

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ SDK("sdk", llvm::cl::desc("path to the SDK to build against"),
245245
static llvm::cl::opt<std::string>
246246
Triple("target", llvm::cl::desc("target triple"), llvm::cl::cat(Category));
247247

248-
static llvm::cl::opt<std::string>
248+
static llvm::cl::list<std::string>
249249
SwiftVersion("swift-version", llvm::cl::desc("Swift version"),
250250
llvm::cl::cat(Category));
251251

@@ -2979,8 +2979,11 @@ int main(int argc, char *argv[]) {
29792979
if (!options::Triple.empty())
29802980
InitInvok.setTargetTriple(options::Triple);
29812981
if (!options::SwiftVersion.empty()) {
2982+
// Honor the *last* -swift-version specified.
2983+
const auto &LastSwiftVersion =
2984+
options::SwiftVersion[options::SwiftVersion.size()-1];
29822985
if (auto swiftVersion =
2983-
version::Version::parseVersionString(options::SwiftVersion,
2986+
version::Version::parseVersionString(LastSwiftVersion,
29842987
SourceLoc(), nullptr)) {
29852988
if (auto actual = swiftVersion.getValue().getEffectiveLanguageVersion())
29862989
InitInvok.getLangOptions().EffectiveLanguageVersion = actual.getValue();

utils/build-script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ iterations with -O",
20442044
"--swift-user-visible-version",
20452045
help="User-visible version of the embedded Swift compiler",
20462046
type=arguments.type.swift_compiler_version,
2047-
default="3.1",
2047+
default="4.0",
20482048
metavar="MAJOR.MINOR")
20492049

20502050
parser.add_argument(

0 commit comments

Comments
 (0)