Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 0/3] toolchain: Add support for Sourcery Codebench Standard
@ 2014-10-28 21:28 Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 1/3] toolchain-external: Detect empty or invalid sysroot Romain Naour
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Romain Naour @ 2014-10-28 21:28 UTC (permalink / raw)
  To: buildroot

The purpose of this series is to provide support for Sourcery Codebench
Standard (licenced) edition in Buildroot.

Since these toolchain can't be downloaded, we need to use the custom toolchain
backend to import them into Buildroot.

In Toolchain menu, select:
  Toolchain type (External toolchain)
  Toolchain (Custom toolchain)
  Toolchain origin (Pre-installed toolchain)

Then set all toolchain settings (kernel headers, libc, rpc, c++ etc...)

I'm using the Sourcery Codebench 2014.05 for IA32 GNU/Linux, here is the
settings:

(i686-pc-linux-gnu) Toolchain prefix
  External toolchain kernel headers series (3.13.x)
  External toolchain C library (glibc/eglibc)
[*] Toolchain has RPC support
[*] Toolchain has C++ support?
(-pipe -msgxx-glibc) Target Optimizations

The "-msgxx-glibc" flag in "Target Optimizations" is mandatory otherwise the
toolchain won't work.

Thanks to Yann E. Morin and Thomas Petazzoni for the help and review on this topic.

v2: Rework entirely this serie to take into account comments received on v1.
http://lists.busybox.net/pipermail/buildroot/2014-October/108641.html

Romain Naour (3):
  toolchain-external: Detect empty or invalid sysroot
  toolchain-helpers: factorise the arch sysroot symlink creation
  toolchain-external: calculation of the symlink to the arch sysroot

 toolchain/helpers.mk                               | 70 +++++++++++++++++++---
 toolchain/toolchain-external/toolchain-external.mk | 28 ++++++---
 2 files changed, 82 insertions(+), 16 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH v2 1/3] toolchain-external: Detect empty or invalid sysroot
  2014-10-28 21:28 [Buildroot] [PATCH v2 0/3] toolchain: Add support for Sourcery Codebench Standard Romain Naour
