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

rclcpp_components_register_node macro: --no-undefined linker option #2744

Open
ottojo opened this issue Feb 14, 2025 · 1 comment
Open

rclcpp_components_register_node macro: --no-undefined linker option #2744

ottojo opened this issue Feb 14, 2025 · 1 comment
Assignees

Comments

@ottojo
Copy link
Contributor

ottojo commented Feb 14, 2025

Hi! When converting nodes to components i found myself running into linker issues of undefined symbols at runtime, which would otherwise occur at compile/link time.

I suggest adding

target_link_options(${target} PRIVATE "-Wl,--no-undefined")

to the rclcpp_components_register_node macro, to ensure there are no undefined symbols when the generated executable is run or the component is loaded into a container later.

I'm unsure of the consequences, or if there are valid use cases for having undefined references in the component library, which is why i want to open this for discussion here first before making a PR. Please let me know if you know of any.
I think users of rclcpp_components_register_node would expect to be able to use the generated executable, which would require this anyways.

@mjcarroll
Copy link
Member

It does seem like this would help a class of runtime errors that would be compile/link time errors if you were, for instance, building an executable.

if there are valid use cases for having undefined references in the component library

I think there are cases, but they would be the rare exception and not the rule. You can use weak symbols (https://en.wikipedia.org/wiki/Weak_symbol), but this isn't a commonly-used thing that I'm aware of.

Since it could have potential impact, I think that we could tick-tock it:

  • Add an-opt in mechanism to the rclcpp_components_register_node and leave it off by default.
  • Turn the opt-in mechanism on in all of the core places (just to see what happens)
  • If there aren't any crazy user-facing impacts, turn it on by default at a later date.

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

No branches or pull requests

2 participants