Skip to content

Commit b03cde6

Browse files
authored
Merge pull request swiftlang#39342 from DougGregor/back-deploy-concurrency-5.5
Back-deploy concurrency
2 parents 92a2a51 + dab326a commit b03cde6

File tree

217 files changed

+3856
-1726
lines changed

Some content is hidden

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

217 files changed

+3856
-1726
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ else()
10041004
add_subdirectory(stdlib/toolchain)
10051005
endif()
10061006

1007+
if (BUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES)
1008+
# Build the back-deployed concurrency library.
1009+
add_subdirectory(stdlib/public/BackDeployConcurrency)
1010+
endif()
1011+
10071012
# Some tools (e.g. swift-reflection-dump) rely on a host swiftReflection, so
10081013
# ensure we build that when building tools.
10091014
if(SWIFT_INCLUDE_TOOLS)

cmake/modules/Libdispatch.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ foreach(sdk ${DISPATCH_SDKS})
6969
foreach(arch ${ARCHS})
7070
set(LIBDISPATCH_VARIANT_NAME "libdispatch-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
7171

72+
if(sdk MATCHES WINDOWS)
73+
set(SWIFT_LIBDISPATCH_COMPILER_TRIPLE_CMAKE_ARGS -DCMAKE_C_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE};-DCMAKE_CXX_COMPILER_TARGET=${SWIFT_SDK_WINDOWS_ARCH_${arch}_TRIPLE})
74+
endif()
75+
76+
7277
if(NOT sdk STREQUAL ANDROID)
7378
set(SWIFT_LIBDISPATCH_SYSTEM_PROCESSOR -DCMAKE_SYSTEM_PROCESSOR=${arch})
7479
endif()
@@ -80,6 +85,7 @@ foreach(sdk ${DISPATCH_SDKS})
8085
-DCMAKE_AR=${CMAKE_AR}
8186
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
8287
${SWIFT_LIBDISPATCH_COMPILER_CMAKE_ARGS}
88+
${SWIFT_LIBDISPATCH_COMPILER_TRIPLE_CMAKE_ARGS}
8389
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
8490
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
8591
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}

cmake/modules/SwiftComponents.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
# The set of "defined" swift components are as follows:
4747
#
4848
# * autolink-driver -- the Swift driver support tools
49+
# * back-deployment -- Swift back-deployment libraries
4950
# * compiler -- the Swift compiler and (on supported platforms) the REPL.
5051
# * clang-builtin-headers -- install a copy of Clang builtin headers under
5152
# 'lib/swift/clang'. This is useful when Swift compiler is installed in
@@ -66,7 +67,7 @@
6667
# * toolchain-dev-tools -- install development tools useful in a shared toolchain
6768
# * dev -- headers and libraries required to use Swift compiler as a library.
6869
set(_SWIFT_DEFINED_COMPONENTS
69-
"autolink-driver;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;parser-lib;editor-integration;tools;testsuite-tools;toolchain-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
70+
"autolink-driver;back-deployment;compiler;clang-builtin-headers;clang-resource-dir-symlink;clang-builtin-headers-in-clang-resource-dir;stdlib;stdlib-experimental;sdk-overlay;parser-lib;editor-integration;tools;testsuite-tools;toolchain-tools;toolchain-dev-tools;dev;license;sourcekit-xpc-service;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers")
7071

7172
# The default install components include all of the defined components, except
7273
# for the following exceptions.
@@ -85,6 +86,8 @@ else()
8586
list(REMOVE_ITEM _SWIFT_DEFAULT_COMPONENTS "sourcekit-xpc-service")
8687
endif()
8788
list(REMOVE_ITEM _SWIFT_DEFAULT_COMPONENTS "stdlib-experimental")
89+
# back-deployment libraries are opt-in
90+
list(REMOVE_ITEM _SWIFT_DEFAULT_COMPONENTS "back-deployment")
8891

8992
macro(swift_configure_components)
9093
# Set the SWIFT_INSTALL_COMPONENTS variable to the default value if it is not passed in via -D

include/swift/AST/ASTContext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,9 @@ class ASTContext final {
731731
/// Get the runtime availability of support for concurrency.
732732
AvailabilityContext getConcurrencyAvailability();
733733

734+
/// Get the back-deployed availability for concurrency.
735+
AvailabilityContext getBackDeployedConcurrencyAvailability();
736+
734737
/// Get the runtime availability of support for differentiation.
735738
AvailabilityContext getDifferentiationAvailability();
736739

@@ -750,6 +753,11 @@ class ASTContext final {
750753
/// compiler for the target platform.
751754
AvailabilityContext getSwift55Availability();
752755

756+
// Note: Update this function if you add a new getSwiftXYAvailability above.
757+
/// Get the runtime availability for a particular version of Swift (5.0+).
758+
AvailabilityContext
759+
getSwift5PlusAvailability(llvm::VersionTuple swiftVersion);
760+
753761
/// Get the runtime availability of features that have been introduced in the
754762
/// Swift compiler for future versions of the target platform.
755763
AvailabilityContext getSwiftFutureAvailability();

include/swift/AST/ASTMangler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ class ASTMangler : public Mangler {
5757
/// to fill these in.
5858
bool AllowSymbolicReferences = false;
5959

60+
/// If enabled, allows the use of standard substitutions for types in the
61+
/// concurrency library.
62+
bool AllowConcurrencyStandardSubstitutions = true;
63+
6064
public:
6165
using SymbolicReferent = llvm::PointerUnion<const NominalTypeDecl *,
6266
const OpaqueTypeDecl *>;

include/swift/AST/IRGenOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ class IRGenOptions {
381381
/// Pull in runtime compatibility shim libraries by autolinking.
382382
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;
383383
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
384+
Optional<llvm::VersionTuple>
385+
AutolinkRuntimeCompatibilityConcurrencyLibraryVersion;
384386

385387
JITDebugArtifact DumpJIT = JITDebugArtifact::None;
386388

include/swift/Demangling/ManglingUtils.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ char translateOperatorChar(char op);
9999
std::string translateOperator(StringRef Op);
100100

101101
/// Returns the standard type kind for an 'S' substitution, e.g. 'i' for "Int".
102-
llvm::Optional<StringRef> getStandardTypeSubst(StringRef TypeName);
102+
///
103+
/// \param allowConcurrencyManglings When true, allows the standard
104+
/// substitutions for types in the _Concurrency module that were introduced in
105+
/// Swift 5.5.
106+
llvm::Optional<StringRef> getStandardTypeSubst(
107+
StringRef TypeName, bool allowConcurrencyManglings);
103108

104109
/// Mangles an identifier using a generic Mangler class.
105110
///

include/swift/Demangling/StandardTypesMangling.def

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
/// STANDARD_TYPE(KIND, MANGLING, TYPENAME)
1414
/// The 1-character MANGLING for a known TYPENAME of KIND.
1515
///
16-
/// STANDARD_TYPE_2(KIND, MANGLING, TYPENAME)
16+
/// STANDARD_TYPE_CONCURRENCY(KIND, MANGLING, TYPENAME)
1717
/// The 1-character MANGLING for a known TYPENAME of KIND that is in the
18-
/// second level of standard types, all of which are mangled with the form
19-
/// Sc<MANGLING>.
18+
/// second level of standard types in the Concurrency model, all of which are
19+
/// mangled with the form Sc<MANGLING>.
2020
///
2121
/// OBJC_INTEROP_STANDARD_TYPE(KIND, MANGLING, TYPENAME)
2222
/// The 1-character MANGLING for a known TYPENAME of KIND, for a type that's
@@ -79,25 +79,25 @@ STANDARD_TYPE(Protocol, y, StringProtocol)
7979
STANDARD_TYPE(Protocol, Z, SignedInteger)
8080
STANDARD_TYPE(Protocol, z, BinaryInteger)
8181

82-
STANDARD_TYPE_2(Protocol, A, Actor)
83-
STANDARD_TYPE_2(Structure, C, CheckedContinuation)
84-
STANDARD_TYPE_2(Structure, c, UnsafeContinuation)
85-
STANDARD_TYPE_2(Structure, E, CancellationError)
86-
STANDARD_TYPE_2(Structure, e, UnownedSerialExecutor)
87-
STANDARD_TYPE_2(Protocol, F, Executor)
88-
STANDARD_TYPE_2(Protocol, f, SerialExecutor)
89-
STANDARD_TYPE_2(Structure, G, TaskGroup)
90-
STANDARD_TYPE_2(Structure, g, ThrowingTaskGroup)
91-
STANDARD_TYPE_2(Protocol, I, AsyncIteratorProtocol)
92-
STANDARD_TYPE_2(Protocol, i, AsyncSequence)
93-
STANDARD_TYPE_2(Structure, J, UnownedJob)
94-
STANDARD_TYPE_2(Class, M, MainActor)
95-
STANDARD_TYPE_2(Structure, P, TaskPriority)
96-
STANDARD_TYPE_2(Structure, S, AsyncStream)
97-
STANDARD_TYPE_2(Structure, s, AsyncThrowingStream)
98-
STANDARD_TYPE_2(Structure, T, Task)
99-
STANDARD_TYPE_2(Structure, t, UnsafeCurrentTask)
82+
STANDARD_TYPE_CONCURRENCY(Protocol, A, Actor)
83+
STANDARD_TYPE_CONCURRENCY(Structure, C, CheckedContinuation)
84+
STANDARD_TYPE_CONCURRENCY(Structure, c, UnsafeContinuation)
85+
STANDARD_TYPE_CONCURRENCY(Structure, E, CancellationError)
86+
STANDARD_TYPE_CONCURRENCY(Structure, e, UnownedSerialExecutor)
87+
STANDARD_TYPE_CONCURRENCY(Protocol, F, Executor)
88+
STANDARD_TYPE_CONCURRENCY(Protocol, f, SerialExecutor)
89+
STANDARD_TYPE_CONCURRENCY(Structure, G, TaskGroup)
90+
STANDARD_TYPE_CONCURRENCY(Structure, g, ThrowingTaskGroup)
91+
STANDARD_TYPE_CONCURRENCY(Protocol, I, AsyncIteratorProtocol)
92+
STANDARD_TYPE_CONCURRENCY(Protocol, i, AsyncSequence)
93+
STANDARD_TYPE_CONCURRENCY(Structure, J, UnownedJob)
94+
STANDARD_TYPE_CONCURRENCY(Class, M, MainActor)
95+
STANDARD_TYPE_CONCURRENCY(Structure, P, TaskPriority)
96+
STANDARD_TYPE_CONCURRENCY(Structure, S, AsyncStream)
97+
STANDARD_TYPE_CONCURRENCY(Structure, s, AsyncThrowingStream)
98+
STANDARD_TYPE_CONCURRENCY(Structure, T, Task)
99+
STANDARD_TYPE_CONCURRENCY(Structure, t, UnsafeCurrentTask)
100100

101101
#undef STANDARD_TYPE
102102
#undef OBJC_INTEROP_STANDARD_TYPE
103-
#undef STANDARD_TYPE_2
103+
#undef STANDARD_TYPE_CONCURRENCY

include/swift/Frontend/BackDeploymentLibs.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
BACK_DEPLOYMENT_LIB((5, 0), all, "swiftCompatibility50")
2828
BACK_DEPLOYMENT_LIB((5, 1), all, "swiftCompatibility51")
2929
BACK_DEPLOYMENT_LIB((5, 0), executable, "swiftCompatibilityDynamicReplacements")
30+
BACK_DEPLOYMENT_LIB((5, 5), all, "swiftCompatibilityConcurrency")
3031

3132
#undef BACK_DEPLOYMENT_LIB

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ def type_info_dump_filter_EQ : Joined<["-"], "type-info-dump-filter=">,
765765
Flags<[FrontendOption]>,
766766
HelpText<"One of 'all', 'resilient' or 'fragile'">;
767767

768-
769768
def emit_ldadd_cfile_path
770769
: Separate<["-"], "emit-ldadd-cfile-path">, MetaVarName<"<path>">,
771770
HelpText<"Generate .c file defining symbols to add back">;

0 commit comments

Comments
 (0)