Bug 11958 - nativesdk-gnutls fails on system with toolchain installed in default location (using headers from toolchain)
Summary: nativesdk-gnutls fails on system with toolchain installed in default location...
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.4
Hardware: x86 Multiple
: Medium major
Target Milestone: 2.5
Assignee: Juro Bystricky
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-08-21 09:04 UTC by Joshua Lock
Modified: 2018-01-05 18:10 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
console.log of failed nativesdk-gnutls build (1.97 MB, text/x-log)
2017-08-21 09:04 UTC, Joshua Lock
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Lock 2017-08-21 09:04:51 UTC
Created attachment 3949 [details]
console.log of failed nativesdk-gnutls build

I have a system with a core-image-sato eSDK (poky-glibc-x86_64-core-image-sato-core2-64-toolchain-2.3.sh) installed in the default location (/opt/poky).

When trying to build nativesdk-gnutls on that system *without* having sourced the environment setup scripts the nativesdk-gnutls build fails because a header from the installed toolchain is used rather than the header from the sysroot and a struct ends up being redefined.

Include paths for the gnutls-nativesdk build include the installed location of nativesdk.

I've not yet determined whether this is a gnutls issue or whether it's a general nativesdk issue.

Attached is the console.log but the interesting parts, I believe, are:

x86_64-pokysdk-linux-libtool: compile:  x86_64-pokysdk-linux-gcc --sysroot=/home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot -DHAVE_CONFIG_H -I. -I../../../gnutls-3.5.13/doc/examples -I../.. -I../../../gnutls-3.5.13/lib/includes -I../../lib/includes -I../../../gnutls-3.5.13/extra/includes -I../../../gnutls-3.5.13/src/gl -I../../src/gl -D_GL_NO_LARGE_FILES -DNO_LIBCURL -I/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include

| ../../x86_64-pokysdk-linux-libtool  --tag=CC   --mode=link x86_64-pokysdk-linux-gcc  --sysroot=/home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot -fno-common -W -Wabi -Waddress -Waggressive-loop-optimizations -Wall -Wattributes -Wbad-function-cast -Wbool-compare -Wbuiltin-macro-redefined -Wcast-align -Wchar-subscripts -Wchkp -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdate-time -Wdeprecated -Wdeprecated-declarations -Wdesignated-init -Wdisabled-optimization -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero -Wdouble-promotion -Wduplicated-cond -Wempty-body -Wendif-labels -Wenum-compare -Wextra -Wformat-contains-nul -Wformat-extra-args -Wformat-security -Wformat-zero-length -Wframe-address -Wfree-nonheap-object -Whsa -Wignored-attributes -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Winit-self -Wint-conversion -Wint-to-pointer-cast -Winvalid-memory-model -Winvalid-pch -Wjump-misses-init -Wlogical-not-parentheses -Wlogical-op -Wmain -Wmaybe-uninitialized -Wmemset-transposed-args -Wmisleading-indentation -Wmissing-braces -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-parameter-type -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wnonnull-compare -Wnull-dereference -Wodr -Wold-style-declaration -Wold-style-definition -Wopenmp-simd -Woverflow -Woverride-init -Wpacked -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-local-addr -Wreturn-type -Wscalar-storage-order -Wsequence-point -Wshadow -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-prototypes -Wsuggest-attribute=format -Wsuggest-final-methods -Wsuggest-final-types -Wswitch -Wswitch-bool -Wsync-nand -Wtautological-compare -Wtrampolines -Wtrigraphs -Wtype-limits -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros -Wunused-parameter -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvector-operation-performance -Wvolatile-register-var -Wwrite-strings -Warray-bounds=2 -Wnormalized=nfc -Wshift-overflow=2 -Wunused-const-variable=2 -Wno-missing-field-initializers -Wno-unused-parameter -fdiagnostics-show-option  -O2 -pipe -no-install -Wl,-O1 -o libexamples.la  ex-alert.lo ex-pkcs12.lo ex-session-info.lo ex-x509-info.lo ex-verify.lo ex-client-x509-3.1.lo tcp.lo udp.lo ex-pkcs11-list.lo verify.lo ex-verify-ssh.lo
| In file included from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/bits/types/locale_t.h:22:0,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/stdlib.h:199,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/cstdlib:75,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/ext/string_conversions.h:41,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/bits/basic_string.h:6159,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/string:52,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/bits/locale_classes.h:40,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/bits/ios_base.h:41,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/ios:42,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/ostream:38,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/iostream:39,
|                  from ../../../gnutls-3.5.13/doc/examples/ex-cxx.cpp:2:
| /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/bits/types/__locale_t.h:28:8: error: redefinition of 'struct __locale_struct'
|  struct __locale_struct
|         ^~~~~~~~~~~~~~~
| In file included from /opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/wchar.h:184:0,
|                  from ../../src/gl/wchar.h:87,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/cwchar:44,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/bits/postypes.h:40,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/iosfwd:40,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/ios:38,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/ostream:38,
|                  from /home/pokybuild/yocto-autobuilder/yocto-worker/intel-corei7-64/build/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-gnutls/3.5.13-r0/recipe-sysroot/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/c++/7.2.0/iostream:39,
|                  from ../../../gnutls-3.5.13/doc/examples/ex-cxx.cpp:2:
| /opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include/xlocale.h:27:16: note: previous definition of 'struct __locale_struct'
|  typedef struct __locale_struct
|                 ^~~~~~~~~~~~~~~
Comment 1 Joshua Lock 2017-08-21 13:27:42 UTC
This appears to be specific to nativesdk-gnutls, or at least I haven't managed to make other nativesdk- recipes fail the same way.

In the generated Makefile I see:

CPPFLAGS = -I/opt/poky/2.3/sysroots/x86_64-pokysdk-linux/usr/include
Comment 2 Juro Bystricky 2017-10-04 23:17:44 UTC
I could reproduce (similar/equivalent problem) quite easily:

1. Install eSDK (into default place /opt/poky..). 
2. Build nativsdk-gnutls

In my case the build was successful, but the log.do_compile did also contain  -I/opt/poky/2.3+snapshot/sysroots/x86_64-pokysdk-linux/usr/include references.

As there were no discrepancies between various include files (taken from /opt/poky/2.3+snapshot/sysroots/x86_64-pokysdk-linux/usr/include), the build did not fail. So this problem may have been around unnoticed for a while.

3. Removing/renaming the eSDK fixed the problem: no references of -I/opt/poky/2.3+snapshot/sysroots/x86_64-pokysdk-linux/usr/include  were present anymore.

So it is just the *presence* of the eSDK in the *default* location that causes this particular bug.
Comment 3 Juro Bystricky 2017-10-12 00:50:04 UTC
This is not nativesdk-gnutls specific, "configure" is called with "--includedir=/opt/poky/2.4/sysroot/<build-host>/usr/include" for all nativesdk apps. However only nativesdk-gnutls seems actually use the value, trying to be smart and .

The culprit seems to be in lib-link.m4, initializing $additional_includeddir for CPPFLAGS.
The comment says:

Potentially add $additional_includeddir to $CPPFLAGS.
But don't add it 
1. if it's the standard /usr/include
2. if it's already present in $CPPFLAGS
3. if it's /usr/local/include and we are using GCC on Linux
4. if it doesn't exist as a directory.

We get added due to 4., if the directory /opt/poky/... exists.

That also explains why gnutls-native works fine (--includedir=/usr/include).
So I think the best way to address this is not to add it also in additional case: 

5. if it's in /opt/poky

I'll test this theory.
Comment 4 Juro Bystricky 2018-01-05 18:10:22 UTC
The problem was caused by mismatched include files. They were mismatched because the "master" git repo did not contain the "snapshot" version, so nativesdk-gnutls build looked into incorrect /opt/poky/xxx folder. (should have been /opt/poky/xxx+snapshot).
This problem was fixed/should not be observed after:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=51cc0b07a14277c71a3b6184575fe30ab489c717