Bug 7143 - When generating a multilib MIPS64 SDK, some environment files are broken
Summary: When generating a multilib MIPS64 SDK, some environment files are broken
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 1.7.1
Hardware: x86 mips
: Medium+ normal
Target Milestone: 1.7.2
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-01-14 22:59 UTC by Mark Hatle
Modified: 2015-01-21 14:31 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hatle 2015-01-14 22:59:02 UTC
configuration (local.conf):

MACHINE = "qemumips64"

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


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 <stdio.h>

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

   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'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.)
Comment 1 Mark Hatle 2015-01-14 23:46:55 UTC
Applying the following patch:

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

The toolchain uses the TRANSLATED_TARGET_ARCH in it'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 <mark.hatle@windriver.com>

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 = "n64"
 BASE_LIB_tune-mips64el-nf = "lib64"
 MIPSPKGSFX_VARIANT_tune-mips64el-nf = "${TUNE_ARCH}"
 PACKAGE_EXTRA_ARCHS_tune-mips64el-nf = "mips64el-nf"
+
+TRANSLATED_TARGET_ARCH_append = "${ABIEXTENSION}"


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 <gnu/stubs-n64_hard.h>
                                 ^
compilation terminated.
Comment 2 Mark Hatle 2015-01-15 01:22:54 UTC
With some help from RP, I got it working.

Configuration:

MACHINE = "qemumips64"

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

USE_LDCONFIG = '0'
IMAGE_INSTALL_append = "lib32-libgcc lib32-libgcc-dev lib32-glibc lib32-glibc-dev lib64-libgcc lib64-libgcc-dev lib64-glibc lib64-glibc-dev"


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 = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
 #
 PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}"
 CANADIANEXTRAOS = ""
+MODIFYTOS = "1"
 python () {
     archs = d.getVar('PACKAGE_ARCHS', True).split()
     sdkarchs = []
@@ -23,6 +24,9 @@ python () {
         sdkarchs.append(arch + '-${SDKPKGSUFFIX}')
     d.setVar('PACKAGE_ARCHS', " ".join(sdkarchs))
 
+    # Allow the following code segment to be disabled, e.g. meta-environment
+    if d.getVar("MODIFYTOS", True) != "1":
+        return
     # PowerPC can build "linux" and "linux-gnuspe"
     tarch = d.getVar("TARGET_ARCH", True)
     if tarch == "powerpc":
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 = "r8"
 
 EXCLUDE_FROM_WORLD = "1"
 
-ORIGOS := "${TARGET_OS}"
-
-REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${ORIGOS}"
+REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}"
 
 inherit toolchain-scripts
 TOOLCHAIN_NEED_CONFIGSITE_CACHE += "zlib"
@@ -31,7 +29,6 @@ python do_generate_content() {
 
     # make sure we only use the SDKTARGETSYSROOT value from 'd'
     localdata.setVar('SDKTARGETSYSROOT', d.getVar('SDKTARGETSYSROOT', True))
-    localdata.setVar('TARGET_OS', d.getVar('ORIGOS', True))
     localdata.setVar('libdir', d.getVar('target_libdir', 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
Comment 3 Richard Purdie 2015-01-15 08:01:44 UTC
There is a MODIFYTOS = "0" missing from my patch in meta-environment?
Comment 4 Mark Hatle 2015-01-15 15:31:13 UTC
re comment #3, was a paste error on my part.  It was there in my testing.