Skip to contentSkip to conversation

toolchain: misc fixes (branch yem/toolchain-fixes)

PATCH New Yann E. MORIN 2 participants 4 messages Mar 17, 2015 – Apr 4, 2015

lore
Share & tools
lore
#0 lore raw

v3 cover toolchain: misc fixes (branch yem/toolchain-fixes)

Hello All!

This series introduces two fixes in the external toolchain handling:

- reject "distro-class" toolchains, i.e. the cross-oolchains packaged in Debian and its derivatives, since those toolchains are both non-relocatable and tainted with a lot of crap (i.e. non-libc libraries) which make them unfit for use by Buildroot;

- try harder to find the gconv modules for those multi-arch toolchains, since there may be gconv modules for each variant, and thus would be located out-side the main sysroot.

Changes v2 -> v3:
- update comment for distro-class toolchains (Thomas, Arnout)
- use TOOLCHAIN_EXTERNAL_PREFIX instead of asking gcc (Thomas)

Regards,
Yann E. MORIN.

The following changes since commit 9b8481671e9d0c6abc90d669f99c6925eda86c96:

package/dovecot: bump version to 2.2.16 (2015-03-17 13:03:02 +0100)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot yem/toolchain-fixes

for you to fetch changes up to 1d2730901d20f1f9bfcfde77883a385b49c73b00:

toolchain: fix installing gconv libs with multi-arch toolchain (2015-03-17 15:04:23 +0100)

----------------------------------------------------------------
Yann E. MORIN (2):
toolchain/external: do not accept distro-class toolchains
toolchain: fix installing gconv libs with multi-arch toolchain

 toolchain/helpers.mk   |  8 ++++++++
 toolchain/toolchain.mk | 26 ++++++++++++++++++--------
 2 files changed, 26 insertions(+), 8 deletions(-)
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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v3 1/2 toolchain/external: do not accept distro-class toolchains

Distro toolchains, i.ie. toolchains coing with distributions, will almost invariably be unsuitable for use with Buildroot:
- they are mostly non-relocatable;
- their sysroot is tainted with a lot of extra libraries.

Especially, the toolchains coming with Ubuntu (really, all the Debian familly of distros) are configured with --sysroot=/ which makes them non-relocatable, and they already contain quite some libraries that conflict (in any combination of version, API or ABI) with what Buildroot wants to build (i.e. extra libraries, some not even present in Buildroot...) but also their mere preence when Buildroot does not expect them to be already built (so that a package would enable features when it should not).

So, try to detect those toolchains and black-list them; inform the user that the toolchain is unusable for the reasons mentioned above.

Cc Thomas Petazzoni <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

---
Changes v1 -> v2:
- update the comment to specify both non-relocatable and polution (Thomas and Arnout)

---
 toolchain/helpers.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
toolchain/helpers.mk +8 -0
index 3121da4..3afb6d6 100644
@@ -347,6 +347,14 @@ check_unusable_toolchain = \
 		echo "them unsuitable as external toolchains for build systems" ; \
 		echo "such as Buildroot." ; \
 		exit 1 ; \
+	fi; \
+	with_sysroot=`$${__CROSS_CC} -v 2>&1 |sed -r -e '/.* --with-sysroot=([^[:space:]]+)[[:space:]].*/!d; s//\1/'`; \
+	if test "$${with_sysroot}"  = "/" ; then \
+		echo "Distribution toolchains are unsuitable for use by Buildroot," ; \
+		echo "as they were configured in a way that makes them non-relocatable,"; \
+		echo "and contain a lot of pre-built libraries that would conflict with"; \
+		echo "the ones Buildroot wants to build."; \
+		exit 1; \
 	fi
 
 #
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/2 toolchain/external: do not accept distro-class toolchains

Dear Yann E. MORIN,

toolchain/helpers.mk check_unusable_toolchain = \ · line 351

Quoted 1 line · Yann E. MORIN
toolchain/helpers.mk +1 -0
+	with_sysroot=`$${__CROSS_CC} -v 2>&1 |sed -r -e '/.* --with-sysroot=([^[:space:]]+)[[:space:]].*/!d; s//\1/'`; \

