Skip to contentSkip to conversation

toolchain: check ARM EABI vs. EABIhf for external toolchains

PATCH New Thomas Petazzoni 3 participants 5 messages Jul 16, 2013 – Jul 17, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain: check ARM EABI vs. EABIhf for external toolchains

Following the introduction of the support of EABIhf as a second ARM ABI, it is important to check whether the external toolchain provided by the user actually uses the ABI that has been selected in the Buildroot configuration. This commit introduces such a check, using a similar solution to the one that was used to check OABI vs. EABI in the past.

---
 toolchain/helpers.mk | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
toolchain/helpers.mk +14 -2
index 95217e7..dc21f8a 100644
@@ -280,8 +280,20 @@ check_uclibc = \
 check_arm_abi = \
 	__CROSS_CC=$(strip $1) ; \
 	EXT_TOOLCHAIN_TARGET=`LANG=C $${__CROSS_CC} -v 2>&1 | grep ^Target | cut -f2 -d ' '` ; \
-	if ! echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi(hf)?$$' ; then \
-		echo "External toolchain uses the unsuported OABI" ; \
+	if echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabi" ; \
+	elif echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabihf$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabihf" ; \
+	else \
+		echo "Unsupported ABI of the external toolchain" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABI) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabihf" ] ; then \
+		echo "Incorrect ABI setting: EABI selected, but toolchain uses EABIhf" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABIHF) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabi" ] ; then \
+		echo "Incorrect ABI setting: EABIhf selected, but toolchain uses EABI" ; \
 		exit 1 ; \
 	fi
 
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 toolchain: check ARM EABI vs. EABIhf for external toolchains

Thomas, All,

On 2013-07-17 00:06 +0200, Thomas Petazzoni spake thusly:

Quoted 17 lines

Following the introduction of the support of EABIhf as a second ARM ABI, it is important to check whether the external toolchain provided by the user actually uses the ABI that has been selected in the Buildroot configuration. This commit introduces such a check, using a similar solution to the one that was used to check OABI vs. EABI in the past.

---
 toolchain/helpers.mk | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
toolchain/helpers.mk +0 -0
index 95217e7..dc21f8a 100644

toolchain/helpers.mk check_uclibc = \ · line 286

Quoted 9 lines
toolchain/helpers.mk +4 -2
@@ -280,8 +280,20 @@ check_uclibc = \
 check_arm_abi = \
 	__CROSS_CC=$(strip $1) ; \
 	EXT_TOOLCHAIN_TARGET=`LANG=C $${__CROSS_CC} -v 2>&1 | grep ^Target | cut -f2 -d ' '` ; \
-	if ! echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi(hf)?$$' ; then \
-		echo "External toolchain uses the unsuported OABI" ; \
+	if echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabi" ; \
+	elif echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabihf$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabihf" ; \

That's not always the case. You can well have a toolchain which tuple ends in eabi, but the toolchain uses the hard-float ABI.

That's the case by default for crosstool-NG toolchains, for example. Since the *eabihf is recent, not all gcc or binutils versions recognise it, while they are absolutely capable of emitting EABI using the hard-float ABI. Hence, ct-ng allows adding the 'hf' suffix as an option. (see attachment for an example of 'gcc -v' dump).

Checking for EABI, it is better and more reliable to run the preprocessor, and check some defines are available or not (I always need a bit of googling to get this):

    ARM_TUPLE-gcc -E -dM -xc - </dev/null |grep __ARM_EABI__

However, I could not find a #define about the float ABI... :-(

toolchain/helpers.mk check_uclibc = \ · line 291

Quoted 5 lines
toolchain/helpers.mk +5 -0
+	else \
+		echo "Unsupported ABI of the external toolchain" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABI) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabihf" ] ; then \

Using this 'x$(VAR) = xy' construct is ugly. Just quote the variables, it is easier to read:

    if [ "$(BR2_ARM_EABI)" = "y" ... ]

The x$VAR construct was from a time when some shells where failing to test against an empty string. That time is long gone. Virtaully all shells can compare to empty strings, nowadays.

toolchain/helpers.mk check_uclibc = \ · line 295

Quoted 4 lines
toolchain/helpers.mk +4 -0
+		echo "Incorrect ABI setting: EABI selected, but toolchain uses EABIhf" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABIHF) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabi" ] ; then \

Ditto.

toolchain/helpers.mk check_uclibc = \ · line 298

Quoted 3 lines
toolchain/helpers.mk +1 -0
+		echo "Incorrect ABI setting: EABIhf selected, but toolchain uses EABI" ; \
 		exit 1 ; \
 	fi

Regards,
Yann E. MORIN.

Signature · 36 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
-------------- next part --------------
Using built-in specs.
COLLECT_GCC=./x-tools/armv6-rpi36-linux-gnueabi/bin/armv6-rpi36-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/ymorin/x-tools/armv6-rpi36-linux-gnueabi/libexec/gcc/armv6-rpi36-linux-gnueabi/4.8.1/lto-wrapper
Target: armv6-rpi36-linux-gnueabi
Configured with:
/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/src/gcc-linaro-4.8-2013.04/configure
    --build=x86_64-build_unknown-linux-gnu
    --host=x86_64-build_unknown-linux-gnu --target=armv6-rpi36-linux-gnueabi
    --prefix=/home/ymorin/x-tools/armv6-rpi36-linux-gnueabi
    --with-sysroot=/home/ymorin/x-tools/armv6-rpi36-linux-gnueabi/armv6-rpi36-linux-gnueabi/sysroot
    --enable-languages=c,c++ --with-arch=armv6zk --with-cpu=arm1176jzf-s
    --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard
    --with-pkgversion='crosstool-NG hg+default-2685dfa9de14'
    --enable-__cxa_atexit --disable-libmudflap --disable-libgomp
    --disable-libssp --disable-libquadmath --disable-libquadmath-support
    --with-gmp=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --with-mpfr=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --with-mpc=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --with-isl=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --with-cloog=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --with-libelf=/home/ymorin/dev/crosstool-NG/ct-ng.current/.build/armv6-rpi36-linux-gnueabi/buildtools
    --enable-threads=posix --enable-target-optspace --disable-libstdcxx-pch
    --enable-linker-build-id --with-linker-hash-style=both
    --enable-plugin --enable-gold --disable-nls --disable-multilib
    --with-local-prefix=/home/ymorin/x-tools/armv6-rpi36-linux-gnueabi/armv6-rpi36-linux-gnueabi/sysroot
    --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.8.1 20130401 (prerelease) (crosstool-NG
hg+default-2685dfa9de14)
#2 lore raw

PATCH 1/1 toolchain: check ARM EABI vs. EABIhf for external toolchains

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 5 lines

toolchain/helpers.mk check_uclibc = \ · line 291

Quoted 5 lines
toolchain/helpers.mk +5 -0
+	else \
+		echo "Unsupported ABI of the external toolchain" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABI) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabihf" ] ; then \

Yann> Using this 'x$(VAR) = xy' construct is ugly. Just quote the variables, Yann> it is easier to read:
Yann> if [ "$(BR2_ARM_EABI)" = "y" ... ]

Yann> The x$VAR construct was from a time when some shells where failing to Yann> test against an empty string. That time is long gone. Virtaully all Yann> shells can compare to empty strings, nowadays.

And we have SHELL=bash

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH 1/1 toolchain: check ARM EABI vs. EABIhf for external toolchains

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 17 lines · Yann E. MORIN

toolchain/helpers.mk check_uclibc = \ · line 286

Quoted 7 lines
toolchain/helpers.mk +4 -2
 	EXT_TOOLCHAIN_TARGET=`LANG=C $${__CROSS_CC} -v 2>&1 | grep ^Target | cut -f2 -d ' '` ; \
-	if ! echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi(hf)?$$' ; then \
-		echo "External toolchain uses the unsuported OABI" ; \
+	if echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabi" ; \
+	elif echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabihf$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabihf" ; \

That's not always the case. You can well have a toolchain which tuple ends in eabi, but the toolchain uses the hard-float ABI.

That's the case by default for crosstool-NG toolchains, for example. Since the *eabihf is recent, not all gcc or binutils versions recognise it, while they are absolutely capable of emitting EABI using the hard-float ABI. Hence, ct-ng allows adding the 'hf' suffix as an option. (see attachment for an example of 'gcc -v' dump).

