Skip to content

[Frontend][AST][IRGen] Improve availability support. #71213

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 4 commits into from
Feb 2, 2024

Conversation

al45tair
Copy link
Contributor

Use .def files to generate code for feature availability and runtime version to OS version mappings.

Also add a min-runtime-version option that can be used to avoid problems when building on Linux and Windows where because the runtime isn't part of the OS, availability doesn't solve the problem of trying to build the compiler against an older runtime.

Added some functions to IRGen to help with that problem; essentially we test both the deployment target availability and the new runtime version based availability.

rdar://121522431

@al45tair al45tair force-pushed the eng/PR-121522431 branch 2 times, most recently from 4179e56 to 1e8622a Compare February 1, 2024 15:55
@al45tair
Copy link
Contributor Author

al45tair commented Feb 1, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

Just to explain the motivation for this, I want to make a change to how the C++ interop exception handling support works, such that we get backtraces from the site of the C++ throw rather than the generated catch site; see #71056 for that work. Doing that, however, risks build problems on Linux because Linux (and other non-Darwin platforms) can't use the minimum OS version from the availability system as a proxy for the runtime version they're using, hence the need for the -min-runtime-version flag (which is only intended for use within the compiler build itself).

@al45tair al45tair marked this pull request as ready for review February 2, 2024 13:12
@al45tair al45tair requested review from aschwaighofer, eeckstein and mikeash and removed request for xedin, slavapestov, hborla, eeckstein and tshortli February 2, 2024 13:12
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, I like this!

Do I understand correctly that this PR contains of two separate features:

  1. the new mechanism in the compiler for availability checking
  2. passing the runtime version via build-script when building the compiler

(maybe worth splitting in two commits)

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those .def files make everything so much nicer now.

@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

Do I understand correctly that this PR contains of two separate features:

  1. the new mechanism in the compiler for availability checking
  2. passing the runtime version via build-script when building the compiler

Yes. I suppose there are logically three pieces:

  1. The new .def-file based availability stuff.
  2. The -min-runtime-version compiler flag (plus the new functions in IRGen that are enabled by (1) that check it).
  3. The use of (2) in the SwiftCompilerSources CMakeLists.txt.

I guess I could split it into three commits maybe to cover those?

Use `.def` files to generate code for feature availability and runtime
version to OS version mappings.

rdar://121522431
Add a `-min-runtime-version` option that can be used to avoid problems
when building on Linux and Windows where because the runtime isn't
part of the OS, availability doesn't solve the problem of trying to
build the compiler against an older runtime.

Also add functions to IRGen to make it easy to test feature
availability using both the runtime version and the existing Darwin
availability support.

rdar://121522431
Turn on the use of `-min-runtime-version` when building the compiler.

rdar://121522431
@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

OK, I've broken it up into three separate commits.

@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

@swift-ci Please smoke test

@al45tair al45tair requested a review from xedin February 2, 2024 17:11
@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

I've also just realised that I somehow accidentally removed the code owners from the review list. I don't believe I did that myself, mind — it happened when I promoted this PR from a draft. Given that I'm tinkering with the availability code here, it's worth anyone interested taking a glance.

Copy link
Contributor

@tshortli tshortli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this seems like a big improvement.

This was just updated in swiftlang#71297.

rdar://121522431
@al45tair
Copy link
Contributor Author

al45tair commented Feb 2, 2024

@swift-ci Please smoke test

@al45tair al45tair merged commit 4c7822c into swiftlang:main Feb 2, 2024
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.

4 participants