Starting with gcc 6, some of the C++ header files like <cmath> and <cstdlib> assume (by using the non-standard preprocessor directive "#include_next") that the C headers come *later* in the header file search path. This assumption is explained in https://gcc.gnu.org/gcc-6/porting_to.html and in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70722.
OSv breaks this assumption by putting our own C header files in the search path, so those will now be *before* the C++ header files (which are last, being on the default search path), breaking the C++ header files' assumption. Those will now wrong include the system's standard header files instead of OSv's, and compilation will fail. To fix this, we must explicitly list the C++ header directory or directories in our compilation line, before the C headers (include/api). We find the C++ header directories by running the C++ compiler to figure out its default header search path, and look for those with "c++" in the name. Usually this will include /usr/include/c++/<version> and also /usr/include/c++/<version>/<arch>. Fixes #768 Signed-off-by: Nadav Har'El <n...@scylladb.com> --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 530e9a5..abc7a8f 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,14 @@ INCLUDES += -isystem $(libfdt_base) endif INCLUDES += $(boost-includes) +ifeq ($(gcc_include_env), host) +# Starting in Gcc 6, the standard C++ header files (which we do not change) +# must precede in the include path the C header files (which we replace). +# This is explained in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70722. +# So we are forced to list here (before include/api) the system's default +# C++ include directories, though they are already in the default search path. +INCLUDES += $(shell $(CXX) -E -xc++ - -v </dev/null 2>&1 | awk '/^End/ {exit} /^ .*c\+\+/ {print "-isystem" $$0}') +endif INCLUDES += -isystem include/api INCLUDES += -isystem include/api/$(arch) ifeq ($(gcc_include_env), external) -- 2.5.5 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.