<?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>7143</bug_id>
          
          <creation_ts>2015-01-14 22:59:02 +0000</creation_ts>
          <short_desc>When generating a multilib MIPS64 SDK, some environment files are broken</short_desc>
          <delta_ts>2015-01-21 14:31:36 +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>devtools / tool chain</component>
          <version>1.7.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>mips</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.7.2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Hatle">mark.hatle</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>richard.purdie</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>47914</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-14 22:59:02 +0000</bug_when>
    <thetext>configuration (local.conf):

MACHINE = &quot;qemumips64&quot;

require conf/multilib.conf
MULTILIBS = &quot;multilib:lib32 multilib:lib64&quot;
DEFAULTTUNE = &quot;mips32r2&quot;
DEFAULTTUNE_virtclass-multilib-lib32 = &quot;mips64-n32&quot;
DEFAULTTUNE_virtclass-multilib-lib64 = &quot;mips64&quot;


Results in an SDK with:

environment-setup-mips32r2-poky-linux
environment-setup-mips64-n32-pokymllib32-linux
environment-setup-mips64-pokymllib64-linux


If you try to use these:

hello.c:
#include &lt;stdio.h&gt;

int main() {
   printf(&quot;Hello World!\n&quot;);

   return 0;
}

for each in environment-setup-mips* ; do (echo $each ; . $each ; $CC -o hello_$each hello.c) ; done

you get:

environment-setup-mips32r2-poky-linux
environment-setup-mips64-n32-pokymllib32-linux
bash: mips64-pokymllib32-linux-gcc: command not found...
environment-setup-mips64-pokymllib64-linux
bash: mips64-pokymllib64-linux-gcc: command not found...

The problem is that the mips64 toolchain is clashing with the mips64-n32 toolchain.  Whichever is build first is the one that is produced, but the filename still doesn&apos;t match the resulting binaries.

sysroots/x86_64-pokysdk-linux/usr/bin/mips64-pokymllib32-linux-gnun32/mips64-pokymllib32-linux-gnun32-gcc
sysroots/x86_64-pokysdk-linux/usr/bin/mips-poky-linux/mips-poky-linux-gcc

(gnun32 comes from the ABIEXTENSION on the MIPS64-n32 configuration.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47916</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-14 23:46:55 +0000</bug_when>
    <thetext>Applying the following patch:

arch-mips.inc: Add the MIPS ABIEXTENSION to toolchain name

The toolchain uses the TRANSLATED_TARGET_ARCH in it&apos;s name, however the
target for mips64 and mips64 n32 were the same, causing a conflict.
Avoid this conflict by adding the ABIEXTENSION to the name.

Signed-off-by: Mark Hatle &lt;mark.hatle@windriver.com&gt;

diff --git a/meta/conf/machine/include/mips/arch-mips.inc b/meta/conf/machine/include/mips/arch-mips.inc
index 02626d3..08d8fdc 100644
--- a/meta/conf/machine/include/mips/arch-mips.inc
+++ b/meta/conf/machine/include/mips/arch-mips.inc
@@ -100,3 +100,5 @@ TUNE_FEATURES_tune-mips64el-nf = &quot;n64&quot;
 BASE_LIB_tune-mips64el-nf = &quot;lib64&quot;
 MIPSPKGSFX_VARIANT_tune-mips64el-nf = &quot;${TUNE_ARCH}&quot;
 PACKAGE_EXTRA_ARCHS_tune-mips64el-nf = &quot;mips64el-nf&quot;
+
+TRANSLATED_TARGET_ARCH_append = &quot;${ABIEXTENSION}&quot;


This allows the system to build the missing toolchains:

[mhatle@msp-dhcp23 linux2]$ find sysroots/ -name *-gcc
sysroots/x86_64-pokysdk-linux/usr/bin/mips64-pokymllib64-linux/mips64-pokymllib64-linux-gcc
sysroots/x86_64-pokysdk-linux/usr/bin/mips64-pokymllib32-linux-gnun32/mips64-pokymllib32-linux-gnun32-gcc
sysroots/x86_64-pokysdk-linux/usr/bin/mips-poky-linux/mips-poky-linux-gcc


However, the environment files still do not work properly:

for each in environment-setup-mips* ; do (echo $each ; . $each ; $CC -o hello_$each hello.c) ; done
environment-setup-mips32r2-poky-linux
environment-setup-mips64-n32-pokymllib32-linux
bash: mips64-pokymllib32-linux-gcc: command not found...
environment-setup-mips64-pokymllib64-linux
In file included from /home/mhatle/git/oss/poky/build-qemumips64/tmp/deploy/sdk/linux2/sysroots/mips32r2-poky-linux/usr/include/features.h:389:0,
                 from /home/mhatle/git/oss/poky/build-qemumips64/tmp/deploy/sdk/linux2/sysroots/mips32r2-poky-linux/usr/include/stdio.h:27,
                 from hello.c:1:
/home/mhatle/git/oss/poky/build-qemumips64/tmp/deploy/sdk/linux2/sysroots/mips32r2-poky-linux/usr/include/gnu/stubs.h:35:33: fatal error: gnu/stubs-n64_hard.h: No such file or directory
 # include &lt;gnu/stubs-n64_hard.h&gt;
                                 ^
compilation terminated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47918</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-15 01:22:54 +0000</bug_when>
    <thetext>With some help from RP, I got it working.

Configuration:

MACHINE = &quot;qemumips64&quot;

require conf/multilib.conf
MULTILIBS = &quot;multilib:lib32 multilib:lib64&quot;
DEFAULTTUNE = &quot;mips32r2&quot;
DEFAULTTUNE_virtclass-multilib-lib32 = &quot;mips64-n32&quot;
DEFAULTTUNE_virtclass-multilib-lib64 = &quot;mips64&quot;

USE_LDCONFIG = &apos;0&apos;
IMAGE_INSTALL_append = &quot;lib32-libgcc lib32-libgcc-dev lib32-glibc lib32-glibc-dev lib64-libgcc lib64-libgcc-dev lib64-glibc lib64-glibc-dev&quot;


Patches:

(See comment 1 for the ABIEXTENSION patch)

Patch from RP:

diff --git a/meta/classes/cross-canadian.bbclass b/meta/classes/cross-canadian.bbclass
index fec6438..824be07 100644
--- a/meta/classes/cross-canadian.bbclass
+++ b/meta/classes/cross-canadian.bbclass
@@ -16,6 +16,7 @@ STAGING_BINDIR_TOOLCHAIN = &quot;${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
 #
 PACKAGE_ARCH = &quot;${SDK_ARCH}-${SDKPKGSUFFIX}&quot;
 CANADIANEXTRAOS = &quot;&quot;
+MODIFYTOS = &quot;1&quot;
 python () {
     archs = d.getVar(&apos;PACKAGE_ARCHS&apos;, True).split()
     sdkarchs = []
@@ -23,6 +24,9 @@ python () {
         sdkarchs.append(arch + &apos;-${SDKPKGSUFFIX}&apos;)
     d.setVar(&apos;PACKAGE_ARCHS&apos;, &quot; &quot;.join(sdkarchs))
 
+    # Allow the following code segment to be disabled, e.g. meta-environment
+    if d.getVar(&quot;MODIFYTOS&quot;, True) != &quot;1&quot;:
+        return
     # PowerPC can build &quot;linux&quot; and &quot;linux-gnuspe&quot;
     tarch = d.getVar(&quot;TARGET_ARCH&quot;, True)
     if tarch == &quot;powerpc&quot;:
diff --git a/meta/recipes-core/meta/meta-environment.bb b/meta/recipes-core/meta/meta-environment.bb
index bb208a3..420c704 100644
--- a/meta/recipes-core/meta/meta-environment.bb
+++ b/meta/recipes-core/meta/meta-environment.bb
@@ -6,9 +6,7 @@ PR = &quot;r8&quot;
 
 EXCLUDE_FROM_WORLD = &quot;1&quot;
 
-ORIGOS := &quot;${TARGET_OS}&quot;
-
-REAL_MULTIMACH_TARGET_SYS = &quot;${TUNE_PKGARCH}${TARGET_VENDOR}-${ORIGOS}&quot;
+REAL_MULTIMACH_TARGET_SYS = &quot;${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}&quot;
 
 inherit toolchain-scripts
 TOOLCHAIN_NEED_CONFIGSITE_CACHE += &quot;zlib&quot;
@@ -31,7 +29,6 @@ python do_generate_content() {
 
     # make sure we only use the SDKTARGETSYSROOT value from &apos;d&apos;
     localdata.setVar(&apos;SDKTARGETSYSROOT&apos;, d.getVar(&apos;SDKTARGETSYSROOT&apos;, True))
-    localdata.setVar(&apos;TARGET_OS&apos;, d.getVar(&apos;ORIGOS&apos;, True))
     localdata.setVar(&apos;libdir&apos;, d.getVar(&apos;target_libdir&apos;, False))
 
     # Process DEFAULTTUNE



Results from building:

for each in environment-setup-mips* ; do (echo $each ; . $each ; $CC -o hello_$each hello.c) ; done
environment-setup-mips32r2-poky-linux
environment-setup-mips64-n32-pokymllib32-linux-gnun32
environment-setup-mips64-pokymllib64-linux

file hello_*
hello_environment-setup-mips32r2-poky-linux:                 ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7c2e4742df4ed7426b3025c71b525d69cf38c962, not stripped
hello_environment-setup-mips64-n32-pokymllib32-linux-gnun32: ELF 32-bit MSB executable, MIPS, N32 MIPS64 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=5bf21ce5f65f281cfd58482f95e0e61ae1d5e0db, not stripped
hello_environment-setup-mips64-pokymllib64-linux:            ELF 64-bit MSB executable, MIPS, MIPS64 version 1 (SYSV), dynamically linked (uses shared libs), BuildID[sha1]=e258c337ce4b54d64985ab98710ba4e9eeb00dbf, for GNU/Linux 2.6.32, not stripped</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47920</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-01-15 08:01:44 +0000</bug_when>
    <thetext>There is a MODIFYTOS = &quot;0&quot; missing from my patch in meta-environment?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47939</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-01-15 15:31:13 +0000</bug_when>
    <thetext>re comment #3, was a paste error on my part.  It was there in my testing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48149</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2015-01-21 14:31:36 +0000</bug_when>
    <thetext>Resolved with the combination of http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=3e4d84aea3623d4eac2e5a094cf103b26859a6b6
http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=db2255dc0bb57d37464de6b4552ee80a7d5c1368</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>