-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add HIDE_SYMBOLS_BY_DEFAULT option #196
Add HIDE_SYMBOLS_BY_DEFAULT option #196
Conversation
Add cmake option to IgnSetCompilerFlags that will hide symbols by default if they are not explicitly specified as visible. This option is disabled by default to match the current behavior of ign-cmake. Signed-off-by: Steve Peters <[email protected]>
cmake/IgnSetCompilerFlags.cmake
Outdated
ign_filter_valid_compiler_options( | ||
CUSTOM_ALL_FLAGS | ||
-Wall -Wextra -Wno-long-long -Wno-unused-value -Wfloat-equal | ||
-Wshadow -Winit-self -Wswitch-default -Wmissing-include-dirs -pedantic | ||
-fvisibility) | ||
${VISIBILITY_FLAG}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmake has a visibility property https://cmake.org/cmake/help/v3.16/prop_tgt/LANG_VISIBILITY_PRESET.html, is there a way to make use of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call!
should we also set VISIBILITY_INLINES_HIDDEN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are now setting CMAKE_C_VISIBILITY_PRESET
and CMAKE_CXX_VISIBILITY_PRESET
as of fd38458
cmake/IgnSetCompilerFlags.cmake
Outdated
@@ -115,11 +115,18 @@ endmacro() | |||
# Set up compilation flags for GCC or Clang | |||
macro(ign_setup_gcc_or_clang) | |||
|
|||
option(USE_DEFAULT_VISIBILITY_HIDDEN "Hide symbols by default if they are not explicitly specified as visible" FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this on by default in the next major version. I think many of other ignition packages also assume it's hidden by default, since they are using _VISIBLE
macros instead of _HIDDEN
macros.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I don't think we should close #166 until it becomes the default.
Add parameter to ign_configure_build that is used to set CMAKE_C_VISIBILITY_PRESET and CMAKE_CXX_VISIBILITY_PRESET. Signed-off-by: Steve Peters <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! I've used abidiff
to compared the shared libraries of ign-math and sdformat created before and after this PR and they were no differences.
cmake/IgnSetCompilerFlags.cmake
Outdated
@@ -115,11 +115,18 @@ endmacro() | |||
# Set up compilation flags for GCC or Clang | |||
macro(ign_setup_gcc_or_clang) | |||
|
|||
option(USE_DEFAULT_VISIBILITY_HIDDEN "Hide symbols by default if they are not explicitly specified as visible" FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I don't think we should close #166 until it becomes the default.
Signed-off-by: Steve Peters <[email protected]>
This pull request has been mentioned on Gazebo Community. There might be relevant details there: https://community.gazebosim.org/t/new-ignition-releases-2022-01-10/1228/1 |
Add HIDE_SYMBOLS_BY_DEFAULT parameter to ign_configure_build that will hide symbols by default if they are not explicitly specified as visible. This parameter is used to set CMAKE_C_VISIBILITY_PRESET and CMAKE_CXX_VISIBILITY_PRESET. Signed-off-by: Steve Peters <[email protected]>
🎉 New feature
Closes #166
Summary
Add cmake option to
IgnSetCompilerFlags
that will hide symbols by default if they are not explicitly specified as visible. This option is disabled by default to match the current behavior of ign-cmake.Test it
The option is used in gazebosim/sdformat@3a37dc8 from gazebosim/sdformat#780. To confirm that it works, remove some of the
target_sources
cmake calls added in gazebosim/sdformat@3a37dc8 and observe the linking errors.Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge