gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
155 stars 90 forks source link

Missing includes when building sdformat with clang #256

Open diegoferigo opened 4 years ago

diegoferigo commented 4 years ago

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 commented 4 years ago

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 https://github.com/ignitionrobotics/ign-physics/pull/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 commented 4 years ago

You may be interested in https://github.com/ignitionrobotics/ign-physics/pull/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 commented 4 years ago

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.