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

Clang on Rolling / Noble fails to compile any package #685

Closed
luca-della-vedova opened this issue May 24, 2024 · 1 comment · Fixed by #686
Closed

Clang on Rolling / Noble fails to compile any package #685

luca-della-vedova opened this issue May 24, 2024 · 1 comment · Fixed by #686
Labels
bug Something isn't working

Comments

@luca-della-vedova
Copy link

luca-della-vedova commented May 24, 2024

Description

colcon build fails to build any package when using clang on Noble / Rolling

To Reproduce

  1. Use the setup-ros action (0.7) on rolling.
  2. Set your compiler to clang (set CC=clang and CXX=clang++)
  3. Try to compile a workspace

System (please complete the following information)

  • OS: Ubuntu noble, on github runner
  • ROS 2 Distro: Rolling

Additional context

Full failed action log here (not sure if it's public but it's on this PR).

An extract from our action:

2024-05-24T07:48:03.2150206Z --- output: rmf_building_map_msgs
2024-05-24T07:48:03.2151052Z -- The C compiler identification is Clang 18.1.3
2024-05-24T07:48:03.2151852Z -- The CXX compiler identification is Clang 18.1.3
2024-05-24T07:48:03.2152585Z -- Detecting C compiler ABI info
2024-05-24T07:48:03.2153291Z -- Detecting C compiler ABI info - failed
2024-05-24T07:48:03.2154522Z -- Check for working C compiler: /usr/bin/clang
2024-05-24T07:48:03.2155470Z -- Check for working C compiler: /usr/bin/clang - broken
2024-05-24T07:48:03.2157216Z -- Configuring incomplete, errors occurred!
2024-05-24T07:48:03.2158922Z CMake Error at /usr/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
2024-05-24T07:48:03.2159908Z   The C compiler
2024-05-24T07:48:03.2160183Z 
2024-05-24T07:48:03.2160360Z     "/usr/bin/clang"
2024-05-24T07:48:03.2160648Z 
2024-05-24T07:48:03.2160918Z   is not able to compile a simple test program.
2024-05-24T07:48:03.2161426Z 
2024-05-24T07:48:03.2161640Z   It fails with the following output:
2024-05-24T07:48:03.2162054Z 
2024-05-24T07:48:03.2163395Z     Change Dir: '/__w/rmf_ci_templates/rmf_ci_templates/ros_ws/build/rmf_building_map_msgs/CMakeFiles/CMakeScratch/TryCompile-CNH656'
2024-05-24T07:48:03.2164523Z     
2024-05-24T07:48:03.2165112Z     Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_7833c/fast
2024-05-24T07:48:03.2165980Z     /usr/bin/gmake  -f CMakeFiles/cmTC_7833c.dir/build.make CMakeFiles/cmTC_7833c.dir/build
2024-05-24T07:48:03.2167065Z     gmake[1]: Entering directory '/__w/rmf_ci_templates/rmf_ci_templates/ros_ws/build/rmf_building_map_msgs/CMakeFiles/CMakeScratch/TryCompile-CNH656'
2024-05-24T07:48:03.2167921Z     Building C object CMakeFiles/cmTC_7833c.dir/testCCompiler.c.o
2024-05-24T07:48:03.2170068Z     /usr/bin/clang  -fsanitize-blacklist=/home/runner/work/rmf_ci_templates/rmf_ci_templates/blacklist.txt   --coverage  -MD -MT CMakeFiles/cmTC_7833c.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_7833c.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_7833c.dir/testCCompiler.c.o -c /__w/rmf_ci_templates/rmf_ci_templates/ros_ws/build/rmf_building_map_msgs/CMakeFiles/CMakeScratch/TryCompile-CNH656/testCCompiler.c
2024-05-24T07:48:03.2171879Z     Linking C executable cmTC_7833c
2024-05-24T07:48:03.2172445Z     /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7833c.dir/link.txt --verbose=1
2024-05-24T07:48:03.2173991Z     /usr/bin/clang  -fsanitize-blacklist=/home/runner/work/rmf_ci_templates/rmf_ci_templates/blacklist.txt --coverage  -fuse-ld=lld  CMakeFiles/cmTC_7833c.dir/testCCompiler.c.o -o cmTC_7833c 
2024-05-24T07:48:03.2175423Z     ld.lld: error: cannot open /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.profile-x86_64.a: No such file or directory
2024-05-24T07:48:03.2176371Z     clang: error: linker command failed with exit code 1 (use -v to see invocation)
2024-05-24T07:48:03.2177003Z     gmake[1]: *** [CMakeFiles/cmTC_7833c.dir/build.make:100: cmTC_7833c] Error 1
2024-05-24T07:48:03.2177974Z     gmake[1]: Leaving directory '/__w/rmf_ci_templates/rmf_ci_templates/ros_ws/build/rmf_building_map_msgs/CMakeFiles/CMakeScratch/TryCompile-CNH656'
2024-05-24T07:48:03.2178759Z     gmake: *** [Makefile:127: cmTC_7833c/fast] Error 2
2024-05-24T07:48:03.2179101Z     
2024-05-24T07:48:03.2179277Z     
2024-05-24T07:48:03.2179390Z 
2024-05-24T07:48:03.2179464Z   
2024-05-24T07:48:03.2179574Z 
2024-05-24T07:48:03.2179777Z   CMake will not be able to correctly generate this project.
2024-05-24T07:48:03.2180199Z Call Stack (most recent call first):
2024-05-24T07:48:03.2180525Z   CMakeLists.txt:3 (project)
2024-05-24T07:48:03.2180718Z 
2024-05-24T07:48:03.2180722Z 
2024-05-24T07:48:03.2180812Z ---
2024-05-24T07:48:03.2181055Z --- stderr: rmf_building_map_msgs

