Skip to contentSkip to conversation

toolchain-external: add a specific check to avoid Angstrom toolchains

PATCH Superseded Thomas Petazzoni 4 participants 6 messages Oct 12, 2013 – Oct 13, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

The Angstrom toolchains available at
http://www.angstrom-distribution.org/toolchains/ are not usable as external toolchains in Buildroot, because they are not pure toolchains with just the C library, but instead complete SDKs with many cross-compiled libraries (Gtk, Qt, glib, neon, sqlite, X.org, and many more, approximately 200 MB of libraries).

Buildroot cannot use such toolchains, and while this is documented in our manual, some users still try to do this. Today, one such user came on the IRC channel, reporting a build problem, which we started investigating, only to realize after a long time that he was using an Angstrom toolchain.

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

---
 toolchain/helpers.mk                               | 18 ++++++++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |  1 +
 2 files changed, 19 insertions(+)
toolchain/helpers.mk +18 -0
index 95120cd..d81e561 100644
@@ -324,3 +324,21 @@ check_cross_compiler_exists = \
 		echo "Cannot execute cross-compiler '$${__CROSS_CC}'" ; \
 		exit 1 ; \
 	fi
+
+#
+# Check for toolchains known to not work with Buildroot. To check for
+# Angstrom toolchains, we're taking the "Target: " line in the output
+# of gcc -v, and look at the vendor part of the tuple.
+#
+# $1: cross-gcc path
+#
+check_wrong_toolchain = \
+	__CROSS_CC=$(strip $1) ; \
+	vendor=`$${__CROSS_CC} -v 2>&1 | sed -n '/^Target/s/Target: [^-]*-\([^-]*\)-.*/\1/p'` ; \
+	if test $${vendor} = "angstrom" ; then \
+		echo "Angstrom toolchains are not pure toolchains: they contain" ; \
+		echo "many other libraries than just the C library, which makes" ; \
+		echo "them unsuitable as external toolchains for build systems" ; \
+		echo "such as Buildroot" ; \
+		exit 1 ; \
+	fi
toolchain/toolchain-external/toolchain-external.mk +1 -0
index b5b1ce7..102bcfd 100644
@@ -371,6 +371,7 @@ endif
 # type of C library and all C library features.
 define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
 	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
+	$(Q)$(call check_wrong_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
 	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
 	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:(usr/)?lib(32|64)?/(.*/)?libc\.a::'` ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

Thomas, All,

On 2013-10-12 12:14 +0200, Thomas Petazzoni spake thusly:

Quoted 13 lines

The Angstrom toolchains available at
http://www.angstrom-distribution.org/toolchains/ are not usable as external toolchains in Buildroot, because they are not pure toolchains with just the C library, but instead complete SDKs with many cross-compiled libraries (Gtk, Qt, glib, neon, sqlite, X.org, and many more, approximately 200 MB of libraries).

Buildroot cannot use such toolchains, and while this is documented in our manual, some users still try to do this. Today, one such user came on the IRC channel, reporting a build problem, which we started investigating, only to realize after a long time that he was using an Angstrom toolchain.

Quoted 7 lines

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

Quoted 50 lines
---
 toolchain/helpers.mk                               | 18 ++++++++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |  1 +
 2 files changed, 19 insertions(+)
toolchain/helpers.mk +18 -0
index 95120cd..d81e561 100644
@@ -324,3 +324,21 @@ check_cross_compiler_exists = \
 		echo "Cannot execute cross-compiler '$${__CROSS_CC}'" ; \
 		exit 1 ; \
 	fi
+
+#
+# Check for toolchains known to not work with Buildroot. To check for
+# Angstrom toolchains, we're taking the "Target: " line in the output
+# of gcc -v, and look at the vendor part of the tuple.
+#
+# $1: cross-gcc path
+#
+check_wrong_toolchain = \
+	__CROSS_CC=$(strip $1) ; \
+	vendor=`$${__CROSS_CC} -v 2>&1 | sed -n '/^Target/s/Target: [^-]*-\([^-]*\)-.*/\1/p'` ; \
+	if test $${vendor} = "angstrom" ; then \
+		echo "Angstrom toolchains are not pure toolchains: they contain" ; \
+		echo "many other libraries than just the C library, which makes" ; \
+		echo "them unsuitable as external toolchains for build systems" ; \
+		echo "such as Buildroot" ; \
+		exit 1 ; \
+	fi
toolchain/toolchain-external/toolchain-external.mk +1 -0
index b5b1ce7..102bcfd 100644
@@ -371,6 +371,7 @@ endif
 # type of C library and all C library features.
 define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
 	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
+	$(Q)$(call check_wrong_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
 	$(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
 	SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:(usr/)?lib(32|64)?/(.*/)?libc\.a::'` ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
Signature · 6 lines
1.8.1.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 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.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

In reply to Thomas Petazzoni

Hi Thomas,

Quoted 30 lines · Thomas Petazzoni

The Angstrom toolchains available at
http://www.angstrom-distribution.org/toolchains/ are not usable as external toolchains in Buildroot, because they are not pure toolchains with just the C library, but instead complete SDKs with many cross-compiled libraries (Gtk, Qt, glib, neon, sqlite, X.org, and many more, approximately 200 MB of libraries).

Buildroot cannot use such toolchains, and while this is documented in our manual, some users still try to do this. Today, one such user came on the IRC channel, reporting a build problem, which we started investigating, only to realize after a long time that he was using an Angstrom toolchain.

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

---
 toolchain/helpers.mk                               | 18 ++++++++++++++++++
 toolchain/toolchain-external/toolchain-external.mk |  1 +
 2 files changed, 19 insertions(+)
toolchain/helpers.mk +0 -0
index 95120cd..d81e561 100644

toolchain/helpers.mk check_cross_compiler_exists = \ · line 329

Quoted 6 lines
toolchain/helpers.mk +3 -0
@@ -324,3 +324,21 @@ check_cross_compiler_exists = \
                echo "Cannot execute cross-compiler '$${__CROSS_CC}'" ; \
                exit 1 ; \
        fi
+
+#
+# Check for toolchains known to not work with Buildroot. To check for

I think it is more common to say 'known not to work' (nit)

toolchain/helpers.mk check_cross_compiler_exists = \ · line 331

Quoted 2 lines
toolchain/helpers.mk +2 -0
+# Angstrom toolchains, we're taking the "Target: " line in the output
+# of gcc -v, and look at the vendor part of the tuple.

Is there a reason why you're not using 'gcc -dumpmachine'? This directly prints the tuple...

toolchain/helpers.mk check_cross_compiler_exists = \ · line 335

Quoted 4 lines
toolchain/helpers.mk +4 -0
+#
+# $1: cross-gcc path
+#
+check_wrong_toolchain = \

This is just nitting about names, but I find 'wrong' odd here. What about 'unusable'?

toolchain/helpers.mk check_cross_compiler_exists = \ · line 338

Quoted 3 lines
toolchain/helpers.mk +3 -0
+       __CROSS_CC=$(strip $1) ; \
+       vendor=`$${__CROSS_CC} -v 2>&1 | sed -n '/^Target/s/Target: [^-]*-\([^-]*\)-.*/\1/p'` ; \
+       if test $${vendor} = "angstrom" ; then \

I think that you should put $${vendor}} in quotes here. Suppose it returns an empty string for one reason or the other, then you'll get a syntax failure.

Quoted 11 lines
toolchain/helpers.mk +6 -0
+               echo "Angstrom toolchains are not pure toolchains: they contain" ; \
+               echo "many other libraries than just the C library, which makes" ; \
+               echo "them unsuitable as external toolchains for build systems" ; \
+               echo "such as Buildroot" ; \
+               exit 1 ; \
+       fi
toolchain/toolchain-external/toolchain-external.mk +0 -0
index b5b1ce7..102bcfd 100644

toolchain/toolchain-external/toolchain-external.mk endif · line 377

Quoted 7 lines
toolchain/toolchain-external/toolchain-external.mk +1 -0
@@ -371,6 +371,7 @@ endif
 # type of C library and all C library features.
 define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
        $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
+       $(Q)$(call check_wrong_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
        $(Q)LIBC_A_LOCATION=`readlink -f $$(LANG=C $(TOOLCHAIN_EXTERNAL_CC) -print-file-name=libc.a)` ; \
        SYSROOT_DIR=`echo $${LIBC_A_LOCATION} | sed -r -e 's:(usr/)?lib(32|64)?/(.*/)?libc\.a::'` ; \
        if test -z "$${SYSROOT_DIR}" ; then \

Best regards,
Thomas

#3 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

In reply to Thomas Petazzoni

Hi Thomas,

Le Sat, 12 Oct 2013 12:14:42 +0200,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 6 lines

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

maybe you should also check for at least "oe" and "poky" as these are the vendor part of toolchains generated with plain OE-Core or Yocto/Poky.

Eric

#4 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

Dear Eric B?nard,

Quoted 11 lines · Eric B?nard

Le Sat, 12 Oct 2013 12:14:42 +0200,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 6 lines

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

maybe you should also check for at least "oe" and "poky" as these are the vendor part of toolchains generated with plain OE-Core or Yocto/Poky.

Hum, right. Are those available in the form of tarballs, like the angstrom toolchain available at
http://www.angstrom-distribution.org/toolchains/ ? I know you can generate such tarballs with OE or Yocto, but unless these tarballs are available pre-built on the web, I guess it's pretty unlikely that such toolchains get used as external toolchains in Buildroot.

Ideally, we would need to check if the toolchain is not a pure toolchain, but it's quite hard to check. We would have to verify if the toolchain does *not* have more than what it should have, but doing that in an exhaustive way is quite difficult.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH 1/1 toolchain-external: add a specific check to avoid Angstrom toolchains

Le Sun, 13 Oct 2013 15:41:06 +0200,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 16 lines

Dear Eric B?nard,

Quoted 11 lines · Eric B?nard

Le Sat, 12 Oct 2013 12:14:42 +0200,
Thomas Petazzoni <[email protected]> a ?crit :

Quoted 6 lines

To avoid this problem in the future, we explicitly check if the toolchain is from Angstrom by looking at the vendor part of the tuple exposed by the toolchain: as soon as it is <something>-angstrom-<something-else>, we reject the toolchain with an explanation.

maybe you should also check for at least "oe" and "poky" as these are the vendor part of toolchains generated with plain OE-Core or Yocto/Poky.

Quoted 7 lines

Hum, right. Are those available in the form of tarballs, like the angstrom toolchain available at
http://www.angstrom-distribution.org/toolchains/ ? I know you can generate such tarballs with OE or Yocto, but unless these tarballs are available pre-built on the web, I guess it's pretty unlikely that such toolchains get used as external toolchains in Buildroot.

http://downloads.yoctoproject.org/releases/yocto/yocto-1.4/toolchain/

Eric