Skip to content

Revert "Use autolinking to pull in compatibility libraries." #25225

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 1 commit into from
Jun 3, 2019
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
45 changes: 9 additions & 36 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,7 @@ function(_add_swift_library_single target name)
OBJECT_LIBRARY
SHARED
STATIC
TARGET_LIBRARY
INSTALL_WITH_SHARED)
TARGET_LIBRARY)
set(SWIFTLIB_SINGLE_single_parameter_options
ARCHITECTURE
DEPLOYMENT_VERSION_IOS
Expand Down Expand Up @@ -1086,24 +1085,18 @@ function(_add_swift_library_single target name)
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}
LIBRARY_DIR ${SWIFT_LIBRARY_OUTPUT_INTDIR})

if(SWIFTLIB_INSTALL_WITH_SHARED)
set(swift_lib_dir ${SWIFTLIB_DIR})
else()
set(swift_lib_dir ${SWIFTSTATICLIB_DIR})
endif()

foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config_upper)
escape_path_for_xcode(
"${config}" "${swift_lib_dir}" config_lib_dir)
"${config}" "${SWIFTSTATICLIB_DIR}" config_lib_dir)
set_target_properties(${target_static} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
endforeach()

set_target_properties(${target_static} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${swift_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY ${swift_lib_dir}/${SWIFTLIB_SINGLE_SUBDIR})
LIBRARY_OUTPUT_DIRECTORY ${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}
ARCHIVE_OUTPUT_DIRECTORY ${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR})
endif()

set_target_properties(${target}
Expand Down Expand Up @@ -1354,14 +1347,8 @@ function(_add_swift_library_single target name)
set_property(TARGET "${target_static}" APPEND_STRING PROPERTY
COMPILE_FLAGS " ${c_compile_flags}")
# FIXME: The fallback paths here are going to be dynamic libraries.

if(SWIFTLIB_INSTALL_WITH_SHARED)
set(search_base_dir ${SWIFTLIB_DIR})
else()
set(search_base_dir ${SWIFTSTATICLIB_DIR})
endif()
set(library_search_directories
"${search_base_dir}/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFTSTATICLIB_DIR}/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFTLIB_SINGLE_SUBDIR}"
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}")
swift_target_link_search_directories("${target_static}" "${library_search_directories}")
Expand Down Expand Up @@ -1490,7 +1477,6 @@ endfunction()
# [IS_STDLIB]
# [IS_STDLIB_CORE]
# [TARGET_LIBRARY]
# [INSTALL_WITH_SHARED]
# INSTALL_IN_COMPONENT comp
# DEPLOYMENT_VERSION_OSX version
# DEPLOYMENT_VERSION_IOS version
Expand Down Expand Up @@ -1597,9 +1583,6 @@ endfunction()
# DEPLOYMENT_VERSION_WATCHOS
# The minimum deployment version to build for if this is an WATCHOS library.
#
# INSTALL_WITH_SHARED
# Install a static library target alongside shared libraries
#
# source1 ...
# Sources to add into this library.
function(add_swift_target_library name)
Expand All @@ -1614,8 +1597,7 @@ function(add_swift_target_library name)
OBJECT_LIBRARY
SHARED
STATIC
TARGET_LIBRARY
INSTALL_WITH_SHARED)
TARGET_LIBRARY)
set(SWIFTLIB_single_parameter_options
DEPLOYMENT_VERSION_IOS
DEPLOYMENT_VERSION_OSX
Expand Down Expand Up @@ -1900,7 +1882,6 @@ function(add_swift_target_library name)
${SWIFTLIB_SHARED_keyword}
${SWIFTLIB_STATIC_keyword}
${SWIFTLIB_OBJECT_LIBRARY_keyword}
${SWIFTLIB_INSTALL_WITH_SHARED_keyword}
${SWIFTLIB_SOURCES}
MODULE_TARGET ${MODULE_VARIANT_NAME}
SDK ${sdk}
Expand Down Expand Up @@ -2015,7 +1996,7 @@ function(add_swift_target_library name)
set(resource_dir_sdk_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
precondition(resource_dir_sdk_subdir)

if(SWIFTLIB_SHARED OR SWIFTLIB_INSTALL_WITH_SHARED)
if(SWIFTLIB_SHARED)
set(resource_dir "swift")
set(file_permissions
OWNER_READ OWNER_WRITE OWNER_EXECUTE
Expand Down Expand Up @@ -2077,18 +2058,10 @@ function(add_swift_target_library name)
list(APPEND THIN_INPUT_TARGETS_STATIC "${TARGET}-static")
endforeach()

if(SWIFTLIB_INSTALL_WITH_SHARED)
set(install_subdir "swift")
set(universal_subdir ${SWIFTLIB_DIR})
else()
set(install_subdir "swift_static")
set(universal_subdir ${SWIFTSTATICLIB_DIR})
endif()

set(lipo_target_static
"${name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-static")
set(UNIVERSAL_LIBRARY_NAME
"${universal_subdir}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
"${SWIFTSTATICLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
_add_swift_lipo_target(SDK
${sdk}
TARGET
Expand All @@ -2097,7 +2070,7 @@ function(add_swift_target_library name)
"${UNIVERSAL_LIBRARY_NAME}"
${THIN_INPUT_TARGETS_STATIC})
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${resource_dir_sdk_subdir}"
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
Expand Down
10 changes: 3 additions & 7 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ function(_compile_swift_files
list(APPEND swift_flags "-module-name" "${SWIFTFILE_MODULE_NAME}")
endif()

# Force swift 5 mode for Standard Library and overlays.
# Force swift 5 mode for Standard Library.
if (SWIFTFILE_IS_STDLIB)
list(APPEND swift_flags "-swift-version" "5")
endif()

# Force swift 4 compatibility mode for overlays.
if (SWIFTFILE_IS_SDK_OVERLAY)
list(APPEND swift_flags "-swift-version" "5")
endif()
Expand All @@ -265,12 +267,6 @@ function(_compile_swift_files
list(APPEND swift_flags "-autolink-force-load")
endif()

# Don't need to link runtime compatibility libraries for older runtimes
# into the new runtime.
if (SWIFTFILE_IS_STDLIB OR SWIFTFILE_IS_SDK_OVERLAY)
list(APPEND swift_flags "-runtime-compatibility-version" "none")
endif()

if (SWIFTFILE_IS_STDLIB_CORE OR SWIFTFILE_IS_SDK_OVERLAY)
list(APPEND swift_flags "-warn-swift3-objc-inference-complete")
endif()
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// FIXME: This include is just for llvm::SanitizerCoverageOptions. We should
// split the header upstream so we don't include so much.
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Support/VersionTuple.h"
#include <string>
#include <vector>

Expand Down Expand Up @@ -225,9 +224,6 @@ class IRGenOptions {
};

TypeInfoDumpFilter TypeInfoFilter;

/// Pull in runtime compatibility shim libraries by autolinking.
Optional<llvm::VersionTuple> AutolinkRuntimeCompatibilityLibraryVersion;

IRGenOptions()
: DWARFVersion(2), OutputKind(IRGenOutputKind::LLVMAssembly),
Expand Down
7 changes: 0 additions & 7 deletions include/swift/Basic/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

namespace llvm {
class Triple;
class VersionTuple;
}

namespace swift {
Expand Down Expand Up @@ -86,12 +85,6 @@ namespace swift {
/// The input triple should already be "normalized" in the sense that
/// llvm::Triple::normalize() would not affect it.
llvm::Triple getTargetSpecificModuleTriple(const llvm::Triple &triple);


/// Get the Swift runtime version to deploy back to, given a deployment target expressed as an
/// LLVM target triple.
Optional<llvm::VersionTuple>
getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple);
} // end namespace swift

#endif // SWIFT_BASIC_PLATFORM_H
Expand Down
5 changes: 0 additions & 5 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,4 @@ def vfsoverlay_EQ : Joined<["-"], "vfsoverlay=">,
def runtime_compatibility_version : Separate<["-"], "runtime-compatibility-version">,
Flags<[FrontendOption]>,
HelpText<"Link compatibility library for Swift runtime version, or 'none'">;

def disable_autolinking_runtime_compatibility : Flag<["-"], "disable-autolinking-runtime-compatibility">,
Flags<[FrontendOption]>,
HelpText<"Do not use autolinking for runtime compatibility libraries">;

include "FrontendOptions.td"
35 changes: 0 additions & 35 deletions lib/Basic/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/VersionTuple.h"

using namespace swift;

Expand Down Expand Up @@ -314,37 +313,3 @@ llvm::Triple swift::getTargetSpecificModuleTriple(const llvm::Triple &triple) {
return triple;
}

Optional<llvm::VersionTuple>
swift::getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple){
unsigned Major, Minor, Micro;

if (Triple.isMacOSX()) {
Triple.getMacOSXVersion(Major, Minor, Micro);
if (Major == 10) {
if (Minor <= 14) {
return llvm::VersionTuple(5, 0);
} else {
return None;
}
} else {
return None;
}
} else if (Triple.isiOS()) { // includes tvOS
Triple.getiOSVersion(Major, Minor, Micro);
if (Major <= 12) {
return llvm::VersionTuple(5, 0);
} else {
return None;
}
} else if (Triple.isWatchOS()) {
Triple.getWatchOSVersion(Major, Minor, Micro);
if (Major <= 5) {
return llvm::VersionTuple(5, 0);
} else {
return None;
}
} else {
return None;
}
}

46 changes: 40 additions & 6 deletions lib/Driver/DarwinToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/VersionTuple.h"

using namespace swift;
using namespace swift::driver;
Expand Down Expand Up @@ -222,6 +221,42 @@ static bool wantsObjCRuntime(const llvm::Triple &triple) {
llvm_unreachable("unknown Darwin OS");
}

/// Return the earliest backward deployment compatibility version we need to
/// link in for the given target triple, if any.
static Optional<std::pair<unsigned, unsigned>>
getSwiftRuntimeCompatibilityVersionForTarget(const llvm::Triple &Triple) {
unsigned Major, Minor, Micro;

if (Triple.isMacOSX()) {
Triple.getMacOSXVersion(Major, Minor, Micro);
if (Major == 10) {
if (Minor <= 14) {
return std::make_pair(5u, 0u);
} else {
return None;
}
} else {
return None;
}
} else if (Triple.isiOS()) { // includes tvOS
Triple.getiOSVersion(Major, Minor, Micro);
if (Major <= 12) {
return std::make_pair(5u, 0u);
} else {
return None;
}
} else if (Triple.isWatchOS()) {
Triple.getWatchOSVersion(Major, Minor, Micro);
if (Major <= 5) {
return std::make_pair(5u, 0u);
} else {
return None;
}
} else {
return None;
}
}

ToolChain::InvocationInfo
toolchains::Darwin::constructInvocation(const LinkJobAction &job,
const JobContext &context) const
Expand Down Expand Up @@ -396,13 +431,12 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,

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

if (context.Args.hasArg(options::OPT_runtime_compatibility_version)) {
auto value = context.Args.getLastArgValue(
options::OPT_runtime_compatibility_version);
auto value = context.Args.getLastArgValue(options::OPT_runtime_compatibility_version);
if (value.equals("5.0")) {
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
runtimeCompatibilityVersion = std::make_pair(5u, 0u);
} else if (value.equals("none")) {
runtimeCompatibilityVersion = None;
} else {
Expand All @@ -414,7 +448,7 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
}

if (runtimeCompatibilityVersion) {
if (*runtimeCompatibilityVersion <= llvm::VersionTuple(5, 0)) {
if (*runtimeCompatibilityVersion <= std::make_pair(5u, 0u)) {
// Swift 5.0 compatibility library
SmallString<128> BackDeployLib;
BackDeployLib.append(RuntimeLibPath);
Expand Down
11 changes: 0 additions & 11 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,17 +433,6 @@ ToolChain::constructInvocation(const CompileJobAction &job,
Arguments.push_back("-debug-info-store-invocation");
}

if (context.Args.hasArg(
options::OPT_disable_autolinking_runtime_compatibility)) {
Arguments.push_back("-disable-autolinking-runtime-compatibility");
}

if (auto arg = context.Args.getLastArg(
options::OPT_runtime_compatibility_version)) {
Arguments.push_back("-runtime-compatibility-version");
Arguments.push_back(arg->getValue());
}

return II;
}

Expand Down
24 changes: 0 additions & 24 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,30 +1155,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
A->getAsString(Args), A->getValue());
}
}

// Autolink runtime compatibility libraries, if asked to.
if (!Args.hasArg(options::OPT_disable_autolinking_runtime_compatibility)) {
Optional<llvm::VersionTuple> runtimeCompatibilityVersion;

if (auto versionArg = Args.getLastArg(
options::OPT_runtime_compatibility_version)) {
auto version = StringRef(versionArg->getValue());
if (version.equals("none")) {
runtimeCompatibilityVersion = None;
} else if (version.equals("5.0")) {
runtimeCompatibilityVersion = llvm::VersionTuple(5, 0);
} else {
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
versionArg->getAsString(Args), version);
}
} else {
runtimeCompatibilityVersion =
getSwiftRuntimeCompatibilityVersionForTarget(Triple);
}

Opts.AutolinkRuntimeCompatibilityLibraryVersion =
runtimeCompatibilityVersion;
}

return false;
}
Expand Down
Loading