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

Missing includes when building sdformat with clang #256

Open
diegoferigo opened this issue Apr 28, 2020 · 3 comments
Open

Missing includes when building sdformat with clang #256

diegoferigo opened this issue Apr 28, 2020 · 3 comments

Comments

@diegoferigo
Copy link

diegoferigo commented Apr 28, 2020

When compiling sdformat with the clang compiler (I tried with clang9), some standard headers like #include <limits> are not found.

I don't know if you officially support clang, though sdformat is the only project part of the colcon configuration to build Ignition Gazebo that does not work with this compiler.

As a side note, a huge advantage of clang >= 9 is that the compilation of the Physics system of Ignition Gazebo is orders of magnitude faster than gcc 8 and gcc 9. It would be great if an entire colcon workspace could be configured to use clang as default compiler.

OS: ubuntu 18.04
Compiler: clang 9 installed from the official PPA

The compiler was enabled by setting:

export CC=clang-9
export CXX=clang++-9

before the first call to CMake in a fresh build folder.

@chapulina
Copy link
Contributor

chapulina commented Apr 28, 2020

I don't know if you officially support clang

We do, through our OSX CI. From time to time I also build things using clang 6 on Ubuntu and haven't had a problem yet. I haven't tried clang 9.

a huge advantage of clang >= 9 is that the compilation of the Physics system of Ignition Gazebo is orders of magnitude faster than gcc 8 and gcc 9

You may be interested in gazebosim/gz-physics#41 (@mxgrey 's work), which drastically reduces ign-physics' and the physics system's compilation times. I've been testing it with gcc 8.

@diegoferigo
Copy link
Author

diegoferigo commented Apr 29, 2020

You may be interested in gazebosim/gz-physics#41

That's cool, thanks for sharing. I haven't yet had the chance to try it, I am looking forward to it. I hope that compiling performances will get close to those of clang 9, that for some reason is already blazing fast on the current codebase.

Said that, I also look forward to a possible fix to make sdformat compatible with clang 9. Reproducing the error is quite easy:

  1. Install clang 9 from the PPA
  2. Export CC=clang-9 and CXX=clang++-9
  3. Follow the installation from source.

Given the exported environment variables, CMake will automatically select clang 9 as default compiler and no CMake option has to be passed to colcon. This is the easiest way to change on-the-fly the compiler of a CMake project I found (note that you need a fresh build folder since CMake does not allow to change the compiler after being configured once).

@azeey
Copy link
Collaborator

azeey commented May 12, 2020

I've solved this before by removing the -stdlib=libc++ from https://github.com/osrf/sdformat/blob/b80e070dbed613e972acfb81e66b24a248eefd6c/cmake/DefaultCFlags.cmake#L70
I think we are (incorrectly) assuming that we're on a macOS if clang is used currently.

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

3 participants