Skip to content

IRGen: Work around RemoteMirror bug generating reflection info for empty builtin types.#29037

Merged
jckarter merged 1 commit into
masterfrom
zero-builtin-type-descriptor-workaround
Jan 7, 2020
Merged

IRGen: Work around RemoteMirror bug generating reflection info for empty builtin types.#29037
jckarter merged 1 commit into
masterfrom
zero-builtin-type-descriptor-workaround

Conversation

@jckarter
Copy link
Copy Markdown
Contributor

@jckarter jckarter commented Jan 7, 2020

The RemoteMirror library in shipping versions of macOS/iOS/tvOS/watchOS crashes if the compiler
emits a BuiltinTypeDescriptor with size zero. Although this is fixed in top-of-tree RemoteMirror,
we want binaries built with the new compiler to still be inspectable when run on older OSes.
Generate the metadata as an empty struct with no fields when deploying back to these older
platforms, which should be functionally equivalent for most purposes.
Fixes rdar://problem/57924984.

…pty builtin types.

The RemoteMirror library in shipping versions of macOS/iOS/tvOS/watchOS crashes if the compiler
emits a BuiltinTypeDescriptor with size zero. Although this is fixed in top-of-tree RemoteMirror,
we want binaries built with the new compiler to still be inspectable when run on older OSes.
Generate the metadata as an empty struct with no fields when deploying back to these older
platforms, which should be functionally equivalent for most purposes.
Fixes rdar://problem/57924984.
@jckarter
Copy link
Copy Markdown
Contributor Author

jckarter commented Jan 7, 2020

@swift-ci Please test

@mikeash
Copy link
Copy Markdown
Contributor

mikeash commented Jan 7, 2020

@tbkka


import EmptyStruct

@_alignment(1) struct EmptyStruct { }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you declaring the alignment here?

Copy link
Copy Markdown
Contributor Author

@jckarter jckarter Jan 7, 2020

Choose a reason for hiding this comment

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

The compiler always generates BuiltinTypeDescriptors for types with declared alignment (because the normal layout algorithm would mis-align them), so this is just to exercise that code path. An empty type should not be able to affect the layout of its enclosing aggregate regardless of its supposed alignment, so it should be OK to fall back to an empty struct layout.

@jckarter jckarter merged commit 6e7521a into master Jan 7, 2020
@jckarter jckarter deleted the zero-builtin-type-descriptor-workaround branch January 7, 2020 19:12
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.

3 participants