Skip to content
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

[objc] Use references to Obj C classes instead of names in descriptors. #7026

Merged
merged 1 commit into from Jan 15, 2020

Conversation

dmaclach
Copy link
Contributor

@dmaclach dmaclach commented Dec 18, 2019

This switches the compiler and library to use objective-c class references instead of class names (that are resolved using objc_getClass/NSClassFromString).

This should:

  1. Reduce binary size slightly as we no longer need the strings.
  2. Add a small performance improvement as we no longer need to look up classes.
  3. Help enforce proper linkage by having actual class references for the linker to resolve. In cases where we are linking static archives there were cases where some of the Objective-C classes were not being pulled into the linkage requiring the use of the -ObjC linker flag (or other linker tricks). There are some other places in the code that we need to do this to get full coverage, but this is a good start.

Copy link
Contributor Author

@dmaclach dmaclach left a comment

Choose a reason for hiding this comment

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

PTAL

objectivec/GPBDescriptor.m Outdated Show resolved Hide resolved
objectivec/GPBDescriptor_PackagePrivate.h Outdated Show resolved Hide resolved
objectivec/google/protobuf/Type.pbobjc.m Outdated Show resolved Hide resolved
src/google/protobuf/compiler/objectivec/objectivec_file.cc Outdated Show resolved Hide resolved
Copy link
Contributor Author

@dmaclach dmaclach left a comment

Choose a reason for hiding this comment

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

Merged in the changes for extensions that I had previously promised would be a separate CL. It seems to make sense to have one CL for this. It's a little larger, but keeps all the changes together if/when things break :)

objectivec/GPBDescriptor.m Show resolved Hide resolved
objectivec/google/protobuf/Duration.pbobjc.m Show resolved Hide resolved
Copy link
Contributor

@thomasvl thomasvl left a comment

Choose a reason for hiding this comment

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

Looks like use of asm is going to cause problem, see google/google-api-objectivec-client-for-rest#322 where this just came up.

@dmaclach
Copy link
Contributor Author

Looks like use of asm is going to cause problem, see google/google-api-objectivec-client-for-rest#322 where this just came up.

Check out latest patch. It should clear bitcode validation now as we are not declaring any new identifiers.

…y name.

This should reduce binary size slightly, small performance improvement, and improve linkage by forcing references to all used classes.

Note that this maintains backwards compatibility for sources generated by older protoc for the time being. If you want the benefits
you will need to recompile your protos with the newer protoc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants