Skip to contentSkip to conversation

cmake: add CMAKE_SYSROOT to generated toolchain file

PATCH In review Pascal Bach 3 participants 13 messages Aug 24, 2018 – Sep 28, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmake: add CMAKE_SYSROOT to generated toolchain file

This already got fixed in the toolchain file that is used during development
in https://github.com/openembedded/openembedded-core/commit/cb42802f2fe1760f894a435b07286bca3a220364

The toolchain file generated by the cmake.bbclass however does not set CMAKE_SYSROOT. Under certain circumstances this also leads to the error:
"stdlib.h: No such file or directory #include_next <stdlib.h>" during the build of a recipe.

An example where this accured was during the upgrade of the Apache Thrift recipe in meta-openembedded to 0.11.0. With this change the build works out of the box.

CMAKE_SYSROOT must only be set when crosscompiling, otherwise it will interfere with the native compiler headers.

---
 meta/classes/cmake.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/cmake.bbclass +5 -0
index fd40a9863e..251ddd9afe 100644
@@ -64,9 +64,12 @@ def map_target_arch_to_uname_arch(target_arch):
         return "ppc64"
     return target_arch
 
+
 cmake_do_generate_toolchain_file() {
 	if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
 		cmake_crosscompiling="set( CMAKE_CROSSCOMPILING FALSE )"
+	else
+		cmake_sysroot="set( CMAKE_SYSROOT \"${RECIPE_SYSROOT}\" )"
 	fi
 	cat > ${WORKDIR}/toolchain.cmake <<EOF
 # CMake system name must be something like "Linux".
@@ -95,6 +98,8 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
 
+$cmake_sysroot
+
 # Use qt.conf settings
 set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
 
Signature · 1 line
2.11.0
Tested-by on v1 1/1
#1 lore raw
Quoted 38 lines · Pascal Bach

This already got fixed in the toolchain file that is used during development
in https://github.com/openembedded/openembedded-core/commit/cb42802f2fe1760f894a435b07286bca3a220364

The toolchain file generated by the cmake.bbclass however does not set CMAKE_SYSROOT. Under certain circumstances this also leads to the error:
"stdlib.h: No such file or directory #include_next <stdlib.h>" during the build of a recipe.

An example where this accured was during the upgrade of the Apache Thrift recipe in meta-openembedded to 0.11.0. With this change the build works out of the box.

CMAKE_SYSROOT must only be set when crosscompiling, otherwise it will interfere with the native compiler headers.

---
 meta/classes/cmake.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/cmake.bbclass +3 -0
index fd40a9863e..251ddd9afe 100644
@@ -64,9 +64,12 @@ def map_target_arch_to_uname_arch(target_arch):
         return "ppc64"
     return target_arch
 
+
 cmake_do_generate_toolchain_file() {
 	if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
 		cmake_crosscompiling="set( CMAKE_CROSSCOMPILING FALSE )"
+	else
+		cmake_sysroot="set( CMAKE_SYSROOT \"${RECIPE_SYSROOT}\" )"
 	fi
 	cat > ${WORKDIR}/toolchain.cmake <<EOF
 # CMake system name must be something like "Linux".

meta/classes/cmake.bbclass set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} ) · line 104

Quoted 7 lines
meta/classes/cmake.bbclass +2 -0
@@ -95,6 +98,8 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
 
+$cmake_sysroot
+
 # Use qt.conf settings
 set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )

Fixes problems which we have also seen on sumo branch. Thanks for this!

#2 lore raw
Quoted 1 line

Fixes problems which we have also seen on sumo branch. Thanks for this!

Sorry, spoke too soon. This fixes compilation on a few recipes in my tree but there are still lots failures with the same error message. We had a hacky patch to cmake as a workaround but that too causes some problems:

Modules/Compiler/GNU.cmake +1 -1
@@ -45,7 +45,7 @@
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
   set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
   if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4) # work around #4462
-    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-I ")
   endif()
 
   set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)

I wonder what the real fix could be...

-Mikko

#3 lore raw
Quoted 6 lines
Quoted 2 lines

