Skip to content

clang_configure: add /usr/lib/libclang.so to search paths#528

Open
trnila wants to merge 1 commit into
mvukov:mainfrom
trnila:clang_configure_libclang
Open

clang_configure: add /usr/lib/libclang.so to search paths#528
trnila wants to merge 1 commit into
mvukov:mainfrom
trnila:clang_configure_libclang

Conversation

@trnila

@trnila trnila commented Sep 17, 2025

Copy link
Copy Markdown

On ArchlinuxARM, running clang --version returns:

clang version 20.1.8
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

compared to Ubuntu:

Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

which breaks the build with:

@@com_github_mvukov_rules_ros2+//repositories/rust:bindgen_toolchain_impl depends on @@com_github_mvukov_rules_ros2++non_module_deps+rules_ros2_config_clang//:libclang in repository @@com_github_mvukov_rules_ros2++non_module_deps+rules_ros2_config_clang which failed to fetch. no such package '@@com_github_mvukov_rules_ros2++non_module_deps+rules_ros2_config_clang//': Failed to fetch libclang_path:
realpath: '/usr/lib/llvm-aarch64-unknown-linux-gnu'$'\n''Thread/lib/libclang.so.1': No such file or directory

On ArchlinuxARM, libclang.so is installed directly under /usr/lib, so theres no need to get the version first. This PR adds a search for libclang.so in /usr/lib first, and falls back to the existing lookup if it’s not found.

I also evaluated a more hermetic approach using toolchains_llvm.
Theres @llvm_toolchain_llvm//:bin/clang and @llvm_toolchain_llvm//:lib/libclang.so target, but it can be added to the root bazel module only. Another issue is size - extracted toolchain is about 6 GB and takes more than 400 seconds to extract on Raspberry Pi - not sure if its worth it. Maybe there could be some rules_ros2 option to provide rules_ros2_config_clang replacement if root module is already using toolchains_llvm...

@mvukov

mvukov commented Sep 22, 2025

Copy link
Copy Markdown
Owner

Hi, IIRC there was a specific reason why I implemented it this way. It could be that it was needed for arm64 platform -- e.g. on nvidia jetson. We'll need to double-check this.

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