* [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains @ 2013-07-16 22:06 Thomas Petazzoni 2013-07-16 22:39 ` Yann E. MORIN 0 siblings, 1 reply; 5+ messages in thread From: Thomas Petazzoni @ 2013-07-16 22:06 UTC (permalink / raw) To: buildroot 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. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- toolchain/helpers.mk | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk index 95217e7..dc21f8a 100644 --- a/toolchain/helpers.mk +++ b/toolchain/helpers.mk @@ -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 -- 1.8.1.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains 2013-07-16 22:06 [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains Thomas Petazzoni @ 2013-07-16 22:39 ` Yann E. MORIN 2013-07-17 5:27 ` Peter Korsgaard 2013-07-17 7:25 ` Thomas Petazzoni 0 siblings, 2 replies; 5+ messages in thread From: Yann E. MORIN @ 2013-07-16 22:39 UTC (permalink / raw) To: buildroot Thomas, All, On 2013-07-17 00:06 +0200, Thomas Petazzoni spake thusly: > 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. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > --- > toolchain/helpers.mk | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk > index 95217e7..dc21f8a 100644 > --- a/toolchain/helpers.mk > +++ b/toolchain/helpers.mk > @@ -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... :-( > + 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. > + 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. > + echo "Incorrect ABI setting: EABIhf selected, but toolchain uses EABI" ; \ > exit 1 ; \ > fi Regards, Yann E. MORIN. -- .-----------------.--------------------.------------------.--------------------. | 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) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains 2013-07-16 22:39 ` Yann E. MORIN @ 2013-07-17 5:27 ` Peter Korsgaard 2013-07-17 7:25 ` Thomas Petazzoni 1 sibling, 0 replies; 5+ messages in thread From: Peter Korsgaard @ 2013-07-17 5:27 UTC (permalink / raw) To: buildroot >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes: Hi, >> + 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 -- Bye, Peter Korsgaard ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains 2013-07-16 22:39 ` Yann E. MORIN 2013-07-17 5:27 ` Peter Korsgaard @ 2013-07-17 7:25 ` Thomas Petazzoni 2013-07-17 7:45 ` Yann E. MORIN 1 sibling, 1 reply; 5+ messages in thread From: Thomas Petazzoni @ 2013-07-17 7:25 UTC (permalink / raw) To: buildroot Dear Yann E. MORIN, On Wed, 17 Jul 2013 00:39:53 +0200, Yann E. MORIN wrote: > > 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... :-( 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? > > + 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. Ok, will fix. Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains 2013-07-17 7:25 ` Thomas Petazzoni @ 2013-07-17 7:45 ` Yann E. MORIN 0 siblings, 0 replies; 5+ messages in thread From: Yann E. MORIN @ 2013-07-17 7:45 UTC (permalink / raw) To: buildroot Thomas, All, On Wednesday 17 July 2013 09:25:19 Thomas Petazzoni wrote: > On Wed, 17 Jul 2013 00:39:53 +0200, Yann E. MORIN wrote: > > > 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... :-( > > 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! :-) > 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. -- .-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------'-------'------------------'--------------------' ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-17 7:45 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-16 22:06 [Buildroot] [PATCH] toolchain: check ARM EABI vs. EABIhf for external toolchains Thomas Petazzoni 2013-07-16 22:39 ` Yann E. MORIN 2013-07-17 5:27 ` Peter Korsgaard 2013-07-17 7:25 ` Thomas Petazzoni 2013-07-17 7:45 ` Yann E. MORIN
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox