Skip to content

Commit 78166f7

Browse files
authored
Merge pull request swiftlang#38616 from gottesmm/pr-43566c09aa169640705f6291f3dd981cc30040da
[concurrency] Implement a compatibility .a library for Concurrency.
2 parents ae6694a + 8441871 commit 78166f7

File tree

15 files changed

+105
-6
lines changed

15 files changed

+105
-6
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ class IRGenOptions {
370370
/// Pull in runtime compatibility shim libraries by autolinking.
371371
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;
372372
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
373+
Optional<llvm::VersionTuple>
374+
AutolinkRuntimeCompatibilityConcurrencyLibraryVersion;
373375

374376
JITDebugArtifact DumpJIT = JITDebugArtifact::None;
375377

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/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,12 @@ def disable_autolinking_runtime_compatibility_dynamic_replacements
12321232
HelpText<"Do not use autolinking for the dynamic replacement runtime "
12331233
"compatibility library">;
12341234

1235+
def disable_autolinking_runtime_compatibility_concurrency
1236+
: Flag<[ "-" ], "disable-autolinking-runtime-compatibility-concurrency">,
1237+
Flags<[ FrontendOption ]>,
1238+
HelpText<"Do not use autolinking for the concurrency runtime "
1239+
"compatibility library">;
1240+
12351241
def emit_symbol_graph: Flag<["-"], "emit-symbol-graph">,
12361242
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput, HelpHidden]>,
12371243
HelpText<"Emit a symbol graph">;

lib/Driver/DarwinToolChains.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
409409
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
410410
} else if (value.equals("5.1")) {
411411
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
412+
} else if (value.equals("5.5")) {
413+
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
412414
} else if (value.equals("none")) {
413415
runtimeCompatibilityVersion = None;
414416
} else {

lib/Driver/ToolChains.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ ToolChain::constructInvocation(const CompileJobAction &job,
560560
options::OPT_disable_autolinking_runtime_compatibility)) {
561561
Arguments.push_back("-disable-autolinking-runtime-compatibility");
562562
}
563-
563+
564564
if (auto arg = context.Args.getLastArg(
565565
options::OPT_runtime_compatibility_version)) {
566566
Arguments.push_back("-runtime-compatibility-version");
@@ -581,6 +581,9 @@ ToolChain::constructInvocation(const CompileJobAction &job,
581581
Arguments,
582582
options::
583583
OPT_disable_autolinking_runtime_compatibility_dynamic_replacements);
584+
context.Args.AddLastArg(
585+
Arguments,
586+
options::OPT_disable_autolinking_runtime_compatibility_concurrency);
584587

585588
if (context.OI.CompilerMode == OutputInfo::Mode::SingleCompile) {
586589
context.Args.AddLastArg(Arguments, options::OPT_emit_symbol_graph);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18361836
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
18371837
} else if (version.equals("5.1")) {
18381838
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
1839+
} else if (version.equals("5.5")) {
1840+
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
18391841
} else {
18401842
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
18411843
versionArg->getAsString(Args), version);
@@ -1858,6 +1860,12 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
18581860
getRuntimeCompatVersion();
18591861
}
18601862

1863+
if (!Args.hasArg(
1864+
options::OPT_disable_autolinking_runtime_compatibility_concurrency)) {
1865+
Opts.AutolinkRuntimeCompatibilityConcurrencyLibraryVersion =
1866+
getRuntimeCompatVersion();
1867+
}
1868+
18611869
if (const Arg *A = Args.getLastArg(OPT_num_threads)) {
18621870
if (StringRef(A->getValue()).getAsInteger(10, Opts.NumThreads)) {
18631871
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ void IRGenModule::emitSourceFile(SourceFile &SF) {
485485
if (libraryName == "swiftCompatibilityDynamicReplacements") {
486486
compatibilityVersion = IRGen.Opts.
487487
AutolinkRuntimeCompatibilityDynamicReplacementLibraryVersion;
488+
} else if (libraryName == "swiftCompatibilityConcurrency") {
489+
compatibilityVersion =
490+
IRGen.Opts.AutolinkRuntimeCompatibilityConcurrencyLibraryVersion;
488491
} else {
489492
compatibilityVersion = IRGen.Opts.
490493
AutolinkRuntimeCompatibilityLibraryVersion;

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ function(_compile_swift_files
459459
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
460460
list(APPEND swift_flags "-runtime-compatibility-version" "none")
461461
list(APPEND swift_flags "-disable-autolinking-runtime-compatibility-dynamic-replacements")
462+
list(APPEND swift_flags "-Xfrontend" "-disable-autolinking-runtime-compatibility-concurrency")
462463
endif()
463464

464465
if (SWIFTFILE_IS_STDLIB_CORE OR SWIFTFILE_IS_SDK_OVERLAY)

stdlib/toolchain/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ add_subdirectory(legacy_layouts)
5454
add_subdirectory(Compatibility50)
5555
add_subdirectory(Compatibility51)
5656
add_subdirectory(CompatibilityDynamicReplacements)
57+
add_subdirectory(CompatibilityConcurrency)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
set(library_name "swiftCompatibilityConcurrency")
2+
3+
add_swift_target_library("${library_name}" STATIC
4+
CompatibilityConcurrency.cpp
5+
6+
TARGET_SDKS ${SWIFT_APPLE_PLATFORMS}
7+
8+
C_COMPILE_FLAGS ${CXX_COMPILE_FLAGS}
9+
LINK_FLAGS ${CXX_LINK_FLAGS}
10+
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
11+
DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
12+
DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS}
13+
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
14+
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
15+
16+
INSTALL_IN_COMPONENT compiler
17+
INSTALL_WITH_SHARED)
18+
19+
# FIXME: We need a more flexible mechanism to add lipo targets generated by
20+
# add_swift_target_library to the ALL target. Until then this hack is necessary
21+
# to ensure these libraries build.
22+
foreach(sdk ${SWIFT_SDKS})
23+
set(target_name "${library_name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
24+
if(NOT TARGET "${target_name}")
25+
continue()
26+
endif()
27+
28+
set_target_properties("${target_name}"
29+
PROPERTIES
30+
EXCLUDE_FROM_ALL FALSE)
31+
endforeach()

0 commit comments

Comments
 (0)