Skip to contentSkip to conversation

Compiling barebox for newest Yocto/meta-freescale

DISCUSSION György Kövesdi 6 participants 13 messages Jun 22, 2015 – Jun 29, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

I have a i.MX6 based board and want to compile barebox using Yocto.
It was successful so far, but something is changed in the gcc behaviour.
The first thing is that some arch-specific parameters must be passed, or else the compilation fails. I could fix it, but there is another problem.
The option "-mfloat-abi=soft" is used in barebox compilation, which seems not supported by gcc. Adding "-mfloat-abi=hard" is not enough, the original "-mfloat-abi=soft" should be removed. Unfortunately, i could not find where this option is added and how to remove it. Can anybody help me to fix it?

Thanx in advance
Gyorgy Kovesdi

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

Hi,

Quoted 4 lines · György Kövesdi

I have a i.MX6 based board and want to compile barebox using Yocto. It was successful so far, but something is changed in the gcc behaviour. The first thing is that some arch-specific parameters must be passed, or else the compilation fails. I could fix it, but there is another problem.

I had to change
- oe_runmake
+ oe_runmake CC="$CC"
for recent yocto versions. What was your fix?

Quoted 5 lines

The option "-mfloat-abi=soft" is used in barebox compilation, which seems not supported by gcc. Adding "-mfloat-abi=hard" is not enough, the original "-mfloat-abi=soft" should be removed. Unfortunately, i could not find where this option is added and how to remove it. Can anybody help me to fix it?

Which yocto and gcc version are you using? Could you show us the actual error messages and yocto recipe?

Regards,
Jan

Signature · 10 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hi Jan,

Quoted 4 lines

I had to change

(quoted diff) +1 -1
-       oe_runmake
+       oe_runmake CC="$CC"

for recent yocto versions. What was your fix?

My fix was more complicated, by exporting ${TOOLCHAIN_OPTIONS} and ${HOST_CC_ARCH}. Thanks for this simpler solution.

Quoted 7 lines
Quoted 5 lines

The option "-mfloat-abi=soft" is used in barebox compilation, which seems not supported by gcc. Adding "-mfloat-abi=hard" is not enough, the original "-mfloat-abi=soft" should be removed. Unfortunately, i could not find where this option is added and how to remove it. Can anybody help me to fix it?

Which yocto and gcc version are you using? Could you show us the actual error messages and yocto recipe?

The current fido and master branches use gcc 4.9.2 and the problem is that soft float abi support seems missing and the option -mfloat-abi=soft is always added by the make rules of barebox. If i use the above mentioned fix, the result is:

arm-poky-linux-gnueabi-gcc: error: -mfloat-abi=soft and -mfloat-abi=hard may not be used together

because -mfloat-abi=hard is passed in ${CC} variable.

If i remove the option -mfloat-abi=hard, then got this error:

... stubs.h:7:29: fatal error: gnu/stubs-soft.h: No such file or directory

that's why i think the soft abi support is missing.
IMHO the float abi should not be set by the make rules because it is hardware specific, and therefore should be set by the build system.

Regards
György Kövesdi

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw

Hi,

Quoted 3 lines

You better ask in some Yocto-specific mailing list, this isn't really
the problem of Barebox anymore. :-) The soft-float option might come
from one of your inherited configuration files.

I am completely confused now, because Yocto guys said that the problem is in Barebox... :-)
At least i can compile thousands of recipes on Yocto, currently Barebox is the only one having this issue. I spent a lot of time debugging this problem in the recent days and i see the float abi is set to hard in the bitbake environment, and the soft float is not even supported by gcc (that is the problem). Currently i blame the kernel build system used by Barebox about setting soft float abi.

Quoted 2 lines

Soft-Float is definitely not optimal for the i.MX6, because this one has FPU commands.

I agree.

Regards
Gyorgy Kovesdi

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#5 lore raw

Look at barebox/arch/arm/Makefile. Around line 47 you see "-msoft-float" specified to both CPPFLAGS and AFLAGS. So specifying "CC=-msoft-hard" would bites with this.

Does compiling Barebox outside of Yocto work? E.g. something like:

make ARCH=arm CROSS_COMPILE=/home/schurig/d/mkarm/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/arm-linux-gnueabihf-

