elvout / cs393r

CS 393R Graduate Autonomous Robots, Fall 2021 | Autobots
0 stars 0 forks source link

Update compilation settings #39

Closed elvout closed 3 years ago

elvout commented 3 years ago

This pull request introduces two major changes to our compilation settings.

Use C++17

ROS Melodic and Noetic both target C++14, but I had no problem compiling the project on Ubuntu 20.04 (Noetic) with C++17. The gcc version on the car supports the majority of C++17 language and library features.

Use clang on x86_64

In my rough testing, clang uses less time and memory when compiling the project. I've introduced a new function in our make wrapper script that sets the compiler to the most recent version of clang if it's installed and if the architecture is x86_64. gcc remains the default compiler on all systems.

It seems like clang caught a few bugs in the codebase that gcc misses. The change introduced in pthread_utils.h fixes the parameter passed to the ScopedLock constructor.

I don't see any downsides to using clang on our dev machines other than maybe a 1-5% performance hit. If any problems arise in the future, we can simply disable the function in the make wrapper script.

aiddun commented 3 years ago

Looks good to me - only thing is the max version on clang on the lab machines is clang-7, and it doesn't look like the script searches that low. Am I missing something?

elvout commented 3 years ago

I was having trouble compiling with clang-10 (I think I should just remove clang-10 from the search as well), so I wasn't sure if lower versions would compile successfully. I'll test the lab machines' clang and post an update here.

elvout commented 3 years ago

On the crispix machine, clang-7 takes way longer to compile the project than gcc-7.

Real time elapsed (mean of 2 runs, warm disk cache):

elvout commented 3 years ago

Tested clang-10 again. It works now, so I think when I tested it yesterday I had some weird compilation settings set.

edit: on Ubuntu 20.04 edit: the problem with clang-10 yesterday seems to have been caused by multiple versions of libomp being installed on the same system