-
Notifications
You must be signed in to change notification settings - Fork 10.5k
stdlib: Add backward deployment versions for the dynamic-replacement runtime functions #25473
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
Changes from all commits
5003c15
f29b77f
eb32194
6f9c50c
da2d418
5d32946
d76c814
906f0b4
05a6299
443719d
a9c83e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -638,7 +638,7 @@ FUNCTION(GetGenericMetadata, swift_getGenericMetadata, | |
// const OpaqueTypeDescriptor *descriptor, | ||
// uintptr_t index); | ||
FUNCTION(GetOpaqueTypeMetadata, swift_getOpaqueTypeMetadata, | ||
SwiftCC, OpaqueTypeAvailability, | ||
SwiftCC, ConditionallyAvailable, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These all still need to call a function to return the availability appropriate for the current deployment target. There will be runtime entry points in the future that are available on a different set of OSes from Swift 5.1, so we shouldn't hardcode that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what conditionally available means? The code in getRuntimeFn() queries whether the feature is available based on whether something is AlwaysAvailable| ConditionallyAvailable | AvailableByCompatibilityLibrary:
In the future we can extend this by adding another entry to runtime.def that specifies at which swift version things became available ...
And then generate the availability based on that.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An entry point is only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will address this in a follow-up patch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attempt of follow-up here: #25573 |
||
RETURNS(TypeMetadataResponseTy), | ||
ARGS(SizeTy, Int8PtrTy, OpaqueTypeDescriptorPtrTy, SizeTy), | ||
ATTRS(NoUnwind, ReadOnly)) | ||
|
@@ -647,7 +647,7 @@ FUNCTION(GetOpaqueTypeMetadata, swift_getOpaqueTypeMetadata, | |
// const OpaqueTypeDescriptor *descriptor, | ||
// uintptr_t index); | ||
FUNCTION(GetOpaqueTypeConformance, swift_getOpaqueTypeConformance, | ||
SwiftCC, OpaqueTypeAvailability, | ||
SwiftCC, ConditionallyAvailable, | ||
RETURNS(WitnessTablePtrTy), | ||
ARGS(Int8PtrTy, OpaqueTypeDescriptorPtrTy, SizeTy), | ||
ATTRS(NoUnwind, ReadOnly)) | ||
|
@@ -1225,12 +1225,14 @@ FUNCTION(EndAccess, swift_endAccess, C_CC, AlwaysAvailable, | |
ARGS(getFixedBufferTy()->getPointerTo()), | ||
ATTRS(NoUnwind)) | ||
|
||
FUNCTION(GetOrigOfReplaceable, swift_getOrigOfReplaceable, C_CC, AlwaysAvailable, | ||
FUNCTION(GetOrigOfReplaceable, swift_getOrigOfReplaceable, C_CC, | ||
AvailableByCompatibilityLibrary, | ||
RETURNS(FunctionPtrTy), | ||
ARGS(FunctionPtrTy->getPointerTo()), | ||
ATTRS(NoUnwind)) | ||
|
||
FUNCTION(GetReplacement, swift_getFunctionReplacement, C_CC, AlwaysAvailable, | ||
FUNCTION(GetReplacement, swift_getFunctionReplacement, C_CC, | ||
AvailableByCompatibilityLibrary, | ||
RETURNS(FunctionPtrTy), | ||
ARGS(FunctionPtrTy->getPointerTo(), FunctionPtrTy), | ||
ATTRS(NoUnwind)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,6 +427,22 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job, | |
} | ||
} | ||
|
||
if (job.getKind() == LinkKind::Executable) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Er, you don't need this part anymore, right? And you never wanted it to just be Executables-linked-with-swiftc anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still ultimately want this to only be linked into executables. We were going to handle that as a followup. For these specific backfill entry points, they're small enough that burning them into dylibs and having potentially-mismatching versions in different images is probably OK, but that's not generally a situation we want to be in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand that part. We can't rely on executables having any Swift in them, and it's unlikely that Xcode will switch to linking with swiftc anyway. The autolinking part for dynamic replacement isn't going away. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I do want a resolution for this because it's interfering with me rebasing #24787.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's any Swift in the process, then the executable is the only useful place to put backward-compatibility fills, so much like arclite, we might want eventually for Xcode to link this in unconditionally because a non-Swift executable could be using dylibs with Swift in them. |
||
if (runtimeCompatibilityVersion) | ||
if (*runtimeCompatibilityVersion <= llvm::VersionTuple(5, 0)) { | ||
// Swift 5.0 dynamic replacement compatibility library. | ||
SmallString<128> BackDeployLib; | ||
BackDeployLib.append(RuntimeLibPath); | ||
llvm::sys::path::append(BackDeployLib, | ||
"libswiftCompatibilityDynamicReplacements.a"); | ||
|
||
if (llvm::sys::fs::exists(BackDeployLib)) { | ||
Arguments.push_back("-force_load"); | ||
Arguments.push_back(context.Args.MakeArgString(BackDeployLib)); | ||
} | ||
} | ||
} | ||
|
||
// Link the standard library. | ||
Arguments.push_back("-L"); | ||
if (context.Args.hasFlag(options::OPT_static_stdlib, | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will export these symbols as a weak definition, which is probably not what you want (and very bad for load time performance). Did you mean
__attribute__((weak_import))
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Will fix.