(I'm using http://releases.linaro.org/14.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz,
but you'd of corse specify your own prefix). Also note that my
compiler is gnueabiarmhf (hf is "hard-float"), but has not trouble
compiling in something with -msoft-float. Maybe your cross-compiler
cannot do that?

PS: despite I was once heavily involved into the early bitbake (during OpenEmbedded time), I stopped using it. I now run Debian on my i.MX6 and don't fuzz with bitbake/OE/Poky/Yocto anymore :-)

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#6 lore raw

Hi all,

Quoted 3 lines · Holger Schurig

Look at barebox/arch/arm/Makefile. Around line 47 you see "-msoft-float" specified to both CPPFLAGS and AFLAGS. So specifying "CC=-msoft-hard" would bites with this.

Many thanx, this was the problem!
I am removed the "-msoft-float" and everything works now.

I just suggest to remove it at all because such settings are belong to the build environment. If someone needs such, it can be set by parameters. Is it acceptable in general?
Shall i send a patch, or someone does it?

Regards
Gyorgy Kovesdi

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#8 lore raw

Hi all,

Quoted 2 lines

Better make a Yocto patch. Not everyone compiles Barebox with a "build environment".

Ok, i will do that.
However, IMHO it is a wrong idea to hard-wire such a setting, because everybody will run into this problem having hard-float-only environment. At least it should be configurable.
BTW everybody must have a (cross) gcc which takes care about that.

Regards
Gyorgy Kovesdi

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw

Am Dienstag, den 23.06.2015, 19:57 +0200 schrieb Gyorgy Kovesdi:

Quoted 9 lines

Hi all,

Quoted 2 lines

Better make a Yocto patch. Not everyone compiles Barebox with a "build environment".

Ok, i will do that.
However, IMHO it is a wrong idea to hard-wire such a setting, because everybody will run into this problem having hard-float-only environment. At least it should be configurable.
BTW everybody must have a (cross) gcc which takes care about that.

It's a completely reasonable decision to explicitly build with the soft-float ABI for a bare metal component like Barebox, in order to prevent the toolchain from using any part of the ARM VFP state, which may not be initialized at that point.

This has nothing to do with the decision to build your userspace with hard-float enabled. Building barebox with the hard-float ABI may actively yield broken binaries. So no, this is not a thing that should be configurable.

Also you don't have a hard-float only environment, your toolchain is perfectly able to build with the soft-float ABI, it's just that Yocto apparently passes the mfloat-abi=hard flag everywhere instead of setting a reasonable toolchain default.

Regards,
Lucas

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#10 lore raw
Quoted 4 lines · Lucas Stach

Also you don't have a hard-float only environment, your toolchain is perfectly able to build with the soft-float ABI, it's just that Yocto apparently passes the mfloat-abi=hard flag everywhere instead of setting a reasonable toolchain default.

I have the same problem now, as well (triggered by setting DEFAULTTUNE="cortexa8hf-neon").

The kernel uses the same -msoft-float in arch/arm/Makefile as we do in barebox. As Lucas said, this is actually important for correct behavior.

Yocto handles this by building the kernel with CC="${KERNEL_CC}" LD="${KERNEL_LD}" instead (see kernel.bbclass and kernel-arch.bbclass). For barebox I now have:
do_compile () {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}"
}

These settings make it impossible to build the barebox target userspace tools from scripts/, though. This is because the --sysroot parameter is passed by Yocto only in ${CC} and not in ${KERNEL_CC}, so the target userspace tools will fail to find their standard headers. So I have as a temporary workaround:

do_configure_prepend() {
        cp ${WORKDIR}/defconfig ${S}/.config
        # do not compile tools when using KERNEL_CC/KERNEL_LD
        echo CONFIG_BAREBOXENV_TARGET=n >> ${S}/.config
        echo CONFIG_BAREBOXCRC32_TARGET=n >> ${S}/.config
        echo CONFIG_KERNEL_INSTALL_TARGET=n >> ${S}/.config
        echo CONFIG_IMD_TARGET=n >> ${S}/.config
        oe_runmake oldconfig
}

To compile the target userspace tools, we'll need to use ${CC} instead, which is currently not supported by our (or the kernel's) kbuild. It seems that we currently build these tools with -msoft-float as well, which causes no problems because we don't use float math, but it's not correct either.

Gyorgy, could you point us to the Yocto side of the discussion, if it was on some list?

Regards,
Jan

Signature · 10 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw
In reply to Jan Lübbe

Hi everybody,

You are right, barebox really cannot be run with hard-float.
I re-enabled soft float in gcc compilation, and now it works perfectly on Yocto build without any modification.

Many thanx
György Kövesdi

Quoted 41 lines · On Wed, 24 Jun 2015 16:33:00 +0200 Jan Lübbe <[email protected]> wrote:
Quoted 4 lines · Lucas Stach

Also you don't have a hard-float only environment, your toolchain is perfectly able to build with the soft-float ABI, it's just that Yocto apparently passes the mfloat-abi=hard flag everywhere instead of setting a reasonable toolchain default.

I have the same problem now, as well (triggered by setting DEFAULTTUNE="cortexa8hf-neon").

The kernel uses the same -msoft-float in arch/arm/Makefile as we do in barebox. As Lucas said, this is actually important for correct behavior.

Yocto handles this by building the kernel with CC="${KERNEL_CC}" LD="${KERNEL_LD}" instead (see kernel.bbclass and kernel-arch.bbclass). For barebox I now have:
do_compile () {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}"
}

These settings make it impossible to build the barebox target userspace tools from scripts/, though. This is because the --sysroot parameter is passed by Yocto only in ${CC} and not in ${KERNEL_CC}, so the target userspace tools will fail to find their standard headers. So I have as a temporary workaround:

do_configure_prepend() {
        cp ${WORKDIR}/defconfig ${S}/.config
        # do not compile tools when using KERNEL_CC/KERNEL_LD
        echo CONFIG_BAREBOXENV_TARGET=n >> ${S}/.config
        echo CONFIG_BAREBOXCRC32_TARGET=n >> ${S}/.config
        echo CONFIG_KERNEL_INSTALL_TARGET=n >> ${S}/.config
        echo CONFIG_IMD_TARGET=n >> ${S}/.config
        oe_runmake oldconfig
}

To compile the target userspace tools, we'll need to use ${CC} instead, which is currently not supported by our (or the kernel's) kbuild. It seems that we currently build these tools with -msoft-float as well, which causes no problems because we don't use float math, but it's not correct either.

Quoted 5 lines

Gyorgy, could you point us to the Yocto side of the discussion, if it was on some list?

Regards,
Jan

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox