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

Standardize system include targets #62

Merged
merged 2 commits into from
Jul 13, 2020

Conversation

RReichert
Copy link
Contributor

@RReichert RReichert commented Jul 8, 2020

Background

This PR works towards our Platform OKR (https://swift-nav.atlassian.net/wiki/spaces/ENG/pages/804816541/Platform+OKRs+Q3+2020) where we try and avoid using THIRD_PARTY_INCLUDE to mask our issues with submodules.

When calling find_package(...) to include a submodule project, we've by default made it so that all submodule projects are treated as foreign code, this is done by doing some cmake magic where we convert all C++ header include -I flags to -isystem. This is harmless in terms of generated code, but it does differ in terms of reporting warnings. Warnings are reported when using -I but not when using -isystem, so any issues in submodules are ignored which is problematic for a multitude of reasons:

  • compiler warnings are ignored for submodules (problem if customer toolchain warning flags are ignored)
  • static analysis is bounded to only the current project

There is an oddity in this logic as well that when cross compiling it no longer considers it "system" targets because of the bug in the toolchain used for starling's Build for Yocto Jenkins stage, so I'd like to fix that by simply fixing the starling build script.

Changes

The changes that I'm introducing makes it clearer what the expected behaviour is. Any Find*.cmake script that calls GenericFindDependency and has SYSTEM_INCLUDES is by default treated as foreign libraries (system headers) which we have little influence over, so things like eigen, variant, gtest, etc fall under this category. If users don't specify SYSTEM_INCLUDES it is assumed to be within our control, so they are local headers by default. We can override this behaviour by passing the THIRD_PARTY_INCLUDES_AS_SYSTEM, a true value will set everything to system header, a value of false will set everything to local.

Below is a list of all the third party projects which we consider SYSTEM (outside our control) vs LOCAL (within our control).

SYSTEM

  • Benchmark
  • Boost-Math
  • Check
  • Eigen
  • FastCSV
  • GFlags
  • GmockGlobal
  • GoogleTest
  • Json
  • Nanopb
  • Nlopt
  • Optional
  • Protobuf
  • RapidCheck
  • Variant
  • Yaml-Cpp

LOCAL

  • gnss-converters
  • Ixcom
  • Orion-Proto
  • Pal++
  • Pal
  • Rtcm
  • Sbp
  • Settings
  • Starling
  • Swiftlets
  • Swiftnav
  • Ubx

PR depends on the following to be merged

Changes tested on a number of down stream PRs

NOTE: the PR failures above are due to clang-format errors (a false positive result because it uses git diff to identify format error, but the hacks in place modify the source code to reflect a uniform cmake/variant/libpal++ repo update across the organization).

@RReichert RReichert changed the title Rodrigor/standardize system include targets Standardize system include targets Jul 9, 2020
@RReichert RReichert marked this pull request as ready for review July 10, 2020 05:32
Copy link
Contributor

@woodfell woodfell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good move.

In the early days of SYSTEM_INCLUDES there were loads of problems with errors being flagged in headers of swift controlled dependencies that weren't being picked up in the dependencies themselves because of differences in compiler flags and .clang-tidy. Have these differences been resolved or the problems somehow gone away now?

@RReichert
Copy link
Contributor Author

RReichert commented Jul 13, 2020

Have these differences been resolved or the problems somehow gone away now?

No these differences have not be resolved, we now have better control of it with this PR (ie. we can restrict/enable third party analysis with a cmake flag). Swiftlets for instance fails unless I add the THIRD_PARTY_INCLUDES_AS_SYSTEM=true flag, which restricts the clang-lint to only its source code and not its submodules. gnss-converters on the other hand doesn't have that issue because the third-party which are swiftnav repos have identical or more restrictive clang-tidy checks than starling.

Long term these clang-tidy/compile flags will need to be standard across the org, this lot of work will help us get to that point slowly.

@RReichert RReichert merged commit 866386c into master Jul 13, 2020
@RReichert RReichert deleted the rodrigor/standardize-system-include-targets branch July 13, 2020 00:12
@woodfell
Copy link
Contributor

Have these differences been resolved or the problems somehow gone away now?

No these differences have not be resolved, we now have better control of it with this PR (ie. we can restrict/enable third party analysis with a cmake flag). Swiftlets for instance fails unless I add the THIRD_PARTY_INCLUDES_AS_SYSTEM=true flag, which restricts the clang-lint to only its source code and not its submodules. starling on the other hand doesn't have that issue because the third-party which are swiftnav repos have identical or more restrictive clang-tidy checks than starling.

Long term these clang-tidy/compile flags will need to be standard across the org, this lot of work will help us get to that point slowly.

Ok, probably worth making sure the orion team is aware of this since they import starling as well

@RReichert
Copy link
Contributor Author

Ok, probably worth making sure the orion team is aware of this since they import starling as well

I've produced two draft PRs for the orion repos to emulate what it would be with this cmake submodule update:

I'll let mark know before I hit the merge button.

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