Clang can't get anything to compile because libclang_rt.profile-x86_64.a is missing. I did some investigation and it seems this is due to the --no-install-recommends passed to the instruction that installs clang here.
The missing file is included in the libclang-rt-18-dev package:

$ dpkg -S libclang_rt.profile-x86_64.a
libclang-rt-18-dev:amd64: /usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.profile-x86_64.a

However, such package is only a recommended dependency of clang:

2024-05-24T07:45:11.8863264Z [command]/usr/bin/sudo DEBIAN_FRONTEND=noninteractive RTI_NC_LICENSE_ACCEPTED=yes apt-get install --no-install-recommends --quiet --yes libssl-dev python3-dev clang lcov python3-rosinstall-generator python3-pip python3-pytest-cov python3-flake8-blind-except python3-flake8-class-newline python3-flake8-deprecated python3-pytest-repeat python3-pytest-rerunfailures ros-dev-tools python3-colcon-coveragepy-result python3-colcon-lcov-result python3-colcon-meson python3-colcon-mixin python3-importlib-metadata
[redacted]
2024-05-24T07:45:12.7066481Z Recommended packages:
2024-05-24T07:45:12.7067231Z   python3-gpg llvm-18-dev libgd-gd2-perl libclang-rt-18-dev
[...]

Which is not installed because of the flag we pass.
Furthermore, in our actions we actually do install clang, without the --no-install-recommends flag, but because it is already installed by the setup-ros action nothing is done and the recommended package is not installed.
I don't have a lot of background on this action so I can't tell the implications of my recommendations, the main solutions I can think of are:

  1. (Easiest) remove the --no-install-recommends flag. Will install some additional cruft but should fix clang compiles.
  2. (Easy but unclear of implications) Remove installation of clang, downstream users that want it will do it themselves and not encounter this silent failure.
  3. (Harder?) Make sure that we either install libclang-rt-18-dev on rolling or the recommended packages altogether.
  4. (No action here but hacky) Force downstream users to deal with this, i.e. by removing and reinstalling clang or forcing to install it with recommended packages.

I'm happy to submit a PR if there is any recommendation.

@christophebedard
Copy link
Member

christophebedard commented May 24, 2024

Thanks for reporting this!

Since I believe that building with clang should just work out of the box, I would simply go with option 3 and add libclang-rt-dev (which depends on libclang-rt-18-dev) to the list of packages we install on Ubuntu Noble.

I've opened #686. Can you give it a try by using ros-tooling/setup-ros@christophebedard/noble-install-libclang-rt-dev?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants