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

[PLAT-8737] Use __attribute__((objc_direct_members)) #1479

Merged
merged 2 commits into from
Sep 13, 2022

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Sep 12, 2022

Goal

Reduce binary code size.

Design

Use __attribute__((objc_direct_members)) on private @interfaces and @implementations to cause their methods to have no associated Objective-C metadata and use C function calling convention.

For information about this attribute, see

Changeset

Adds BSG_OBJC_DIRECT_MEMBERS macro to BSGDefines.h.

Applies BSG_OBJC_DIRECT_MEMBERS to private @interfaces and @implementations not delared in the public headers or BugsnagInternals.h.

Testing

Tested via existing unit and E2E tests.

Use of __attribute__((objc_direct_members)) is disabled when building for testing to allow linking to private methods - direct methods have enforced hidden visibility and hence unreachable cross image.

@github-actions
Copy link

Bugsnag.framework binary size decreased by 54,504 bytes from 757,680 to 703,176 🎉

    FILE SIZE        VM SIZE    
 --------------  -------------- 
 -36.3% -4.97Ki  +264% +11.0Ki    [__DATA]
  +6.1% +1.55Ki  +6.1% +1.55Ki    [__TEXT]
  -0.6%     -12  -0.6%     -12    __TEXT,__stub_helper
  -0.6%     -12  -0.6%     -12    __TEXT,__stubs
  -0.5%     -21  -0.5%     -21    [3 Others]
  -0.2%     -32  -0.2%     -32    __DATA,__cfstring
  -0.9%     -40  -0.9%     -40    Lazy Binding Info
  -0.3%     -56  -0.3%     -56    __TEXT,__cstring
  -5.3%     -64  -5.3%     -64    Export Info
  -3.9%     -72  -3.9%     -72    Rebase Info
  -3.4%    -104  -3.4%    -104    __TEXT,__unwind_info
  -7.9%    -136  -7.9%    -136    Function Start Addresses
  -5.3%    -172  -5.3%    -172    __TEXT,__gcc_except_tab
 -15.5%    -377 -15.5%    -377    __TEXT,__objc_methtype
 -29.4% -1.88Ki -29.4% -1.88Ki    __DATA,__objc_selrefs
 -30.2% -7.70Ki -30.2% -7.70Ki    __TEXT,__objc_methname
 -20.1% -9.11Ki -20.1% -9.11Ki    __DATA,__objc_const
  -3.9% -9.12Ki  -3.9% -9.12Ki    __TEXT,__text
  -7.9% -10.4Ki  -7.9% -10.4Ki    Symbol Table
  -6.4% -10.5Ki  -6.4% -10.5Ki    String Table
  [ = ]       0 -89.2% -10.8Ki    [__LINKEDIT]
  -7.2% -53.2Ki  -6.4% -48.0Ki    TOTAL

Generated by 🚫 Danger

@nickdowell nickdowell merged commit 8d7d490 into next Sep 13, 2022
@nickdowell nickdowell deleted the nickdowell/objc-direct-members branch September 13, 2022 10:21
@nickdowell nickdowell mentioned this pull request Sep 14, 2022
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.

2 participants