Skip to contentSkip to conversation

Pull request for branch ext-toolchain-fixes

GIT PULL New Thomas Petazzoni 3 participants 19 messages Jun 14, 2010 – Jun 28, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

Here is a patch set improving the support for external toolchains, after testing with Buildroot x86-64 toolchain, Crosstool-NG x86-64 toolchain, MIPS and PowerPC CodeSourcery toolchains.

The MIPS CodeSourcery toolchain is not fully supported yet: it is a very smart multilib toolchain, which supports both glibc and uclibc in a single toolchain, with -muclibc being the gcc flag to switch to uClibc. For the moment, only the default variant (glibc) is supported.

This patchset only touches toolchain/external-toolchain/ext-tool.mk, except for a patch that is added to uClibc to fix fcntl64() on 64 bits targets. This patch is already upstream in the master branch, and a bug has been filled into the uClibc bug tracker to ask for this patch to be merged into the 0.9.31 branch.

Thomas

The following changes since commit 7c709f4affc44f3bbc9a09fec8d84ae3807e31e7:
Peter Korsgaard (1):
file: don't force _GNU_SOURCE in CFLAGS

are available in the git repository at:

git://git.busybox.net/~tpetazzoni/git/buildroot ext-toolchain-fixes

Thomas Petazzoni (10):
ext-toolchains: take into account other Glibc dynamic loader variants
ext-toolchain: Fix ARCH_SYSROOT detection
external-toolchain: only copy existing directories of the sysroot
external-toolchain: support 64 bits glibc toolchains
external-toolchain: create lib64 symlinks if needed
external-toolchain: mention MIPS and PowerPC CodeSourcery toolchains
external-toolchain: recognize uClibc 64 bits toolchains
uclibc: add patch to fix fcntl64() on 64 bits targets
external-toolchain: handle libstdc++/libgcc_s for BR toolchains
external-toolchain: hardcode the destination directory for a library

 toolchain/external-toolchain/ext-tool.mk           |   92 +++++++++++++-------
 ...ibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch |   34 +++++++
 2 files changed, 96 insertions(+), 30 deletions(-)
 create mode 100644 toolchain/uClibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch

Thanks,

Signature · 1 line
Thomas Petazzoni
#1 lore raw

PATCH 1/10 ext-toolchains: take into account other Glibc dynamic loader variants

External toolchains using Glibc have different names for the dynamic loader. Some of them name it ld-linux.so.*, while some others (such as the PowerPC and MIPS CodeSourcery toolchains) name it simply ld.so.*.

Therefore, we fix the glibc detection code to handle this case.

---
 toolchain/external-toolchain/ext-tool.mk |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
toolchain/external-toolchain/ext-tool.mk +4 -6
index 8daae15..3943ceb 100644
@@ -155,7 +155,7 @@ check_glibc_feature = \
 #
 check_glibc = \
 	SYSROOT_DIR="$(strip $1)"; \
-	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* ; then \
+	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \
 		echo "Incorrect selection of the C library"; \
 		exit -1; \
 	fi; \
@@ -251,11 +251,9 @@ check_cross_compiler_exists = \
 
 uclibc: dependencies $(STAMP_DIR)/ext-toolchain-installed
 
-EXTERNAL_LIBS=libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
-ifeq ($(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
-EXTERNAL_LIBS+=ld-uClibc.so
-else
-EXTERNAL_LIBS+=ld-linux.so libnss_files.so libnss_dns.so
+EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
+ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GCLIBC),y)
+EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
 endif
 
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 1/10 ext-toolchains: take into account other Glibc dynamic loader variants

Thomas, All,

Quoted 5 lines · On Monday 14 June 2010 13:54:12 Thomas Petazzoni wrote:

External toolchains using Glibc have different names for the dynamic loader. Some of them name it ld-linux.so.*, while some others (such as the PowerPC and MIPS CodeSourcery toolchains) name it simply ld.so.*.

Therefore, we fix the glibc detection code to handle this case.

[--SNIP--]

toolchain/external-toolchain/ext-tool.mk check_glibc_feature = \ · line 158

Quoted 4 lines

check_glibc = \

toolchain/external-toolchain/ext-tool.mk +1 -1
 	SYSROOT_DIR="$(strip $1)"; \
