Skip to content

Commit c1328bd

Browse files
authored
Merge pull request #36857 from DougGregor/import-concurrency-by-default-take-2
Enable import of the _Concurrency module by default.
2 parents 3a551f8 + 2e86896 commit c1328bd

File tree

64 files changed

+398
-258
lines changed

Some content is hidden

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

64 files changed

+398
-258
lines changed

cmake/modules/Libdispatch.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ foreach(sdk ${DISPATCH_SDKS})
101101
# ensure that we strip out the DESTDIR environment
102102
# from the sub-build
103103
${CMAKE_COMMAND} -E env --unset=DESTDIR ${CMAKE_COMMAND} --build . --target install
104+
COMMAND
105+
${CMAKE_COMMAND} -E copy
106+
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
107+
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}dispatch${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
108+
COMMAND
109+
${CMAKE_COMMAND} -E copy
110+
<INSTALL_DIR>/${LIBDISPATCH_RUNTIME_DIR}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
111+
${SWIFTLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}/${SWIFT_SDK_${sdk}_SHARED_LIBRARY_PREFIX}BlocksRuntime${SWIFT_SDK_${sdk}_SHARED_LIBRARY_SUFFIX}
104112
STEP_TARGETS
105113
install
106114
BUILD_BYPRODUCTS

lib/Frontend/Frontend.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,20 @@ CompilerInstance::openModuleDoc(const InputFile &input) {
754754
return None;
755755
}
756756

757+
/// Enable Swift concurrency on a per-target basis
758+
static bool shouldImportConcurrencyByDefault(const llvm::Triple &target) {
759+
if (target.isOSDarwin())
760+
return true;
761+
if (target.isOSWindows())
762+
return true;
763+
if (target.isOSLinux())
764+
return true;
765+
return false;
766+
}
767+
757768
bool CompilerInvocation::shouldImportSwiftConcurrency() const {
758-
return getLangOptions().EnableExperimentalConcurrency
759-
&& !getLangOptions().DisableImplicitConcurrencyModuleImport &&
769+
return shouldImportConcurrencyByDefault(getLangOptions().Target) &&
770+
!getLangOptions().DisableImplicitConcurrencyModuleImport &&
760771
getFrontendOptions().InputMode !=
761772
FrontendOptions::ParseInputMode::SwiftModuleInterface;
762773
}

test/Concurrency/async_main_no_concurrency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -parse-as-library %s
1+
// RUN: %target-typecheck-verify-swift -parse-as-library -disable-implicit-concurrency-module-import %s
22
// RUN: %target-typecheck-verify-swift -parse-as-library -enable-experimental-concurrency -parse-stdlib %s
33

44
@main struct Main {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -target x86_64-unknown-linux-android -disable-objc-interop -swift-version 5 -O -module-name _Concurrency

test/IDE/Inputs/foo_swift_module.printed.comments.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftOnoneSupport
2+
import _Concurrency
23

34
func %%% (lhs: Int, rhs: Int) -> Int
45

test/IDE/complete_from_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
2+
// RUN: %target-swift-ide-test -disable-implicit-concurrency-module-import -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
33

44
// NO_STDLIB_PRIVATE: Begin completions
55
// NO_STDLIB_PRIVATE-NOT: Decl{{[^:]*}}/IsSystem: _

test/IDE/complete_override.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
2+
// RUN: %target-swift-ide-test -disable-implicit-concurrency-module-import -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
33
// RUN: sed -n -e '1,/NO_ERRORS_UP_TO_HERE$/ p' %s > %t_no_errors.swift
44
// RUN: %target-swift-frontend -typecheck -verify -disable-objc-attr-requires-foundation-module -enable-objc-interop %t_no_errors.swift
55

test/IRGen/ELF-remove-autolink-section.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// RUN: %swiftc_driver -emit-ir %s -o - | %FileCheck %s -check-prefix ELF
1+
// RUN: %swiftc_driver -emit-ir %s -o - -Xfrontend -disable-implicit-concurrency-module-import | %FileCheck %s -check-prefix ELF
22

33
// Check that the swift auto link section is available in the object file.
4-
// RUN: %swiftc_driver -c %s -o %t
4+
// RUN: %swiftc_driver -c %s -o %t -Xfrontend -disable-implicit-concurrency-module-import
55
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix SECTION
66

77
// Checks that the swift auto link section is removed from the final binary.
8-
// RUN: %swiftc_driver -emit-executable %s -o %t
8+
// RUN: %swiftc_driver -emit-executable %s -o %t -Xfrontend -disable-implicit-concurrency-module-import
99
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix NOSECTION
1010

1111
// REQUIRES: OS=linux-gnu

test/Index/Store/cross-import-overlay.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ from__ABAdditionsCAdditions()
3030
// MAIN-NEXT: is-debug: 1
3131
// MAIN-NEXT: DEPEND START
3232
// MAIN-NEXT: Unit | system | Swift | {{.*}}{{/|\\}}Swift.swiftmodule
33+
// MAIN-NEXT: Unit | system | _Concurrency | {{.*}}{{/|\\}}_Concurrency.swiftmodule
3334
// MAIN-NEXT: Unit | system | B | {{.*}}{{/|\\}}B.swiftmodule{{/|\\}}{{.*}}
3435
// MAIN-NEXT: Unit | system | C | {{.*}}{{/|\\}}C.swiftmodule{{/|\\}}{{.*}}
3536
// MAIN-NEXT: Unit | system | A | {{.*}}{{/|\\}}__ABAdditionsCAdditions.swiftmodule{{/|\\}}{{.*}}

test/Index/Store/unit-from-compile.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
// CHECK: DEPEND START
1818
// CHECK: Unit | system | {{.*}}{{/|\\}}Swift.swiftmodule
19-
// CHECK: DEPEND END (1)
19+
// CHECK: Unit | system | _Concurrency
20+
// CHECK: DEPEND END (2)
2021

2122
// OPT: is-debug: 1

0 commit comments

Comments
 (0)