@ 2014-10-28 21:28 ` Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 2/3] toolchain-helpers: factorise the arch sysroot symlink creation Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot Romain Naour
  2 siblings, 0 replies; 5+ messages in thread
From: Romain Naour @ 2014-10-28 21:28 UTC (permalink / raw)
  To: buildroot

With the Sourcery Codebench standard edition, the sysroot returned
point to a non existant directory if no CFLAGS are specified.

Here are the results of -print-sysroot gcc option:

$ ./i686-pc-linux-gnu-gcc -print-sysroot
Full/path/to/i686-pc-linux-gnu/libc/system32 (doesn't exist)

$ ./i686-pc-linux-gnu-gcc -m64 -print-sysroot
Full/path/to/i686-pc-linux-gnu/libc/system64 (doesn't exist)

$ ./i686-pc-linux-gnu-gcc -msgxx-glibc -print-sysroot
Full/path/to/i686-pc-linux-gnu/libc/sgxx-glibc (exist)

The problem is that in the "libc" directory there is only the sub-directory
"sgxx-glibc". Therefore all hearders files and libraries are only available
in arch specific sysroot.

When using the -print-file-name gcc option, the result is quite buggy and it
is not empty.

$ ./i686-pc-linux-gnu-gcc -print-file-name=libc.a
libc.a

So the toolchain check fail because $PWD/libc.a is used as SYSROOT_DIR since
the toolchain-external backend does not always use CFLAGS.

This patch change the SYSROOT_DIR/ARCH_SYSROOT_DIR detection logic so that if
SYSROOT_DIR is empty/bogus, then the same value as ARCH_SYSROOT_DIR is used.

This ensures that both SYSROOT_DIR and ARCH_SYSROOT_DIR point to valid
directories (which would the same in the case of this toolchain, which brings
us back to the non-multilib toolchain case).

If toolchain_find_sysroot() was used without flags, then flags are added to
allow the fallback to arch sysroot. In normal cases the same behavior as
before is expected.

If toolchain_find_sysroot() was used with flags, then it's replaced by
toolchain_find_arch_sysroot() with the same flags.

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
 toolchain/toolchain-external/toolchain-external.mk | 28 +++++++++++++++-------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/toolchain/toolchain-external/toolchain-external.mk b/toolchain/toolchain-external/toolchain-external.mk
index b7a0e60..2aee133 100644
--- a/toolchain/toolchain-external/toolchain-external.mk
+++ b/toolchain/toolchain-external/toolchain-external.mk
@@ -437,9 +437,9 @@ define toolchain_find_libc_a
 $$(readlink -f $$(LANG=C $(1) -print-file-name=libc.a))
 endef
 
-# Returns the sysroot location for the given compiler + flags
-define toolchain_find_sysroot
-$$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::')
+# Returns the arch sysroot location for the given compiler + flags
+define toolchain_find_arch_sysroot
+$$(echo -n $(call toolchain_find_libc_a,$(1) $(2)) | sed -r -e 's:(usr/)?lib(32|64)?/([^/]*/)?libc\.a::')
 endef
 
 # Returns the lib subdirectory for the given compiler + flags (i.e
@@ -448,6 +448,18 @@ define toolchain_find_libdir
 $$(echo -n $(call toolchain_find_libc_a,$(1)) | sed -r -e 's:.*/(usr/)?(lib(32|64)?)/([^/]*/)?libc.a:\2:')
 endef
 
+# Returns the main sysroot location for the given compiler + flags
+# First, try to find the sysroot without flags.
+# If the sysroot path is empty/bogus then use the arch sysroot instead.
+define toolchain_find_sysroot
+$$(main_sysroot="$(call toolchain_find_arch_sysroot,$(1))"; \
+if ! test -d $${main_sysroot}; then \
+	echo -n $(call toolchain_find_arch_sysroot,$(1), $(2)) ; \
+else \
+	echo -n $${main_sysroot}; \
+fi)
+endef
+
 # Checks for an already installed toolchain: check the toolchain
 # location, check that it supports sysroot, and then verify that it
 # matches the configuration provided in Buildroot: ABI, C++ support,
@@ -455,13 +467,13 @@ endef
 define TOOLCHAIN_EXTERNAL_CONFIGURE_CMDS
 	$(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC))
 	$(Q)$(call check_unusable_toolchain,$(TOOLCHAIN_EXTERNAL_CC))
-	$(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
+	$(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC), $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
 		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
 		exit 1 ; \
 	fi ; \
 	$(call check_kernel_headers_version,\
-		$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC)),\
+		$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC), $(TOOLCHAIN_EXTERNAL_CFLAGS)),\
 		$(call qstrip,$(BR2_TOOLCHAIN_HEADERS_AT_LEAST))); \
 	if test "$(BR2_arm)" = "y" ; then \
 		$(call check_arm_abi,\
@@ -544,12 +556,12 @@ endif
 #                       to the target filesystem.
 
 define TOOLCHAIN_EXTERNAL_INSTALL_CORE
-	$(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; \
+	$(Q)SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC), $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	if test -z "$${SYSROOT_DIR}" ; then \
 		@echo "External toolchain doesn't support --sysroot. Cannot use." ; \
 		exit 1 ; \
 	fi ; \
-	ARCH_SYSROOT_DIR="$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+	ARCH_SYSROOT_DIR="$(call toolchain_find_arch_sysroot,$(TOOLCHAIN_EXTERNAL_CC), $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	ARCH_LIB_DIR="$(call toolchain_find_libdir,$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	SUPPORT_LIB_DIR="" ; \
 	if test `find $${ARCH_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
@@ -595,7 +607,7 @@ ifeq ($(BR2_BFIN_INSTALL_FDPIC_SHARED),y)
 define TOOLCHAIN_EXTERNAL_INSTALL_BFIN_FDPIC
 	$(Q)$(call MESSAGE,"Install external toolchain FDPIC libraries to target...") ; \
 	FDPIC_EXTERNAL_CC=$(dir $(TOOLCHAIN_EXTERNAL_CC))/../../bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc ; \
-	FDPIC_SYSROOT_DIR="$(call toolchain_find_sysroot,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
+	FDPIC_SYSROOT_DIR="$(call toolchain_find_arch_sysroot,$${FDPIC_EXTERNAL_CC}, $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	FDPIC_LIB_DIR="$(call toolchain_find_libdir,$${FDPIC_EXTERNAL_CC} $(TOOLCHAIN_EXTERNAL_CFLAGS))" ; \
 	FDPIC_SUPPORT_LIB_DIR="" ; \
 	if test `find $${FDPIC_SYSROOT_DIR} -name 'libstdc++.a' | wc -l` -eq 0 ; then \
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH v2 2/3] toolchain-helpers: factorise the arch sysroot symlink creation
  2014-10-28 21:28 [Buildroot] [PATCH v2 0/3] toolchain: Add support for Sourcery Codebench Standard Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 1/3] toolchain-external: Detect empty or invalid sysroot Romain Naour
@ 2014-10-28 21:28 ` Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot Romain Naour
  2 siblings, 0 replies; 5+ messages in thread
From: Romain Naour @ 2014-10-28 21:28 UTC (permalink / raw)
  To: buildroot

The part of copy_toolchain_sysroot function that create the symlink in the
staging directory will be used in two different place in the following patch.
So factorize this part in a new function called
toolchain_create_arch_sysroot_symlink.

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
 toolchain/helpers.mk | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 3121da4..7d7af5f 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -83,6 +83,20 @@ copy_toolchain_lib_root = \
 \
 	echo -n
 
+# Calculate the symlink's depth by counting the number of slashs.
+# Then create the symlink to arch sysroot.
+# $1: arch specific subdirectory in the sysroot
+toolchain_create_arch_sysroot_symlink = \
+	ARCH_SUBDIR="$(strip $1)"; \
+	mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
+	relpath="./" ; \
+	nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
+	for slash in `seq 1 $${nbslashs}` ; do \
+		relpath=$${relpath}"../" ; \
+	done ; \
+	ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
+	echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}"
+
 #
 # Copy the full external toolchain sysroot directory to the staging
 # dir. The operation of this function is rendered a little bit
@@ -148,14 +162,7 @@ copy_toolchain_sysroot = \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
 			cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
 		fi ; \
-		mkdir -p `dirname $(STAGING_DIR)/$${ARCH_SUBDIR}` ; \
-		relpath="./" ; \
-		nbslashs=`echo -n $${ARCH_SUBDIR} | sed 's%[^/]%%g' | wc -c` ; \
-		for slash in `seq 1 $${nbslashs}` ; do \
-			relpath=$${relpath}"../" ; \
-		done ; \
-		ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
-		echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
+		$(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \
 	fi ; \
 	if test -n "$${SUPPORT_LIB_DIR}" ; then \
 		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot
  2014-10-28 21:28 [Buildroot] [PATCH v2 0/3] toolchain: Add support for Sourcery Codebench Standard Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 1/3] toolchain-external: Detect empty or invalid sysroot Romain Naour
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 2/3] toolchain-helpers: factorise the arch sysroot symlink creation Romain Naour
@ 2014-10-28 21:28 ` Romain Naour
  2014-11-13 22:54   ` Romain Naour
  2 siblings, 1 reply; 5+ messages in thread
From: Romain Naour @ 2014-10-28 21:28 UTC (permalink / raw)
  To: buildroot

When copying external toolchain sysroot to staging, we need to
create the symbolic link that matches the name of the subdirectory
for the architecture variant in the original sysroot.
(ex: sgxx-glibc for CodeSourcery Standard edition)
To do that, SYSROOT_DIR must be different than ARCH_SYSROOT_DIR.

In the case where ARCH_SYSROOT_DIR is used as SYSROOT_DIR  we need
to check again the path to the main sysroot directory.
if SYSROOT_DIR returned by toolchain_find_sysroot without
TOOLCHAIN_EXTERNAL_CFLAGS is empty/invalid, then compute the common
part between SYSROOT_DIR and ARCH_SYSROOT_DIR returned by
toolchain_print_sysroot in order to get the "base sysroot".
This "base sysroot" is used as SYSROOT_DIR to create the symlink
in the staging directory.

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
 toolchain/helpers.mk | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
index 7d7af5f..a4a3661 100644
--- a/toolchain/helpers.mk
+++ b/toolchain/helpers.mk
@@ -97,6 +97,32 @@ toolchain_create_arch_sysroot_symlink = \
 	ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
 	echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}"
 
+# Returns the location of the sysroot for the given compiler + flags using
+# -print-sysroot gcc option (gcc > 4.3 is needed)
+define toolchain_print_sysroot
+$$(readlink -f $$(LANG=C $(1) -print-sysroot))
+endef
+
+# Returns the common path between the main sysroot and arch sysroot returned by
+# toolchain_print_sysroot. This is required to calculate the depth of the symlink
+# in the staging directory when the main sysroot directory is empty/bogus.
+define toolchain_calculate_base_sysroot
+$$(index=0 ; \
+common_sysroot_path="" ; \
+main_sysroot_path=$(call toolchain_print_sysroot,$(TOOLCHAIN_EXTERNAL_CC)); \
+arch_sysroot_path=$(call toolchain_print_sysroot,$(TOOLCHAIN_EXTERNAL_CC),$(TOOLCHAIN_EXTERNAL_CFLAGS)); \
+while [ "$${main_sysroot_path:$${index}:1}" = "$${arch_sysroot_path:$${index}:1}" ] ; do \
+	if [ "$${main_sysroot_path:$${index}:1}" = "/" ]; then \
+		common_sysroot_path="$${main_sysroot_path:0:$${index}+1}"; \
+	fi ; \
+	if [ "$${main_sysroot_path:$${index}:1}" = "" ] || [ "$${arch_sysroot_path:$${index}:1}" = "" ]; then \
+		break; \
+	fi ; \
+	: $$((index++)) ; \
+done ; \
+echo -n $${common_sysroot_path})
+endef
+
 #
 # Copy the full external toolchain sysroot directory to the staging
 # dir. The operation of this function is rendered a little bit
@@ -130,6 +156,17 @@ toolchain_create_arch_sysroot_symlink = \
 #    non-default architecture variant is used. Without this, the
 #    compiler fails to find libraries and headers.
 #
+# Some toolchain (i.e CodeSourcery Standard edition) doesn't have
+# a main sysroot directory and use the arch sysroot as fallback.
+# In this case we need to check again the path to the main sysroot
+# directory when SYSROOT_DIR == ARCH_SYSROOT_DIR.
+# if SYSROOT_DIR returned by toolchain_find_sysroot without
+# TOOLCHAIN_EXTERNAL_CFLAGS point to valid directory.
+# If SYSROOT_DIR is empty/invalid, compute the common part between
+# SYSROOT_DIR and ARCH_SYSROOT_DIR returned by toolchain_print_sysroot
+# in order to get the "base sysroot". This "base sysroot" is used
+# to create the symlink in the staging directory.
+#
 # Some toolchains (i.e Linaro binary toolchains) store support
 # libraries (libstdc++, libgcc_s) outside of the sysroot, so we simply
 # copy all the libraries from the "support lib directory" into our
@@ -163,6 +200,16 @@ copy_toolchain_sysroot = \
 			cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
 		fi ; \
 		$(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \
+	else \
+		if ! test -d "$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; then \
+			SYSROOT_DIR="$(call toolchain_calculate_base_sysroot)"; \
+			if ! test -d $${SYSROOT_DIR} ; then \
+				echo "ERROR: Unable to find the main sysroot directory." ; \
+				exit 1; \
+			fi ; \
+			ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
+			$(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \
+		fi ; \
 	fi ; \
 	if test -n "$${SUPPORT_LIB_DIR}" ; then \
 		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot
  2014-10-28 21:28 ` [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot Romain Naour
@ 2014-11-13 22:54   ` Romain Naour
  0 siblings, 0 replies; 5+ messages in thread
From: Romain Naour @ 2014-11-13 22:54 UTC (permalink / raw)
  To: buildroot

Hi Yann, Thomas, all

Le 28/10/2014 22:28, Romain Naour a ?crit :
> When copying external toolchain sysroot to staging, we need to
> create the symbolic link that matches the name of the subdirectory
> for the architecture variant in the original sysroot.
> (ex: sgxx-glibc for CodeSourcery Standard edition)
> To do that, SYSROOT_DIR must be different than ARCH_SYSROOT_DIR.
> 
> In the case where ARCH_SYSROOT_DIR is used as SYSROOT_DIR  we need
> to check again the path to the main sysroot directory.
> if SYSROOT_DIR returned by toolchain_find_sysroot without
> TOOLCHAIN_EXTERNAL_CFLAGS is empty/invalid, then compute the common
> part between SYSROOT_DIR and ARCH_SYSROOT_DIR returned by
> toolchain_print_sysroot in order to get the "base sysroot".
> This "base sysroot" is used as SYSROOT_DIR to create the symlink
> in the staging directory.
> 
> Signed-off-by: Romain Naour <romain.naour@openwide.fr>
> ---
>  toolchain/helpers.mk | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/toolchain/helpers.mk b/toolchain/helpers.mk
> index 7d7af5f..a4a3661 100644
> --- a/toolchain/helpers.mk
> +++ b/toolchain/helpers.mk
> @@ -97,6 +97,32 @@ toolchain_create_arch_sysroot_symlink = \
>  	ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
>  	echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}"
>  
> +# Returns the location of the sysroot for the given compiler + flags using
> +# -print-sysroot gcc option (gcc > 4.3 is needed)
> +define toolchain_print_sysroot
> +$$(readlink -f $$(LANG=C $(1) -print-sysroot))

Here I forgot to add the second argument $(2) that is passed...

> +endef
> +
> +# Returns the common path between the main sysroot and arch sysroot returned by
> +# toolchain_print_sysroot. This is required to calculate the depth of the symlink
> +# in the staging directory when the main sysroot directory is empty/bogus.
> +define toolchain_calculate_base_sysroot
> +$$(index=0 ; \
> +common_sysroot_path="" ; \
> +main_sysroot_path=$(call toolchain_print_sysroot,$(TOOLCHAIN_EXTERNAL_CC)); \
> +arch_sysroot_path=$(call toolchain_print_sysroot,$(TOOLCHAIN_EXTERNAL_CC),$(TOOLCHAIN_EXTERNAL_CFLAGS)); \

... here
So main_sysroot_path and arch_sysroot_path are always the same... :-/
main_sysroot_path=/path/to/sysroot/libc/system32

> +while [ "$${main_sysroot_path:$${index}:1}" = "$${arch_sysroot_path:$${index}:1}" ] ; do \
> +	if [ "$${main_sysroot_path:$${index}:1}" = "/" ]; then \
> +		common_sysroot_path="$${main_sysroot_path:0:$${index}+1}"; \
> +	fi ; \
> +	if [ "$${main_sysroot_path:$${index}:1}" = "" ] || [ "$${arch_sysroot_path:$${index}:1}" = "" ]; then \
> +		break; \
> +	fi ; \
> +	: $$((index++)) ; \

But since the case where main_sysroot_path and arch_sysroot_path is not handled
correctly, the last sub-string is removed.

So here it works for me but it's lucky because:
common_sysroot_path=/path/to/sysroot/libc/
and arch_sysroot=/path/to/sysroot/libc/msgxx-glibc/

I'll send another version.

Best regards,
Romain

> +done ; \
> +echo -n $${common_sysroot_path})
> +endef
> +
>  #
>  # Copy the full external toolchain sysroot directory to the staging
>  # dir. The operation of this function is rendered a little bit
> @@ -130,6 +156,17 @@ toolchain_create_arch_sysroot_symlink = \
>  #    non-default architecture variant is used. Without this, the
>  #    compiler fails to find libraries and headers.
>  #
> +# Some toolchain (i.e CodeSourcery Standard edition) doesn't have
> +# a main sysroot directory and use the arch sysroot as fallback.
> +# In this case we need to check again the path to the main sysroot
> +# directory when SYSROOT_DIR == ARCH_SYSROOT_DIR.
> +# if SYSROOT_DIR returned by toolchain_find_sysroot without
> +# TOOLCHAIN_EXTERNAL_CFLAGS point to valid directory.
> +# If SYSROOT_DIR is empty/invalid, compute the common part between
> +# SYSROOT_DIR and ARCH_SYSROOT_DIR returned by toolchain_print_sysroot
> +# in order to get the "base sysroot". This "base sysroot" is used
> +# to create the symlink in the staging directory.
> +#
>  # Some toolchains (i.e Linaro binary toolchains) store support
>  # libraries (libstdc++, libgcc_s) outside of the sysroot, so we simply
>  # copy all the libraries from the "support lib directory" into our
> @@ -163,6 +200,16 @@ copy_toolchain_sysroot = \
>  			cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
>  		fi ; \
>  		$(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \
> +	else \
> +		if ! test -d "$(call toolchain_find_sysroot,$(TOOLCHAIN_EXTERNAL_CC))" ; then \
> +			SYSROOT_DIR="$(call toolchain_calculate_base_sysroot)"; \
> +			if ! test -d $${SYSROOT_DIR} ; then \
> +				echo "ERROR: Unable to find the main sysroot directory." ; \
> +				exit 1; \
> +			fi ; \
> +			ARCH_SUBDIR=`echo $${ARCH_SYSROOT_DIR} | sed -r -e "s:^$${SYSROOT_DIR}(.*)/$$:\1:"` ; \
> +			$(call toolchain_create_arch_sysroot_symlink,$${ARCH_SUBDIR}) ; \
> +		fi ; \
>  	fi ; \
>  	if test -n "$${SUPPORT_LIB_DIR}" ; then \
>  		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
> 

-- 
Romain Naour

OPEN WIDE Ing?nierie - Paris
23/25, rue Daviel| 75013 PARIS
http://ingenierie.openwide.fr

Le blog des technologies libres et embarqu?es :
http://www.linuxembedded.fr

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-13 22:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 21:28 [Buildroot] [PATCH v2 0/3] toolchain: Add support for Sourcery Codebench Standard Romain Naour
2014-10-28 21:28 ` [Buildroot] [PATCH v2 1/3] toolchain-external: Detect empty or invalid sysroot Romain Naour
2014-10-28 21:28 ` [Buildroot] [PATCH v2 2/3] toolchain-helpers: factorise the arch sysroot symlink creation Romain Naour
2014-10-28 21:28 ` [Buildroot] [PATCH v2 3/3] toolchain-external: calculation of the symlink to the arch sysroot Romain Naour
2014-11-13 22:54   ` Romain Naour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox