Bug 8025 - UClibc (SDK) toolchain built by meta-toolchain contains wrong compiler
Summary: UClibc (SDK) toolchain built by meta-toolchain contains wrong compiler
Status: VERIFIED FIXED
Alias: None
Product: ADT
Classification: Yocto Project Subprojects
Component: adt (show other bugs)
Version: 1.8
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 1.9 M3
Assignee: Richard Purdie
QA Contact: Bogdan Alexandru Voiculescu
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-07-17 06:57 UTC by Paul Grant
Modified: 2015-09-02 14:02 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
local.conf used (10.44 KB, application/octet-stream)
2015-07-17 06:57 UTC, Paul Grant
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Grant 2015-07-17 06:57:41 UTC
Created attachment 2594 [details]
local.conf used

I'm trying to build a cross compiler toolchain for PowerPC (mpc8544).  

I'm able to successfully bitbake the meta-toolchain target for glibc, when I check inside the sysroot directory of the sdk, I find the following directories:  

ppce500v2-poky-linux-gnuspe 
x86_64-pokysdk-linux  

The directory ppce500v2-poky-linux-gnuspe, contains root filesystem for target (ppc500v2). 
The directory x86_64-pokysdk-linux, contains the cross development tools, for my host, particularly gcc (powerpc-poky-linux-gnuspe-gcc)  

If I execute:  powerpc-poky-linux-gnuspe-gcc -v  the target is set to: powerpc-poky-linux  which I interpret to mean a powerpc based target with glibc&linux  


I want to build a uclibc toolchain:  

To achieve this I understand you need to add the following line to my local.conf:  

TCLIBC = "uclibc"  

After doing so, I am again able successfully build the target meta-toolchain. Again if I look inside the sysroot directory two directories have been created:

ppce500v2-poky-linux-uclibcspe 
x86_64-pokysdk-linux  

ppce500v2-poky-linux-uclibcspe, this time the root filesystem is based on uclibc and this is refelected in the name. 
x86_64-pokysdk-linux, again a directory to hold the host tools has been created. 

The gcc tools are located in under directory ./usr/bin/powerpc-poky-linux-gnuspe as before,  

If I execute:  powerpc-poky-linux-gnuspe-gcc -v  
the target is set to: powerpc-poky-linux  

However given that I've selected uclibc, I was expecting the gcc tools to be located under a directory: ./usr/bin/powerpc-poky-linux-uclibcspe 

to reflect the fact that the tools are targeting uclibc.  

If I look inside the environment script created by the meta-toolchain target it shares this expectation as is reflected by the extract for CC envvar:  

export CC="powerpc-poky-linux-uclibcspe-gcc -m32 -mcpu=8548 -mabi=spe -mspe -mfloat-gprs=double --sysroot=$SDKTARGETSYSROOT"  

If I search the files created by the target meta-toolchain, it has actually created an apprpriate gcc located deeply nested under the work diretcory, a gcc toolset of the correct form has been created, namely:  

powerpc-poky-linux-uclibcspe-g++  

Just to confirm when I run with the -v option it shows its target as:  

powerpc-poky-linux-uclibcspe  

Can someone clarify what's happening here?!?  

1. Are my expectations correct? 
2. If so, why is the correct toolchain created, but not put in the correct place by the populate-sdk target? 

Thanks in advance for any help you can provide!
Comment 1 Richard Purdie 2015-07-24 13:00:13 UTC
Looking at a local build, if you do this in a clean build directory, I believe the toolchain will build correctly.

I believe there is a problem that nativesdk glibc components are reused in the uclibc case when they clearly shouldn't be.
Comment 2 Richard Purdie 2015-07-24 13:36:26 UTC
I think something like this should fix this but I need to do a lot more testing:

[PATCH] cross-canadian: Put links in place for uclibc and musl

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/meta/classes/cross-canadian.bbclass b/meta/classes/cross-canadian.bbclass
index 18d9d9a..9e06884 100644
--- a/meta/classes/cross-canadian.bbclass
+++ b/meta/classes/cross-canadian.bbclass
@@ -16,7 +16,7 @@ STAGING_BINDIR_TOOLCHAIN = "${STAGING_DIR_NATIVE}${bindir_native}/${SDK_ARCH}${S
 # Update BASE_PACKAGE_ARCH and PACKAGE_ARCHS
 #
 PACKAGE_ARCH = "${SDK_ARCH}-${SDKPKGSUFFIX}"
-CANADIANEXTRAOS = ""
+CANADIANEXTRAOS = "linux-uclibc linux-musl"
 MODIFYTOS ??= "1"
 python () {
     archs = d.getVar('PACKAGE_ARCHS', True).split()
@@ -28,25 +28,26 @@ python () {
     # Allow the following code segment to be disabled, e.g. meta-environment
     if d.getVar("MODIFYTOS", True) != "1":
         return
+    tos = d.getVar("TARGET_OS", True)
+    if (tos != "linux" and tos != "linux-gnuspe"
+        and tos != "linux-uclibc" and tos != "linux-uclibcspe"
+        and tos != "linux-musl" and tos != "linux-muslspe"):
+            bb.fatal("Building cross-candian powerpc for an unknown TARGET_SYS (%s), please update cross-canadian.bbclass" % d.getVar("TARGET_SYS", True))
+    for n in ["PROVIDES", "DEPENDS"]:
+        d.setVar(n, d.getVar(n, True))
+    d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN", True))
+    for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]:
+        n = prefix + "_FOR_TARGET"
+        d.setVar(n, d.getVar(n, True))
     # PowerPC can build "linux" and "linux-gnuspe"
     tarch = d.getVar("TARGET_ARCH", True)
     if tarch == "powerpc":
-        tos = d.getVar("TARGET_OS", True)
-        if (tos != "linux" and tos != "linux-gnuspe"
-            and tos != "linux-uclibc" and tos != "linux-uclibcspe"
-            and tos != "linux-musl" and tos != "linux-muslspe"):
-            bb.fatal("Building cross-candian powerpc for an unknown TARGET_SYS (%s), please update cross-canadian.bbclass" % d.getVar("TARGET_SYS", True))
         # This is a bit ugly. We need to zero LIBC/ABI extension which will change TARGET_OS
         # however we need the old value in some variables. We expand those here first.
-        d.setVar("DEPENDS", d.getVar("DEPENDS", True))
-        d.setVar("STAGING_BINDIR_TOOLCHAIN", d.getVar("STAGING_BINDIR_TOOLCHAIN", True))
-        for prefix in ["AR", "AS", "DLLTOOL", "CC", "CXX", "GCC", "LD", "LIPO", "NM", "OBJDUMP", "RANLIB", "STRIP", "WINDRES"]:
-            n = prefix + "_FOR_TARGET"
-            d.setVar(n, d.getVar(n, True))
-
         d.setVar("LIBCEXTENSION", "")
         d.setVar("ABIEXTENSION", "")
-        d.setVar("CANADIANEXTRAOS", "linux-gnuspe")
+        d.appendVar("CANADIANEXTRAOS", " linux-gnuspe linux-uclibcspe linux-muslspe")
+    d.setVar("TARGET_OS", "linux")
 }
 MULTIMACH_TARGET_SYS = "${PACKAGE_ARCH}${HOST_VENDOR}-${HOST_OS}"
Comment 3 Richard Purdie 2015-07-24 16:49:51 UTC
Looks like the environment file also needs a -mmuclibc to make this work...
Comment 4 Paul Grant 2015-07-24 17:05:12 UTC
This is brilliant!

I'll try it out over weekend!
Comment 5 Richard Purdie 2015-07-24 21:39:29 UTC
The other part of this in patch form is:

diff --git a/meta/classes/toolchain-scripts.bbclass b/meta/classes/toolchain-scripts.bbclass
index a6ad041..d0b2b91 100644
--- a/meta/classes/toolchain-scripts.bbclass
+++ b/meta/classes/toolchain-scripts.bbclass
@@ -3,6 +3,8 @@ inherit siteinfo kernel-arch
 # We want to be able to change the value of MULTIMACH_TARGET_SYS, because it
 # doesn't always match our expectations... but we default to the stock value
 REAL_MULTIMACH_TARGET_SYS ?= "${MULTIMACH_TARGET_SYS}"
