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

makefile: workaround boost errors under latest compilers #757

Merged
merged 1 commit into from
Oct 1, 2020

Conversation

SteVwonder
Copy link
Member

@SteVwonder SteVwonder commented Sep 30, 2020

Problem: when using the latest gcc/clang compilers, older boost versions
create multiple warnings to be emitted. Our use of -Werror turns
these warnings in boost into hard errors, despite being in a third-party
dependency.

Solution: use -isystem rather than -I for the boost cppflags to
denote that the boost headers are system-provided headers, which turns
off most static analysis warnings for those headers.

Related Documentation:

Closes #300
Closes #747
Closes #732

@SteVwonder SteVwonder added this to the 2020 September Release milestone Sep 30, 2020
@SteVwonder SteVwonder requested a review from trws September 30, 2020 20:17
Copy link
Member

@trws trws left a comment

Choose a reason for hiding this comment

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

This is how any system library like that should come in most likely, makes perfect sense.

@SteVwonder
Copy link
Member Author

SteVwonder commented Sep 30, 2020

It looks like this workaround breaks when BOOST_PREFIX=/usr, as per this GCC bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129. Which also explains why it works just fine under Spack, since the boost prefix will always be non-standard under Spack.

The three potential paths forward that I see are:

  • Check if BOOST_PREFIX is one of the default system search paths, and if it is, still use -I. Unfortunately, I think this means the warnings will only be silenced if boost isn't in a default system location
  • Check if BOOST_PREFIX is one of the default system search paths, and if it is, set BOOST_CPPFLAGS="" and rely on the compiler picking up the header from one of the default paths
  • Insert compiler-specific pragmas to turn off warnings for certain includes:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <third-party-library/header.h>
#pragma GCC diagnostic pop

@trws
Copy link
Member

trws commented Sep 30, 2020 via email

@SteVwonder
Copy link
Member Author

Default system paths are included by the -isystem method unless otherwise specified. If they are not explicitly added to a -I the warnings should be supppressed just by nature of coming from those places.

Ok. IIUC it sounds like Check if BOOST_PREFIX is one of the default system search paths, and if it is, set BOOST_CPPFLAGS="" and rely on the compiler picking up the header from one of the default paths is the way to go. That also seems to be the way that CMake is handling this: https://gitlab.kitware.com/cmake/cmake/-/issues/16291

Any objections to just checking for /usr/include rather than going down the rabbit hole of querying each possible compiler for the full list of their default locations with a set of magic runes that is specific to each compiler? GCC's magic runes, for example. According to the filed issues, it looks like /usr/include covers 99% of cases and the 1% edge cases are mostly cross-compilation.

@SteVwonder
Copy link
Member Author

SteVwonder commented Oct 1, 2020

That latest change seems to have done the trick. Works on both the Travis tests and under Spack. @trws , can you give the new couple of lines at the end of the boost.m4 a quick look?

Copy link
Member

@milroy milroy left a comment

Choose a reason for hiding this comment

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

LGTM! This builds correctly on my test system. I did ask one question, but I'm almost sure these changes can be merged. Thanks!

dnl Due to a change in GCC 6+, searching a default system path via -isystem
dnl causes compilation issues. Let the compiler find headers in default
dnl system paths "naturally".
if test "$BOOST_CPPFLAGS" = "-isystem /usr/include" ; then
Copy link
Member

Choose a reason for hiding this comment

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

Is is possible that $BOOST_CPPFLAGS will resolve to something like -isystem __ /usr/include (where __ indicates multiple whitsepaces) or -isystem /usr/include/? I don't see that it's defined elsewhere in flux-sched (and based on the file here these cases won't occur), but I want to make sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good question.

I don't see that it's defined elsewhere in flux-sched (and based on the file here these cases won't occur), but I want to make sure.

That was the conclusion of my analysis as well. The only other case I could think of was the user manually specifying the variable at the configuration line BOOST_CPPFLAGS=/usr/include/ ./configure, but I don't think we can really protect against the user shooting themselves in the foot in that scenario.

@SteVwonder SteVwonder added the merge-when-passing mergify.io - merge PR automatically once CI passes label Oct 1, 2020
@SteVwonder
Copy link
Member Author

Thanks @milroy and @trws! Setting the label so that we can tag 0.12.0 with this fix included.

Problem: when using the latest gcc/clang compilers, older boost versions
create multiple warnings to be emitted.  Our use of `-Werror` turns
these warnings in boost into hard errors, despite being in a third-party
dependency.

Solution: use `-isystem` rather than `-I` for the boost cppflags to
denote that the boost headers are system-provided headers, which turns
off most static analysis warnings for those headers.  Special care must
be taken to ensure that a compiler default system path (i.e.,
`/usr/include`) is not passed to `-isystem` to avoid compilation issues
in GCC 6+.

Related Documentation:
- Clang:
http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers
- GCC: https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2020

Codecov Report

Merging #757 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #757      +/-   ##
==========================================
+ Coverage   75.94%   75.95%   +0.01%     
==========================================
  Files          82       82              
  Lines        9220     9220              
==========================================
+ Hits         7002     7003       +1     
+ Misses       2218     2217       -1     
Impacted Files Coverage Δ
qmanager/modules/qmanager_callbacks.cpp 78.20% <0.00%> (+0.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9031326...b7d7e19. Read the comment docs.

@mergify mergify bot merged commit 154b748 into flux-framework:master Oct 1, 2020
@SteVwonder SteVwonder deleted the boost-isystem branch October 2, 2020 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-passing mergify.io - merge PR automatically once CI passes
Projects
None yet
4 participants