Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

default to -fvisibility=hidden #898

Closed

Description

@jfirebaugh

Expose symbols only for the public API.

From @springmeyer:

one gocha is that -fvisibility=hidden interacts in interesting ways with -flto. I've gotten mapnik working with both combined but it required some careful usage of __attribute__ ((visibility ("default"))) and extern template

Refs #759.

Activity

  1. ljbade commented on Feb 18, 2015

    @ljbade
    Contributor

    I did not realise you needed this flag Linux/OSX. I know on Windows the default is to only expose specifically marked symbols from shared lib.

  2. mikemorris commented on Oct 15, 2015

    @mikemorris
    Contributor
  3. mikemorris commented on Oct 15, 2015

    @mikemorris
    Contributor

    Made a preliminary attempt at setting this up in 898-visibility-hidden, seeing the following two linker warnings from Boost when running make run-osx that I'm attributing to the cross-lib exceptions issue with hidden symbols, but trying to track this down I can't find anywhere that we're using boost::throw_exception or boost::exception_detail?

    ld: warning: direct access in void boost::throw_exception<boost::bad_function_call>(boost::bad_function_call const&) to global weak symbol typeinfo for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> > means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
    ld: warning: direct access in boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> >::rethrow() const to global weak symbol typeinfo for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::bad_function_call> > means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
    
  4. mikemorris commented on Oct 15, 2015

    @mikemorris
    Contributor

    ^ Uh, my branch unexpectedly passed CI when I assumed it wouldn't. Anyone want to review and see if it's actually doing what I think it is? I'm assuming that we'll still need to explicitly set symbol visibility for the public API to actually USE the library in an app? Or is this somehow taken care of through the platform bindings?

  5. mikemorris commented on Oct 15, 2015

    @mikemorris
    Contributor

    Rebasing geojsonvt-2.1.6-rapidjson onto this branch doesn't solve the linker warnings during iOS tests - is visibility not actually set correctly here, or could the issue be that mason packages (like GeoJSONVT) are only built with -fvisibility-inlines-hidden?

  6. mikemorris commented on Nov 4, 2015

    @mikemorris
    Contributor

    Halfway there as of #2584 with -fvisibility-inlines-hidden

  7. removed their assignment
    on Nov 4, 2015
  8. self-assigned this
    on Nov 18, 2015
  9. mikemorris commented on Nov 19, 2015

    @mikemorris
    Contributor

    Started work on this again today in 898-visibility-hidden in light of needs for smaller binaries on Android and iOS.

  10. mikemorris commented on Nov 19, 2015

    @mikemorris
    Contributor

    Not seeing any reduction in iOS binary size from this yet, possible because we're still building a static library? Might need to revisit #828

  11. zugaldia commented on Nov 20, 2015

    @zugaldia
    Member

    FWIW I just did a make android for both master and https://github.com/mapbox/mapbox-gl-native/tree/898-visibility-hidden and these are the results size-wise:

    $ ls -l build/android-arm-v7/Release/lib.target/libmapbox-gl.so
    Master: 91307852 Nov 20 15:46 build/android-arm-v7/Release/lib.target/libmapbox-gl.so
    Branch: 90523492 Nov 20 15:46 build/android-arm-v7/Release/lib.target/libmapbox-gl.so
    

    I see a smaller size (784,360 bytes less) or is there a better way to measure this impact?

  12. jfirebaugh commented on Jul 15, 2016

    @jfirebaugh
    ContributorAuthor

    Done for Android in #5656.

  13. removed their assignment
    on Oct 19, 2016
  14. kkaefer commented on Jan 4, 2017

    @kkaefer
    Member

    macOS PR in #7509

  15. kkaefer commented on Jan 5, 2017

    @kkaefer
    Member

    iOS is in #7604

  16. added
    performance
    on Feb 22, 2017
  17. added
    Core
    on May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Corebuildperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions