Skip to content

Bump Swift version to 4.0 #8861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b7b9245
Bump Swift version to 4.0
tkremenek Apr 19, 2017
dcc43ec
Adjust to return compatibility version in Swift 3 mode.
tkremenek Apr 19, 2017
7c664d1
Bump default version in build script.
tkremenek Apr 19, 2017
6106868
Force -swift-version 3 for Standard Library and overlays.
tkremenek Apr 20, 2017
d36b0b6
Compile all standard library as Swift 3 mode.
tkremenek Apr 20, 2017
0a469be
Merge branch 'master' into ver-4-bump
tkremenek Apr 21, 2017
3fb6e71
Force the benchmark suite to build with -swift-version 3.
tkremenek Apr 22, 2017
81b00d4
These tests explicitly need -swift-version 3.
tkremenek Apr 23, 2017
243f614
Update test to reflect new default is -swift-version 4.
tkremenek Apr 23, 2017
4aa0f46
Underlying Swift 3 version is now ‘3.2’
tkremenek Apr 23, 2017
01e0903
baseAddress is optional.
tkremenek Apr 23, 2017
ad5eab9
Force specific tests from validation suit to -swift-version 3.
tkremenek Apr 24, 2017
b8d135a
Enhance swift-ide-test to accept -swift-version multiple times.
tkremenek Apr 25, 2017
be5d87a
Add “-swift-version X” to %target-swift-ide-test substitution.
tkremenek Apr 25, 2017
8eed9ac
Remove hard passing -swift-version X for some tests.
tkremenek Apr 25, 2017
758d5d4
Resolve merge conflict.
tkremenek Apr 25, 2017
ae591c0
Remove hard-coding of -swift-version 3 in some validation tests.
tkremenek Apr 28, 2017
157133d
Pass -swift-version X for %target-swift-frontend
tkremenek Apr 28, 2017
ef98f2b
Merge branch 'master' into ver-4-bump
tkremenek Apr 28, 2017
48eb937
Revert "Pass -swift-version X for %target-swift-frontend"
tkremenek Apr 28, 2017
42ea938
Include config.swift_test_options in config.target_swift_frontend for…
tkremenek Apr 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
set_property(CACHE SWIFT_ANALYZE_CODE_COVERAGE PROPERTY
STRINGS FALSE "NOT-MERGED" "MERGED")

set(SWIFT_VERSION "3.1" CACHE STRING
set(SWIFT_VERSION "4.0" CACHE STRING
"The user-visible version of the Swift compiler")
set(SWIFT_VENDOR "" CACHE STRING
"The vendor name of the Swift compiler")
Expand Down
1 change: 1 addition & 0 deletions benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function (swift_benchmark_compile_archopts)
set(bench_flags "${${benchvar}}")

set(common_options
"-swift-version" "3" # FIXME: Force Swift 3 version compatibility.
"-c"
"-sdk" "${sdk}"
"-target" "${target}"
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ function(_compile_swift_files
endif()
endif()

# Force swift 3 compatibility mode for Standard Library and overlay.
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
list(APPEND swift_flags "-swift-version" "3")
endif()

if(SWIFTFILE_IS_SDK_OVERLAY)
list(APPEND swift_flags "-autolink-force-load")
endif()
Expand Down
16 changes: 10 additions & 6 deletions lib/Basic/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,23 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
return None;
}

// FIXME: When we switch to Swift 4 by default, the "3" case should return
// a version newer than any released 3.x compiler (probably "3.2"), and the
// "4" case should start returning getCurrentLanguageVersion. We should
// FIXME: When we switch to Swift 5 by default, the "4" case should return
// a version newer than any released 4.x compiler, and the
// "5" case should start returning getCurrentLanguageVersion. We should
// also check for the presence of SWIFT_VERSION_PATCHLEVEL, and if that's
// set apply it to the "3" case, so that Swift 4.0.1 will automatically
// have a compatibility mode of 3.2.1.
switch (Components[0]) {
case 3:
static_assert(SWIFT_VERSION_MAJOR == 3,
#ifdef SWIFT_VERSION_PATCHLEVEL
return Version{3, 2, SWIFT_VERSION_PATCHLEVEL};
#else
return Version{3, 2};
#endif
case 4:
static_assert(SWIFT_VERSION_MAJOR == 4,
"getCurrentLanguageVersion is no longer correct here");
return Version::getCurrentLanguageVersion();
case 4:
return Version{4, 0};
default:
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions test/Driver/swift-version-default.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jkl
#endif

#if swift(>=4)
aoeu
aoeu // expected-error {{use of unresolved identifier}}
#else
htn // expected-error {{use of unresolved identifier}}
htn
#endif

#if swift(>=4.1)
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/local_types.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Tests lookup and mangling of local types

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

public func singleFunc() {
// CHECK-DAG: 10LocalTypes10singleFuncyyF06SingleD6StructL_V
Expand Down
4 changes: 2 additions & 2 deletions test/IDE/merge_local_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// RUN: rm -rf %t && mkdir -p %t

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

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

public func toMerge() {
// CHECK-DAG: 16LocalTypesMerged7toMergeyyF16SingleFuncStructL_V
Expand Down
2 changes: 1 addition & 1 deletion test/Serialization/Recovery/crash-recovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Sub: Base {

// CHECK-CRASH: error: fatal error encountered while reading from module 'Lib'; please file a bug report with your project and the crash log
// CHECK-CRASH-3-NOT: note
// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.1
// CHECK-CRASH-4: note: compiling as Swift 4.0, with 'Lib' built as Swift 3.2
// CHECK-CRASH-LABEL: *** DESERIALIZATION FAILURE (please include this section in any bug report) ***
// CHECK-CRASH: could not find 'disappearingMethod()' in parent class
// CHECK-CRASH: While loading members for 'Sub' in module 'Lib'
12 changes: 7 additions & 5 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,9 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi
% (config.swiftc, config.variant_triple, resource_dir_opt, mcp_opt,
config.swift_test_options, swift_execution_tests_extra_flags))
config.target_swift_frontend = (
'%s -frontend -target %s %s %s'
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt))
'%s -frontend -target %s %s %s %s'
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt,
config.swift_test_options))
subst_target_swift_frontend_mock_sdk = config.target_swift_frontend
subst_target_swift_frontend_mock_sdk_after = ""
config.target_run = ''
Expand Down Expand Up @@ -1019,10 +1020,11 @@ config.substitutions.append(('%target-sil-llvm-gen', config.target_sil_llvm_gen)
config.substitutions.append(('%target-sil-nm', config.target_sil_nm))
config.substitutions.append(
('%target-swift-ide-test\(mock-sdk:([^)]+)\)',
'%s \\1 %s' %
'%s \\1 %s -swift-version %s' %
(subst_target_swift_ide_test_mock_sdk,
subst_target_swift_ide_test_mock_sdk_after)))
config.substitutions.append(('%target-swift-ide-test', config.target_swift_ide_test))
subst_target_swift_ide_test_mock_sdk_after,
swift_version)))
config.substitutions.append(('%target-swift-ide-test', "%s -swift-version %s" % (config.target_swift_ide_test, swift_version)))
config.substitutions.append(('%target-swift-reflection-test', lit.util.which('swift-reflection-test{variant_suffix}'.format(variant_suffix=config.variant_suffix), config.environment['PATH'])))
config.substitutions.append(('%target-swift-reflection-dump', '{} {} {}'.format(config.swift_reflection_dump, '-arch', run_cpu)))
config.substitutions.append(('%target-swiftc_driver', config.target_swiftc_driver))
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/NSStringAPI.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-run-simple-swift
// RUN: %target-run-simple-swift -swift-version 3
// REQUIRES: executable_test

// REQUIRES: objc_interop
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TestUUID : TestUUIDSuper {
let valFromRef = ref as UUID
var bytes: [UInt8] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
let valFromBytes = bytes.withUnsafeMutableBufferPointer { buffer -> UUID in
ref.getBytes(buffer.baseAddress)
ref.getBytes(buffer.baseAddress!)
return UUID(uuid: UnsafeRawPointer(buffer.baseAddress!).load(as: uuid_t.self))
}
let valFromStr = UUID(uuidString: ref.uuidString)
Expand Down
7 changes: 5 additions & 2 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ SDK("sdk", llvm::cl::desc("path to the SDK to build against"),
static llvm::cl::opt<std::string>
Triple("target", llvm::cl::desc("target triple"), llvm::cl::cat(Category));

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

Expand Down Expand Up @@ -2979,8 +2979,11 @@ int main(int argc, char *argv[]) {
if (!options::Triple.empty())
InitInvok.setTargetTriple(options::Triple);
if (!options::SwiftVersion.empty()) {
// Honor the *last* -swift-version specified.
const auto &LastSwiftVersion =
options::SwiftVersion[options::SwiftVersion.size()-1];
if (auto swiftVersion =
version::Version::parseVersionString(options::SwiftVersion,
version::Version::parseVersionString(LastSwiftVersion,
SourceLoc(), nullptr)) {
if (auto actual = swiftVersion.getValue().getEffectiveLanguageVersion())
InitInvok.getLangOptions().EffectiveLanguageVersion = actual.getValue();
Expand Down
2 changes: 1 addition & 1 deletion utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -2044,7 +2044,7 @@ iterations with -O",
"--swift-user-visible-version",
help="User-visible version of the embedded Swift compiler",
type=arguments.type.swift_compiler_version,
default="3.1",
default="4.0",
metavar="MAJOR.MINOR")

parser.add_argument(
Expand Down