Quoted 6 lines

Checking for EABI, it is better and more reliable to run the preprocessor, and check some defines are available or not (I always need a bit of googling to get this):

    ARM_TUPLE-gcc -E -dM -xc - </dev/null |grep __ARM_EABI__

However, I could not find a #define about the float ABI... :-(

Ah, interesting. Originally, I wasn't planning on checking the tuple, and I was instead thinking of using a specific tag in the ELF headers.

A binary compiled with an EABIhf toolchain:

$ arm-linux-gnueabihf-readelf -A toto.o | grep Tag_ABI_VFP_args
  Tag_ABI_VFP_args: VFP registers
$

A binary compiled with an EABI toolchain:

$ arm-linux-gnueabihf-readelf -A toto.o | grep Tag_ABI_VFP_args
$

I would run this on the libc or ld.so provided with the toolchain.

What do you think?

Quoted 8 lines

toolchain/helpers.mk check_uclibc = \ · line 291

Quoted 5 lines
toolchain/helpers.mk +5 -0
+	else \
+		echo "Unsupported ABI of the external toolchain" ; \
+		exit 1 ; \
+	fi ; \
+	if [ x$(BR2_ARM_EABI) = x"y" -a $${EXT_TOOLCHAIN_ABI} = "eabihf" ] ; then \

Using this 'x$(VAR) = xy' construct is ugly. Just quote the variables, it is easier to read:

Quoted 5 lines
    if [ "$(BR2_ARM_EABI)" = "y" ... ]

The x$VAR construct was from a time when some shells where failing to test against an empty string. That time is long gone. Virtaully all shells can compare to empty strings, nowadays.

Ok, will fix.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#4 lore raw

PATCH 1/1 toolchain: check ARM EABI vs. EABIhf for external toolchains

Thomas, All,

Quoted 25 lines · On Wednesday 17 July 2013 09:25:19 Thomas Petazzoni wrote:
Quoted 17 lines · Yann E. MORIN

toolchain/helpers.mk check_uclibc = \ · line 286

Quoted 7 lines
toolchain/helpers.mk +4 -2
 	EXT_TOOLCHAIN_TARGET=`LANG=C $${__CROSS_CC} -v 2>&1 | grep ^Target | cut -f2 -d ' '` ; \
-	if ! echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi(hf)?$$' ; then \
-		echo "External toolchain uses the unsuported OABI" ; \
+	if echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabi$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabi" ; \
+	elif echo $${EXT_TOOLCHAIN_TARGET} | grep -qE 'eabihf$$' ; then \
+		EXT_TOOLCHAIN_ABI="eabihf" ; \

That's not always the case. You can well have a toolchain which tuple ends in eabi, but the toolchain uses the hard-float ABI.

That's the case by default for crosstool-NG toolchains, for example. Since the *eabihf is recent, not all gcc or binutils versions recognise it, while they are absolutely capable of emitting EABI using the hard-float ABI. Hence, ct-ng allows adding the 'hf' suffix as an option. (see attachment for an example of 'gcc -v' dump).

Quoted 6 lines

Checking for EABI, it is better and more reliable to run the preprocessor, and check some defines are available or not (I always need a bit of googling to get this):

    ARM_TUPLE-gcc -E -dM -xc - </dev/null |grep __ARM_EABI__

However, I could not find a #define about the float ABI... :-(

Quoted 7 lines

Ah, interesting. Originally, I wasn't planning on checking the tuple, and I was instead thinking of using a specific tag in the ELF headers.

A binary compiled with an EABIhf toolchain:

$ arm-linux-gnueabihf-readelf -A toto.o | grep Tag_ABI_VFP_args
  Tag_ABI_VFP_args: VFP registers

Woot! I learned something! :-)

Quoted 8 lines

A binary compiled with an EABI toolchain:

$ arm-linux-gnueabihf-readelf -A toto.o | grep Tag_ABI_VFP_args
$

I would run this on the libc or ld.so provided with the toolchain.

What do you think?

Yes, great! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< O_o >==-- '------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL    |  """  conspiracy.  |
'------------------------------'-------'------------------'--------------------'