Skip to content

Assorted fixes for runtime metadata mangling and demangling #78729

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

Conversation

rjmccall
Copy link
Contributor

Primarily, teach the compiler to not use the runtime demangler to produce @MainActor (...) -> sending T and similar type metadata unless the deployment includes the bug fix in Swift 6.1. But I've also fixed the metadata-to-demangling-tree walk to preserve the @isolated(any) bit, and I've removed some code that was duplicating the information in RuntimeVersions.def and implicitly making aggressive assumptions about future OS releases.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from 15c164d to 27e40a6 Compare January 18, 2025 06:50
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from 27e40a6 to c564bd4 Compare January 18, 2025 07:19
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

2 similar comments
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@AnthonyLatsis
Copy link
Collaborator

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from c564bd4 to cfc7ff7 Compare January 21, 2025 08:07
@rjmccall rjmccall requested a review from jckarter as a code owner January 21, 2025 08:07
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from cfc7ff7 to 10bce2a Compare January 21, 2025 17:49
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from 10bce2a to cefbff3 Compare January 21, 2025 23:20
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from b4f5647 to 2818875 Compare January 23, 2025 02:52
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

RuntimeVersions.def.

This really *ought* to be NFC, but alas, there are two behavior changes.
The first is that arbitrary future versions (short of the special future
version of 99.99) used to be considered to be free of all deployment
issues, but are now just considered to offer the Swift release that's
attached to the last known release of the target platform. The old behavior
was fine in a sense: deployment issues require updating the compiler anyway,
so if you haven't taught the compiler that iOS 31 provides Swift 8.3, you
probably also haven't taught it about any problems that are fixed in
Swift 8.3. The only problem with this logic is that we often implement
compiler fixes for these deployment issues before that first OS actually
ships (and thus before we've settled on a release number), and so we end
up with a race where we start considering new releases to fix the issue
even without updating the release mapping. The new approach fixes this:
we say that the bug will be fixed in Swift 8.3, and for the time being,
there are simply no platforms that provide that fix yet. Later, we update
the mapping to say that iOS 31 provides it, and compilations targeting that
release will be able to take advantage.

The other issue is that we actually treated "future" releases of macOS 10.x
(starting with 10.16, which ended up being 11.0) the same way, instead of
treating them logically as intermediate between 10.15 and 11.0.

My initial attempt at this generation used a constexpr array of a struct
with a std::initializer_list of platform releases, exactly mirroring the
structure of the .def file and requiring the compiler to parse out the
bits relevant to the target dynamically. The approach I ended up with is
much better, but I was actually forced into it because MSVC miscompiled
those global "temporary" arrays --- they ended up uninitialized.
with sending results:

- The sending result mangling was added in the 6.0 runtime, so demangling
  cannot be used to produce this metadata when targeting an earlier
  runtime.

- The combination of a sending result with isolation requires the 6.1
  runtime to successfully demangle, due to a bug in the 6.0 demangler.
instead of the notional 10.24, which the old logic in Platform.cpp
accidentally treated as a future release with no runtime restrictions.
@rjmccall rjmccall force-pushed the isolated-sending-results-compiler-fix branch from 2818875 to a4853f8 Compare January 23, 2025 07:25
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall
Copy link
Contributor Author

@swift-ci Please test macOS

@rjmccall
Copy link
Contributor Author

@swift-ci Please test Linux

@rjmccall rjmccall merged commit 95dca81 into swiftlang:main Jan 24, 2025
5 checks passed
@rjmccall rjmccall deleted the isolated-sending-results-compiler-fix branch January 24, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants