Bug 161697 - [CMake] Build failure with libstdc++ (>= 6) when cross-compiling (fatal error: stdlib.h: No such file or directory)
Summary: [CMake] Build failure with libstdc++ (>= 6) when cross-compiling (fatal error...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Carlos Alberto Lopez Perez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-09-07 10:12 PDT by Carlos Alberto Lopez Perez
Modified: 2022-03-02 07:05 PST (History)
18 users (show)

See Also:


Attachments
Patch (3.13 KB, patch)
2016-09-08 09:05 PDT, Carlos Alberto Lopez Perez
no flags Details | Formatted Diff | Diff
Patch (1.67 KB, patch)
2022-03-01 03:26 PST, Adrian Perez
no flags Details | Formatted Diff | Diff
Patch (1.71 KB, patch)
2022-03-02 04:48 PST, Adrian Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Alberto Lopez Perez 2016-09-07 10:12:20 PDT
Trying to build WebKitGTK+ with GCC 6 I got this error:

In file included from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/ext/string_conversions.h:41:0,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/bits/basic_string.h:5402,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/string:52,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/debug.h:14,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/mathutil.h:12,
                 from /home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/work/i586-oe-linux/webkitgtk/2.12.5-r0/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/mathutil.cpp:9:
/home/igalia/clopez/yocto/commit-builds/meta-webkit/builds/qemux86-64/tmp-glibc/sysroots/qemux86/usr/include/c++/6.2.0/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>

The issue seems to be that GCC 6 has now introduced stdlib.h in libstdc++ for better compliance and its including the C library stdlib.h using include_next which is sensitive to order of system header include paths. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129

The recommended way to fix this is to stop adding include directories as system ones (-isystem) and instead use the standard way to include directories (-I)

The openembedded project is carrying this downstream patch against WebKitGTK+ 2.12 with the above fix: http://git.openembedded.org/openembedded-core/tree/meta/recipes-sato/webkit/files/0001-WebKitMacros-Append-to-I-and-not-to-isystem.patch


Seems that we started using -isystem on r185806 <http://trac.webkit.org/r185806> as a way to silence warnings.
Comment 1 Carlos Alberto Lopez Perez 2016-09-07 10:44:53 PDT
So my understandings is that we need to either:

 Option 1: Obtain the list of default system includes and put it as first option when using include_directories(SYSTEM and target_include_directories(...SYTEM

 Option 2: Stop using the SYSTEM modifier on include_directories( and target_include_directories and live with the extra warnings.


I don't know how to do option 1. I was unable so far to find a CMake variable with this info.
Comment 2 Michael Catanzaro 2016-09-07 11:07:51 PDT
(In reply to comment #1)
> So my understandings is that we need to either:
> 
>  Option 1: Obtain the list of default system includes and put it as first
> option when using include_directories(SYSTEM and
> target_include_directories(...SYTEM
> 
>  Option 2: Stop using the SYSTEM modifier on include_directories( and
> target_include_directories and live with the extra warnings.
> 
> 
> I don't know how to do option 1. I was unable so far to find a CMake
> variable with this info.

I would be OK with option 1, but I don't know how to do it either.

I don't want to do option 2 unless we have some other way to silence warnings from system headers outside our control. As far as I know, passing SYSTEM to include_directories is the recommended way to do so; I don't know what else we could do to accomplish that, and I do not want to live with the warnings.

FWIW I've been building WebKit with GCC/libstdc++ 6 for months without issue, so GCC 6 isn't the only factor here.

(In reply to comment #0) 
> Seems that we started using -isystem on r185806
> <http://trac.webkit.org/r185806> as a way to silence warnings.

We've used it for slightly longer than that; that commit was a follow-up because I forgot about the Tools directory. :)
Comment 3 Michael Catanzaro 2016-09-07 11:18:09 PDT
I'm curious (a) what cmake version you have, and (b) what linker flags are getting passed to that file?

In Fedora with CMake 3.5.2, it looks like this:

[  1%] Building CXX object Source/WebCore/CMakeFiles/ANGLESupport.dir/__/ThirdParty/ANGLE/src/common/angleutils.cpp.o
cd /builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/Source/WebCore && /usr/bin/c++   -DBUILDING_GTK__=1 -DBUILDING_WEBKIT -DBUILDING_WITH_CMAKE=1 -DDATA_DIR=\"share\" -DGETTEXT_PACKAGE=\"WebKit2GTK-4.0\" -DHAVE_CONFIG_H=1 -DUSER_AGENT_GTK_MAJOR_VERSION=\"602\" -DUSER_AGENT_GTK_MINOR_VERSION=\"1\" -DWEBKITGTK_API_VERSION_STRING=\"4.0\" -DWEBKIT_DOM_USE_UNSTABLE_API -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/airplay -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/battery -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/encryptedmedia -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/fetch -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/geolocation -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/indexeddb -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/indexeddb/client -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/indexeddb/server -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/indexeddb/shared -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/indieui -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/mediacontrols -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/mediasession -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/mediasource -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/mediastream -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/navigatorcontentutils -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/notifications -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/plugins -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/proximity -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/quota -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/speech -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/streams -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/vibration -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/webaudio -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/webdatabase -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/Modules/websockets -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/accessibility -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bindings -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bindings/generic -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bindings/js -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bridge -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bridge/c -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bridge/jsc -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/contentextensions -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/crypto -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/crypto/algorithms -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/crypto/keys -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/crypto/parameters -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/css -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/cssjit -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/dom -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/dom/default -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/editing -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/fileapi -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/history -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html/canvas -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html/forms -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html/parser -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html/shadow -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/html/track -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/inspector -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader/appcache -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader/archive -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader/archive/mhtml -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader/cache -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/loader/icon -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/mathml -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/page -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/page/animation -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/page/csp -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/page/scrolling -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/animation -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/audio -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/cpu/arm -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/cpu/arm/filters -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/displaylists -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/filters -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/harfbuzz -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/harfbuzz/ng -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/opentype -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/transforms -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/mediastream -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/mock -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/mock/mediasource -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/network -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/sql -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/text -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/text/icu -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/plugins -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering/line -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering/mathml -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering/shapes -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering/style -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/rendering/svg -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/replay -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/storage -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/style -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/svg -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/svg/animation -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/svg/graphics -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/svg/graphics/filters -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/svg/properties -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/websockets -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/workers -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/xml -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/xml/parser -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources/ForwardingHeaders -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources/WebCore -I/builddir/build/BUILD/webkitgtk-2.12.5/Source -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/gpu -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/mediastream/openwebrtc -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/gstreamer -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/audio/gstreamer -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/bmp -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/gif -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/ico -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/jpeg -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/png -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/image-decoders/webp -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/linux -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/texmap -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources/JavaScriptCore -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources/JavaScriptCore/inspector -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/ForwardingHeaders -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/API -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/assembler -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/bytecode -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/bytecompiler -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/dfg -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/disassembler -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/heap -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/debugger -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/interpreter -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/jit -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/llint -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/parser -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/profiler -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/runtime -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/JavaScriptCore/yarr -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/ThirdParty/ANGLE -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/include/KHR -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/accessibility/atk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/editing/atk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/page/gtk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/cairo -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/geoclue -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/gtk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/cairo -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/egl -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/glx -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/gtk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/freetype -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/opengl -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/wayland -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/graphics/x11 -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/network/gtk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/network/soup -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/platform/text/gtk -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WTF -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/bindings/gobject -I/builddir/build/BUILD/webkitgtk-2.12.5/x86_64-redhat-linux-gnu/DerivedSources/webkitdom -isystem /usr/include/gstreamer-1.0 -isystem /usr/lib64/gstreamer-1.0/include -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/atk-1.0 -isystem /usr/include/cairo -isystem /usr/include/enchant -isystem /usr/include/freetype2/freetype -isystem /usr/include/freetype2 -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/harfbuzz -isystem /usr/include/libsecret-1 -isystem /usr/include/libsoup-2.4 -isystem /usr/include/libxml2 -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/WebCore/testing -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/include -I/builddir/build/BUILD/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -DUSER_AGENT_GTK_DISTRIBUTOR_NAME='"Fedora"'  -std=c++11 -DNDEBUG -fno-exceptions -fno-strict-aliasing -fno-rtti   -fPIC  -o CMakeFiles/ANGLESupport.dir/__/ThirdParty/ANGLE/src/common/angleutils.cpp.o -c /builddir/build/BUILD/webkitgtk-2.12.5/Source/ThirdParty/ANGLE/src/common/angleutils.cpp

And that works.
Comment 4 Carlos Alberto Lopez Perez 2016-09-07 14:28:39 PDT
(In reply to comment #3)
> I'm curious (a) what cmake version you have, and (b) what linker flags are
> getting passed to that file?

This is a clean build log with -j1: http://sprunge.us/LbIg
Comment 5 Carlos Alberto Lopez Perez 2016-09-07 14:42:07 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > I'm curious (a) what cmake version you have, and (b) what linker flags are
> > getting passed to that file?
> 
> This is a clean build log with -j1: http://sprunge.us/LbIg

The problem seems to be adding -isystem $DEFAULTINCLUDEPATH before the others -isystems. Removing that one it builds.

Also It don't matters the order, it fails awalys if i put it after, in the middle or before the others -isystem parameters. It only builds when the "-isystem $DEFAULTINCLUDEPATH" is removed... strange.
Comment 6 Michael Catanzaro 2016-09-07 14:47:11 PDT
(In reply to comment #5)
> The problem seems to be adding -isystem $DEFAULTINCLUDEPATH before the
> others -isystems. Removing that one it builds.

It's what I suspected, so the question now is: why is it happening? Or rather: why ISN'T it happening with /usr/include, when surely many pkg-config files put /usr/include in their CFLAGS? Is /usr/include being stripped out by pkg-config, or by CMake?

This might be a tough issue. :(
Comment 7 Carlos Alberto Lopez Perez 2016-09-07 14:50:31 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > I'm curious (a) what cmake version you have, and (b) what linker flags are
> > > getting passed to that file?
> > 
> > This is a clean build log with -j1: http://sprunge.us/LbIg
> 
> The problem seems to be adding -isystem $DEFAULTINCLUDEPATH before the
> others -isystems. Removing that one it builds.
> 
> Also It don't matters the order, it fails awalys if i put it after, in the
> middle or before the others -isystem parameters. It only builds when the
> "-isystem $DEFAULTINCLUDEPATH" is removed... strange.

Yes, the issue is specifically adding -isystem $DEFAULTINCLUDEPATH

Explanation here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=823145#25
Comment 8 Carlos Alberto Lopez Perez 2016-09-07 15:24:16 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > The problem seems to be adding -isystem $DEFAULTINCLUDEPATH before the
> > others -isystems. Removing that one it builds.
> 
> It's what I suspected, so the question now is: why is it happening? Or
> rather: why ISN'T it happening with /usr/include, when surely many
> pkg-config files put /usr/include in their CFLAGS? Is /usr/include being
> stripped out by pkg-config, or by CMake?
> 
> This might be a tough issue. :(

Seems that CMake ignores some directories on the include_directories list when passing the -I/-isystem arguments to the compiler. /usr/include is one of this directories
That explains why is working on the 99% of the cases, but this is broken when cross-compiling or when using a non default system include path.

The list of directories to remove is defined on the CMakes variables CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES and CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES.

So I understand that if we find a way of getting the default include directory, is a matter of appending it to this variables.

However this feels like we are work-arounding the bugs of others (GCC: i'm looking at you)

More info at https://public.kitware.com/Bug/view.php?id=8598 and CMake commits 39f8b91, cb788e8 and 8c3290b
Comment 9 Michael Catanzaro 2016-09-07 15:58:09 PDT
(In reply to comment #8)
> So I understand that if we find a way of getting the default include
> directory, is a matter of appending it to this variables.

That should probably be done by CMake itself.
Comment 10 Khem Raj 2016-09-07 16:03:16 PDT
you can also look at setting CMAKE_NO_SYSTEM_FROM_IMPORTED=1
which will set NO_SYSTEM_FROM_IMPORTED as explained here

https://cmake.org/cmake/help/v3.5/prop_tgt/NO_SYSTEM_FROM_IMPORTED.html#prop_tgt:NO_SYSTEM_FROM_IMPORTED
Comment 11 Carlos Alberto Lopez Perez 2016-09-07 20:10:08 PDT
(In reply to comment #10)
> you can also look at setting CMAKE_NO_SYSTEM_FROM_IMPORTED=1
> which will set NO_SYSTEM_FROM_IMPORTED as explained here
> 
> https://cmake.org/cmake/help/v3.5/prop_tgt/NO_SYSTEM_FROM_IMPORTED.
> html#prop_tgt:NO_SYSTEM_FROM_IMPORTED

Not sure how this will work. The idea is to keep using -isystem for headers included from outside of webkit (like third party libraries) to avoid the noise produced by the warnings of some of this libraries (specially verbose with clang sometimes)...

But, I think I found a way of getting the list of default system include directories from GCC, so then I can append them to CMAKE_C/CXX_IMPLICIT_INCLUDE_DIRECTORIES. I will upload a patch soon if all the tests i'm doing with it end being successful.
Comment 12 Carlos Alberto Lopez Perez 2016-09-08 09:05:21 PDT
Created attachment 288270 [details]
Patch
Comment 13 Michael Catanzaro 2016-09-08 12:27:15 PDT
Comment on attachment 288270 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=288270&action=review

I'm OK with this on one condition: we should take the time to file a bug report with the CMake developers. They will probably want to handle this automatically at the CMake level. If not, they should have some suggestion to us for a better way to handle this.

> Source/cmake/OptionsCommon.cmake:48
> +    execute_process(COMMAND ${_compiler} ${_buildFlags} -v -E -x ${_lang} -dD dummy
> +                  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles OUTPUT_QUIET
> +                  ERROR_VARIABLE _gccOutput)

I'm surprised this passed CMake style check; these lines should all be aligned.
Comment 14 Carlos Alberto Lopez Perez 2016-09-08 13:00:03 PDT
(In reply to comment #13)
> Comment on attachment 288270 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=288270&action=review
> 
> I'm OK with this on one condition: we should take the time to file a bug
> report with the CMake developers. They will probably want to handle this
> automatically at the CMake level. If not, they should have some suggestion
> to us for a better way to handle this.
> 

Why do you think this is a CMake bug? I think the ones that should really fix this are GCC developers. They have introduced a breaking change for no good reason (I don't buy the "slowing everything" argument) and they don't seem to care.

Other compilers (clang) and older versions of GCC cope just fine with this.
Comment 15 Michael Catanzaro 2016-09-08 13:08:52 PDT
(In reply to comment #14) 
> Why do you think this is a CMake bug?

Because they have code that exists to deal with this issue, it just assumes that /usr/include is the default include path. Let's at least see what they have to say about it. We already know libstdc++ isn't going to change.
Comment 16 Carlos Alberto Lopez Perez 2016-09-08 15:52:46 PDT
(In reply to comment #15)
> (In reply to comment #14) 
> > Why do you think this is a CMake bug?
> 
> Because they have code that exists to deal with this issue, it just assumes
> that /usr/include is the default include path. Let's at least see what they
> have to say about it. We already know libstdc++ isn't going to change.

Ok.

I'm first going to commit this and then open the bug on CMake tracker, so I can point to the commit url to show the code as example.
Comment 17 Carlos Alberto Lopez Perez 2016-09-08 15:56:57 PDT
Committed r205672: <http://trac.webkit.org/changeset/205672>
Comment 18 Carlos Alberto Lopez Perez 2016-09-08 16:12:15 PDT
Comment on attachment 288270 [details]
Patch

Clearing flags on attachment.
Comment 19 Carlos Alberto Lopez Perez 2016-09-08 16:13:30 PDT
Reported bug to CMake developers here: https://gitlab.kitware.com/cmake/cmake/issues/16291
Comment 20 Carlos Alberto Lopez Perez 2016-12-07 12:19:33 PST
This is also an issue when using clang with libstdc++ http://lists.openembedded.org/pipermail/openembedded-core/2016-December/129617.html
Comment 21 Aleix Pol 2017-03-11 03:30:55 PST
Hi,
This is also an issue when compiling QtWebKit.
Comment 22 Aleix Pol 2017-03-11 03:31:06 PST
Hi,
This is also an issue when compiling QtWebKit.
https://lists.freedesktop.org/archives/xdg-app/2017-March/000600.html
Comment 23 Michael Catanzaro 2017-03-11 10:38:52 PST
QtWebKit was deleted from the WebKit project over four years ago. Report bugs to the Qt project if you are using their official deprecated and insecure QtWebKit, or to https://github.com/annulen/webkit if you are using Konstantin's fork, as I would recommend.

It is an extremely serious security problem if the Freedesktop Flatpak runtime includes the QtWebKit provided by the Qt project. It is affected by over 200 known security vulnerabilities, most of which could allow for remote code execution. You should complain about this on the Flatpak mailing list. "Still getting security updates from the Yocto project" indicates that there may be a serious misunderstanding somewhere along the line.
Comment 24 Michael Catanzaro 2017-03-11 11:09:14 PST
Aaaah, I misunderstood, I didn't realize you were maintaining the KDE runtime.

I would definitely recommend switching to Konstantin's fork of QtWebKit. I imagine he must have already found some solution to this issue.
Comment 25 Konstantin Tokarev 2018-01-08 17:53:11 PST
This patch breaks on localized systems, because "search starts here" and "End of (search) list" are translated
Comment 26 Michael Catanzaro 2018-01-08 19:51:29 PST
Easy fix would be 'env LANG=C gcc ...'
Comment 27 Adrian Perez 2022-03-01 03:26:37 PST
Created attachment 453484 [details]
Patch
Comment 28 EWS 2022-03-01 04:54:14 PST
Committed r290641 (247914@main): <https://commits.webkit.org/247914@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453484 [details].
Comment 29 Radar WebKit Bug Importer 2022-03-01 04:55:17 PST
<rdar://problem/89613152>
Comment 30 Adrian Perez 2022-03-02 04:42:38 PST
Comment on attachment 453484 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=453484&action=review

> Source/cmake/WebKitCompilerFlags.cmake:281
> +    execute_process(COMMAND env LANG=C ${_compiler} ${_buildFlags} -v -E -x ${_lang} -dD dummy

Probably this should have been “${CMAKE_COMMAND} -E env LANG=C” for the sake
of portability 🤔️ — I'll submit a follow-up.
Comment 31 Adrian Perez 2022-03-02 04:44:54 PST
Let's change plain “env” to “cmake -E” :)
Comment 32 Adrian Perez 2022-03-02 04:48:12 PST
Created attachment 453589 [details]
Patch
Comment 33 EWS 2022-03-02 07:05:25 PST
Committed r290727 (247974@main): <https://commits.webkit.org/247974@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453589 [details].