-	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* ; then \
+	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \

Can't we just readelf(1) the libc.so to get the dynamic linker name ?

Regards,
Yann E. MORIN.

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.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 2/10 ext-toolchain: Fix ARCH_SYSROOT detection

In reply to Thomas Petazzoni

For the detection of the ARCH_SYSROOT_DIR (which contains the C library variant specific to the compiler flags), we used to pass only the -march argument instead of the full TARGET_CFLAGS. This was done because TARGET_CFLAGS contains --sysroot, and we don't want to tell here the compiler which sysroot to use, because we're specifically asking the compiler where the *normal* arch sysroot directory is.

Unfortunately, there are some multilib variants that aren't decided only based on -march, but also on -msoft-float or other compiler flags. Therefore, we take the opposite approach: pass the full TARGET_CFLAGS, from which we have stripped the --sysroot option.

For example, this allows a PowerPC CodeSourcery toolchain, on which we're using the soft-float multilib variant, to work properly as an external toolchain.

---
 toolchain/external-toolchain/ext-tool.mk |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)
toolchain/external-toolchain/ext-tool.mk +9 -9
index 3943ceb..b1eee23 100644
@@ -270,9 +270,10 @@ endif # ! no threads
 # SYSROOT_DIR selection. We first try the -print-sysroot option,
 # available in gcc 4.4.x and in some Codesourcery toolchains. If this
 # option is not available, we fallback to the value of --with-sysroot
-# as visible in CROSS-gcc -v. We don't pass the -march= option to gcc
-# as we want the "main" sysroot, which contains all variants of the C
-# library in the case of multilib toolchains.
+# as visible in CROSS-gcc -v. We don't pass any option to gcc that
+# could select a multilib variant as we want the "main" sysroot, which
+# contains all variants of the C library in the case of multilib
+# toolchains.
 SYSROOT_DIR=$(shell $(TARGET_CC) -print-sysroot 2>/dev/null)
 ifeq ($(SYSROOT_DIR),)
 SYSROOT_DIR=$(shell readlink -f $$(LANG=C $(TARGET_CC) -print-file-name=libc.a |sed -r -e 's:usr/lib/libc\.a::;'))
@@ -281,15 +282,14 @@ endif
 # Now, find if the toolchain specifies a sub-directory for the
 # specific architecture variant we're interested in. This is the case
 # with multilib toolchain, when the selected architecture variant is
-# not the default one. To do so, we ask the compiler by passing the
-# appropriate -march= flags. ARCH_SUBDIR will contain the
+# not the default one. To do so, we ask the compiler by passing all
+# flags, except the --sysroot flag since we want to the compiler to
+# tell us where its original sysroot is. ARCH_SUBDIR will contain the
 # subdirectory, in the main SYSROOT_DIR, that corresponds to the
 # selected architecture variant. ARCH_SYSROOT_DIR will contain the
 # full path to this location.
-ifneq ($(CC_TARGET_ARCH_),)
-TARGET_CC_ARCH_CFLAGS+=-march=$(CC_TARGET_ARCH_)
-endif
-ARCH_SUBDIR=$(shell $(TARGET_CC) $(TARGET_CC_ARCH_CFLAGS) -print-multi-directory)
+TARGET_CFLAGS_NO_SYSROOT=$(filter-out --sysroot=%,$(TARGET_CFLAGS))
+ARCH_SUBDIR=$(shell $(TARGET_CC) $(TARGET_CFLAGS_NO_SYSROOT) -print-multi-directory)
 ARCH_SYSROOT_DIR=$(SYSROOT_DIR)/$(ARCH_SUBDIR)
 
 $(STAMP_DIR)/ext-toolchain-installed:
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 2/10 ext-toolchain: Fix ARCH_SYSROOT detection

Quoted 1 line · On Monday 14 June 2010 13:54:13 Thomas Petazzoni wrote:

FWIW:

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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 2/10 ext-toolchain: Fix ARCH_SYSROOT detection

In reply to Thomas Petazzoni
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hi,

Thomas> For the detection of the ARCH_SYSROOT_DIR (which contains the C Thomas> library variant specific to the compiler flags), we used to Thomas> pass only the -march argument instead of the full Thomas> TARGET_CFLAGS. This was done because TARGET_CFLAGS contains Thomas> --sysroot, and we don't want to tell here the compiler which Thomas> sysroot to use, because we're specifically asking the compiler Thomas> where the *normal* arch sysroot directory is.

Thomas> Unfortunately, there are some multilib variants that aren't Thomas> decided only based on -march, but also on -msoft-float or other Thomas> compiler flags. Therefore, we take the opposite approach: pass Thomas> the full TARGET_CFLAGS, from which we have stripped the Thomas> --sysroot option.

[snip]

Thomas> +TARGET_CFLAGS_NO_SYSROOT=$(filter-out --sysroot=%,$(TARGET_CFLAGS))

Hmm, in package/Makefile.in I see:

else ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
TARGET_CFLAGS+=--sysroot $(STAGING_DIR)/
TARGET_CXXFLAGS=$(TARGET_CFLAGS)

E.G. no = between --sysroot and the value.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH 3/10 external-toolchain: only copy existing directories of the sysroot

In reply to Thomas Petazzoni

Instead of copying all directories in "etc lib sbin usr", check that each of them exists before doing the copy. This is only to avoid an harmless error message.

---
 toolchain/external-toolchain/ext-tool.mk |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
toolchain/external-toolchain/ext-tool.mk +3 -1
index b1eee23..9c1ec8f 100644
@@ -120,7 +120,9 @@ copy_toolchain_sysroot = \
 	ARCH_SYSROOT_DIR="$(strip $2)"; \
 	ARCH_SUBDIR="$(strip $3)"; \
 	for i in etc lib sbin usr ; do \
-		cp -a $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
+		if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
+			cp -a $${ARCH_SYSROOT_DIR}/$$i $(STAGING_DIR)/ ; \
+		fi ; \
 	done ; \
 	if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
 		if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH 3/10 external-toolchain: only copy existing directories of the sysroot

Quoted 1 line · On Monday 14 June 2010 13:54:14 Thomas Petazzoni wrote:
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.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH 4/10 external-toolchain: support 64 bits glibc toolchains

In reply to Thomas Petazzoni

On 64 bits glibc toolchains, the dynamic loader is named ld-linux-x86-64.so and not simply ld-linux.so. So, adjust the detection of the C library accordingly.

---
 toolchain/external-toolchain/ext-tool.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
toolchain/external-toolchain/ext-tool.mk +1 -1
index 9c1ec8f..a181f25 100644
@@ -157,7 +157,7 @@ check_glibc_feature = \
 #
 check_glibc = \
 	SYSROOT_DIR="$(strip $1)"; \
-	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \
+	if ! test -f $${SYSROOT_DIR}/lib/ld-linux*.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \
 		echo "Incorrect selection of the C library"; \
 		exit -1; \
 	fi; \
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH 4/10 external-toolchain: support 64 bits glibc toolchains

Quoted 3 lines · On Monday 14 June 2010 13:54:15 Thomas Petazzoni wrote:

On 64 bits glibc toolchains, the dynamic loader is named ld-linux-x86-64.so and not simply ld-linux.so. So, adjust the detection of the C library accordingly.

[--SNIP--]

toolchain/external-toolchain/ext-tool.mk check_glibc_feature = \ · line 160

Quoted 4 lines

check_glibc = \

toolchain/external-toolchain/ext-tool.mk +1 -1
 	SYSROOT_DIR="$(strip $1)"; \
-	if ! test -f $${SYSROOT_DIR}/lib/ld-linux.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \
+	if ! test -f $${SYSROOT_DIR}/lib/ld-linux*.so.* -o -f $${SYSROOT_DIR}/lib/ld.so.* ; then \

Using readelf(1) on libc.so would give us the exact name of the dynamic linker ( but I'm just repeating myself here... :-) )

Regards,
Yann E. MORIN.

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.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

PATCH 4/10 external-toolchain: support 64 bits glibc toolchains

Quoted 2 lines · On Mon, 14 Jun 2010 22:07:30 +0200 "Yann E. MORIN"…

Using readelf(1) on libc.so would give us the exact name of the dynamic linker ( but I'm just repeating myself here... :-) )

That's a good idea to investigate. I'll have a look at it, but I'd prefer if this patch set could get merged as is, and have a look at this idea afterwards.

Thanks for the hint!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#11 lore raw

PATCH 4/10 external-toolchain: support 64 bits glibc toolchains

Thomas, All,

Quoted 7 lines · On Monday 14 June 2010 22:59:02 Thomas Petazzoni wrote:
Quoted 2 lines · On Mon, 14 Jun 2010 22:07:30 +0200 "Yann E. MORIN"…

Using readelf(1) on libc.so would give us the exact name of the dynamic linker ( but I'm just repeating myself here... :-) )

That's a good idea to investigate. I'll have a look at it, but I'd prefer if this patch set could get merged as is, and have a look at this idea afterwards.

Yes, sure! You can add my:

to the 3 patches which deal with that:
[PATCH 01/10] ext-toolchains: take into account other Glibc dynamic [...] [PATCH 04/10] external-toolchain: support 64 bits glibc toolchains [PATCH 07/10] external-toolchain: recognize uClibc 64 bits toolchains

Regards,
Yann E. MORIN.

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.  |
'------------------------------^-------^------------------^--------------------'
#12 lore raw

PATCH 5/10 external-toolchain: create lib64 symlinks if needed

In reply to Thomas Petazzoni

Create lib64 -> lib and usr/lib64 -> usr/lib symbolic links in the target and staging directories. This is needed for some 64 bits toolchains such as the Crosstool-NG toolchains, for which the path to the dynamic loader and other libraries is /lib64, but the libraries are stored in /lib.

---
 toolchain/external-toolchain/ext-tool.mk |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
toolchain/external-toolchain/ext-tool.mk +17 -0
index a181f25..d5a64b5 100644
@@ -133,6 +133,19 @@ copy_toolchain_sysroot = \
 	find $(STAGING_DIR) -type d | xargs chmod 755
 
 #
+# Create lib64 -> lib and usr/lib64 -> usr/lib symbolic links in the
+# target and staging directories. This is needed for some 64 bits
+# toolchains such as the Crosstool-NG toolchains, for which the path
+# to the dynamic loader and other libraries is /lib64, but the
+# libraries are stored in /lib.
+#
+create_lib64_symlinks = \
+	(cd $(TARGET_DIR) ;      ln -s lib lib64) ; \
+	(cd $(TARGET_DIR)/usr ;  ln -s lib lib64) ; \
+	(cd $(STAGING_DIR) ;     ln -s lib lib64) ; \
+	(cd $(STAGING_DIR)/usr ; ln -s lib lib64)
+
+#
 # Check the availability of a particular glibc feature. We assume that
 # all Buildroot toolchain options are supported by glibc, so we just
 # check that they are enabled.
@@ -319,4 +332,8 @@ endif
 	done
 	@echo "Copy external toolchain sysroot to staging..."
 	$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
+	# Create lib64 symbolic links if needed
+	$(Q)if [ -L $(ARCH_SYSROOT_DIR)/lib64 ] ; then \
+		$(call create_lib64_symlinks) ; \
+	fi
 	@touch $@
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH 5/10 external-toolchain: create lib64 symlinks if needed

Thomas, All,

Quoted 20 lines · On Monday 14 June 2010 13:54:16 Thomas Petazzoni wrote:

Create lib64 -> lib and usr/lib64 -> usr/lib symbolic links in the target and staging directories. This is needed for some 64 bits toolchains such as the Crosstool-NG toolchains, for which the path to the dynamic loader and other libraries is /lib64, but the libraries are stored in /lib.

---
 toolchain/external-toolchain/ext-tool.mk |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
toolchain/external-toolchain/ext-tool.mk +1 -0
index a181f25..d5a64b5 100644
@@ -133,6 +133,19 @@ copy_toolchain_sysroot = \
 	find $(STAGING_DIR) -type d | xargs chmod 755
 
 #
+# Create lib64 -> lib and usr/lib64 -> usr/lib symbolic links in the

toolchain/external-toolchain/ext-tool.mk copy_toolchain_sysroot = \ · line 146

Quoted 10 lines
toolchain/external-toolchain/ext-tool.mk +10 -0
+# target and staging directories. This is needed for some 64 bits
+# toolchains such as the Crosstool-NG toolchains, for which the path
+# to the dynamic loader and other libraries is /lib64, but the
+# libraries are stored in /lib.
+#
+create_lib64_symlinks = \
+	(cd $(TARGET_DIR) ;      ln -s lib lib64) ; \
+	(cd $(TARGET_DIR)/usr ;  ln -s lib lib64) ; \
+	(cd $(STAGING_DIR) ;     ln -s lib lib64) ; \
+	(cd $(STAGING_DIR)/usr ; ln -s lib lib64)

That holds true for crosstool-NG, but what if another toolchain has the lib64 -> lib, but usr/lib64 is a directory (or the other way around) ?

toolchain/external-toolchain/ext-tool.mk endif · line 338

Quoted 11 lines
toolchain/external-toolchain/ext-tool.mk +4 -0
 # Check the availability of a particular glibc feature. We assume that
 # all Buildroot toolchain options are supported by glibc, so we just
 # check that they are enabled.
@@ -319,4 +332,8 @@ endif
 	done
 	@echo "Copy external toolchain sysroot to staging..."
 	$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
+	# Create lib64 symbolic links if needed
+	$(Q)if [ -L $(ARCH_SYSROOT_DIR)/lib64 ] ; then \
+		$(call create_lib64_symlinks) ; \
+	fi

I think that should be called unconditionally for 64-bit targets, but only create missing .../lib (or .../lib64) as symlink to the other.

Regards,
Yann E. MORIN.

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.  |
'------------------------------^-------^------------------^--------------------'
#14 lore raw

PATCH 6/10 external-toolchain: mention MIPS and PowerPC CodeSourcery toolchains

In reply to Thomas Petazzoni
---
 toolchain/external-toolchain/ext-tool.mk |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
toolchain/external-toolchain/ext-tool.mk +3 -1
index d5a64b5..d591781 100644
@@ -7,7 +7,9 @@
 #
 #  * Toolchains generated by Crosstool-NG
 #  * Toolchains generated by Buildroot
-#  * ARM toolchains made available by Codesourcery
+#  * ARM, MIPS and PowerPC toolchains made available by
+#    Codesourcery. For the MIPS toolchain, the -muclibc variant isn't
+#    supported yet, only the default glibc-based variant is.
 #
 # The basic principle is the following
 #
Signature · 1 line
1.7.0.4
#15 lore raw

PATCH 7/10 external-toolchain: recognize uClibc 64 bits toolchains

In reply to Thomas Petazzoni

With uClibc 64 bits toolchain, the dynamic loader is named ld64-uClibc.so.0 and not ld-uClibc.so.0. So, this commit adjust the uClibc detection code for external toolchains.

---
 toolchain/external-toolchain/ext-tool.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
toolchain/external-toolchain/ext-tool.mk +1 -1
index d591781..3996184 100644
@@ -216,7 +216,7 @@ check_uclibc_feature = \
 #
 check_uclibc = \
 	SYSROOT_DIR="$(strip $1)"; \
-	if ! test -f $${SYSROOT_DIR}/lib/ld-uClibc.so.* ; then \
+	if ! test -f $${SYSROOT_DIR}/lib/ld*-uClibc.so.* ; then \
 		echo "Incorrect selection of the C library"; \
 		exit -1; \
 	fi; \
Signature · 1 line
1.7.0.4
#16 lore raw

PATCH 8/10 uclibc: add patch to fix fcntl64() on 64 bits targets

In reply to Thomas Petazzoni

The patch is already in upstream uClibc, in the master branch, at
http://git.buildroot.net/uClibc/commit/?id=6f1daaaf2d94c1e6184add44eda38b0781b88cf0.

---
 ...ibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch |   34 ++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 toolchain/uClibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch
toolchain/uClibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch new file +34 -0
new file mode 100644
index 0000000..763bfd3
@@ -0,0 +1,34 @@
+From 6f1daaaf2d94c1e6184add44eda38b0781b88cf0 Mon Sep 17 00:00:00 2001
+From: Rob Landley <[email protected]>
+Date: Sun, 16 May 2010 21:41:36 +0000
+Subject: Fix fcntl64 for 64 bit targets.
+
+64 bit targets often don't have a separate fcntl64() system call, because they don't need one.
+
+Signed-off-by: Rob Landley <[email protected]>
+Signed-off-by: Austin Foxley <[email protected]>
+---
+diff --git a/include/fcntl.h b/include/fcntl.h
+index e37073f..3cfb25f 100644
+--- a/include/fcntl.h
++++ b/include/fcntl.h
+@@ -73,7 +73,7 @@ __BEGIN_DECLS
+ 
+    This function is a cancellation point and therefore not marked with
+    __THROW.  */
+-#ifndef __USE_FILE_OFFSET64
++#if !defined(__USE_FILE_OFFSET64) || defined(__LP64__)
+ extern int fcntl (int __fd, int __cmd, ...);
+ libc_hidden_proto(fcntl)
+ #else
+@@ -83,7 +83,7 @@ extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
+ #  define fcntl fcntl64
+ # endif
+ #endif
+-#ifdef __USE_LARGEFILE64
++#if defined(__USE_LARGEFILE64) && !defined(__LP64__)
+ extern int fcntl64 (int __fd, int __cmd, ...);
+ libc_hidden_proto(fcntl64)
+ #endif
+--
+cgit v0.8.2.1
Signature · 1 line
1.7.0.4
#17 lore raw

PATCH 9/10 external-toolchain: handle libstdc++/libgcc_s for BR toolchains

In reply to Thomas Petazzoni

Most toolchains have their libraries either in /lib or /usr/lib relative to their ARCH_SYSROOT_DIR. Buildroot toolchains, however, have basic libraries in /lib, and libstdc++/libgcc_s in /usr/<target-name>/lib(64).

---
 toolchain/external-toolchain/ext-tool.mk |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
toolchain/external-toolchain/ext-tool.mk +10 -1
index 3996184..1c84893 100644
@@ -42,6 +42,11 @@
 # directory to the target directory. Also optionaly strips the
 # library.
 #
+# Most toolchains have their libraries either in /lib or /usr/lib
+# relative to their ARCH_SYSROOT_DIR. Buildroot toolchains, however,
+# have basic libraries in /lib, and libstdc++/libgcc_s in
+# /usr/<target-name>/lib(64).
+#
 # $1: arch specific sysroot directory
 # $2: library name
 # $3: destination directory
@@ -52,7 +57,11 @@ copy_toolchain_lib_root = \
 	LIB="$(strip $2)"; \
 	STRIP="$(strip $4)"; \
  \
-	LIBS=`(cd $${ARCH_SYSROOT_DIR}; find . -path "./lib/$${LIB}.*" -o -path "./usr/lib/$${LIB}.*")` ; \
+	LIBS=`(cd $${ARCH_SYSROOT_DIR}; \
+		find -L . -path "./lib/$${LIB}.*"     -o \
+			  -path "./usr/lib/$${LIB}.*" -o \
+			  -path "./usr/$(TOOLCHAIN_EXTERNAL_PREFIX)/lib*/$${LIB}.*" \
+		)` ; \
 	for FILE in $${LIBS} ; do \
 		LIB=`basename $${FILE}`; \
 		LIBDIR=`dirname $${FILE}` ; \
Signature · 1 line
1.7.0.4
#18 lore raw

PATCH 10/10 external-toolchain: hardcode the destination directory for a library

In reply to Thomas Petazzoni

Until now, the function copy_toolchain_lib_root was copying a given library to the target filesystem by assuming that it should be at the same place it was in the toolchain sysroot.

However, with Buildroot hiding libstdc++ in /usr/<target-name>/lib(64), this isn't correct, and it is probably safer not to rely on the toolchain organization anyway.

Therefore :

* Instead of having a single EXTERNAL_LIBS variable, we now have LIB_EXTERNAL_LIBS and USR_LIB_EXTERNAL_LIBS, which respectively list the libraries that should be copied to /lib and /usr/lib. As of today, only libstdc++ is part of the second list.

* The copy_toolchain_lib_root takes another argument, which is the destination directory of the library, relative to $(TARGET_DIR)

---
 toolchain/external-toolchain/ext-tool.mk |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)
toolchain/external-toolchain/ext-tool.mk +17 -13
index 1c84893..7ca138b 100644
@@ -49,12 +49,13 @@
 #
 # $1: arch specific sysroot directory
 # $2: library name
-# $3: destination directory
+# $3: destination directory of the libary, relative to $(TARGET_DIR)
 # $4: strip (y|n), default is to strip
 #
 copy_toolchain_lib_root = \
 	ARCH_SYSROOT_DIR="$(strip $1)"; \
 	LIB="$(strip $2)"; \
+	DESTDIR="$(strip $3)" ; \
 	STRIP="$(strip $4)"; \
  \
 	LIBS=`(cd $${ARCH_SYSROOT_DIR}; \
@@ -67,17 +68,17 @@ copy_toolchain_lib_root = \
 		LIBDIR=`dirname $${FILE}` ; \
 		while test \! -z "$${LIB}"; do \
 			FULLPATH="$${ARCH_SYSROOT_DIR}/$${LIBDIR}/$${LIB}" ; \
-			rm -fr $(TARGET_DIR)/$${LIBDIR}/$${LIB}; \
-			mkdir -p $(TARGET_DIR)/$${LIBDIR}; \
+			rm -fr $(TARGET_DIR)/$${DESTDIR}/$${LIB}; \
+			mkdir -p $(TARGET_DIR)/$${DESTDIR}; \
 			if test -h $${FULLPATH} ; then \
-				cp -d $${FULLPATH} $(TARGET_DIR)/$${LIBDIR}/; \
+				cp -d $${FULLPATH} $(TARGET_DIR)/$${DESTDIR}/; \
 			elif test -f $${FULLPATH}; then \
-				$(INSTALL) -D -m0755 $${FULLPATH} $(TARGET_DIR)/$${LIBDIR}/$${LIB}; \
+				$(INSTALL) -D -m0755 $${FULLPATH} $(TARGET_DIR)/$${DESTDIR}/$${LIB}; \
 				case "$${STRIP}" in \
 				(0 | n | no) \
 ;; \
 				(*) \
-					$(TARGET_CROSS)strip "$(TARGET_DIR)/$${LIBDIR}/$${LIB}"; \
+					$(TARGET_CROSS)strip "$(TARGET_DIR)/$${DESTDIR}/$${LIB}"; \
 ;; \
 				esac; \
 			else \
@@ -277,19 +278,19 @@ check_cross_compiler_exists = \
 
 uclibc: dependencies $(STAMP_DIR)/ext-toolchain-installed
 
-EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
+LIB_EXTERNAL_LIBS=ld*.so libc.so libcrypt.so libdl.so libgcc_s.so libm.so libnsl.so libresolv.so librt.so libutil.so
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_GCLIBC),y)
-EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
+LIB_EXTERNAL_LIBS+=libnss_files.so libnss_dns.so
 endif
 
 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
-EXTERNAL_LIBS+=libstdc++.so
+USR_LIB_EXTERNAL_LIBS+=libstdc++.so
 endif
 
 ifneq ($(BR2_PTHREADS_NONE),y)
-EXTERNAL_LIBS+=libpthread.so
+LIB_EXTERNAL_LIBS+=libpthread.so
 ifeq ($(BR2_PACKAGE_GDB_SERVER),y)
-EXTERNAL_LIBS+=libthread_db.so
+LIB_EXTERNAL_LIBS+=libthread_db.so
 endif # gdbserver
 endif # ! no threads
 
@@ -338,8 +339,11 @@ else
 endif
 	mkdir -p $(TARGET_DIR)/lib
 	@echo "Copy external toolchain libraries to target..."
-	$(Q)for libs in $(EXTERNAL_LIBS); do \
-		$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
+	$(Q)for libs in $(LIB_EXTERNAL_LIBS); do \
+		$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
+	done
+	$(Q)for libs in $(USR_LIB_EXTERNAL_LIBS); do \
+		$(call copy_toolchain_lib_root,$(ARCH_SYSROOT_DIR),$$libs,/usr/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
 	done
 	@echo "Copy external toolchain sysroot to staging..."
 	$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR),$(ARCH_SYSROOT_DIR),$(ARCH_SUBDIR))
Signature · 1 line
1.7.0.4