[Bug libstdc++/70129] [6 Regression] stdlib.h: No such file or directory when using -isystem /usr/include

2017-10-31 Thread chuck at ece dot cmu.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

chuck cranor  changed:

   What|Removed |Added

 CC||chuck at ece dot cmu.edu

--- Comment #3 from chuck cranor  ---
If the only difference between "-isystem" and "-I" was the change in the
handling of warnings, the #include_next of stdlib.h in libstdc++ would not be
a problem.

The real problem here is that "-isystem /usr/include" changes the include
search path in a way that is incompatible with "-I /usr/include" e.g.

% cat try.cc
#include 
% g++ -c try.cc
% g++ -I /usr/include -c try.cc
% g++ -isystem /usr/include -c try.cc
In file included from try.cc:1:0:
/proj/testbed/data/travis/cache/gcc/include/c++/6.2.0/cstdlib:75:25: fatal
error: stdlib.h: No such file or directory
 #include_next 
 ^
compilation terminated.
% 

I think you'll find most build systems that do "-isystem /usr/include"
instead of "-I /usr/include" are only using "-isystem" for the change
in the warning behavior.  The change in the include path order is not
wanted...

[Bug libstdc++/70129] [6 Regression] stdlib.h: No such file or directory when using -isystem /usr/include

2017-10-31 Thread chuck at ece dot cmu.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

--- Comment #5 from chuck cranor  ---
I don't think anyone would manually add "-isystem /usr/include" ...
but build systems that provide variables for third party headers that
may or may not be installed in /usr/include often trigger this.

e.g. if boost is installed in prefix /pkg, then you want to include
/pkg/include in the search path.   if boost is installed in /usr
then you want /usr/include in the search path.  if you have 
"-isystem ${BOOST_PREFIX}/include" in your CXXFLAGS and BOOST_PREFIX
happens to be set to /usr somewhere earlier, you lose.


For what it's worth, this definitely crops up in cmake-based builds:

https://gitlab.kitware.com/cmake/cmake/issues/16291

I triggered it with cmake and Boost on a Cray.  It is partly cmake's
fault too.  Its handling of CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
isn't correct.