Files
swift-mirror/stdlib/toolchain/Compatibility51/Overrides.cpp
Joe Groff ca48939816 Compatibility51: Backport the 5.2 implementation of the conformance cache.
The runtime that shipped with Swift 5.1 and earlier had a bug that interfered with backward
deployment of binaries that dynamically check for protocol conformances on conditionally-available
tests. This was fixed in the top-of-tree Swift runtime by https://github.com/apple/swift/pull/29887;
however, that doesn't do much good for running binaries on older OSes that don't have that fix.
In order for binaries built with a newer Swift compiler to run successfully on older OSes,
introduce a compatibility hook that replaces the conformance cache implementation in the original
OS runtime with a version based on the current implementation that has the fix for the protocol
conformance bug. Fixes rdar://problem/59460603
2020-04-24 10:52:29 -07:00

43 lines
1.4 KiB
C++

//===--- Overrides.cpp - Compat override table for Swift 5.1 runtime ------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file provides compatibility override hooks for Swift 5.1 runtimes.
//
//===----------------------------------------------------------------------===//
#include "../../public/runtime/CompatibilityOverride.h"
#include "Overrides.h"
#include <dlfcn.h>
#include <mach-o/dyld.h>
#include <mach-o/getsect.h>
using namespace swift;
struct OverrideSection {
uintptr_t version;
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
Override_ ## name name;
#include "../../public/runtime/CompatibilityOverride.def"
};
OverrideSection Swift51Overrides
__attribute__((used, section("__DATA,__swift51_hooks"))) = {
.version = 0,
.conformsToSwiftProtocol = swift51override_conformsToSwiftProtocol,
};
// Allow this library to get force-loaded by autolinking
__attribute__((weak, visibility("hidden")))
extern "C"
char _swift_FORCE_LOAD_$_swiftCompatibility51 = 0;