Skip to content

[concurrency] fixes to enable building swift with concurrency on by default #34609

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 3 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ namespace swift {
/// Enable experimental concurrency model.
bool EnableExperimentalConcurrency = false;

/// Disable the implicit import of the _Concurrency module.
bool DisableImplicitConcurrencyModuleImport = false;

/// Should we check the target OSs of serialized modules to see that they're
/// new enough?
bool EnableTargetOSChecking = true;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ def disable_clangimporter_source_import : Flag<["-"],
"disable-clangimporter-source-import">,
HelpText<"Disable ClangImporter and forward all requests straight the DWARF importer.">;

def disable_implicit_concurrency_module_import : Flag<["-"],
"disable-implicit-concurrency-module-import">,
HelpText<"Disable the implicit import of the _Concurrency module.">;

def disable_arc_opts : Flag<["-"], "disable-arc-opts">,
HelpText<"Don't run SIL ARC optimization passes.">;
def disable_ossa_opts : Flag<["-"], "disable-ossa-opts">,
Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableExperimentalConcurrency |=
Args.hasArg(OPT_enable_experimental_concurrency);

Opts.DisableImplicitConcurrencyModuleImport |=
Args.hasArg(OPT_disable_implicit_concurrency_module_import);

Opts.EnableSubstSILFunctionTypesForFunctionValues |=
Args.hasArg(OPT_enable_subst_sil_function_types_for_function_values);

Expand Down
3 changes: 2 additions & 1 deletion lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ CompilerInstance::openModuleDoc(const InputFile &input) {
}

bool CompilerInvocation::shouldImportSwiftConcurrency() const {
return getLangOptions().EnableExperimentalConcurrency;
return getLangOptions().EnableExperimentalConcurrency
&& !getLangOptions().DisableImplicitConcurrencyModuleImport;
}

/// Implicitly import the SwiftOnoneSupport module in non-optimized
Expand Down
6 changes: 6 additions & 0 deletions stdlib/cmake/modules/AddSwiftStdlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,12 @@ function(add_swift_target_library name)
list(APPEND SWIFTLIB_DEPENDS clang)
endif()

# Turn off implicit import of _Concurrency when building libraries
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
list(APPEND SWIFTLIB_SWIFT_COMPILE_FLAGS
"-Xfrontend;-disable-implicit-concurrency-module-import")
endif()

# If we are building this library for targets, loop through the various
# SDKs building the variants of this library.
list_intersect(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency -disable-implicit-concurrency-module-import
// REQUIRES: concurrency


protocol P : Actor { } // expected-error{{cannot find type 'Actor' in scope}}