Create SDK with hard float support

Hello,

I created the SDK corresponding to my Image using “-c populate_sdk”, and everything went ok.

When I try to use the generated toolchain (which is inside “arm-angstrom-linux-gnueabi” folder, using arm-angstrom-linux-gnueabi-g++ compiler), then I get many error messages about *.h missing. Strange.

Then I downloaded the “gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf.tar”, this with hard float support, and everything compiles fine.

So my question is how to create an SDK with hard float support. I think it should be in the DEFAULTTUNE of the MACHINE, but I am not really familiar with it. I see no such variable in my machine *.conf file, so I guess it is inherited from another layer, but which one ? What could I use for an apalis iMX6D 512MB ?

Thank you.

Nicola

Hi Nicola

OE moved away from generating different toolchains depending on the calling convention.

angstrom-linux-gnueabi-g++ can generate hard float code but the default setting is not hard float.
You need to add -mfloat-abi=hard when calling the compiler and linker.

Have a look on the environment after you sourced the environment script:

$ . /usr/local/oecore-x86_64/environment-setup-armv7at2hf-neon-angstrom-linux-gnueabi 
$ set | grep hard
CC='arm-angstrom-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'
CPP='arm-angstrom-linux-gnueabi-gcc -E  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'
CXX='arm-angstrom-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'
OE_QMAKE_CC='arm-angstrom-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'
OE_QMAKE_CXX='arm-angstrom-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'
OE_QMAKE_LINK='arm-angstrom-linux-gnueabi-g++  -march=armv7-a -mthumb -mfpu=neon  -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7at2hf-neon-angstrom-linux-gnueabi'

Max

Hello Max,

thank you for your answer. I understand it now.

I was able to compile the single .cpp files by replacing the CXX (and use the one from the environment script) inside my makefile.

Then I had an issue with CXXFLAGS. Inside my original makefile I am using CXXFLAGS = -Wall -O2 -static.

When using the “gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf” I can compile and link my project without changing my original CXXFLAGS, while if I use the Open Embedded SDK, I have to use the same CXXFLAGS as the environment script (CXXFLAGS= -O2 -pipe -g -feliminate-unused-debug-types). My original CXXFLAGS without -static also works (CXXFLAGS = -Wall -O2).

Is there any difference in this respect between the OpenEmbedded SDK (with flags for Hard float) and “gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf” ?

Thank you.

Nicola

Hi Nicola

Is there any difference in this respect between the OpenEmbedded SDK (with flags for Hard float) and “gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf” ?

One difference is that the binary toolchain is packaged with a version of the gcc and libc libraries, both for static and dynamic linking while OE puts those libraries into the target rootfs and by default only installed the shared libraries.

I guess this is also the reason why you see differences. The OE SDK by default do not contain statically linked libraries which results in error messages like the following:

gcc -static -O3 -o prog prog.c
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status

If you really want to link with -static you could add all libraries additionally in their static form to the SDK.
Please have a look at the this post on the yocto mailinglist.

Max

Hello Max,

this is exactly the error I am having, I think related to the following 3 libraries:


/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1/real-ld: error: cannot find -lc

/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1/real-ld: error: cannot find -lstdc++

/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1/real-ld: error: cannot find -lm

…/sysdeps/arm/start.S:124: error: undefined reference to ‘__libc_start_main’

Looking at your suggestion, I tried to add the following:
SDKIMAGE_FEATURES = “dev-pkgs dbg-pkgs staticdev-pkgs”

to my layer image:
…/meta-my-layer/recipes-images/images/my_image.bb

Then I rebuilt my Image: bitbake my-image

Then populated the SDK: bitbake my-image -c populate_sdk

but again I receive the above errors.

Something strange is the fact that I don’t see anything new built with today’s date inside the SDK, especially in the path where it looks for the libraries:

/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/6.2.1

Is bitbake really repopulating the SDK ? I see it doing it inside do_populate_sdk() for a couple of minutes, but the compiling problem still persists.

Any suggestions on how to debug the problem further ?

Thanks,
Nicola

Hi

Something strange is the fact that I don’t see anything new built with today’s date inside the SDK, especially in the path where it looks for the libraries.

That is expected. The static libraries have been built alongside the dynamic ones. The difference should be that the packages which contain them should additionally be installed.

Any suggestions on how to debug the problem further ?

  • Are those libraries really not in the SDK?
    e.g.


    find -name libc.*
    find -name libstdc++.*
    find -name libm.*

  • Did you reinstall the SDK after you built it?

  • Does the setting of SDKIMAGE_FEATURES work?

bitbake my-image -e > my-image.txt

Then search in my-image.txt how the SDKIMAGE_FEATURES is constructed and what it finally expands to.

  • Does rebuilding with force help?
bitbake my-image -fc populate_sdk

Max

Hello Max,

my stupid mistake … I forgot to reinstall the SDK after building it.

After reinstalling the SDK, I am able to build my projects with -static original flags.

Thanks again for your help !!

Nicola