Skip to content

Library Evolution for Stable ABIs #1025

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 11 commits into from
May 7, 2019
Merged

Library Evolution for Stable ABIs #1025

merged 11 commits into from
May 7, 2019

Conversation

airspeedswift
Copy link
Member

No description provided.

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Structural and typo comments only. Regular review comments will go to the forums as usual.

Copy link
Contributor

@NevinBR NevinBR left a comment

Choose a reason for hiding this comment

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

A few typos


- The struct is *ABI-public* (see [SE-0193][]), i.e. `public` or marked `@usableFromInline`.
- Every class, enum, struct, protocol, or typealias mentioned in the types of the struct's fields is ABI-public.
- No fields have observing accessors (`willSet` or `didSet`).
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the forum is the best place to discuss this but I feel like this restriction is somewhat arbitrary and doesn’t buy us much.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Thank you for taking this on.


When a library is compiled with library evolution mode enabled, it is not an ABI-breaking change to modify the fields in a struct (to add, remove, or reorder them), and to add new enum cases (including with associated values). This implies that clients must manipulate fields and enum cases indirectly, via non-inlinable function calls. Information such as the size of the type, and the layout of its fields, becomes something that can only be determined at runtime. Types that reserve this flexibility are referred to as "resilient types".

A new `@frozen` keyword will be introduced to allow library authors to opt out of this flexibility on a per-type basis. This keyword promises that stored instance properties within the struct will not be *added,* *removed,* or *reordered*, and that an enum will never *add,* *remove,* or *reorder* its cases (note removing, and sometimes reordering, cases can already be source breaking, not just ABI breaking). The compiler will use this for optimization purposes when compiling clients of the type. The precise set of allowed changes is defined below.

Choose a reason for hiding this comment

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

@frozen an attribute, not a keyword, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes! thanks.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, as an implicit contrast with the column to the left?

Yes. There are some things that affect the ABI even without frozen, which aren't bolded.

I think it might be better to be stronger about this than "Affects".

Yeah, I guess "Not Allowed". The question would be, not allowed by whom, given the compiler isn't going to stop you. @jrose-apple do you have an opinion?

Copy link
Contributor

@rjmccall rjmccall May 7, 2019

Choose a reason for hiding this comment

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

(Somehow this ended up attached to the wrong comment)

"Not allowed" works for me. "Allowed" has the same actorship problem. :)

| Changing a computed instance property to stored | Allowed | **Affects ABI**
| Changing the access of a non-ABI-public field | Allowed | Allowed
| Marking an `internal` field as `@usableFromInline` | Allowed | Allowed
| Changing an `internal` ABI-public field to be `public` | Allowed | Allowed
Copy link
Contributor

Choose a reason for hiding this comment

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

What's with the inconsistent bolding?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bold indicates inconsistency between frozen and unfrozen.

Copy link
Contributor

@rjmccall rjmccall May 7, 2019

Choose a reason for hiding this comment

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

Okay, as an implicit contrast with the column to the left?

I think it might be better to be stronger about this than "Affects".


## Naming

`@frozen` was used here, as originally used in [SE-0192][], for both fixed-layout structs and enums.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fill in these links and make any other editorial changes you intend to make before this goes up.

Copy link
Member Author

Choose a reason for hiding this comment

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

The link's there, it's (implicit) reference style markdown link. Renders correctly in GitHub.

* Authors: [Jordan Rose](https://github.com/jrose-apple), [Ben Cohen](https://github.com/airspeedswift)
* Review Manager: TBD
* Status: **Awaiting review**
* Implementation: Implemented in Swift 5 for standard library use
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you whip up an implementation PR that actually uses the command-line and attribute spelling you're proposing?

Copy link
Member Author

@airspeedswift airspeedswift May 7, 2019

Choose a reason for hiding this comment

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

PR here, but it's far easier to use the shipping toolchain to try it out with the underscores than one generated from that PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

PR where?

Copy link
Member Author

Choose a reason for hiding this comment

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

Link added.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see it, thanks.

@rjmccall rjmccall merged commit b30121e into swiftlang:master May 7, 2019
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.

6 participants