I found this sed expression a bit complicated, but maybe there's no other choice. So I've applied this.

Thanks,

Thomas

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

PATCH v3 2/2 toolchain: fix installing gconv libs with multi-arch toolchain

In reply to Yann E. MORIN

For a multi-arch toolchain, gconv modules are in a sub-directory named after the machine gcc targets. This is the case, for example, for the Linaro ARM 2014.09 toolchain, which has the gconv modules in (relative to the sysroot):
/usr/lib/arm-linux-gnueabihf/gconv

while the Sourcery CodeBench ARM 2014.05 (non-multi-arch) has them in:
/usr/lib/gconv

So, to catter for both cases, search both paths. We want to favour the machine-specific gconv modules over potentially existing "generic" ones, so we first search that (if it exists) and fallback to looking in the generic location.

---
Changes v2 -> v3:
- use TOOLCHAIN_EXTERNAL_PREFIX instead of computing it again

Changes v1 -> v2:
- also handle the case where the gconv modules list is specified

---
Notes: I'm not too happy about the use of "gcc -dumpmachine", but that's the only solution I found that worked on my use-case. I tried duplicating the ARCH_SUBDIR trick from toolchain-external, but that did not work...

---
 toolchain/toolchain.mk | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
toolchain/toolchain.mk +18 -8
index 3f9900b..0a35909 100644
@@ -17,28 +17,38 @@ endif
 ifeq ($(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY),y)
 GCONV_LIBS = $(call qstrip,$(BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_LIST))
 define COPY_GCONV_LIBS
-	$(Q)if [ -z "$(GCONV_LIBS)" ]; then \
-		$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/gconv/gconv-modules \
-				      $(TARGET_DIR)/usr/lib/gconv/gconv-modules; \
-		$(INSTALL) -m 0644 $(STAGING_DIR)/usr/lib/gconv/*.so \
+	$(Q)found_gconv=no; \
+	for d in $(TOOLCHAIN_EXTERNAL_PREFIX) ''; do \
+		[ -d "$(STAGING_DIR)/usr/lib/$${d}/gconv" ] || continue; \
+		found_gconv=yes; \
+		break; \
+	done; \
+	if [ "$${found_gconv}" = "no" ]; then \
+		printf "Unable to find gconv modules\n" >&2; \
+		exit 1; \
+	fi; \
+	if [ -z "$(GCONV_LIBS)" ]; then \
+		$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules \
+				      $(TARGET_DIR)/usr/lib/gconv/gconv-modules && \
+		$(INSTALL) -m 0644 $(STAGING_DIR)/usr/lib/$${d}/gconv/*.so \
 				   $(TARGET_DIR)/usr/lib/gconv \
 		|| exit 1; \
 	else \
 		for l in $(GCONV_LIBS); do \
-			$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/gconv/$${l}.so \
+			$(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/$${l}.so \
 					      $(TARGET_DIR)/usr/lib/gconv/$${l}.so \
 			|| exit 1; \
-			$(TARGET_READELF) -d $(STAGING_DIR)/usr/lib/gconv/$${l}.so |\
+			$(TARGET_READELF) -d $(STAGING_DIR)/usr/lib/$${d}/gconv/$${l}.so |\
 			sort -u |\
 			sed -e '/.*(NEEDED).*\[\(.*\.so\)\]$$/!d; s//\1/;' |\
 			while read lib; do \
-				 $(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/gconv/$${lib} \
+				 $(INSTALL) -m 0644 -D $(STAGING_DIR)/usr/lib/$${d}/gconv/$${lib} \
 						       $(TARGET_DIR)/usr/lib/gconv/$${lib} \
 				 || exit 1; \
 			done; \
 		done; \
 		./support/scripts/expunge-gconv-modules "$(GCONV_LIBS)" \
-			<$(STAGING_DIR)/usr/lib/gconv/gconv-modules \
+			<$(STAGING_DIR)/usr/lib/$${d}/gconv/gconv-modules \
 			>$(TARGET_DIR)/usr/lib/gconv/gconv-modules; \
 	fi
 endef
Signature · 1 line
1.9.1