Skip to contentSkip to conversation

toolchain-external: Fix EABIhf check

PATCH Superseded Thomas De Schampheleire 3 participants 4 messages May 9, 2014 – May 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 toolchain-external: Fix EABIhf check

From: Stefan S?rensen <[email protected]>

Currently the check for EABI/EABIhf toolchains looks for the Tag_ABI_VFP_args attribute in the crt1.o file which gcc adds in an EABIhf toolchain.
In uClibc, however, crt1.o is not compiled from c but assembly, so the Tag_ABI_VFP_args attribute is not added in the object file. This causes the EABIhf check in the external toolchain logic to fail for uClibc-based toolchains.

Fix by compiling a dummy .c file and trying to link the object against the C library. Since it is impossible to mix EABI and EABIhf code, a mismatch between the buildroot and toolchain ABI settings will be detected during this link step.

Fixes bug #6842: https://bugs.busybox.net/show_bug.cgi?id=6842

[ThomasDS: do full link iso readelf test, update commit message]

---
Note: this v4 did not change the error message, awaiting Arnout's input.

v4: (ThomasDS)
- avoid creating a temporary object file (Arnout)

v3: (ThomasDS)
- v2 properly recognized a uClibc EABIhf toolchain, but failed to detect a mismatch with buildroot settings (detected by ThomasP). Fix by performing an actual link step to detect any incompatibility.
v2: (ThomasDS)
- avoid creating a temporary source file
- update commit message

 toolchain/helpers.mk |  16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
toolchain/helpers.mk +4 -12
@@ -297,20 +297,12 @@ check_arm_abi = \
 		echo "External toolchain uses the unsuported OABI" ; \
 		exit 1 ; \
 	fi ; \
-	EXT_TOOLCHAIN_CRT1=`LANG=C $${__CROSS_CC} -print-file-name=crt1.o` ; \
-	if $${__CROSS_READELF} -A $${EXT_TOOLCHAIN_CRT1} | grep -q "Tag_ABI_VFP_args:" ; then \
-		EXT_TOOLCHAIN_ABI="eabihf" ; \
-	else \
-		EXT_TOOLCHAIN_ABI="eabi" ; \
-	fi ; \
-	if [ "$(BR2_ARM_EABI)" = "y" -a "$${EXT_TOOLCHAIN_ABI}" = "eabihf" ] ; then \
-		echo "Incorrect ABI setting: EABI selected, but toolchain uses EABIhf" ; \
+	if ! echo 'int main(void) {}' | $${__CROSS_CC} -x c -o /dev/null - 2>/dev/null; then \
+		abistr_$(BR2_ARM_EABI)='EABI'; \
+		abistr_$(BR2_ARM_EABIHF)='EABIhf'; \
+		echo "Incorrect ABI setting: $${abistr_y} selected, but toolchain is incompatible"; \
 		exit 1 ; \
 	fi ; \
-	if [ "$(BR2_ARM_EABIHF)" = "y" -a "$${EXT_TOOLCHAIN_ABI}" = "eabi" ] ; then \
-		echo "Incorrect ABI setting: EABIhf selected, but toolchain uses EABI" ; \
-		exit 1 ; \
-	fi
 
 #
 # Check that the external toolchain supports C++
#1 lore raw

PATCH v4 1/1 toolchain-external: Fix EABIhf check

Quoted 15 lines · Thomas De Schampheleire

From: Stefan S?rensen <[email protected]>

Currently the check for EABI/EABIhf toolchains looks for the Tag_ABI_VFP_args attribute in the crt1.o file which gcc adds in an EABIhf toolchain.
In uClibc, however, crt1.o is not compiled from c but assembly, so the Tag_ABI_VFP_args attribute is not added in the object file. This causes the EABIhf check in the external toolchain logic to fail for uClibc-based toolchains.

Fix by compiling a dummy .c file and trying to link the object against the C library. Since it is impossible to mix EABI and EABIhf code, a mismatch between the buildroot and toolchain ABI settings will be detected during this link step.

Quoted 5 lines

Fixes bug #6842: https://bugs.busybox.net/show_bug.cgi?id=6842

[ThomasDS: do full link iso readelf test, update commit message]

[snip]

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#2 lore raw

PATCH v4 1/1 toolchain-external: Fix EABIhf check

In reply to Thomas De Schampheleire
Quoted 50 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas De Schampheleire <[email protected]> writes:

From: Stefan S?rensen <[email protected]> Currently the check for EABI/EABIhf toolchains looks for the Tag_ABI_VFP_args attribute in the crt1.o file which gcc adds in an EABIhf toolchain.
In uClibc, however, crt1.o is not compiled from c but assembly, so the Tag_ABI_VFP_args attribute is not added in the object file. This causes the EABIhf check in the external toolchain logic to fail for uClibc-based toolchains.

Fix by compiling a dummy .c file and trying to link the object against the C library. Since it is impossible to mix EABI and EABIhf code, a mismatch between the buildroot and toolchain ABI settings will be detected during this link step.

Fixes bug #6842: https://bugs.busybox.net/show_bug.cgi?id=6842

[ThomasDS: do full link iso readelf test, update commit message]

---
Note: this v4 did not change the error message, awaiting Arnout's input.

v4: (ThomasDS)
- avoid creating a temporary object file (Arnout)

v3: (ThomasDS)
- v2 properly recognized a uClibc EABIhf toolchain, but failed to detect a mismatch with buildroot settings (detected by ThomasP). Fix by performing an actual link step to detect any incompatibility.
v2: (ThomasDS)
- avoid creating a temporary source file
- update commit message

 toolchain/helpers.mk |  16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
