Skip to content

Install clang-tools by default - #133

Open
mini-1235 wants to merge 4 commits into
RoboStack:masterfrom
mini-1235:codex/macos-clang-scan-deps
Open

Install clang-tools by default#133
mini-1235 wants to merge 4 commits into
RoboStack:masterfrom
mini-1235:codex/macos-clang-scan-deps

Conversation

@mini-1235

Copy link
Copy Markdown
Contributor

Summary

Add central macOS support for Clang's C++ dependency scanner in generated CMake, Catkin, and Ament CMake recipes.

Problem

CMake 3.28 and newer may scan C++20 sources for module dependencies. On macOS, conda-forge activates a target-prefixed compiler such as arm64-apple-darwin20.0.0-clang++, while clang-tools installs the scanner as the unprefixed $BUILD_PREFIX/bin/clang-scan-deps.

CMake derives the toolchain prefix from the compiler name and therefore fails to discover the packaged scanner, eventually attempting to run CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND.

Changes

  • Add a macOS-only clang-tools build requirement to CMake, Catkin, and Ament CMake recipes.
  • Match the clang-tools major version to cxx_compiler_version, with * as the fallback when the compiler version is undefined.
  • Leave Python-only and dummy recipes unchanged.
  • In both Unix CMake templates, verify that $BUILD_PREFIX/bin/clang-scan-deps exists and pass it through CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS.
  • Place the central scanner argument before package-specific CMake arguments so packages can still override it explicitly.

The scanner path does not enable module scanning by itself. CMake continues to decide whether to scan based on the C++ standard, generator, compiler support, policy settings, and CXX_SCAN_FOR_MODULES properties.

Validation

  • Generated ros-rolling-ur-controllers recipes with this Vinca checkout.
  • Confirmed the macOS recipe renders clang-tools 19.*.
  • Confirmed dependency solving selects Clang 19.1.7 and clang-tools 19.1.7.
  • Removed the package-specific CMAKE_CXX_SCAN_FOR_MODULES=OFF workaround for the focused verification.
  • Built ros-rolling-ur-controllers successfully on osx-arm64; Ninja completed nine dependency-scanning steps and the log contained no CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND in the successful build section.

The Vinca unit, lint, and formatting baselines were not run as part of this focused verification.

@mini-1235

mini-1235 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Note that unprefixed clang scan deps is also supported in a newer cmake Kitware/CMake@5537b3d, but we are currently pinning cmake to 3.* due to RoboStack/ros-jazzy#40 (comment)

@mini-1235

Copy link
Copy Markdown
Contributor Author

fyi @Tobias-Fischer

@traversaro

Copy link
Copy Markdown
Member

That seems quite a bit of complexity. Perhaps at this point is just easier to unpin cmake so we use the latest cmake, and fix any possible remaining error?

@mini-1235

Copy link
Copy Markdown
Contributor Author

I can remove the *.sh.in changes if we are able to upgrade the cmake version, and just keep the changes in main.py. I can try unpinning cmake today in my ros-rolling PR and see how the CI goes

However, based on your previous comment, I think the root cause might actually be related to vinca setting:

$Env:AMENT_PYTHON_EXECUTABLE="${env:CONDA_PREFIX}\python.exe"

It seems like this may need to be changed to:

$Env:AMENT_PYTHON_EXECUTABLE="${env:CONDA_PREFIX}/python.exe"

My main question is whether Windows is ready for us to bump the cmake version now. Do you happen to remember any of the details around the previous issue?

Admittedly, I a not very familiar with Windows, and I don't have a Windows machine available to test this locally :(

@mini-1235

Copy link
Copy Markdown
Contributor Author

Maybe I was wrong, looks like the error comes from ament-cmake-python a3577e9

Signed-off-by: Maurice <mauricepurnawan@gmail.com>
@mini-1235 mini-1235 changed the title Add macOS clang-scan-deps support Install clang-tools by default Aug 11, 2026
@mini-1235

Copy link
Copy Markdown
Contributor Author

@traversaro I reverted the *.sh.in changes and keep clang-tools install by default, I confirm that I have tested locally and this should fix RoboStack/ros-rolling#31 (comment) . Could you please take a look again?

Signed-off-by: Maurice <mauricepurnawan@gmail.com>
@traversaro

Copy link
Copy Markdown
Member

There is something I am missing here, sorry. Is clang-tools required if one uses cxx-compiler on macOS with C++20? In that case, shouldn't clang-tools be a dependency of cxx-compiler? No problem for me if that is the case, I just wanted to understand if that is the problem (and probably we would need to open also an issue in https://github.com/conda-forge/compilers-feedstock if that is the case.

@mini-1235

mini-1235 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

This is only required when the project uses cmake_minimum_required version >= 3.28 with C++20 like https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/blob/f6cae596ae0ba7a5045a89b1e847c47155d7e203/ur_controllers/CMakeLists.txt#L1. If clang-tools is not installed, the build can fail with a clang-scan-deps not found error.

One workaround is to disable module dependency scanning with:

additional_cmake_args: "-DCMAKE_CXX_SCAN_FOR_MODULES=OFF"

This was actually what I tried at first in RoboStack/ros-rolling#31 (comment). However, it doesn’t seem like a good long-term solution.

@Tobias-Fischer later suggested adding clang-tools as a build dependency in vinca instead: RoboStack/ros-rolling#31 (comment), which led to this PR. Let me know what you think.

You can also find the corresponding error log here:
https://github.com/RoboStack/ros-rolling/actions/runs/31469507094/job/93709516192?pr=31

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

Successfully merging this pull request may close these issues.

2 participants