-
Notifications
You must be signed in to change notification settings - Fork 34
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
Misc rosidl_typesupport cleanup #123
Conversation
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@hidmic I added you as a reviewer, but this one seems to depend on ros2/rosidl#662 so I've left it as a draft until that one is merged. |
|
||
# The visibility header macros for symbols defined by this package are created by rosidl_generator_c | ||
target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix} | ||
PRIVATE "ROSIDL_GENERATOR_C_BUILDING_DLL_${PROJECT_NAME}") |
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.
@sloretz nit: same comment as in ros2/rosidl#662 about this definition being unnecessary outside Windows.
#define ROSIDL_TYPESUPPORT_C_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_C_IMPORT_@PROJECT_NAME@ | ||
#endif | ||
#else | ||
#define ROSIDL_TYPESUPPORT_C_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default"))) |
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.
@sloretz mind to explain why visibility control is no longer necessary? Specifically why dllexport
and dllimport
attributes are no longer necessary on Windows anymore.
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.
It's not that they're not necessary, but that there's already a visibility file for this symbol created by rosidl_generator_c
. This generator creates the .cpp
file which has the symbol in a cpp file declared with the export macro from this file
rosidl_typesupport/rosidl_typesupport_c/resource/msg__type_support.cpp.em
Lines 128 to 130 in 97bc0a7
ROSIDL_TYPESUPPORT_C_EXPORT_@(package_name) | |
const rosidl_message_type_support_t * | |
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))() { |
But the header included by downstream packages is generated by rosidl_generator_c
, and that uses a different visibility header file also generated by rosidl_generator_c
See how it's included in the detail/interface__type_support.h
header generated by rosidl_generator_c
.
Currently this generator has to set both compiler definitions because the .cpp
generated by rosidl_typesupport_c
file includes that typesupport header generated by rosidl_generator_c
. If it didn't, the compiler would complain about the header saying dllimport while the .cpp file says dllexport.
rosidl_typesupport/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake
Lines 103 to 106 in 97bc0a7
target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix} | |
PRIVATE "ROSIDL_GENERATOR_C_BUILDING_DLL_${PROJECT_NAME}") | |
target_compile_definitions(${rosidl_generate_interfaces_TARGET}${_target_suffix} | |
PRIVATE "ROSIDL_TYPESUPPORT_C_BUILDING_DLL_${PROJECT_NAME}") |
This PR cleans it up by removing the visibility header generated by rosidl_typesupport_c
. The header generated by rosidl_generator_c
already has the symbol with an export macro, and the .cpp
file includes it, so the .cpp
file doesn't need it again. The result is it uses the visibility header generated by rosidl_generator_c
.
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.
This had a missing piece. I assumed the rosidl_generator_c
generated visibility header was included when building the .cpp
file, but that wasn't the case. 57c6c7a fixes that.
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
CI failure involves rosidl_generator_py. I'll look into why it failed with this PR:
|
…ader Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
CI LGTM 🎉 The windows warning is in |
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 successfully used this change during testing on RHEL and verified that it substantially reduces the unnecessary linking observed in our message packages.
Thanks for the much-needed cleanup.
This cleans up the rosidl generator code in the packages
rosidl_typesupport_c
and rosidl_typesupport_cpprosidl_typesupport_c
onlyrosidl_typesupport_cpp
onlyrcutils
rosidl_typesupport_c
androsidl_typesupport_cpp
ament_target_dependencies
withtarget_link_libraries()
Is ament_target_dependencies() still necessary? ament/ament_cmake#292DEFINE_SYMBOL
for setting the compiler definition that toggles the visibility export macros.rosidl_generator_c
orrosidl_generator_cpp
, instead of hard coding include directories that they're going to createament_export_dependencies()
the packages needed by generated targets_generator_sources
check that can't work because other CMake code would error if it were ever actually emptydepends on ros2/rosidl#666Merged 🎉depend on ros2/rosidl#662Merged 🎉