[OE-core] [PATCH] cmake: add CMAKE_SYSROOT to generated toolchain file

Bach, Pascal pascal.bach at siemens.com
Fri Sep 28 13:03:40 UTC 2018


> 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

> On Fri, Aug 24, 2018 at 5:34 AM Pascal Bach <pascal.bach at siemens.com>
> wrote:
> >
> > This already got fixed in the toolchain file that is used during
> > development in
> > https://github.com/openembedded/openembedded-
> core/commit/cb42802f2fe17
> > 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.
> >
> > Signed-off-by: Pascal Bach <pascal.bach at siemens.com>
> > ---
> >  meta/classes/cmake.bbclass | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
> > index fd40a9863e..251ddd9afe 100644
> > --- a/meta/classes/cmake.bbclass
> > +++ b/meta/classes/cmake.bbclass
> > @@ -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
> > Openembedded-core at lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core


More information about the Openembedded-core mailing list