Skip to contentSkip to conversation

toolchain: add a harmless link when sysroot detection is not accurate

PATCH Superseded Vicente Olivert Riera 3 participants 7 messages Jan 22, 2016 – May 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

 toolchain/helpers.mk | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
toolchain/helpers.mk +16 -0
index 70695ee..c8245f7 100644
@@ -130,6 +130,12 @@ copy_toolchain_lib_root = \
 #
 # * Create a symbolic link
 #
+# If we are in the situation where we don't know if the sysroot layout
+# is nested of side by side, we:
+#
+# * Create a symbolic link because it's harmless and is necessary for
+#   certain toolchains like Codescape for MIPS.
+#
 # Finally, 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"
@@ -160,9 +166,12 @@ copy_toolchain_sysroot = \
 	done ; \
 	SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
 	ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+	echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
+	echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
 	if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
 		relpath="./" ; \
 		if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} == $${SYSROOT_DIR_CANON} ] ; then \
+			echo "Nested sysroots detected." ; \
 			if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
 				cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
 			fi ; \
@@ -174,9 +183,16 @@ copy_toolchain_sysroot = \
 			ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
 			echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
 		elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname $${SYSROOT_DIR_CANON}` ] ; then \
+			echo "Side by side sysroots detected." ; \
 			ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \
 			echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
 		fi ; \
+	else \
+		relpath="./" ; \
+		echo "Unable to detect if sysroots are nested or side by side." ; \
+		echo "Creating a harmless symlink necessary for certain toolchains." ; \
+		ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \
+		echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
 	fi ; \
 	if test -n "$${SUPPORT_LIB_DIR}" ; then \
 		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
Signature · 1 line
2.4.10
#1 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

ping

Currently Codescape MIPS toolchains are broken for big-endian. This patch fixes the problem.

Quoted 90 lines · Vicente Olivert Riera

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

  toolchain/helpers.mk | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
toolchain/helpers.mk +16 -0
index 70695ee..c8245f7 100644
@@ -130,6 +130,12 @@ copy_toolchain_lib_root = \
  #
  # * Create a symbolic link
  #
+# If we are in the situation where we don't know if the sysroot layout
+# is nested of side by side, we:
+#
+# * Create a symbolic link because it's harmless and is necessary for
+#   certain toolchains like Codescape for MIPS.
+#
  # Finally, 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"
@@ -160,9 +166,12 @@ copy_toolchain_sysroot = \
  	done ; \
  	SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
  	ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+	echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
+	echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
  	if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
  		relpath="./" ; \
  		if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} == $${SYSROOT_DIR_CANON} ] ; then \
+			echo "Nested sysroots detected." ; \
  			if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
  				cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
  			fi ; \
@@ -174,9 +183,16 @@ copy_toolchain_sysroot = \
  			ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
  			echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
  		elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname $${SYSROOT_DIR_CANON}` ] ; then \
+			echo "Side by side sysroots detected." ; \
  			ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \
  			echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
  		fi ; \
+	else \
+		relpath="./" ; \
+		echo "Unable to detect if sysroots are nested or side by side." ; \
+		echo "Creating a harmless symlink necessary for certain toolchains." ; \
+		ln -snf $${relpath} $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` ; \
+		echo "Symlinking $(STAGING_DIR)/`basename $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
  	fi ; \
  	if test -n "$${SUPPORT_LIB_DIR}" ; then \
  		cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \
#2 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Hi Vicente,

Le 02/02/2016 11:57, Vicente Olivert Riera a ?crit :

Quoted 9 lines

ping

Currently Codescape MIPS toolchains are broken for big-endian. This patch fixes the problem.

Quoted 3 lines · Vicente Olivert Riera

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

By sometime, you mean toolchains generated by Crosstool-ng and Buildroot which doesn't support multi-lib.

Quoted 22 lines
Quoted 22 lines

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
Quoted 5 lines
Quoted 5 lines

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

Since Codescape are supported in Buildroot as external toolchain and the issue appear only with it for BE, you can probability use a TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS like for some Linaro toolchains instead ?

Thoughts ?

Quoted 26 lines
Quoted 26 lines

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

  toolchain/helpers.mk | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
toolchain/helpers.mk +6 -0
index 70695ee..c8245f7 100644
@@ -130,6 +130,12 @@ copy_toolchain_lib_root = \
  #
  # * Create a symbolic link
  #
