<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10255</bug_id>
          
          <creation_ts>2016-09-12 03:27:39 +0000</creation_ts>
          <short_desc>SDK siteconfig has HOST information instead of TARGET&apos;s</short_desc>
          <delta_ts>2016-09-28 05:57:01 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>deployment</component>
          <version>2.0.3</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>2.2 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>tmatsuzawa</reporter>
          <assigned_to name="Chen Qi">Qi.Chen</assigned_to>
          <cc>mark.hatle</cc>
    
    <cc>poky.adt.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>Qi.Chen</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>66026</commentid>
    <comment_count>0</comment_count>
    <who name="">tmatsuzawa</who>
    <bug_when>2016-09-12 03:27:39 +0000</bug_when>
    <thetext>1) Issue

When site-config-xxxx script (tobe included in SDK and referred by CONFIG_SITE in SDK environment) is generated, it is appended
by HOST arch/os information instead of the TARGET arch/os information.

2) Symptom

Yocto ver: jethro
Host: x86_64
Target: arm (32bit)

Build SDK, setting SDKMACHINE to x86_64.

After SDK is generated, install it and source its environment-setup script.

And if I invoke $CC (arm-poky-linux-gnueabi-gcc), using this SDK, sizeof (long) is 4 (long = int)

However, if I look into $CONFIG_SITE&apos;s definition of ac_cv_sizeof_long, it is defined as &apos;8&apos;.
I feel this is strange since if this cached configure data is for the target (and cross-compiling), this value should be 4, to match the above (arm-poky-linux-gnueabi-gcc) result.
(I think this part of the cache is being copied from poky/meta/site/x86_64-linux, )

This is causing break if I build autotool based program using the SDK.

3) Analysis

If I look into toolchain-scripts.bbclass, I can see toolchain_create_sdk_siteconfig is gathering site-config information from the following two lists:

1) TOOLCHAIN_CONFIGSITE_NOCACHE
2) TOOLCHAIN_NEED_CONFIGSITE_CACHE

2) Seems to be OK, since it is getting the sitefiles from the target files.
However, 1) is gathering the sitefiles by calling siteinfo_get_files().
If I look into siteinfo_get_files(), it returns information on HOST_ARCH-HOST_OS pair (here, I think HOST_ARCH-HOST_OS is not that of my target machine but my x86_64 HOST)

In fact, if I debug bitbake behavior, I can see following files are actually appended as TOOLCHAIN_CONFIGSITE_NOCACHE files.

xxx/meta-oe/site/endian-little
xxx/poky/meta/site/endian-little
xxx/poky/meta/site/ix86_common
xxx/poky/meta/site/common-linux
xxx/poky/meta/site/common-glibc
xxx/poky/meta/site/common

I think for toolchain_create_sdk_siteconfig(), TARGET_ARCH-TARGET_OS pair should be used to generate this list. 

(toolchain-scripts.bbclass excerpt)

#we get the cached site config in the runtime
TOOLCHAIN_CONFIGSITE_NOCACHE = &quot;${@siteinfo_get_files(d, True)}&quot;
TOOLCHAIN_CONFIGSITE_SYSROOTCACHE = &quot;${STAGING_DIR}/${MLPREFIX}${MACHINE}/${target_datadir}/${TARGET_SYS}_config_site.d&quot;
TOOLCHAIN_NEED_CONFIGSITE_CACHE ??= &quot;virtual/${MLPREFIX}libc ncurses&quot;

#This function create a site config file
toolchain_create_sdk_siteconfig () {
	local siteconfig=$1

	rm -f $siteconfig
	touch $siteconfig

	for sitefile in ${TOOLCHAIN_CONFIGSITE_NOCACHE} ; do
		cat $sitefile &gt;&gt; $siteconfig
	done

	#get cached site config
	for sitefile in ${TOOLCHAIN_NEED_CONFIGSITE_CACHE}; do
		# Resolve virtual/* names to the real recipe name using sysroot-providers info
		case $sitefile in virtual/*)
			sitefile=`echo $sitefile | tr / _`
			sitefile=`cat ${STAGING_DIR_TARGET}/sysroot-providers/$sitefile`
		esac

		if [ -r ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config ]; then
			cat ${TOOLCHAIN_CONFIGSITE_SYSROOTCACHE}/${sitefile}_config &gt;&gt; $siteconfig
		fi
	done
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66038</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2016-09-12 14:34:01 +0000</bug_when>
    <thetext>Moving to oe-core domain</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66039</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2016-09-12 15:20:19 +0000</bug_when>
    <thetext>I was able to reproduce the problem with the following configuration:

(poky repository)
git checkout jethro
. ./oe-init-build-env

MACHINE=&quot;qemuarm&quot; SDKMACHINE=&quot;x86_64&quot; bitbake -c populate_sdk core-image-minimal

Inspecting the site config file:

ac_cv_sizeof_long=${ac_cv_sizeof_long=8}
ac_cv_sizeof_unsigned_long=${ac_cv_sizeof_unsigned_long=8}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66040</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2016-09-12 15:30:00 +0000</bug_when>
    <thetext>Further info, the siteconfig file is generated as part of the recipe: meta-environment

The meta-environment is an SDK package, not a target package -- so it gets the wrong
siteconfig</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66044</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2016-09-12 16:23:39 +0000</bug_when>
    <thetext>I&apos;ve verified.  master is also broken in the same way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66664</commentid>
    <comment_count>5</comment_count>
    <who name="Chen Qi">Qi.Chen</who>
    <bug_when>2016-09-28 05:57:01 +0000</bug_when>
    <thetext>commit 725e66e1d08ae000d8f68455ddca0e192080dc1f
Author: Chen Qi &lt;Qi.Chen@windriver.com&gt;
Date:   Mon Sep 26 11:20:28 2016 +0800

    meta-environment: ensure corret TOOLCHAIN_CONFIGSITE_NOCACHE value
    
    Expand TOOLCHAIN_CONFIGSITE_NOCACHE value immediately before inheriting
    cross-canadian to avoid HOST_ARCH being changed from TARGET_ARCH to SDK_ARCH,
    thus ensuring its correct value.
    
    [YOCTO #10255]
    
    (From OE-Core rev: 1e13d1fd22186af5544e7248dc12635cd2f2e08b)
    
    Signed-off-by: Chen Qi &lt;Qi.Chen@windriver.com&gt;
    Signed-off-by: Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>