Say, I have a very simple program that utilizes cstdlib
:
#include <cstdlib>
main() {}
With the following commandline it compiles just fine:
$ g++ test.cc -o test
Yet sometimes make
appends a -isystem /usr/include
which, according to isystem
's usage, seems to be quite useless. Yet this results in a compile error:
$ g++ test.cc -o test -isystem /usr/include -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-gentoo-freebsd11.0/6.4.0/lto-wrapper
Target: x86_64-gentoo-freebsd11.0
Configured with: /var/tmp/portage/sys-devel/gcc-6.4.0/work/gcc-6.4.0/configure --host=x86_64-gentoo-freebsd11.0 --build=x86_64-gentoo-freebsd11.0 --prefix=/usr --bindir=/usr/x86_64-gentoo-freebsd11.0/gcc-bin/6.4.0 --includedir=/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include --datadir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0 --mandir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/man --infodir=/usr/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6 --with-python-dir=/share/gcc-data/x86_64-gentoo-freebsd11.0/6.4.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 6.4.0 p1.0' --disable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-multilib --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx --disable-vtable-verify --disable-libvtv --enable-lto --without-isl --disable-libsanitizer --disable-default-pie --enable-default-ssp
Thread model: posix
gcc version 6.4.0 (Gentoo 6.4.0 p1.0)
COLLECT_GCC_OPTIONS='-o' 'test' '-isystem' '/usr/include' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/libexec/gcc/x86_64-gentoo-freebsd11.0/6.4.0/cc1plus -quiet -v -isystem /usr/include test.cc -quiet -dumpbase test.cc -mtune=generic -march=x86-64 -auxbase test -version -o /tmp//cclevcZR.s
GNU C++14 (Gentoo 6.4.0 p1.0) version 6.4.0 (x86_64-gentoo-freebsd11.0)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/../../../../x86_64-gentoo-freebsd11.0/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/x86_64-gentoo-freebsd11.0
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/backward
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include-fixed
End of search list.
GNU C++14 (Gentoo 6.4.0 p1.0) version 6.4.0 (x86_64-gentoo-freebsd11.0)
compiled by GNU C version 6.4.0, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2edeed218f8bfd16af7f8b4e68596a6d
In file included from test.cc:1:0:
/usr/lib/gcc/x86_64-gentoo-freebsd11.0/6.4.0/include/g++-v6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next <stdlib.h>
^
compilation terminated.
GCC 5.4 does not exhibit this issue while GCC 6.4 does.
Is this because of something wrong in my configuration (say, when bootstrapping GCC or the like) or simply a bug in GCC 6? How to work around this issue?