osrf / nexus

Core packages of Nexus
30 stars 7 forks source link

Improve compile time #2

Closed Yadunund closed 1 year ago

Yadunund commented 1 year ago

It turns out passing libraries to link in target_link_libraries() as ${foo_pkg_LIBRARIES} introduces a lot of duplicate of the same library that needs to be linked. This the reason why the ld linker takes a REALLY long time to finish linking since it does not de-duplicate the duplicate libraries and links all them. The lld linker seems to be smarter about this.

Switching to ${foo_pkg_TARGETS} prevents the duplicate libraries that were previously included as transitives. This is also the pattern that ROS 2 follows. See.

With these changes, I can compile the workspace faster than ever with just ld.

I removed the need to install and use lld in the README so that users can follow regular ROS patterns to build the workspace. But kept it in CI so that i can be faster since at the end of the day lld with these changes is faster than lld without these changes.