+# If we are in the situation where we don't know if the sysroot layout
+# is nested of side by side, we:
+#
+# * Create a symbolic link because it's harmless and is necessary for
+#   certain toolchains like Codescape for MIPS.
+#
Quoted 8 lines

toolchain/helpers.mk copy_toolchain_sysroot = \ · line 169

Quoted 8 lines
toolchain/helpers.mk +1 -0
  # Finally, 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"
@@ -160,9 +166,12 @@ copy_toolchain_sysroot = \
      done ; \
      SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
      ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+    echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \

should be SYSROOT_DIR_CANON

Best regards,
Romain

Quoted 36 lines
Quoted 27 lines
toolchain/helpers.mk +2 -0
+    echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
      if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
          relpath="./" ; \
          if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} ==
 $${SYSROOT_DIR_CANON} ] ; then \
+            echo "Nested sysroots detected." ; \
              if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
                  cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
              fi ; \
toolchain/helpers.mk +6 -0
@@ -174,9 +183,16 @@ copy_toolchain_sysroot = \
              ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
              echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
          elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname
 $${SYSROOT_DIR_CANON}` ] ; then \
+            echo "Side by side sysroots detected." ; \
              ln -snf $${relpath} $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` ; \
              echo "Symlinking $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
          fi ; \
+    else \
+        relpath="./" ; \
+        echo "Unable to detect if sysroots are nested or side by side." ; \
+        echo "Creating a harmless symlink necessary for certain toolchains." ; \
+        ln -snf $${relpath} $(STAGING_DIR)/`basename

$${ARCH_SYSROOT_DIR_CANON}` ; \
+ echo "Symlinking $(STAGING_DIR)/basename $${ARCH_SYSROOT_DIR_CANON}

Quoted 5 lines
-> $${relpath}" ; \
      fi ; \
      if test -n "$${SUPPORT_LIB_DIR}" ; then \
          cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#3 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Hello Romain,

Quoted 8 lines · Romain Naour

Hi Vicente,

Le 02/02/2016 11:57, Vicente Olivert Riera a ?crit :

Quoted 5 lines

ping

Currently Codescape MIPS toolchains are broken for big-endian. This patch fixes the problem.

Quoted 7 lines
Quoted 4 lines · Vicente Olivert Riera
Quoted 3 lines

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

By sometime, you mean toolchains generated by Crosstool-ng and Buildroot which doesn't support multi-lib.

Only toolchains generated by Crosstool-ng and Buildroot? Are you sure about that? I think the Codescape toolchains are not generated by Crosstool-ng and they do support multi-lib.

Quoted 33 lines
Quoted 22 lines
Quoted 22 lines

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
Quoted 5 lines
Quoted 5 lines

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

Since Codescape are supported in Buildroot as external toolchain and the issue appear only with it for BE, you can probability use a TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS like for some Linaro toolchains instead ?

Quoted 1 line

Thoughts ?

Well, the whole point for this patch [1] was to get rid of that hook (which was the first approach when I sent the patches to add the Codescape toolchains) and add that functionality in the toolchain infra just in case more toolchains with this problem were added in the future.

1:
https://git.busybox.net/buildroot/commit/?id=9a1e9efe2618ebbf12ed2567bcd6e8cca5619547

Maintainers, thoughts?

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

   toolchain/helpers.mk | 16 ++++++++++++++++
   1 file changed, 16 insertions(+)
toolchain/helpers.mk +6 -0
index 70695ee..c8245f7 100644
@@ -130,6 +130,12 @@ copy_toolchain_lib_root = \
   #
   # * Create a symbolic link
   #
+# If we are in the situation where we don't know if the sysroot layout
+# is nested of side by side, we:
+#
+# * Create a symbolic link because it's harmless and is necessary for
+#   certain toolchains like Codescape for MIPS.
+#
   # Finally, some toolchains (i.e Linaro binary toolchains) store
   # support libraries (libstdc++, libgcc_s) outside of the sysroot, so
Quoted 8 lines
Quoted 6 lines

toolchain/helpers.mk copy_toolchain_sysroot = \ · line 169

Quoted 6 lines
toolchain/helpers.mk +1 -0
   # we simply copy all the libraries from the "support lib directory"
@@ -160,9 +166,12 @@ copy_toolchain_sysroot = \
       done ; \
       SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
       ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+    echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \

should be SYSROOT_DIR_CANON

