Gentoo building qtgui error – g++-v8/cstdlib:75:15: fatal error: stdlib.h: No such file or directory

Most cases this error happens after you updated the GNU GCC (this update triggers the error, but it might be not the problem)! This was the case with us we updated the GNU GCC and then wanted to update QT libraries and several packages were built OK, but then this error occurred when compiling dev-qt/qtgui.

x86_64-pc-linux-gnu-g++ -c -march=haswell -O2 -fomit-frame-pointer -pipe -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DENABLE_PIXMAN_DRAWHELPERS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_GUI_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I../../include -I../../include/QtGui -I../../include/QtGui/5.11.2 -I../../include/QtGui/5.11.2/QtGui -I.tracegen -isystem /usr/include/libdrm -isystem /usr/include -isystem /usr/include/qt5/QtCore/5.11.2 -isystem /usr/include/qt5/QtCore/5.11.2/QtCore -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -I.moc -isystem /usr/include/libpng16 -I../../mkspecs/linux-g++ -o .obj/qaccessible.o accessible/qaccessible.cpp
distcc[8024] (dcc_build_somewhere) Warning: failed to distribute, running locally instead
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/bits/stl_algo.h:59,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/algorithm:62,
                 from ../../include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from ../../include/QtCore/qglobal.h:1,
                 from ../../include/QtGui/../../src/gui/kernel/qtguiglobal.h:43,
                 from ../../include/QtGui/qtguiglobal.h:1,
                 from ../../include/QtGui/../../src/gui/image/qimage.h:43,
                 from ../../include/QtGui/qimage.h:1,
                 from image/qimage_sse4.cpp:40:
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
distcc[8012] ERROR: compile image/qimage_sse4.cpp on localhost failed
make: *** [Makefile:2414: .obj/qimage_sse4.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/bits/stl_algo.h:59,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/algorithm:62,
                 from ../../include/QtCore/../../src/corelib/global/qglobal.h:142,
                 from ../../include/QtCore/qglobal.h:1,
                 from ../../include/QtGui/../../src/gui/kernel/qtguiglobal.h:43,
                 from ../../include/QtGui/qtguiglobal.h:1,
                 from ../../include/QtGui/5.11.2/QtGui/private/../../../../../src/gui/kernel/qtguiglobal_p.h:54,
                 from ../../include/QtGui/5.11.2/QtGui/private/qtguiglobal_p.h:1,
                 from ../../include/QtGui/5.11.2/QtGui/private/../../../../../src/gui/painting/qdrawhelper_p.h:54,
                 from ../../include/QtGui/5.11.2/QtGui/private/qdrawhelper_p.h:1,
                 from painting/qdrawhelper_sse4.cpp:40:
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.


The problem is that it cannot be true, stdlib.h cannot be missing in our installation and indeed it appears the file is there:

srv.local ~ # find /usr/lib/gcc/x86_64-pc-linux-gnu/|grep stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include/g++-v7/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/include/g++-v7/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include/g++-v4/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/6.4.0/include/g++-v6/stdlib.h

And you can see that there are two locations as for the last 3 major GNU GCC releases.

So the problem looks like wrong configuration of GNU GCC – wrong include configuration or not including all directories.

After some googling we found that there was a bad version of dev-util/meson package, which generated broken pkgconfig files (.pc files in “/usr/lib64/pkgconfig/”) in some packages’ builds!
The solution is:

  1. Install the latest dev-util/meson
  2. Rebuild all the packages installed with the old one. If you do not know which one you can search them in “/usr/lib64/pkgconfig/” with:
    grep "I/usr/include/\B" /usr/lib64/pkgconfig/*.pc
    

    Here is the bug filed in Gentoo: https://bugs.gentoo.org/649264#c4

So after some tests here is what worked for us:

srv.local ~ # emerge -v meson

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] x11-base/xcb-proto-1.13::gentoo  ABI_X86="32 (64) (-x32)" PYTHON_TARGETS="python2_7 python3_4 python3_5 python3_6 -python3_7%" 149 KiB
[ebuild     U  ] dev-util/meson-0.48.2::gentoo [0.47.1::gentoo] PYTHON_TARGETS="python3_5 python3_6 -python3_7%" 1281 KiB
[ebuild   R    ] x11-base/xorg-proto-2018.4::gentoo  0 KiB
[ebuild   R    ] x11-libs/libxshmfence-1.3-r1::gentoo  USE="-static-libs" ABI_X86="32 (64) (-x32)" 0 KiB

....
....
....

srv.local ~ # emerge -v libxshmfence x11-base/xcb-proto x11-libs/libxcb $(qlist -IC|grep x11-libs/xcb |sort|uniq)

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] x11-libs/libxshmfence-1.3-r1::gentoo  USE="-static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-base/xcb-proto-1.13::gentoo  ABI_X86="32 (64) (-x32)" PYTHON_TARGETS="python2_7 python3_4 python3_5 python3_6 -python3_7" 0 KiB
[ebuild     U  ] x11-libs/libxcb-1.13.1:0/1.12::gentoo [1.13:0/1.12::gentoo] USE="(selinux) xkb -doc -static-libs -test" ABI_X86="32 (64) (-x32)" 495 KiB
[ebuild   R    ] x11-libs/xcb-util-keysyms-0.4.0-r1::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 284 KiB
[ebuild   R    ] x11-libs/xcb-util-renderutil-0.3.9-r2::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 287 KiB
[ebuild   R    ] x11-libs/xcb-util-wm-0.4.1-r2::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 315 KiB
[ebuild   R    ] x11-libs/xcb-util-0.4.0-r1::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 291 KiB
[ebuild   R    ] x11-libs/xcb-util-image-0.4.0-r1::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 321 KiB
[ebuild   R    ] x11-libs/xcb-util-cursor-0.1.3-r2::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 289 KiB

And after that we were able to successfully build and install “dev-qt/qtgui”

* Bonus

In one of our system appeared that the above solution did not help. After building the above proposed packages it still got the same error (fatal error: stdlib.h: No such file or directory) building “dev-qt/qtgui”. So here what we did:

First we tried to rebuild all the dependencies of the currently installed “dev-qt/qtgui-5.11.1”

srv.local ~ # equery g =dev-qt/qtgui-5.11.1
 * Searching for qtgui5.11.1 in dev-qt ...

 * dependency graph for dev-qt/qtgui-5.11.1
 `--  dev-qt/qtgui-5.11.1  ~amd64 
   `--  dev-libs/glib-2.56.2  (dev-libs/glib) ~amd64 
   `--  dev-qt/qtcore-5.11.1-r1  (~dev-qt/qtcore-5.11.1) amd64 
   `--  media-libs/fontconfig-2.13.1-r2  (media-libs/fontconfig) ~amd64 
   `--  media-libs/freetype-2.9.1-r4  (>=media-libs/freetype-2.6.1) ~amd64 
   `--  media-libs/harfbuzz-2.1.3  (>=media-libs/harfbuzz-1.6.0) ~amd64 
   `--  sys-libs/zlib-1.2.11-r2  (>=sys-libs/zlib-1.2.5) amd64 
   `--  virtual/opengl-7.0-r2  (virtual/opengl) amd64 
   `--  dev-qt/qtdbus-5.11.1  (~dev-qt/qtdbus-5.11.1) amd64 
   `--  media-libs/mesa-18.3.0_rc3  (media-libs/mesa) ~amd64  [egl]
   `--  x11-libs/libdrm-2.4.96  (x11-libs/libdrm) amd64 
   `--  sys-libs/mtdev-1.1.5  (sys-libs/mtdev) amd64 
   `--  virtual/jpeg-0-r2  (virtual/jpeg) amd64 
   `--  dev-libs/libinput-1.12.3  (dev-libs/libinput) ~amd64 
   `--  x11-libs/libxkbcommon-0.8.2  (x11-libs/libxkbcommon) amd64 
   `--  media-libs/libpng-1.6.35-r1  (media-libs/libpng) ~amd64 
   `--  x11-libs/tslib-1.0-r3  (x11-libs/tslib) amd64 
   `--  dev-qt/qtnetwork-5.11.1  (~dev-qt/qtnetwork-5.11.1) amd64 
   `--  virtual/libudev-232  (virtual/libudev) amd64 
   `--  x11-libs/libICE-1.0.9-r2  (x11-libs/libICE) amd64 
   `--  x11-libs/libSM-1.2.3  (x11-libs/libSM) amd64 
   `--  x11-libs/libX11-1.6.7  (x11-libs/libX11) amd64 
   `--  x11-libs/libXi-1.7.9-r1  (>=x11-libs/libXi-1.7.5) amd64 
   `--  x11-libs/libxcb-1.13.1  (>=x11-libs/libxcb-1.10) amd64  [xkb]
   `--  x11-libs/xcb-util-image-0.4.0-r1  (x11-libs/xcb-util-image) amd64 
   `--  x11-libs/xcb-util-keysyms-0.4.0-r1  (x11-libs/xcb-util-keysyms) amd64 
   `--  x11-libs/xcb-util-renderutil-0.3.9-r2  (x11-libs/xcb-util-renderutil) amd64 
   `--  x11-libs/xcb-util-wm-0.4.1-r2  (x11-libs/xcb-util-wm) amd64 
   `--  sys-kernel/linux-headers-4.19  (sys-kernel/linux-headers) ~amd64 
   `--  dev-lang/perl-5.26.2  (dev-lang/perl) ~amd64 
   `--  virtual/pkgconfig-0-r1  (virtual/pkgconfig) amd64 
   `--  dev-qt/qttest-5.11.1  (~dev-qt/qttest-5.11.1) amd64 
   `--  app-i18n/ibus-1.5.19  (app-i18n/ibus) ~amd64 
   `--  dev-qt/qtchooser-0_p20170803  (dev-qt/qtchooser) amd64 
[ dev-qt/qtgui-5.11.1 stats: packages (34), max depth (1) ]

srv.local ~ # emerge -v =dev-libs/glib-2.56.2 =dev-qt/qtcore-5.11.1-r1 =media-libs/fontconfig-2.13.1-r2 =media-libs/freetype-2.9.1-r4 =media-libs/harfbuzz-2.1.3 =sys-libs/zlib-1.2.11-r2 =virtual/opengl-7.0-r2 =dev-qt/qtdbus-5.11.1 =media-libs/mesa-18.3.0_rc3 =x11-libs/libdrm-2.4.96 =sys-libs/mtdev-1.1.5 =virtual/jpeg-0-r2 =dev-libs/libinput-1.12.3 =x11-libs/libxkbcommon-0.8.2 =media-libs/libpng-1.6.35-r1 =x11-libs/tslib-1.0-r3 =dev-qt/qtnetwork-5.11.1 =virtual/libudev-232 =x11-libs/libICE-1.0.9-r2 =x11-libs/libSM-1.2.3 =x11-libs/libX11-1.6.7 =x11-libs/libXi-1.7.9-r1 =x11-libs/libxcb-1.13.1 =x11-libs/xcb-util-image-0.4.0-r1 =x11-libs/xcb-util-keysyms-0.4.0-r1 =x11-libs/xcb-util-renderutil-0.3.9-r2 =x11-libs/xcb-util-wm-0.4.1-r2 =sys-kernel/linux-headers-4.19 =dev-lang/perl-5.26.2 =virtual/pkgconfig-0-r1 =dev-qt/qttest-5.11.1 =app-i18n/ibus-1.5.19 =dev-qt/qtchooser-0_p20170803

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] dev-qt/qtchooser-0_p20170803::gentoo  USE="-test" 32 KiB
[ebuild   R    ] virtual/pkgconfig-0-r1::gentoo  ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] virtual/jpeg-0-r2::gentoo  USE="-static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] virtual/libudev-232:0/1::gentoo  USE="-static-libs (-systemd)" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] virtual/opengl-7.0-r2::gentoo  ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/libdrm-2.4.96::gentoo  USE="-libkms -valgrind" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="intel -amdgpu (-exynos) (-freedreno) -nouveau (-omap) -radeon (-tegra) (-vc4) (-vivante) -vmware" 0 KiB
[ebuild   R    ] sys-libs/zlib-1.2.11-r2:0/1::gentoo  USE="minizip -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/libxcb-1.13.1:0/1.12::gentoo  USE="(selinux) xkb -doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/libICE-1.0.9-r2::gentoo  USE="ipv6 -doc -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild  N     ] x11-libs/tslib-1.0-r3::gentoo  ABI_X86="32 (64) (-x32)" 53 KiB
[ebuild   R    ] dev-lang/perl-5.26.2:0/5.26::gentoo  USE="berkdb gdbm ithreads -debug -doc" 0 KiB
[ebuild   R    ] x11-libs/libX11-1.6.7::gentoo  USE="ipv6 -doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild     U  ] media-libs/libpng-1.6.35-r1:0/16::gentoo [1.6.35:0/16::gentoo] USE="apng (-neon) -static-libs" ABI_X86="32 (64) (-x32)" CPU_FLAGS_X86="sse" 1001 KiB
[ebuild   R    ] x11-libs/libSM-1.2.3::gentoo  USE="ipv6 uuid -doc -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/libxkbcommon-0.8.2::gentoo  USE="X -doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/xcb-util-keysyms-0.4.0-r1::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/xcb-util-image-0.4.0-r1::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/xcb-util-renderutil-0.3.9-r2::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] x11-libs/xcb-util-wm-0.4.1-r2::gentoo  USE="-doc -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] media-libs/freetype-2.9.1-r4:2::gentoo  USE="X adobe-cff bzip2 cleartype_hinting fontforge infinality png -bindist -debug -doc -harfbuzz -static-libs -utils" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] media-libs/mesa-18.3.0_rc3::gentoo  USE="classic dri3 egl gallium gbm gles2 llvm lm_sensors (selinux) vaapi vdpau wayland -d3d9 -debug -gles1 -opencl -osmesa -pax_kernel -pic -test -unwind -valgrind -vulkan -xa -xvmc" ABI_X86="32 (64) (-x32)" VIDEO_CARDS="i915 i965 intel (-freedreno) (-imx) -nouveau -r100 -r200 -r300 -r600 -radeon -radeonsi (-vc4) -virgl (-vivante) -vmware" 0 KiB
[ebuild   R    ] x11-libs/libXi-1.7.9-r1::gentoo  USE="-doc -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] sys-kernel/linux-headers-4.19::gentoo  USE="-headers-only" 0 KiB
[ebuild   R    ] dev-libs/glib-2.56.2:2::gentoo  USE="dbus mime (selinux) xattr -debug (-fam) -static-libs -systemtap -test -utils" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] media-libs/fontconfig-2.13.1-r2:1.0::gentoo  USE="-doc -static-libs" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] sys-libs/mtdev-1.1.5::gentoo  USE="-static-libs" 268 KiB
[ebuild   R    ] dev-qt/qtcore-5.11.1-r1:5/5.11::gentoo  USE="icu -debug (-systemd) -test" 0 KiB
[ebuild   R    ] media-libs/harfbuzz-2.1.3:0/0.9.18::gentoo  USE="cairo fontconfig glib graphite icu introspection truetype -debug -static-libs -test" ABI_X86="32 (64) (-x32)" 0 KiB
[ebuild   R    ] dev-libs/libinput-1.12.3:0/10::gentoo  USE="-doc" INPUT_DEVICES="-wacom" 0 KiB
[ebuild   R    ] dev-qt/qtdbus-5.11.1:5/5.11::gentoo  USE="-debug -test" 0 KiB
[ebuild   R    ] dev-qt/qttest-5.11.1:5/5.11::gentoo  USE="-debug -test" 0 KiB
[ebuild     U  ] app-i18n/ibus-1.5.19::gentoo [1.5.18::gentoo] USE="X emoji gtk gtk2 introspection libnotify nls python unicode wayland -gconf -kde -test -vala" PYTHON_TARGETS="python2_7 python3_4 python3_5 python3_6" 2776 KiB
[ebuild   R    ] dev-qt/qtnetwork-5.11.1:5/5.11::gentoo  USE="libproxy networkmanager ssl -bindist -connman -debug -test" 0 KiB

Total: 33 packages (2 upgrades, 1 new, 30 reinstalls), Size of downloads: 4129 KiB

All the deps were build successfully BUT we still got the error!!!
We tried strace to see where the compilation was looking for the stdlib.h file:

srv.local ~ # strace -o ./qtgui.strace.log -s 256 -f ebuild /usr/portage/dev-qt/qtgui/qtgui-5.11.1.ebuild compile
srv.local ~ #  grep stdlib.h qtgui-5.11.1.log
13370 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/x86_64-pc-linux-gnu/stdlib.h", 0x7ffe437bf040) = -1 ENOENT (No such file or directory)
13370 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/x86_64-pc-linux-gnu/stdlib.h", 0x7ffe437bdfe0) = -1 ENOENT (No such file or directory)
13370 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/backward/stdlib.h", 0x7ffe437bf040) = -1 ENOENT (No such file or directory)
13370 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/backward/stdlib.h", 0x7ffe437bdfe0) = -1 ENOENT (No such file or directory)
13370 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdlib.h", 0x7ffe437bf040) = -1 ENOENT (No such file or directory)
13370 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdlib.h", 0x7ffe437bdfe0) = -1 ENOENT (No such file or directory)
13370 lstat("/usr/local/include/stdlib.h", 0x7ffe437bf040) = -1 ENOENT (No such file or directory)
13370 stat("/usr/local/include/stdlib.h", 0x7ffe437bdfe0) = -1 ENOENT (No such file or directory)
13370 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/stdlib.h",  <unfinished ...>
13370 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/stdlib.h",  <unfinished ...>
13373 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/x86_64-pc-linux-gnu/stdlib.h", 0x7ffc28a9b6b0) = -1 ENOENT (No such file or directory)
13373 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/x86_64-pc-linux-gnu/stdlib.h", 0x7ffc28a9a650) = -1 ENOENT (No such file or directory)
13373 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/backward/stdlib.h", 0x7ffc28a9b6b0) = -1 ENOENT (No such file or directory)
13373 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/backward/stdlib.h", 0x7ffc28a9a650) = -1 ENOENT (No such file or directory)
13373 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdlib.h", 0x7ffc28a9b6b0) = -1 ENOENT (No such file or directory)
13373 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/stdlib.h", 0x7ffc28a9a650) = -1 ENOENT (No such file or directory)
13373 lstat("/usr/local/include/stdlib.h", 0x7ffc28a9b6b0) = -1 ENOENT (No such file or directory)
13373 stat("/usr/local/include/stdlib.h", 0x7ffc28a9a650) = -1 ENOENT (No such file or directory)
13373 lstat("/usr/lib64/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/stdlib.h", 0x7ffc28a9b6b0) = -1 ENOENT (No such file or directory)
13373 stat("/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include-fixed/stdlib.h", 0x7ffc28a9a650) = -1 ENOENT (No such file or directory)

So the file “stdlib.h” is not found and is not searched in the directory where it is located (above there is search example)

/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/tr1/stdlib.h
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/stdlib.h

We even recompile all world packages with:

eix -u --only-names|sort|uniq|grep -v kde|while read one; do emerge -v "$one"; emerge -v --nodeps =dev-qt/qtwidgets-5.11.1; rm -R /var/tmp/portage/*;done

So rebuilding all packages and after each package we tried to rebuild the “=dev-qt/qtwidgets-5.11.1” (don’t ask, just we have a really fast and multi processors and cores idling machine ) and after the last package we still got the same error! Then someone found this mega (mega because look how many dependency it has – 27 other bugs depend on it) bug report https://bugs.gentoo.org/666134 (look at the end of this article if this URL does not work any more) and YES our

GLIBC was 2.28!

Meanwhile there was a newer glibc 2.28-r5 (which includes some of the bug fixes) and a newer gcc-8.2.0-r6. So we rebuilt the linux-headers, then glibc and the last GCC (this order is important -> linux-headers -> glibc -> gcc):

srv.local # emerge -vu linux-headers

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-kernel/linux-headers-4.20::gentoo [4.19::gentoo] USE="-headers-only" 7858 KiB

Total: 1 package (1 upgrade), Size of downloads: 7858 KiB

>>> Verifying ebuild manifests
 * gentoo-headers-4.20-1.tar.xz BLAKE2B SHA512 size 😉 ...                                                                                            [ ok ]
>>> Unpacking source...
>>> Unpacking gentoo-headers-base-4.20.tar.xz to /var/tmp/portage/sys-kernel/linux-headers-4.20/work
>>> Unpacking gentoo-headers-4.20-1.tar.xz to /var/tmp/portage/sys-kernel/linux-headers-4.20/work
>>> Source unpacked in /var/tmp/portage/sys-kernel/linux-headers-4.20/work
>>> Preparing source in /var/tmp/portage/sys-kernel/linux-headers-4.20/work/gentoo-headers-base-4.20 ...
 * Applying 00_all_0001-linux-stat.h-remove-__GLIBC__-checks.patch ...                                                                                 [ ok ]
 * Applying 00_all_0002-netfilter-pull-in-limits.h.patch ...                                                                                           [ ok ]
 * Applying 00_all_0003-convert-PAGE_SIZE-usage.patch ...                                                                                              [ ok ]
 * Applying 00_all_0004-asm-generic-fcntl.h-namespace-kernel-file-structs.patch ...                                                                    [ ok ]
 * Applying 00_all_0005-unifdef-drop-unused-errno.h-include.patch ...                                                                                  [ ok ]
 * Applying 00_all_0006-x86-do-not-build-relocs-tool-when-installing-headers.patch ...                                                                 [ ok ]
 * Applying 00_all_0007-netlink-drop-int-cast-on-length-arg-in-NLMSG_OK.patch ...                                                                      [ ok ]
 * Applying 00_all_0008-uapi-fix-System-V-buf-header-includes.patch ...                                                                                [ ok ]
>>> Source prepared.
.....
.....
srv.local # emerge -vu glibc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-libs/glibc-2.28-r5:2.2::gentoo [2.28-r2:2.2::gentoo] USE="audit gd multiarch (multilib) (selinux) suid -caps (-cet) (-compile-locales) -doc -headers-only -nscd -profile -systemtap -test (-vanilla) (-hardened%)" 0 KiB

Total: 1 package (1 upgrade), Size of downloads: 0 KiB

>>> Verifying ebuild manifests
>>> Running pre-merge checks for sys-libs/glibc-2.28-r5
 * Checking general environment sanity.
make -j5 -s glibc-test 
 * Checking that IA32 emulation is enabled in the running kernel ...                                                                                   [ ok ]
 * Checking gcc for __thread support ...                                                                                                               [ ok ]
 * Checking running kernel version (4.19.0-gentoo >= 3.2.0) ...                                                                                        [ ok ]
 * Checking linux-headers version (4.20.0 >= 3.2.0) ...                                                                                                [ ok ]

>>> Emerging (1 of 1) sys-libs/glibc-2.28-r5::gentoo
 * glibc-2.28.tar.xz BLAKE2B SHA512 size 😉 ...                                                                                                       [ ok ]
 * glibc-2.28-patches-8.tar.xz BLAKE2B SHA512 size 😉 ...                                                                                             [ ok ]
 * gcc-multilib-bootstrap-20180511.tar.xz BLAKE2B SHA512 size 😉 ...                                                                                  [ ok ]
>>> Unpacking source...
.....
.....
srv.local # emerge -v gcc

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] sys-devel/gcc-8.2.0-r6:8.2.0::gentoo [8.2.0-r5:8.2.0::gentoo] USE="cxx fortran (multilib) nls nptl openmp pch (pie) sanitize ssp vtv (-altivec) -debug -doc (-fixed-point) -go -graphite -hardened (-jit) (-libssp) -mpx -objc -objc++ -objc-gc -pgo -regression-test -systemtap -vanilla" 18 KiB

Total: 1 package (1 upgrade), Size of downloads: 18 KiB


>>> Recording sys-devel/gcc in "world" favorites file...

>>> Verifying ebuild manifests
>>> Running pre-merge checks for sys-devel/gcc-8.2.0-r6

>>> Emerging (1 of 1) sys-devel/gcc-8.2.0-r6::gentoo
 * gcc-8.2.0.tar.xz BLAKE2B SHA512 size 😉 ...
.....
.....

Then we tried again with “dev-qt/qtcore-5.11.1-r1” (because we were stuck with this QT version all other packages were this version and we wanted to know if there is still this bug) with NO SUCCESS
This time another error

/usr/include/linux/stat.h:18:8: error: redefinition of ‘struct statx_timestamp’

This is one of the bugs, which glibc mega bug depends on (the https://bugs.gentoo.org/666134 look at the end of this article if this URL does not work any more)

srv.local # emerge -va --nodeps =dev-qt/qtcore-5.11.1-r1

These are the packages that would be merged, in order:

[ebuild   R    ] dev-qt/qtcore-5.11.1-r1:5/5.11::gentoo  USE="icu -debug (-systemd) -test" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No] yes

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-qt/qtcore-5.11.1-r1::gentoo
 * qtbase-everywhere-src-5.11.1.tar.xz BLAKE2B SHA512 size 😉 ...                                                                                     [ ok ]
>>> Unpacking source...
x86_64-pc-linux-gnu-g++ -c -o qlibraryinfo.o  -march=haswell -O2 -fomit-frame-pointer -pipe -std=c++11 -ffunction-sections  -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake/library -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake/generators -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake/generators/unix -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake/generators/win32 -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/qmake/generators/mac -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/5.11.1 -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/5.11.1/QtCore -I../src/corelib/global -I/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/mkspecs/linux-g++ -DQT_VERSION_STR=\"5.11.1\" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=11 -DQT_VERSION_PATCH=1 -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_FOREACH -DQT_BUILD_QMAKE_BOOTSTRAP /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/global/qlibraryinfo.cpp
In file included from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:94:
/usr/include/linux/stat.h:18:8: error: redefinition of 'struct statx_timestamp'
 struct statx_timestamp {
        ^~~~~~~~~~~~~~~
In file included from /usr/include/sys/stat.h:446,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/mkspecs/linux-g++/qplatformdefs.h:75,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:42:
/usr/include/bits/statx.h:25:8: note: previous definition of 'struct statx_timestamp'
 struct statx_timestamp
        ^~~~~~~~~~~~~~~
In file included from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:94:
/usr/include/linux/stat.h:61:8: error: redefinition of 'struct statx'
 struct statx {
        ^~~~~
In file included from /usr/include/sys/stat.h:446,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/mkspecs/linux-g++/qplatformdefs.h:75,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:42:
/usr/include/bits/statx.h:36:8: note: previous definition of 'struct statx'
 struct statx
        ^~~~~
/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:110:12: error: 'int renameat2(int, const char*, int, const char*, unsigned int)' was declared 'extern' and later 'static' [-fpermissive]
 static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newpath, unsigned flags)
            ^~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/cstdio:42,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/ext/string_conversions.h:43,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/bits/basic_string.h:6391,
                 from /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8/string:52,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/../../src/corelib/tools/qbytearray.h:52,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/qbytearray.h:1,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/../../src/corelib/tools/qstring.h:49,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/qstring.h:1,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/../../src/corelib/io/qiodevice.h:50,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/qiodevice.h:1,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/../../src/corelib/io/qfiledevice.h:43,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/include/QtCore/qfiledevice.h:1,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfile.h:44,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_p.h:54,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:43:
/usr/include/stdio.h:164:12: note: previous declaration of 'int renameat2(int, const char*, int, const char*, unsigned int)'
 extern int renameat2 (int __oldfd, const char *__old, int __newfd,
            ^~~~~~~~~
/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:115:12: error: 'int statx(int, const char*, int, unsigned int, statx*)' was declared 'extern' and later 'static' [-fpermissive]
 static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
            ^~~~~
In file included from /usr/include/sys/stat.h:446,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/mkspecs/linux-g++/qplatformdefs.h:75,
                 from /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp:42:
/usr/include/bits/statx.h:87:5: note: previous declaration of 'int statx(int, const char*, int, unsigned int, statx*)'
 int statx (int __dirfd, const char *__restrict __path, int __flags,
     ^~~~~
distcc[1030] ERROR: compile /var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1/src/corelib/io/qfilesystemengine_unix.cpp on localhost failed
gmake: *** [Makefile:422: qfilesystemengine_unix.o] Error 1
gmake: *** Waiting for unfinished jobs....
 * ERROR: dev-qt/qtcore-5.11.1-r1::gentoo failed (configure phase):
 *   configure failed
 * 
 * Call stack:
 *     ebuild.sh, line  124:  Called src_configure
 *   environment, line 2799:  Called qt5-build_src_configure
 *   environment, line 2367:  Called qt5_base_configure
 *   environment, line 2476:  Called die
 * The specific snippet of code:
 *       "${S}"/configure "${conf[@]}" || die "configure failed";
 * 
 * If you need support, post the output of `emerge --info '=dev-qt/qtcore-5.11.1-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-qt/qtcore-5.11.1-r1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1'
 * S: '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1'

>>> Failed to emerge dev-qt/qtcore-5.11.1-r1, Log file:

>>>  '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/temp/build.log'

 * Messages for package dev-qt/qtcore-5.11.1-r1:

 * ERROR: dev-qt/qtcore-5.11.1-r1::gentoo failed (configure phase):
 *   configure failed
 * 
 * Call stack:
 *     ebuild.sh, line  124:  Called src_configure
 *   environment, line 2799:  Called qt5-build_src_configure
 *   environment, line 2367:  Called qt5_base_configure
 *   environment, line 2476:  Called die
 * The specific snippet of code:
 *       "${S}"/configure "${conf[@]}" || die "configure failed";
 * 
 * If you need support, post the output of `emerge --info '=dev-qt/qtcore-5.11.1-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-qt/qtcore-5.11.1-r1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1'
 * S: '/var/tmp/portage/dev-qt/qtcore-5.11.1-r1/work/qtbase-everywhere-src-5.11.1'

So the solution was to use the patch version of qtcore-5.11.3-r2 (and so to upgrade all the QT packages) to version 5.11.3

Bonus 2

Here is the https://bugs.gentoo.org/663916
Title: Bug 663916 (glibc-2.28) – [TRACKER] Issues with sys-libs/glibc-2.28 (directly and indirectly)
Depends on:
Bug 146882 – sys-libs/glibc locale generation should be done in src_*() instead of pkg_postinst()
Bug 669206 – app-arch/freeze-2.5.0-r1 : freeze.h:20:33: error: FILE {aka struct _IO_FILE } has no member named _cnt
Bug 669338 – dev-libs/libprelude-4.1.0 : fseeko.c:110:4: error: #error Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib.
Bug 669452 – net-misc/dhcpd-pools-2.21 : fseeko.c:103:4: error: #error Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib.
Bug 669606 – net-p2p/gtk-gnutella-1.1.14 : stats.c:53:8: error: redefinition of struct statx
Bug 669676 – dev-util/idutils-4.6 : fseterr.c:74:3: error: #error Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib.
Bug 669686 – games-action/atanks-6.4-r1 : /…/mathcalls-narrow.h:24:20: error: conflicting declaration of C function float fadd(double, double)
Bug 669742 – sci-mathematics/pspp-0.10.2 : fseterr.c:78:3: error: #error Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib.
Bug 670781 – dev-games/aseprite-1.1.7 : /…/alcompat.h:44:7: error: conflicting declaration of C function fixed fadd(fixed, fixed)
Bug 657404 – sys-libs/glibc-2.27-r3 : file collision with sys-auth/libnss-compat-1.2
Bug 662776 – =sys-apps/systemd-239-r1 fails to build against glibc-2.28: error: redefinition of ‘struct statx_timestamp’
Bug 663242 – sys-apps/findutils fails to build with sys-libs/glibc-2.28
Bug 663924 – =sys-devel/m4-1.4.18: build failure against glibc-2.28: fseeko.c:110:4: error: #error “Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib.”
Bug 663928 – =app-arch/gzip-1.9: build failure against gcc-8/glibc-2.28: cc1: error: -Wabi won’t warn about anything [-Werror=abi]
Bug 663930 – =sys-fs/reiserfsprogs-3.6.27: build failure against glibc-2.28: ../include/misc.h:76:26: error: unknown type name ‘loff_t’; did you mean ‘off_t’?
Bug 664750 – net-dialup/ppp-2.4.7-r6 with sys-libs/glibc-2.28 – pppcrypt.c: undefined reference to `setkey’
Bug 666134 – =sys-libs/glibc-2.28: error: redefinition of ‘struct statx_timestamp’
Bug 666202 – net-mail/dovecot-2.3.2.1 crashes when built with glibc-2.28
Bug 669330 – dev-lang/icon-9.5.1-r1 : fpoll.c:67:9: error: FILE {aka struct _IO_FILE } has no member named _bufp
Bug 669332 – app-misc/ckermit-8.0.211-r4 : ckucmd.c:7118:48: error: FILE {aka struct _IO_FILE } has no member named _cnt
Bug 669334 – app-misc/gcal-4.1 : fseeko.c:110:4: error: #error Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib.
Bug 669336 – sys-auth/oath-toolkit-2.6.2 : fseeko.c:110:4: error: #error Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib.
Bug 669560 – sys-apps/systemd-239-r1 with sys-libs/glibc-2.28 – In file included from ../systemd-239/src/libsystemd/sd-resolve/sd-resolve.c:20: /usr/include/linux/stat.h:18:8: error: redefinition of ‘struct statx_timestamp’
Bug 669594 – app-arch/lbzip2-2.5 : /…/fseterr.c:77:3: error: #error Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib.
Bug 669694 – app-admin/metalog-3-r2 : fseterr.c:77:3: error: #error Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib.
Bug 669846 – sys-boot/systemd-boot-239 : /…/stat.h:18:8: error: redefinition of struct statx_timestamp
Bug 671856 – =sys-fs/udev-239 fails to build against glibc-2.28: error: redefinition of ‘struct statx_timestamp’

Leave a Reply

Your email address will not be published. Required fields are marked *