Skip to content

Commit b4b78c6

Browse files
authored
Merge pull request #25225 from apple/revert-25148-runtime-compatibility-autolink
Revert "Use autolinking to pull in compatibility libraries."
2 parents 6c69c8d + a7cc3a3 commit b4b78c6

File tree

15 files changed

+61
-196
lines changed

15 files changed

+61
-196
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,7 @@ function(_add_swift_library_single target name)
730730
OBJECT_LIBRARY
731731
SHARED
732732
STATIC
733-
TARGET_LIBRARY
734-
INSTALL_WITH_SHARED)
733+
TARGET_LIBRARY)
735734
set(SWIFTLIB_SINGLE_single_parameter_options
736735
ARCHITECTURE
737736
DEPLOYMENT_VERSION_IOS
@@ -1086,24 +1085,18 @@ function(_add_swift_library_single target name)
10861085
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
10871086
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})
10881087

1089-
if(SWIFTLIB_INSTALL_WITH_SHARED)
1090-
set(swift_lib_dir ${SWIFTLIB_DIR})
1091-
else()
1092-
set(swift_lib_dir ${SWIFTSTATICLIB_DIR})
1093-
endif()
1094-
10951088
foreach(config ${CMAKE_CONFIGURATION_TYPES})
10961089
string(TOUPPER ${config} config_upper)
10971090
escape_path_for_xcode(
1098-
"${config}" "${swift_lib_dir}" config_lib_dir)
1091+
"${config}" "${SWIFTSTATICLIB_DIR}" config_lib_dir)
10991092
set_target_properties(${target_static} PROPERTIES
11001093
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
11011094
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
11021095
endforeach()
11031096

11041097
set_target_properties(${target_static} PROPERTIES
1105-
LIBRARY_OUTPUT_DIRECTORY ${swift_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
1106-
ARCHIVE_OUTPUT_DIRECTORY ${swift_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
1098+
LIBRARY_OUTPUT_DIRECTORY ${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}
1099+
ARCHIVE_OUTPUT_DIRECTORY ${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
11071100
endif()
11081101

11091102
set_target_properties(${target}
@@ -1354,14 +1347,8 @@ function(_add_swift_library_single target name)
13541347
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY
13551348
COMPILE_FLAGS " ${c_compile_flags}")
13561349
# FIXME: The fallback paths here are going to be dynamic libraries.
1357-
1358-
if(SWIFTLIB_INSTALL_WITH_SHARED)
1359-
set(search_base_dir ${SWIFTLIB_DIR})
1360-
else()
1361-
set(search_base_dir ${SWIFTSTATICLIB_DIR})
1362-
endif()
13631350
set(library_search_directories
1364-
"${search_base_dir}/${SWIFTLIB_SINGLE_SUBDIR}"
1351+
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
13651352
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
13661353
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
13671354
swift_target_link_search_directories("${target_static}" "${library_search_directories}")
@@ -1490,7 +1477,6 @@ endfunction()
14901477
# [IS_STDLIB]
14911478
# [IS_STDLIB_CORE]
14921479
# [TARGET_LIBRARY]
1493-
# [INSTALL_WITH_SHARED]
14941480
# INSTALL_IN_COMPONENT comp
14951481
# DEPLOYMENT_VERSION_OSX version
14961482
# DEPLOYMENT_VERSION_IOS version
@@ -1597,9 +1583,6 @@ endfunction()
15971583
# DEPLOYMENT_VERSION_WATCHOS
15981584
# The minimum deployment version to build for if this is an WATCHOS library.
15991585
#
1600-
# INSTALL_WITH_SHARED
1601-
# Install a static library target alongside shared libraries
1602-
#
16031586
# source1 ...
16041587
# Sources to add into this library.
16051588
function(add_swift_target_library name)
@@ -1614,8 +1597,7 @@ function(add_swift_target_library name)
16141597
OBJECT_LIBRARY
16151598
SHARED
16161599
STATIC
1617-
TARGET_LIBRARY
1618-
INSTALL_WITH_SHARED)
1600+
TARGET_LIBRARY)
16191601
set(SWIFTLIB_single_parameter_options
16201602
DEPLOYMENT_VERSION_IOS
16211603
DEPLOYMENT_VERSION_OSX
@@ -1900,7 +1882,6 @@ function(add_swift_target_library name)
19001882
${SWIFTLIB_SHARED_keyword}
19011883
${SWIFTLIB_STATIC_keyword}
19021884
${SWIFTLIB_OBJECT_LIBRARY_keyword}
1903-
${SWIFTLIB_INSTALL_WITH_SHARED_keyword}
19041885
${SWIFTLIB_SOURCES}
19051886
MODULE_TARGET ${MODULE_VARIANT_NAME}
19061887
SDK ${sdk}
@@ -2015,7 +1996,7 @@ function(add_swift_target_library name)
20151996
set(resource_dir_sdk_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
20161997
precondition(resource_dir_sdk_subdir)
20171998

2018-
if(SWIFTLIB_SHARED OR SWIFTLIB_INSTALL_WITH_SHARED)
1999+
if(SWIFTLIB_SHARED)
20192000
set(resource_dir "swift")
20202001
set(file_permissions
20212002
OWNER_READ OWNER_WRITE OWNER_EXECUTE
@@ -2077,18 +2058,10 @@ function(add_swift_target_library name)
20772058
list(APPEND THIN_INPUT_TARGETS_STATIC "${TARGET}-static")
20782059
endforeach()
20792060

2080-
if(SWIFTLIB_INSTALL_WITH_SHARED)
2081-
set(install_subdir "swift")
2082-
set(universal_subdir ${SWIFTLIB_DIR})
2083-
else()
2084-
set(install_subdir "swift_static")
2085-
set(universal_subdir ${SWIFTSTATICLIB_DIR})
2086-
endif()
2087-
20882061
set(lipo_target_static
20892062
"${name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-static")
20902063
set(UNIVERSAL_LIBRARY_NAME
2091-
"${universal_subdir}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
2064+
"${SWIFTSTATICLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
20922065
_add_swift_lipo_target(SDK
20932066
${sdk}
20942067
TARGET
@@ -2097,7 +2070,7 @@ function(add_swift_target_library name)
20972070
"${UNIVERSAL_LIBRARY_NAME}"
20982071
${THIN_INPUT_TARGETS_STATIC})
20992072
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
2100-
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}"
2073+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${resource_dir_sdk_subdir}"
21012074
PERMISSIONS
21022075
OWNER_READ OWNER_WRITE
21032076
GROUP_READ

cmake/modules/SwiftSource.cmake

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,12 @@ function(_compile_swift_files
253253
list(APPEND swift_flags "-module-name" "${SWIFTFILE_MODULE_NAME}")
254254
endif()
255255

256-
# Force swift 5 mode for Standard Library and overlays.
256+
# Force swift 5 mode for Standard Library.
257257
if (SWIFTFILE_IS_STDLIB)
258258
list(APPEND swift_flags "-swift-version" "5")
259259
endif()
260+
261+
# Force swift 4 compatibility mode for overlays.
260262
if (SWIFTFILE_IS_SDK_OVERLAY)
261263
list(APPEND swift_flags "-swift-version" "5")
262264
endif()
@@ -265,12 +267,6 @@ function(_compile_swift_files
265267
list(APPEND swift_flags "-autolink-force-load")
266268
endif()
267269

268-
# Don't need to link runtime compatibility libraries for older runtimes
269-
# into the new runtime.
270-
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
271-
list(APPEND swift_flags "-runtime-compatibility-version" "none")
272-
endif()
273-
274270
if (SWIFTFILE_IS_STDLIB_CORE OR SWIFTFILE_IS_SDK_OVERLAY)
275271
list(APPEND swift_flags "-warn-swift3-objc-inference-complete")
276272
endif()

include/swift/AST/IRGenOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// FIXME: This include is just for llvm::SanitizerCoverageOptions. We should
2727
// split the header upstream so we don't include so much.
2828
#include "llvm/Transforms/Instrumentation.h"
29-
#include "llvm/Support/VersionTuple.h"
3029
#include <string>
3130
#include <vector>
3231

@@ -225,9 +224,6 @@ class IRGenOptions {
225224
};
226225

227226
TypeInfoDumpFilter TypeInfoFilter;
228-
229-
/// Pull in runtime compatibility shim libraries by autolinking.
230-
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;
231227

232228
IRGenOptions()
233229
: DWARFVersion(2), OutputKind(IRGenOutputKind::LLVMAssembly),

include/swift/Basic/Platform.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
namespace llvm {
2121
class Triple;
22-
class VersionTuple;
2322
}
2423

2524
namespace swift {
@@ -86,12 +85,6 @@ namespace swift {
8685
/// The input triple should already be "normalized" in the sense that
8786
/// llvm::Triple::normalize() would not affect it.
8887
llvm::Triple getTargetSpecificModuleTriple(const llvm::Triple &triple);
89-
90-
91-
/// Get the Swift runtime version to deploy back to, given a deployment target expressed as an
92-
/// LLVM target triple.
93-
Optional<llvm::VersionTuple>
94-
getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple);
9588
} // end namespace swift
9689

9790
#endif // SWIFT_BASIC_PLATFORM_H

include/swift/Option/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,4 @@ def vfsoverlay_EQ : Joined<["-"], "vfsoverlay=">,
892892
def runtime_compatibility_version : Separate<["-"], "runtime-compatibility-version">,
893893
Flags<[FrontendOption]>,
894894
HelpText<"Link compatibility library for Swift runtime version, or 'none'">;
895-
896-
def disable_autolinking_runtime_compatibility : Flag<["-"], "disable-autolinking-runtime-compatibility">,
897-
Flags<[FrontendOption]>,
898-
HelpText<"Do not use autolinking for runtime compatibility libraries">;
899-
900895
include "FrontendOptions.td"

lib/Basic/Platform.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "llvm/ADT/StringExtras.h"
1515
#include "llvm/ADT/StringSwitch.h"
1616
#include "llvm/ADT/Triple.h"
17-
#include "llvm/Support/VersionTuple.h"
1817

1918
using namespace swift;
2019

@@ -314,37 +313,3 @@ llvm::Triple swift::getTargetSpecificModuleTriple(const llvm::Triple &triple) {
314313
return triple;
315314
}
316315

317-
Optional<llvm::VersionTuple>
318-
swift::getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple){
319-
unsigned Major, Minor, Micro;
320-
321-
if (Triple.isMacOSX()) {
322-
Triple.getMacOSXVersion(Major, Minor, Micro);
323-
if (Major == 10) {
324-
if (Minor <= 14) {
325-
return llvm::VersionTuple(5, 0);
326-
} else {
327-
return None;
328-
}
329-
} else {
330-
return None;
331-
}
332-
} else if (Triple.isiOS()) { // includes tvOS
333-
Triple.getiOSVersion(Major, Minor, Micro);
334-
if (Major <= 12) {
335-
return llvm::VersionTuple(5, 0);
336-
} else {
337-
return None;
338-
}
339-
} else if (Triple.isWatchOS()) {
340-
Triple.getWatchOSVersion(Major, Minor, Micro);
341-
if (Major <= 5) {
342-
return llvm::VersionTuple(5, 0);
343-
} else {
344-
return None;
345-
}
346-
} else {
347-
return None;
348-
}
349-
}
350-

lib/Driver/DarwinToolChains.cpp

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "llvm/Support/Path.h"
3434
#include "llvm/Support/Process.h"
3535
#include "llvm/Support/Program.h"
36-
#include "llvm/Support/VersionTuple.h"
3736

3837
using namespace swift;
3938
using namespace swift::driver;
@@ -222,6 +221,42 @@ static bool wantsObjCRuntime(const llvm::Triple &triple) {
222221
llvm_unreachable("unknown Darwin OS");
223222
}
224223

224+
/// Return the earliest backward deployment compatibility version we need to
225+
/// link in for the given target triple, if any.
226+
static Optional<std::pair<unsigned, unsigned>>
227+
getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple) {
228+
unsigned Major, Minor, Micro;
229+
230+
if (Triple.isMacOSX()) {
231+
Triple.getMacOSXVersion(Major, Minor, Micro);
232+
if (Major == 10) {
233+
if (Minor <= 14) {
234+
return std::make_pair(5u, 0u);
235+
} else {
236+
return None;
237+
}
238+
} else {
239+
return None;
240+
}
241+
} else if (Triple.isiOS()) { // includes tvOS
242+
Triple.getiOSVersion(Major, Minor, Micro);
243+
if (Major <= 12) {
244+
return std::make_pair(5u, 0u);
245+
} else {
246+
return None;
247+
}
248+
} else if (Triple.isWatchOS()) {
249+
Triple.getWatchOSVersion(Major, Minor, Micro);
250+
if (Major <= 5) {
251+
return std::make_pair(5u, 0u);
252+
} else {
253+
return None;
254+
}
255+
} else {
256+
return None;
257+
}
258+
}
259+
225260
ToolChain::InvocationInfo
226261
toolchains::Darwin::constructInvocation(const LinkJobAction &job,
227262
const JobContext &context) const
@@ -396,13 +431,12 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
396431

397432
// Link compatibility libraries, if we're deploying back to OSes that
398433
// have an older Swift runtime.
399-
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
434+
Optional<std::pair<unsigned, unsigned>> runtimeCompatibilityVersion;
400435

401436
if (context.Args.hasArg(options::OPT_runtime_compatibility_version)) {
402-
auto value = context.Args.getLastArgValue(
403-
options::OPT_runtime_compatibility_version);
437+
auto value = context.Args.getLastArgValue(options::OPT_runtime_compatibility_version);
404438
if (value.equals("5.0")) {
405-
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
439+
runtimeCompatibilityVersion = std::make_pair(5u, 0u);
406440
} else if (value.equals("none")) {
407441
runtimeCompatibilityVersion = None;
408442
} else {
@@ -414,7 +448,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
414448
}
415449

416450
if (runtimeCompatibilityVersion) {
417-
if (*runtimeCompatibilityVersion <= llvm::VersionTuple(5, 0)) {
451+
if (*runtimeCompatibilityVersion <= std::make_pair(5u, 0u)) {
418452
// Swift 5.0 compatibility library
419453
SmallString<128> BackDeployLib;
420454
BackDeployLib.append(RuntimeLibPath);

lib/Driver/ToolChains.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,17 +433,6 @@ ToolChain::constructInvocation(const CompileJobAction &job,
433433
Arguments.push_back("-debug-info-store-invocation");
434434
}
435435

436-
if (context.Args.hasArg(
437-
options::OPT_disable_autolinking_runtime_compatibility)) {
438-
Arguments.push_back("-disable-autolinking-runtime-compatibility");
439-
}
440-
441-
if (auto arg = context.Args.getLastArg(
442-
options::OPT_runtime_compatibility_version)) {
443-
Arguments.push_back("-runtime-compatibility-version");
444-
Arguments.push_back(arg->getValue());
445-
}
446-
447436
return II;
448437
}
449438

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,30 +1155,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
11551155
A->getAsString(Args), A->getValue());
11561156
}
11571157
}
1158-
1159-
// Autolink runtime compatibility libraries, if asked to.
1160-
if (!Args.hasArg(options::OPT_disable_autolinking_runtime_compatibility)) {
1161-
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;
1162-
1163-
if (auto versionArg = Args.getLastArg(
1164-
options::OPT_runtime_compatibility_version)) {
1165-
auto version = StringRef(versionArg->getValue());
1166-
if (version.equals("none")) {
1167-
runtimeCompatibilityVersion = None;
1168-
} else if (version.equals("5.0")) {
1169-
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
1170-
} else {
1171-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
1172-
versionArg->getAsString(Args), version);
1173-
}
1174-
} else {
1175-
runtimeCompatibilityVersion =
1176-
getSwiftRuntimeCompatibilityVersionForTarget(Triple);
1177-
}
1178-
1179-
Opts.AutolinkRuntimeCompatibilityLibraryVersion =
1180-
runtimeCompatibilityVersion;
1181-
}
11821158

11831159
return false;
11841160
}

0 commit comments

Comments
 (0)