Fixes problems which we have also seen on sumo branch. Thanks for this!

Sorry, spoke too soon. This fixes compilation on a few recipes in my tree but there are still lots failures with the same error message. We had a hacky patch to cmake as a workaround but that too causes some problems:

I have not yet figured out what CMake based projects are affected and why. The error seems to happen only for certain projects.

Quoted 17 lines
Modules/Compiler/GNU.cmake +0 -0
@@ -45,7 +45,7 @@
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE

"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS
4) # work around #4462

Modules/Compiler/GNU.cmake +1 -1
-    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-I ")
   endif()
 
   set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
Quoted 2 lines

I wonder what the real fix could be...

This looks similar to another workaround I saw.
Setting CMAKE_NO_SYSTEM_FROM_IMPORTED to True. I'm also not sure what the real fix is. The issue is also discussed here: https://gitlab.kitware.com/cmake/cmake/issues/16291

Pascal

#4 lore raw
Quoted 28 lines · Pascal
Quoted 4 lines
Quoted 2 lines

Fixes problems which we have also seen on sumo branch. Thanks for this!

Sorry, spoke too soon. This fixes compilation on a few recipes in my

tree but

Quoted 2 lines

there are still lots failures with the same error message. We had a hacky patch to cmake as a workaround but that too causes some problems:

I have not yet figured out what CMake based projects are affected and why. The error seems to happen only for certain projects.

Quoted 17 lines
Modules/Compiler/GNU.cmake +0 -0
@@ -45,7 +45,7 @@
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE

"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS
4) # work around #4462

Modules/Compiler/GNU.cmake +1 -1
-    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-I ")
   endif()
 
   set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
Quoted 9 lines
Quoted 2 lines

I wonder what the real fix could be...

This looks similar to another workaround I saw.
Setting CMAKE_NO_SYSTEM_FROM_IMPORTED to True. I'm also not sure what the real fix is.
The issue is also discussed here:
https://gitlab.kitware.com/cmake/cmake/issues/16291

IIRC this was a defect in cmake

Quoted 8 lines

Pascal
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#5 lore raw
In reply to Bach, Pascal
Quoted 9 lines · Pascal
Quoted 6 lines
Quoted 2 lines

Fixes problems which we have also seen on sumo branch. Thanks for this!

Sorry, spoke too soon. This fixes compilation on a few recipes in my tree but there are still lots failures with the same error message. We had a hacky patch to cmake as a workaround but that too causes some problems:

I have not yet figured out what CMake based projects are affected and why. The error seems to happen only for certain projects.

In our case it looks like a library is adding target_include_directories() with SYSTEM keyword in its cmake module. Everyone who includes the cmake module fails to build. This repeats with a handful of cmake modules and causes all of their dependencies to fail build with errors like:

.../recipe-sysroot/usr/include/c++/7.3.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory

|  #include_next <stdlib.h>
|                ^~~~~~~~~~
| compilation terminated.

or

| cc1plus: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
...
.../recipe-sysroot/usr/include/stdlib.h:133:35: error: missing binary operator before token
"("
| #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
| ^

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

Quoted 15 lines
Quoted 15 lines
Modules/Compiler/GNU.cmake +0 -0
@@ -45,7 +45,7 @@
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE

"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS
4) # work around #4462

Modules/Compiler/GNU.cmake +1 -1
-    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-I ")
   endif()
Quoted 8 lines
Quoted 4 lines
   set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)

I wonder what the real fix could be...

This looks similar to another workaround I saw.
Setting CMAKE_NO_SYSTEM_FROM_IMPORTED to True. I'm also not sure what the real fix is. The issue is also discussed here: https://gitlab.kitware.com/cmake/cmake/issues/16291

Thanks for the ticket link.

-Mikko

#6 lore raw
Quoted 38 lines · On Fri, Aug 24, 2018 at 8:48 AM <[email protected]> wrote:
Quoted 2 lines · Pascal
Quoted 2 lines
Quoted 2 lines

Fixes problems which we have also seen on sumo branch. Thanks for

this!

Quoted 2 lines
Quoted 2 lines

Sorry, spoke too soon. This fixes compilation on a few recipes in my

tree but

Quoted 1 line
Quoted 1 line

there are still lots failures with the same error message. We had a

hacky

Quoted 3 lines
Quoted 1 line

patch to cmake as a workaround but that too causes some problems:

I have not yet figured out what CMake based projects are affected and

why.

Quoted 1 line

The error seems to happen only for certain projects.

In our case it looks like a library is adding target_include_directories() with SYSTEM keyword in its cmake module. Everyone who includes the cmake module
fails to build. This repeats with a handful of cmake modules and causes all of their dependencies to fail build with errors like:

.../recipe-sysroot/usr/include/c++/7.3.0/cstdlib:75:15: fatal error:
stdlib.h: No such file or directory

|  #include_next <stdlib.h>
|                ^~~~~~~~~~
| compilation terminated.

or

| cc1plus: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
...
.../recipe-sysroot/usr/include/stdlib.h:133:35: error: missing binary operator before token
"("
| #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
| ^

Quoted 6 lines

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

That’s right there is a patch I did in WebKitgtk recipe in Oe Core you might want to include similar fixes for this package the patch actually it a workaround but then I also think using isystem in apps is a bad idea

Quoted 36 lines
Quoted 16 lines
Quoted 16 lines
Modules/Compiler/GNU.cmake +0 -0
@@ -45,7 +45,7 @@
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE

"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
"<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
if(NOT APPLE OR NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS
4) # work around #4462

Modules/Compiler/GNU.cmake +1 -1
-    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+    set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-I ")
   endif()
Quoted 7 lines
Quoted 4 lines
   set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)

I wonder what the real fix could be...

This looks similar to another workaround I saw.
Setting CMAKE_NO_SYSTEM_FROM_IMPORTED to True. I'm also not sure what

the real fix is.

Quoted 1 line

The issue is also discussed here:

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

Thanks for the ticket link.

-Mikko
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#7 lore raw
Quoted 11 lines · Khem Raj
Quoted 6 lines · On Fri, Aug 24, 2018 at 8:48 AM <[email protected]> wrote:

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

That’s right there is a patch I did in WebKitgtk recipe in Oe Core you might want to include similar fixes for this package the patch actually it a workaround but then I also think using isystem in apps is a bad idea

Yes, I tend to agree, but developers have used this to silence compiler warnings from system header files.

In a few cases I saw that there were no longer any warnings coming from the headers but in some others there were.

Any other ideas how to suppress compiler wanings from system headers?

-Mikko

#8 lore raw
Quoted 14 lines · On Fri, Aug 24, 2018 at 9:17 AM <[email protected]> wrote:
Quoted 11 lines · Khem Raj
Quoted 6 lines · On Fri, Aug 24, 2018 at 8:48 AM <[email protected]> wrote:

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

That’s right there is a patch I did in WebKitgtk recipe in Oe Core you might want to include similar fixes for this package the patch actually it a workaround but then I also think using isystem in apps is a bad idea

Quoted 6 lines

Yes, I tend to agree, but developers have used this to silence compiler warnings from system header files.

In a few cases I saw that there were no longer any warnings coming from the headers but in some others there were.

Unlike olden days, cross gcc compiler now a days knows about its system headers and adds them implicitly with right options so doing this include dance manually is not useful. Let compiler decide to do the needed
for system headers, one must just specify --sysroot and let it handle everything from sysroot.

Quoted 2 lines

Any other ideas how to suppress compiler wanings from system headers?

what kind of warnings do you see ?

Quoted 1 line

-Mikko

#9 lore raw
Quoted 29 lines · Khem Raj
Quoted 14 lines · On Fri, Aug 24, 2018 at 9:17 AM <[email protected]> wrote:
Quoted 11 lines · Khem Raj
Quoted 6 lines · On Fri, Aug 24, 2018 at 8:48 AM <[email protected]> wrote:

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

That’s right there is a patch I did in WebKitgtk recipe in Oe Core you might want to include similar fixes for this package the patch actually it a workaround but then I also think using isystem in apps is a bad idea

Quoted 6 lines

Yes, I tend to agree, but developers have used this to silence compiler warnings from system header files.

In a few cases I saw that there were no longer any warnings coming from the headers but in some others there were.

Unlike olden days, cross gcc compiler now a days knows about its system headers and adds them implicitly with right options so doing this include dance manually is not useful. Let compiler decide to do the needed
for system headers, one must just specify --sysroot and let it handle everything from sysroot.

Quoted 4 lines
Quoted 2 lines

Any other ideas how to suppress compiler wanings from system headers?

what kind of warnings do you see ?

After a ton of components have exported their headers to system paths, I see all kinds of crap. Some developers have cleaned up their own tree and added strict compiler flags, which I now have to relax since header file warning suppressions don't work, and new compiler produces new bunch of warnings. Here are few sample warnings from an ongoing build with counts redacted:

$ egrep -ho "warning: .*" tmp-glibc/work/*/*/*/temp/log.do_compile| sort | uniq -c|sort -rn | head -8

warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
warning: conversion to 'int' from 'long unsigned int' may alter its value [-Wconversion]
warning: missed loop optimization, the loop counter may overflow [-Wunsafe-loop-optimizations]
warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C
warning: this statement may fall through [-Wimplicit-fallthrough=]
warning: ISO C++ forbids zero-size array 'f_handle' [-Wpedantic]

-Mikko

#10 lore raw
Quoted 45 lines · On Fri, Aug 24, 2018 at 9:41 AM <[email protected]> wrote:
Quoted 29 lines · Khem Raj
Quoted 14 lines · On Fri, Aug 24, 2018 at 9:17 AM <[email protected]> wrote:
Quoted 11 lines · Khem Raj
Quoted 6 lines · On Fri, Aug 24, 2018 at 8:48 AM <[email protected]> wrote:

So to me it looks like using SYSTEM with target_include_directories() is no longer possible with CMake and gcc > 6:

https://cmake.org/cmake/help/v3.10/command/target_include_directories.html?highlight=target_include_directories

That’s right there is a patch I did in WebKitgtk recipe in Oe Core you might want to include similar fixes for this package the patch actually it a workaround but then I also think using isystem in apps is a bad idea

Quoted 6 lines

Yes, I tend to agree, but developers have used this to silence compiler warnings from system header files.

In a few cases I saw that there were no longer any warnings coming from the headers but in some others there were.

Unlike olden days, cross gcc compiler now a days knows about its system headers and adds them implicitly with right options so doing this include dance manually is not useful. Let compiler decide to do the needed
for system headers, one must just specify --sysroot and let it handle everything from sysroot.

Quoted 4 lines
Quoted 2 lines

Any other ideas how to suppress compiler wanings from system headers?

what kind of warnings do you see ?

After a ton of components have exported their headers to system paths, I see all kinds of crap. Some developers have cleaned up their own tree and added strict compiler flags, which I now have to relax since header file warning suppressions don't work, and new compiler produces new bunch of warnings. Here are few sample warnings from an ongoing build with counts redacted:

$ egrep -ho "warning: .*" tmp-glibc/work/*/*/*/temp/log.do_compile| sort | uniq -c|sort -rn | head -8
Quoted 8 lines

warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
warning: conversion to 'int' from 'long unsigned int' may alter its value [-Wconversion]
warning: missed loop optimization, the loop counter may overflow [-Wunsafe-loop-optimizations]
warning: command line option '-std=c++11' is valid for C++/ObjC++ but not for C
warning: this statement may fall through [-Wimplicit-fallthrough=]
warning: ISO C++ forbids zero-size array 'f_handle' [-Wpedantic]

Perhaps you can just remove adding these system headers at all and let compiler include
them for you

Quoted 1 line

-Mikko

#11 lore raw
In reply to Pascal Bach

since it was staged in oe-core/master-next, it got into my testing queue and is causing several recipes FTBFS

see

http://errors.yoctoproject.org/Errors/Build/66877/

Quoted 55 lines · Pascal Bach

This already got fixed in the toolchain file that is used during development
in https://github.com/openembedded/openembedded-core/commit/cb42802f2fe1760f894a435b07286bca3a220364

The toolchain file generated by the cmake.bbclass however does not set CMAKE_SYSROOT. Under certain circumstances this also leads to the error:
"stdlib.h: No such file or directory #include_next <stdlib.h>" during the build of a recipe.

An example where this accured was during the upgrade of the Apache Thrift recipe in meta-openembedded to 0.11.0. With this change the build works out of the box.

CMAKE_SYSROOT must only be set when crosscompiling, otherwise it will interfere with the native compiler headers.

---
 meta/classes/cmake.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/cmake.bbclass +5 -1
index fd40a9863e..251ddd9afe 100644
@@ -64,9 +64,12 @@ def map_target_arch_to_uname_arch(target_arch):
         return "ppc64"
     return target_arch
 
+
 cmake_do_generate_toolchain_file() {
        if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
                cmake_crosscompiling="set( CMAKE_CROSSCOMPILING FALSE )"
+       else
+               cmake_sysroot="set( CMAKE_SYSROOT \"${RECIPE_SYSROOT}\" )"
        fi
        cat > ${WORKDIR}/toolchain.cmake <<EOF
 # CMake system name must be something like "Linux".
@@ -95,6 +98,8 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
 
+$cmake_sysroot
+
 # Use qt.conf settings
 set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
 
--

2.11.0

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#12 lore raw
Quoted 6 lines

since it was staged in oe-core/master-next, it got into my testing queue and is causing several recipes FTBFS

see

http://errors.yoctoproject.org/Errors/Build/66877/

I did some digging and it seems all of these failures are related.

Each of them is adding the host path /usr/include somewhere which should not be the case when cross compiling.
GCC even detects this and issues warnings: cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]

CMake has some magic inside that removes "implicit include" paths. By default this is set to "/urs/include" as this makes sense when doing non cross compilation.

Setting CMAKE_SYSROOT changes this as the "implicit include" paths are now re rooted to CMAKE_SYSROOT. This leads to CMake no longer considering /usr/include a special path and thus it is no longer removed.

In my opinion this is an issue with the recipes that failed. I already found how to fix it for wireshark and I will try to fix the others too, then I will send an updated patchset.

Pascal

Quoted 62 lines
Quoted 4 lines · Pascal Bach

This already got fixed in the toolchain file that is used during development in
https://github.com/openembedded/openembedded-

core/commit/cb42802f2fe17

Quoted 24 lines

60f894a435b07286bca3a220364

The toolchain file generated by the cmake.bbclass however does not set CMAKE_SYSROOT. Under certain circumstances this also leads to the error:
"stdlib.h: No such file or directory #include_next <stdlib.h>" during the build of a recipe.

An example where this accured was during the upgrade of the Apache Thrift recipe in meta-openembedded to 0.11.0. With this change the build works out of the box.

CMAKE_SYSROOT must only be set when crosscompiling, otherwise it will interfere with the native compiler headers.

---
 meta/classes/cmake.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/cmake.bbclass +0 -0
index fd40a9863e..251ddd9afe 100644

meta/classes/cmake.bbclass def map_target_arch_to_uname_arch(target_arch): · line 72

Quoted 9 lines
meta/classes/cmake.bbclass +3 -0
@@ -64,9 +64,12 @@ def map_target_arch_to_uname_arch(target_arch):
         return "ppc64"
     return target_arch
 
+
 cmake_do_generate_toolchain_file() {
        if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
                cmake_crosscompiling="set( CMAKE_CROSSCOMPILING FALSE )"
+       else
+               cmake_sysroot="set( CMAKE_SYSROOT \"${RECIPE_SYSROOT}\"

)"

Quoted 21 lines
meta/classes/cmake.bbclass +0 -0
        fi
        cat > ${WORKDIR}/toolchain.cmake <<EOF  # CMake system name

must be something like "Linux".

meta/classes/cmake.bbclass +0 -0
@@ -95,6 +98,8 @@ set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM

${OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM} ) set(
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) set(
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

+$cmake_sysroot
+
# Use qt.conf settings
set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )

--
2.11.0

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core