Yes, that's right.

Regards,

Vincent.

Quoted 40 lines

Best regards,
Romain

Quoted 36 lines
Quoted 27 lines
toolchain/helpers.mk +2 -0
+    echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
       if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
           relpath="./" ; \
           if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} ==
 $${SYSROOT_DIR_CANON} ] ; then \
+            echo "Nested sysroots detected." ; \
               if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
                   cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
               fi ; \
toolchain/helpers.mk +6 -0
@@ -174,9 +183,16 @@ copy_toolchain_sysroot = \
               ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
               echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} -> $${relpath}" ; \
           elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname
 $${SYSROOT_DIR_CANON}` ] ; then \
+            echo "Side by side sysroots detected." ; \
               ln -snf $${relpath} $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` ; \
               echo "Symlinking $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
           fi ; \
+    else \
+        relpath="./" ; \
+        echo "Unable to detect if sysroots are nested or side by side." ; \
+        echo "Creating a harmless symlink necessary for certain toolchains." ; \
+        ln -snf $${relpath} $(STAGING_DIR)/`basename

$${ARCH_SYSROOT_DIR_CANON}` ; \
+ echo "Symlinking $(STAGING_DIR)/basename $${ARCH_SYSROOT_DIR_CANON}

Quoted 5 lines
-> $${relpath}" ; \
       fi ; \
       if test -n "$${SUPPORT_LIB_DIR}" ; then \
           cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Hi Vicente,

Le 02/02/2016 16:14, Vicente Olivert Riera a ?crit :

Quoted 16 lines

Hello Romain,

Quoted 13 lines · Romain Naour

Hi Vicente,

Le 02/02/2016 11:57, Vicente Olivert Riera a ?crit :

Quoted 9 lines

ping

Currently Codescape MIPS toolchains are broken for big-endian. This patch fixes the problem.

Quoted 3 lines · Vicente Olivert Riera

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

Quoted 6 lines
Quoted 2 lines

By sometime, you mean toolchains generated by Crosstool-ng and Buildroot which doesn't support multi-lib.

Only toolchains generated by Crosstool-ng and Buildroot? Are you sure about that? I think the Codescape toolchains are not generated by Crosstool-ng and they do support multi-lib.

Well, I checked with two of the autobuilder toolchains:

http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-a9-musl-2015.11-rc1-71-g90d1299.tar.bz2

http://autobuild.buildroot.org/toolchains/tarballs/i686-ctng-linux-gnu.tar.xz

And I get this:

SYSROOT_DIR_CANON:
/home/naourr/git/buildroot/test/musl/host/opt/ext-toolchain/arm-buildroot-linux-musleabihf/sysroot ARCH_SYSROOT_DIR_CANON:
/home/naourr/git/buildroot/test/musl/host/opt/ext-toolchain/arm-buildroot-linux-musleabihf/sysroot

Unable to detect if sysroots are nested or side by side.
Creating a harmless symlink necessary for certain toolchains.
Symlinking /home/naourr/git/buildroot/test/musl/host/usr/arm-buildroot-linux-musleabihf/sysroot/sysroot -> ./

Quoted 34 lines
Quoted 34 lines
Quoted 23 lines
Quoted 23 lines

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
Quoted 5 lines
Quoted 5 lines

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

Since Codescape are supported in Buildroot as external toolchain and the issue appear only with it for BE, you can probability use a TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS like for some Linaro toolchains instead ?

Quoted 6 lines
Quoted 1 line

Thoughts ?

Well, the whole point for this patch [1] was to get rid of that hook (which was the first approach when I sent the patches to add the Codescape toolchains) and add that functionality in the toolchain infra just in case more toolchains with this problem were added in the future.

I understand, let see what maintainers says.

Best regards,
Romain

Quoted 92 lines

1:
https://git.busybox.net/buildroot/commit/?id=9a1e9efe2618ebbf12ed2567bcd6e8cca5619547

Maintainers, thoughts?

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

   toolchain/helpers.mk | 16 ++++++++++++++++
   1 file changed, 16 insertions(+)
toolchain/helpers.mk +6 -0
index 70695ee..c8245f7 100644
@@ -130,6 +130,12 @@ copy_toolchain_lib_root = \
   #
   # * Create a symbolic link
   #
+# If we are in the situation where we don't know if the sysroot layout
+# is nested of side by side, we:
+#
+# * Create a symbolic link because it's harmless and is necessary for
+#   certain toolchains like Codescape for MIPS.
+#
   # Finally, some toolchains (i.e Linaro binary toolchains) store
   # support libraries (libstdc++, libgcc_s) outside of the sysroot, so
Quoted 8 lines
Quoted 6 lines

toolchain/helpers.mk copy_toolchain_sysroot = \ · line 169

Quoted 6 lines
toolchain/helpers.mk +1 -0
   # we simply copy all the libraries from the "support lib directory"
@@ -160,9 +166,12 @@ copy_toolchain_sysroot = \
       done ; \
       SYSROOT_DIR_CANON=`readlink -f $${SYSROOT_DIR}` ; \
       ARCH_SYSROOT_DIR_CANON=`readlink -f $${ARCH_SYSROOT_DIR}` ; \
+    echo "SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \

should be SYSROOT_DIR_CANON

Yes, that's right.

Regards,

Vincent.

Quoted 42 lines

Best regards,
Romain

Quoted 38 lines
Quoted 29 lines
toolchain/helpers.mk +2 -0
+    echo "ARCH_SYSROOT_DIR_CANON: $${ARCH_SYSROOT_DIR_CANON}" ; \
       if [ $${SYSROOT_DIR_CANON} != $${ARCH_SYSROOT_DIR_CANON} ] ; then \
           relpath="./" ; \
           if [ $${ARCH_SYSROOT_DIR_CANON:0:$${\#SYSROOT_DIR_CANON}} ==
 $${SYSROOT_DIR_CANON} ] ; then \
+            echo "Nested sysroots detected." ; \
               if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
                   cp -a $${SYSROOT_DIR}/usr/include $(STAGING_DIR)/usr ; \
               fi ; \
toolchain/helpers.mk +5 -0
@@ -174,9 +183,16 @@ copy_toolchain_sysroot = \
               ln -s $${relpath} $(STAGING_DIR)/$${ARCH_SUBDIR} ; \
               echo "Symlinking $(STAGING_DIR)/$${ARCH_SUBDIR} ->
 $${relpath}" ; \
           elif [ `dirname $${ARCH_SYSROOT_DIR_CANON}` == `dirname
 $${SYSROOT_DIR_CANON}` ] ; then \
+            echo "Side by side sysroots detected." ; \
               ln -snf $${relpath} $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` ; \
               echo "Symlinking $(STAGING_DIR)/`basename
 $${ARCH_SYSROOT_DIR_CANON}` -> $${relpath}" ; \
           fi ; \
+    else \
+        relpath="./" ; \
+        echo "Unable to detect if sysroots are nested or side by side." ; \
+        echo "Creating a harmless symlink necessary for certain

toolchains." ; \
+ ln -snf $${relpath} $(STAGING_DIR)/`basename
$${ARCH_SYSROOT_DIR_CANON}` ; \
+ echo "Symlinking $(STAGING_DIR)/basename $${ARCH_SYSROOT_DIR_CANON}

Quoted 5 lines
-> $${relpath}" ; \
       fi ; \
       if test -n "$${SUPPORT_LIB_DIR}" ; then \
           cp -a $${SUPPORT_LIB_DIR}/* $(STAGING_DIR)/lib/ ; \

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#5 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Hi Thomas,

Le 02/02/2016 ? 16:30, Romain Naour a ?crit :

Quoted 80 lines

Hi Vicente,

Le 02/02/2016 16:14, Vicente Olivert Riera a ?crit :

Quoted 16 lines

Hello Romain,

Quoted 13 lines · Romain Naour

Hi Vicente,

Le 02/02/2016 11:57, Vicente Olivert Riera a ?crit :

Quoted 9 lines

ping

Currently Codescape MIPS toolchains are broken for big-endian. This patch fixes the problem.

Quoted 3 lines · Vicente Olivert Riera

Sometimes is not possible to detect if the sysroots are nested or side by side. For instance this happens for MIPS big endian, where the sysroot and the arch-sysroot directories are the same. Examples:

Quoted 6 lines
Quoted 2 lines

By sometime, you mean toolchains generated by Crosstool-ng and Buildroot which doesn't support multi-lib.

Only toolchains generated by Crosstool-ng and Buildroot? Are you sure about that? I think the Codescape toolchains are not generated by Crosstool-ng and they do support multi-lib.

Well, I checked with two of the autobuilder toolchains:

http://autobuild.buildroot.org/toolchains/tarballs/br-arm-cortex-a9-musl-2015.11-rc1-71-g90d1299.tar.bz2

http://autobuild.buildroot.org/toolchains/tarballs/i686-ctng-linux-gnu.tar.xz

And I get this:

SYSROOT_DIR_CANON:
/home/naourr/git/buildroot/test/musl/host/opt/ext-toolchain/arm-buildroot-linux-musleabihf/sysroot ARCH_SYSROOT_DIR_CANON:
/home/naourr/git/buildroot/test/musl/host/opt/ext-toolchain/arm-buildroot-linux-musleabihf/sysroot

Unable to detect if sysroots are nested or side by side.
Creating a harmless symlink necessary for certain toolchains.
Symlinking /home/naourr/git/buildroot/test/musl/host/usr/arm-buildroot-linux-musleabihf/sysroot/sysroot -> ./

Quoted 34 lines
Quoted 34 lines
Quoted 23 lines
Quoted 23 lines

=== Mentor Sourcery CodeBench toolchain

$ readlink -f $(LANG=C mips-linux-gnu-gcc -print-file-name=libc.a) | sed
-r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/
$ readlink -f $(LANG=C mips-linux-gnu-gcc -EB -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-2015.11/mips-linux-gnu/libc/

=== Codescape toolchain

$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -print-file-name=libc.a) |
sed -r -e 's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
$ readlink -f $(LANG=C mips-img-linux-gnu-gcc -EB
-print-file-name=libc.a) | sed -r -e
's:(usr/)?lib(32|64)?([^/]*)?/([^/]*/)?libc\.a::'
/toolchains/mips-img-linux-gnu/2015.06-05/sysroot/mips-r6-hard/
Quoted 5 lines
Quoted 5 lines

For those cases where the sysroot detection is not accurate we add a harmless symlink necessary for certain toolchains such as Codescape for MIPS. The other toolchains in this situation (unknown sysroot layout) don't need this symlink to work, but as stated before, this symlink is harmless.

Since Codescape are supported in Buildroot as external toolchain and the issue appear only with it for BE, you can probability use a TOOLCHAIN_EXTERNAL_POST_INSTALL_STAGING_HOOKS like for some Linaro toolchains instead ?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Thoughts ?

Well, the whole point for this patch [1] was to get rid of that hook (which was the first approach when I sent the patches to add the Codescape toolchains) and add that functionality in the toolchain infra just in case more toolchains with this problem were added in the future.

I understand, let see what maintainers says.

Like for CodeSourcery AArch64 toolchain recently [1], what about adding a post-install hook instead ?

[1]
https://git.busybox.net/buildroot/commit/?id=4d39ca1c2ab19766abf0430abe9b65ba0e16602b

Best regards,
Romain

Quoted 20 lines

Best regards,
Romain

Quoted 16 lines

1:
https://git.busybox.net/buildroot/commit/?id=9a1e9efe2618ebbf12ed2567bcd6e8cca5619547

Maintainers, thoughts?

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

---
Changes v1 -> v2:
- Update the comment above the copy_toolchain_sysroot function.
- Explain in the commit log which toolchains are affected and provide some outputs of -print-file-name to explain the problem. (Both changes requested by Thomas Petazzoni)

#6 lore raw

PATCH v2 1/1 toolchain: add a harmless link when sysroot detection is not accurate

Hello,

Quoted 5 lines · Romain Naour
Quoted 5 lines
Quoted 4 lines

Well, the whole point for this patch [1] was to get rid of that hook (which was the first approach when I sent the patches to add the Codescape toolchains) and add that functionality in the toolchain infra just in case more toolchains with this problem were added in the future.

Quoted 7 lines
Quoted 1 line

I understand, let see what maintainers says.

Like for CodeSourcery AArch64 toolchain recently [1], what about adding a post-install hook instead ?

[1]
https://git.busybox.net/buildroot/commit/?id=4d39ca1c2ab19766abf0430abe9b65ba0e16602b

Yeah, I don't know. There's a trade-off here:

- By having the logic in the common external toolchain logic, it's usually more complicated, but at least it works for "custom" external toolchains as well.

- By having a custom logic only for this toolchain, it's usually much simpler, but it doesn't work for custom external toolchains.

Not easy to decide which approach is the most appropriate.

Thomas

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