+TARGET_CC_ARCH_append_libc-uclibc = " -muclibc"
+TARGET_CC_ARCH_append_libc-musl = " -mmusl"
 
 # This function creates an environment-setup-script for use in a deployable SDK
 toolchain_create_sdk_env_script () {

but note again that this still needs a lot of testing...
Comment 7 Bogdan Alexandru Voiculescu 2015-09-02 14:02:51 UTC
commits are on master;
also after building the uclibc toolchain for mpc8544 we have the tools in the right location:
 ls -ila  ./build/tmp/sysroots/x86_64-linux/usr/bin/powerpc-poky-linux-uclibcspe
total 29028
6866686 drwxr-xr-x  2 bvoiculescu bvoiculescu    4096 sep  2 13:13 .
4892490 drwxr-xr-x 13 bvoiculescu bvoiculescu   12288 sep  2 15:16 ..
6610515 -rwxr-xr-x  2 bvoiculescu bvoiculescu  969912 sep  2 13:01 powerpc-poky-linux-uclibcspe-addr2line
6610509 -rwxr-xr-x  2 bvoiculescu bvoiculescu  998464 sep  2 13:01 powerpc-poky-linux-uclibcspe-ar
6610489 -rwxr-xr-x  2 bvoiculescu bvoiculescu 1438720 sep  2 13:01 powerpc-poky-linux-uclibcspe-as
 965350 -rwxr-xr-x  4 bvoiculescu bvoiculescu  850160 sep  2 13:13 powerpc-poky-linux-uclibcspe-c++
6610507 -rwxr-xr-x  2 bvoiculescu bvoiculescu  965304 sep  2 13:01 powerpc-poky-linux-uclibcspe-c++filt
 965392 -rwxr-xr-x  2 bvoiculescu bvoiculescu  846064 sep  2 13:13 powerpc-poky-linux-uclibcspe-cpp
6610516 -rwxr-xr-x  2 bvoiculescu bvoiculescu 3056152 sep  2 13:01 powerpc-poky-linux-uclibcspe-dwp
6610518 -rwxr-xr-x  2 bvoiculescu bvoiculescu   31424 sep  2 13:01 powerpc-poky-linux-uclibcspe-elfedit
6610492 -rwxr-xr-x  3 bvoiculescu bvoiculescu    8624 sep  2 13:01 powerpc-poky-linux-uclibcspe-embedspu
 965350 -rwxr-xr-x  4 bvoiculescu bvoiculescu  850160 sep  2 13:13 powerpc-poky-linux-uclibcspe-g++
 965356 -rwxr-xr-x  4 bvoiculescu bvoiculescu  846064 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcc
 965356 -rwxr-xr-x  4 bvoiculescu bvoiculescu  846064 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcc-4.9.3
 965368 -rwxr-xr-x  2 bvoiculescu bvoiculescu   26976 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcc-ar
 965388 -rwxr-xr-x  2 bvoiculescu bvoiculescu   26976 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcc-nm
 965353 -rwxr-xr-x  2 bvoiculescu bvoiculescu   26976 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcc-ranlib
 965406 -rwxr-xr-x  2 bvoiculescu bvoiculescu  458424 sep  2 13:13 powerpc-poky-linux-uclibcspe-gcov
6610511 -rwxr-xr-x  2 bvoiculescu bvoiculescu 1036664 sep  2 13:01 powerpc-poky-linux-uclibcspe-gprof
6610510 -rwxr-xr-x  4 bvoiculescu bvoiculescu 1607936 sep  2 13:01 powerpc-poky-linux-uclibcspe-ld
6610510 -rwxr-xr-x  4 bvoiculescu bvoiculescu 1607936 sep  2 13:01 powerpc-poky-linux-uclibcspe-ld.bfd
6610505 -rwxr-xr-x  2 bvoiculescu bvoiculescu 4994648 sep  2 13:01 powerpc-poky-linux-uclibcspe-ld.gold
6610517 -rwxr-xr-x  2 bvoiculescu bvoiculescu  982904 sep  2 13:01 powerpc-poky-linux-uclibcspe-nm
6610486 -rwxr-xr-x  2 bvoiculescu bvoiculescu 1153656 sep  2 13:01 powerpc-poky-linux-uclibcspe-objcopy
6610514 -rwxr-xr-x  2 bvoiculescu bvoiculescu 1483576 sep  2 13:01 powerpc-poky-linux-uclibcspe-objdump
6610519 -rwxr-xr-x  2 bvoiculescu bvoiculescu  998464 sep  2 13:01 powerpc-poky-linux-uclibcspe-ranlib
6610506 -rwxr-xr-x  2 bvoiculescu bvoiculescu  451680 sep  2 13:01 powerpc-poky-linux-uclibcspe-readelf
6610521 -rwxr-xr-x  2 bvoiculescu bvoiculescu  969784 sep  2 13:01 powerpc-poky-linux-uclibcspe-size
6610508 -rwxr-xr-x  2 bvoiculescu bvoiculescu  969848 sep  2 13:01 powerpc-poky-linux-uclibcspe-strings
6610520 -rwxr-xr-x  2 bvoiculescu bvoiculescu 1153720 sep  2 13:01 powerpc-poky-linux-uclibcspe-strip