Skip to content

Commit f7810ad

Browse files
committed
Revert "Merge pull request #60459 from etcwilde/ewilde/revert-backdeploy56"
This reverts commit 93387f8, reversing changes made to 88304c3.
1 parent 50d6d6a commit f7810ad

32 files changed

+4263
-8
lines changed

Diff for: include/swift/Frontend/BackDeploymentLibs.def

+1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ BACK_DEPLOYMENT_LIB((5, 0), all, "swiftCompatibility50")
2828
BACK_DEPLOYMENT_LIB((5, 1), all, "swiftCompatibility51")
2929
BACK_DEPLOYMENT_LIB((5, 0), executable, "swiftCompatibilityDynamicReplacements")
3030
BACK_DEPLOYMENT_LIB((5, 4), all, "swiftCompatibilityConcurrency")
31+
BACK_DEPLOYMENT_LIB((5, 6), all, "swiftCompatibility56")
3132

3233
#undef BACK_DEPLOYMENT_LIB

Diff for: lib/Driver/DarwinToolChains.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
412412
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
413413
} else if (value.equals("5.5")) {
414414
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
415+
} else if (value.equals("5.6")) {
416+
runtimeCompatibilityVersion = llvm::VersionTuple(5, 6);
415417
} else if (value.equals("none")) {
416418
runtimeCompatibilityVersion = None;
417419
} else {

Diff for: lib/Frontend/CompilerInvocation.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
22962296
runtimeCompatibilityVersion = llvm::VersionTuple(5, 1);
22972297
} else if (version.equals("5.5")) {
22982298
runtimeCompatibilityVersion = llvm::VersionTuple(5, 5);
2299+
} else if (version.equals("5.6")) {
2300+
runtimeCompatibilityVersion = llvm::VersionTuple(5, 6);
22992301
} else {
23002302
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
23012303
versionArg->getAsString(Args), version);

Diff for: stdlib/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ include(StdlibOptions)
3939
# End of user-configurable options.
4040
#
4141

42+
set(SWIFT_STDLIB_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
43+
4244
# Remove llvm-project/llvm/include directory from -I search part when building
4345
# the stdlib. We have our own fork of LLVM includes (Support, ADT) in
4446
# stdlib/include/llvm and we don't want to silently use headers from LLVM.

Diff for: stdlib/toolchain/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
5050
add_subdirectory(legacy_layouts)
5151
add_subdirectory(Compatibility50)
5252
add_subdirectory(Compatibility51)
53+
add_subdirectory(Compatibility56)
5354
add_subdirectory(CompatibilityDynamicReplacements)
5455
add_subdirectory(CompatibilityConcurrency)
5556
add_subdirectory(CompatibilityThreading)
@@ -63,6 +64,7 @@ if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
6364
swiftCompatibilityConcurrency${vsuffix}
6465
swiftCompatibilityDynamicReplacements${vsuffix}
6566
swiftCompatibility50${vsuffix}
66-
swiftCompatibility51${vsuffix})
67+
swiftCompatibility51${vsuffix}
68+
swiftCompatibility56${vsuffix})
6769
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS HostCompatibilityLibs)
6870
endif()

Diff for: stdlib/toolchain/Compatibility56/CMakeLists.txt

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
set(library_name "swiftCompatibility56")
2+
3+
include_directories("include/" "${SWIFT_STDLIB_SOURCE_DIR}")
4+
5+
add_swift_target_library("${library_name}" STATIC
6+
Overrides.cpp
7+
Concurrency/Task.cpp
8+
Concurrency/Error.cpp
9+
Concurrency/Actor.cpp
10+
Concurrency/AsyncLet.cpp
11+
12+
TARGET_SDKS ${SWIFT_DARWIN_PLATFORMS}
13+
14+
C_COMPILE_FLAGS ${CXX_COMPILE_FLAGS}
15+
LINK_FLAGS ${CXX_LINK_FLAGS}
16+
INCORPORATE_OBJECT_LIBRARIES swiftThreading
17+
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
18+
DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
19+
DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS}
20+
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
21+
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
22+
23+
INSTALL_IN_COMPONENT compiler
24+
INSTALL_WITH_SHARED)
25+
26+
27+
# FIXME: We need a more flexible mechanism to add lipo targets generated by
28+
# add_swift_target_library to the ALL target. Until then this hack is necessary
29+
# to ensure these libraries build.
30+
foreach(sdk ${SWIFT_SDKS})
31+
set(target_name "${library_name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
32+
if(NOT TARGET "${target_name}")
33+
continue()
34+
endif()
35+
36+
set_target_properties("${target_name}"
37+
PROPERTIES
38+
EXCLUDE_FROM_ALL FALSE)
39+
endforeach()
+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
//===--- CompatibiltyOverride.h - Back-deploying compatibility fixes --*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Support back-deploying compatibility fixes for newer apps running on older runtimes.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#ifndef COMPATIBILITY_OVERRIDE_H
18+
#define COMPATIBILITY_OVERRIDE_H
19+
20+
#include "public/runtime/Private.h"
21+
22+
#include "Runtime/Concurrency.h"
23+
#include "swift/Runtime/Metadata.h"
24+
#include "swift/Runtime/Once.h"
25+
#include <type_traits>
26+
27+
namespace swift {
28+
29+
// Macro utilities.
30+
#define COMPATIBILITY_UNPAREN(...) __VA_ARGS__
31+
#define COMPATIBILITY_CONCAT2(x, y) x##y
32+
#define COMPATIBILITY_CONCAT(x, y) COMPATIBILITY_CONCAT2(x, y)
33+
34+
// This ridiculous construct will remove the parentheses from the argument and
35+
// add a trailing comma, or will produce nothing when passed no argument. For
36+
// example:
37+
// COMPATIBILITY_UNPAREN_WITH_COMMA((1, 2, 3)) -> 1, 2, 3,
38+
// COMPATIBILITY_UNPAREN_WITH_COMMA((4)) -> 4,
39+
// COMPATIBILITY_UNPAREN_WITH_COMMA() ->
40+
#define COMPATIBILITY_UNPAREN_WITH_COMMA(x) \
41+
COMPATIBILITY_CONCAT(COMPATIBILITY_UNPAREN_ADD_TRAILING_COMMA_, \
42+
COMPATIBILITY_UNPAREN_WITH_COMMA2 x)
43+
#define COMPATIBILITY_UNPAREN_WITH_COMMA2(...) PARAMS(__VA_ARGS__)
44+
#define COMPATIBILITY_UNPAREN_ADD_TRAILING_COMMA_PARAMS(...) __VA_ARGS__,
45+
#define COMPATIBILITY_UNPAREN_ADD_TRAILING_COMMA_COMPATIBILITY_UNPAREN_WITH_COMMA2
46+
47+
// This ridiculous construct will preserve the parentheses around the argument,
48+
// or will produce an empty pair of parentheses when passed no argument. For
49+
// example:
50+
// COMPATIBILITY_PAREN((1, 2, 3)) -> (1, 2, 3)
51+
// COMPATIBILITY_PAREN((4)) -> (4)
52+
// COMPATIBILITY_PAREN() -> ()
53+
#define COMPATIBILITY_PAREN(x) \
54+
COMPATIBILITY_CONCAT(COMPATIBILITY_PAREN_, COMPATIBILITY_PAREN2 x)
55+
#define COMPATIBILITY_PAREN2(...) PARAMS(__VA_ARGS__)
56+
#define COMPATIBILITY_PAREN_PARAMS(...) (__VA_ARGS__)
57+
#define COMPATIBILITY_PAREN_COMPATIBILITY_PAREN2 ()
58+
59+
// Include path computation. Code that includes this file can write
60+
// `#include COMPATIBILITY_OVERRIDE_INCLUDE_PATH` to include the appropriate
61+
// .def file for the current library.
62+
#define COMPATIBILITY_OVERRIDE_INCLUDE_PATH_swiftRuntime \
63+
"CompatibilityOverrideRuntime.def"
64+
#define COMPATIBILITY_OVERRIDE_INCLUDE_PATH_swift_Concurrency \
65+
"CompatibilityOverrideConcurrency.def"
66+
67+
#define COMPATIBILITY_OVERRIDE_INCLUDE_PATH \
68+
COMPATIBILITY_CONCAT(COMPATIBILITY_OVERRIDE_INCLUDE_PATH_, \
69+
SWIFT_TARGET_LIBRARY_NAME)
70+
71+
// Compatibility overrides are only supported on Darwin.
72+
#ifndef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
73+
#if !(defined(__APPLE__) && defined(__MACH__))
74+
#define SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
75+
#endif
76+
#endif
77+
78+
#ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
79+
80+
# error Back-deployment library must always be built with compatibilty overrides
81+
82+
#else // #ifdef SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
83+
84+
// Override section name computation. `COMPATIBILITY_OVERRIDE_SECTION_NAME` will
85+
// resolve to string literal containing the appropriate section name for the
86+
// current library.
87+
#define COMPATIBILITY_OVERRIDE_SECTION_NAME_swift_Concurrency "__s_async_hook"
88+
89+
#define COMPATIBILITY_OVERRIDE_SECTION_NAME \
90+
COMPATIBILITY_CONCAT(COMPATIBILITY_OVERRIDE_SECTION_NAME_, \
91+
SWIFT_TARGET_LIBRARY_NAME)
92+
93+
// Create typedefs for function pointers to call the original implementation.
94+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
95+
ccAttrs typedef ret(*Original_##name) COMPATIBILITY_PAREN(typedArgs);
96+
#include "CompatibilityOverrideRuntime.def"
97+
#include "CompatibilityOverrideConcurrency.def"
98+
#undef OVERRIDE
99+
100+
101+
// Create typedefs for override function pointers.
102+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
103+
ccAttrs typedef ret (*Override_##name)(COMPATIBILITY_UNPAREN_WITH_COMMA( \
104+
typedArgs) Original_##name originalImpl);
105+
#include "CompatibilityOverrideRuntime.def"
106+
#include "CompatibilityOverrideConcurrency.def"
107+
#undef OVERRIDE
108+
109+
// Create declarations for getOverride functions.
110+
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
111+
Override_ ## name getOverride_ ## name();
112+
#include "CompatibilityOverrideRuntime.def"
113+
#include "CompatibilityOverrideConcurrency.def"
114+
#undef OVERRIDE
115+
116+
/// Used to define an override point. The override point #defines the appropriate
117+
/// OVERRIDE macro from CompatibilityOverride.def to this macro, then includes
118+
/// the file to generate the override points. The original implementation of the
119+
/// functionality must be available as swift_funcNameHereImpl.
120+
#define COMPATIBILITY_OVERRIDE(name, ret, attrs, ccAttrs, namespace, \
121+
typedArgs, namedArgs) \
122+
attrs ccAttrs ret namespace swift_##name COMPATIBILITY_PAREN(typedArgs) { \
123+
static Override_##name Override; \
124+
static swift_once_t Predicate; \
125+
swift_once( \
126+
&Predicate, [](void *) { Override = getOverride_##name(); }, nullptr); \
127+
if (Override != nullptr) \
128+
return Override(COMPATIBILITY_UNPAREN_WITH_COMMA(namedArgs) \
129+
swift_##name##Impl); \
130+
return swift_##name##Impl COMPATIBILITY_PAREN(namedArgs); \
131+
}
132+
133+
#endif // #else SWIFT_RUNTIME_NO_COMPATIBILITY_OVERRIDES
134+
135+
} /* end namespace swift */
136+
137+
#endif /* COMPATIBILITY_OVERRIDE_H */

0 commit comments

Comments
 (0)