toolchain/helpers.mk +0 -4
@@ -297,20 +297,12 @@ check_arm_abi = \
 		echo "External toolchain uses the unsuported OABI" ; \
 		exit 1 ; \
 	fi ; \
-	EXT_TOOLCHAIN_CRT1=`LANG=C $${__CROSS_CC} -print-file-name=crt1.o` ; \
-	if $${__CROSS_READELF} -A $${EXT_TOOLCHAIN_CRT1} | grep -q "Tag_ABI_VFP_args:" ; then \
-		EXT_TOOLCHAIN_ABI="eabihf" ; \
-	else \

toolchain/helpers.mk check_arm_abi = \ · line 305

Quoted 10 lines
toolchain/helpers.mk +4 -4
-		EXT_TOOLCHAIN_ABI="eabi" ; \
-	fi ; \
-	if [ "$(BR2_ARM_EABI)" = "y" -a "$${EXT_TOOLCHAIN_ABI}" = "eabihf" ] ; then \
-		echo "Incorrect ABI setting: EABI selected, but toolchain uses EABIhf" ; \
+	if ! echo 'int main(void) {}' | $${__CROSS_CC} -x c -o /dev/null - 2>/dev/null; then \
+		abistr_$(BR2_ARM_EABI)='EABI'; \
+		abistr_$(BR2_ARM_EABIHF)='EABIhf'; \
+		echo "Incorrect ABI setting: $${abistr_y} selected, but toolchain is incompatible"; \
 		exit 1 ; \
 	fi ; \

This final line should just be 'fi' otherwise the shell gets confused and I get:

Quoted 1 line
Quoted 1 line
Quoted 1 line

toolchain-external undefined Configuring

/bin/bash: -c: line 0: syntax error near unexpected token `;'

Committed with that fixed, thanks.

Quoted 4 lines
toolchain/helpers.mk +0 -4
-	if [ "$(BR2_ARM_EABIHF)" = "y" -a "$${EXT_TOOLCHAIN_ABI}" = "eabi" ] ; then \
-		echo "Incorrect ABI setting: EABIhf selected, but toolchain uses EABI" ; \
-		exit 1 ; \
-	fi
Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v4 1/1 toolchain-external: Fix EABIhf check

Peter Korsgaard <[email protected]> schreef:

Quoted 64 lines
Quoted 50 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas De Schampheleire <[email protected]> writes:

From: Stefan S?rensen <[email protected]> Currently the check for EABI/EABIhf toolchains looks for the Tag_ABI_VFP_args attribute in the crt1.o file which gcc adds in an EABIhf toolchain.
In uClibc, however, crt1.o is not compiled from c but assembly, so the Tag_ABI_VFP_args attribute is not added in the object file. This causes the EABIhf check in the external toolchain logic to fail for uClibc-based toolchains.

Fix by compiling a dummy .c file and trying to link the object against the C library. Since it is impossible to mix EABI and EABIhf code, a mismatch between the buildroot and toolchain ABI settings will be detected during this link step.

Fixes bug #6842: https://bugs.busybox.net/show_bug.cgi?id=6842

[ThomasDS: do full link iso readelf test, update commit message]

---
Note: this v4 did not change the error message, awaiting Arnout's input.

v4: (ThomasDS)
- avoid creating a temporary object file (Arnout)

v3: (ThomasDS)
- v2 properly recognized a uClibc EABIhf toolchain, but failed to detect a mismatch with buildroot settings (detected by ThomasP). Fix by performing an actual link step to detect any incompatibility.
v2: (ThomasDS)
- avoid creating a temporary source file
- update commit message

 toolchain/helpers.mk |  16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
toolchain/helpers.mk +0 -4
@@ -297,20 +297,12 @@ check_arm_abi = \
 		echo "External toolchain uses the unsuported OABI" ; \
 		exit 1 ; \
 	fi ; \
-	EXT_TOOLCHAIN_CRT1=`LANG=C $${__CROSS_CC} -print-file-name=crt1.o` ; \
-	if $${__CROSS_READELF} -A $${EXT_TOOLCHAIN_CRT1} | grep -q "Tag_ABI_VFP_args:" ; then \
-		EXT_TOOLCHAIN_ABI="eabihf" ; \
-	else \

toolchain/helpers.mk check_arm_abi = \ · line 305

Quoted 10 lines
toolchain/helpers.mk +4 -4
-		EXT_TOOLCHAIN_ABI="eabi" ; \
-	fi ; \
-	if [ "$(BR2_ARM_EABI)" = "y" -a "$${EXT_TOOLCHAIN_ABI}" = "eabihf" ] ; then \
-		echo "Incorrect ABI setting: EABI selected, but toolchain uses EABIhf" ; \
+	if ! echo 'int main(void) {}' | $${__CROSS_CC} -x c -o /dev/null - 2>/dev/null; then \
+		abistr_$(BR2_ARM_EABI)='EABI'; \
+		abistr_$(BR2_ARM_EABIHF)='EABIhf'; \
+		echo "Incorrect ABI setting: $${abistr_y} selected, but toolchain is incompatible"; \
 		exit 1 ; \
 	fi ; \

This final line should just be 'fi' otherwise the shell gets confused and I get:

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

toolchain-external undefined Configuring

/bin/bash: -c: line 0: syntax error near unexpected token `;'

Committed with that fixed, thanks.

Aargh, that's entirely my fault due to removing the temporary file in v4 and not retesting, sorry.

Best regards,
Thomas