-
Notifications
You must be signed in to change notification settings - Fork 484
Set symbol visibility to hidden for rclcpp #638
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Copyright 2019 Open Source Robotics Foundation, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # Configures ros client library with custom settings. | ||
| # The custom settings are all related to library symbol visibility, see: | ||
| # https://gcc.gnu.org/wiki/Visibility | ||
| # http://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/ | ||
| # | ||
| # Below code is heavily referenced from a similar functionality in rmw: | ||
| # https://github.com/ros2/rmw/blob/master/rmw/cmake/configure_rmw_library.cmake | ||
| # | ||
| # :param library_target: the library target | ||
| # :type library_target: string | ||
| # :param LANGUAGE: Optional flag for the language of the library. | ||
| # Allowed values are "C" and "CXX". The default is "CXX". | ||
| # :type LANGUAGE: string | ||
| # | ||
| # @public | ||
| # | ||
| macro(configure_rclcpp library_target) | ||
| cmake_parse_arguments(_ARG "" "LANGUAGE" "" ${ARGN}) | ||
| if(_ARG_UNPARSED_ARGUMENTS) | ||
| message(FATAL_ERROR "configure_rclcpp() called with unused arguments: ${_ARG_UNPARSED_ARGUMENTS}") | ||
| endif() | ||
|
|
||
| if(NOT _ARG_LANGUAGE) | ||
| set(_ARG_LANGUAGE "CXX") | ||
| endif() | ||
|
|
||
| if(_ARG_LANGUAGE STREQUAL "C") | ||
| # Set the visibility to hidden by default if possible | ||
| if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") | ||
| # Set the visibility of symbols to hidden by default for gcc and clang | ||
| # (this is already the default on Windows) | ||
| set_target_properties(${library_target} | ||
| PROPERTIES | ||
| COMPILE_FLAGS "-fvisibility=hidden" | ||
| ) | ||
| endif() | ||
|
|
||
| elseif(_ARG_LANGUAGE STREQUAL "CXX") | ||
| # Set the visibility to hidden by default if possible | ||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| # Set the visibility of symbols to hidden by default for gcc and clang | ||
| # (this is already the default on Windows) | ||
| set_target_properties(${library_target} | ||
| PROPERTIES | ||
| COMPILE_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden" | ||
| ) | ||
| endif() | ||
|
|
||
| else() | ||
| message(FATAL_ERROR "configure_rclcpp() called with unsupported LANGUAGE: '${_ARG_LANGUAGE}'") | ||
| endif() | ||
| endmacro() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you explain why? We explicitly avoided this, choosing to make each method public manually. We've had issues making these public on Windows due to the std data structures which are private members of the class.
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.
Here's a sample error I ran into while running rclcpp package with visibility set to hidden. Is there any other way to handle this instead of making the class visible?
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 adding it to the class may be required, but you need to test it on Windows too, because I think it might be in conflict.
If you do leave the public in the class declaration, then the
RCLCPP_PUBLICfor each method in the class is redundant and should be removed.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 removed all the inner RCLCPP_PUBLIC keywords from the modified classes. Will request @thomas-moulard to run this on windows CI for a quick check