Skip to contentSkip to conversation

Copying extra libs into image using external toolchain

Buildroot Cameron Hutchison 4 participants 7 messages Feb 2, 2010 – Feb 8, 2010

lore
Share & tools
lore
#0 lore raw

I have two buildroot (2009.11) configs set up:
1. A config that only builds a toolchain and installs it in /opt/brtc/<srch-tag> (with uClibc and C++ support)
2. A config that uses that toolchain as an external toolchain and builds the entire image (at91bootstrap, u-boot, linux, rootfs)

In the toolchain's output/target/usr/lib is libstdc++.so - as I specified to build a C++ compiler.

When I build the image, this library is not copied into it. The uClibc libraries are copied.

What do I need to do to get this library copied into the image?

The docco talks about "Core C library from external toolchain" and "Libraries to copy from the external toolchain" options but I cannot find these under menuconfig.

The option for "Build/install c++ compiler and libstdc++" are enabled in both configs.

Thanks

#1 lore raw
Quoted 11 lines · Cameron Hutchison

I have two buildroot (2009.11) configs set up:
1. A config that only builds a toolchain and installs it in /opt/brtc/<srch-tag> (with uClibc and C++ support)
2. A config that uses that toolchain as an external toolchain and builds the entire image (at91bootstrap, u-boot, linux, rootfs)

In the toolchain's output/target/usr/lib is libstdc++.so - as I specified to build a C++ compiler.

When I build the image, this library is not copied into it. The uClibc libraries are copied.

I ran into this a few weeks ago:

http://article.gmane.org/gmane.comp.lib.uclibc.buildroot/19226/

Quoted 1 line

What do I need to do to get this library copied into the image?

I wrote a shell script that does the "make" and then copies to the proper locations the various libraries and include files that buildroot forgets. [There are some kernel headers that don't get copied also.] Here's the bash fragment that does that:

        # if toolchain is to be used as external toolchain, some
        # libraries neeed to be moved into expected locations
        echo "*** copying libs to expected locations ***"
        cp -av output/staging/usr/arm-linux-uclibc/lib/* output/staging/lib
        # some required kernel headers don't get copied 
        echo "*** copying kernel headers ***"
        cp -av output/toolchain/linux/include/mtd output/staging/usr/include
Quoted 6 lines

The docco talks about "Core C library from external toolchain" and "Libraries to copy from the external toolchain" options but I cannot find these under menuconfig.

The option for "Build/install c++ compiler and libstdc++" are enabled in both configs.

After you do the "make" to build to toolchain, you've got to manually copy the libraries into the locations where buildroot expects to find them.

Signature · 3 lines
Grant Edwards                   grante             Yow! I'm dressing up in
                                  at               an ill-fitting IVY-LEAGUE
                               visi.com            SUIT!!  Too late...
#2 lore raw
Quoted 9 lines · Grant Edwards
Quoted 3 lines · Cameron Hutchison

When I build the image, this library [libstdc++] is not copied into it. The uClibc libraries are copied.
What do I need to do to get this library copied into the image?

I wrote a shell script that does the "make" and then copies to the proper locations the various libraries and include files that buildroot forgets.

Thanks for that info. I'll add an extra step to my build process. I guess I just wanted to make sure I wasn't missing anything built into buildroot since...

Quoted 2 lines
Quoted 2 lines

The docco talks about "Core C library from external toolchain" and "Libraries to copy from the external toolchain" options

....but I could not find them anywhere.

#3 lore raw

Le mercredi 03 f?vrier 2010 ? 22:13 +0000, Cameron Hutchison a ?crit :

Quoted 12 lines
Quoted 9 lines · Grant Edwards
Quoted 3 lines · Cameron Hutchison

When I build the image, this library [libstdc++] is not copied into it. The uClibc libraries are copied.
What do I need to do to get this library copied into the image?

I wrote a shell script that does the "make" and then copies to the proper locations the various libraries and include files that buildroot forgets.

Quoted 9 lines

Thanks for that info. I'll add an extra step to my build process. I guess I just wanted to make sure I wasn't missing anything built into buildroot since...

Quoted 2 lines
Quoted 2 lines

The docco talks about "Core C library from external toolchain" and "Libraries to copy from the external toolchain" options

....but I could not find them anywhere.

With external toolchains, buildroot assumes that libstdc++ is installed in $(SYSROOT)/lib/ which isn't always the case.
For example the STLinux toolchain has its libstdc++ installed in $(SYSROOT)/usr/lib like your toolchain.

We should rather fix the buildroot script that copies the libraries than adding extra scripts outside of buildroot. It's in toolchain/external-toolchain/ext-tool.mk

Signature · 1 line
Lionel Landwerlin <[email protected]>
#4 lore raw
Quoted 4 lines · On Thu, 04 Feb 2010 01:01:28 +0100 Lionel Landwerlin <[email protected]>…

With external toolchains, buildroot assumes that libstdc++ is installed in $(SYSROOT)/lib/ which isn't always the case. For example the STLinux toolchain has its libstdc++ installed in $(SYSROOT)/usr/lib like your toolchain.

Yes, correct.

Quoted 3 lines

We should rather fix the buildroot script that copies the libraries than adding extra scripts outside of buildroot. It's in toolchain/external-toolchain/ext-tool.mk

This is something I already have a patch for in my codesourcery-toolchain-support branch:

http://git.buildroot.net/~tpetazzoni/git/buildroot/commit/?h=codesourcery-toolchain-support&id=e6eec872c5720be4438f1d0db28f69ed50620b58

Unfortunately, the changes needed to get the libraries from either /lib or /usr/lib are mixed with other changes related to multilib support, and these latter changes are not ready for submission.

I'll try to split the /lib - /usr/lib thing from the rest and submit a proper patch.

Cheers,

Thomas

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

We should rather fix the buildroot script that copies the libraries than adding extra scripts outside of buildroot. It's in toolchain/external-toolchain/ext-tool.mk

Quoted 8 lines

This is something I already have a patch for in my codesourcery-toolchain-support branch:

http://git.buildroot.net/~tpetazzoni/git/buildroot/commit/?h=codesourcery-toolchain-support&id=e6eec872c5720be4438f1d0db28f69ed50620b58

Unfortunately, the changes needed to get the libraries from either /lib or /usr/lib are mixed with other changes related to multilib support, and these latter changes are not ready for submission.

I've patched by buildroot (against 2009.11) with something similar to your patch, but I did it a little differently.

I've added a couple of extra BR_* config items, one for extra libraries to copy, one for extra directories to search in the sysroot for libraries. I've also added defaults to ext-tools.mk such that if you have an external uClibc toolchain, usr/$(ARCH)-$(BR2_GNU_TARGET_SUFFIX)/lib is search, and usr/lib for libstdc++.so .

Similar to your patch, the directory in which the library is found in the sysroot is maintained in the output target root. But I'm not sure that this is right. That usr/$(ARCH)-$(BR2_GNU_TARGET_SUFFIX)/lib should not exist in the target root, but that's where my libstdc++.so and libgcc_s.so are. They should probably go into /usr/lib in the target root, but I dont know how that should be derived from the source path without an ugly heuristic. Alternatively, I could put all the libraries in /lib and just forget about /usr/lib (I prefer to on embedded systems, but that's probably not a commonly accepted idea).

Any comments on the best way to proceed?

Here's my unofficial patch so far:

[BTW. I'm not sold on the idea of the extra config variables. They are not needed to get my initial problem solved (libstdc++.so and now libgcc_s.so), but thought it might be useful. They should probably be part 2 of the patch]

toolchain/external-toolchain/Config.in +18 -0
index efc8378..9c157f3 100644
@@ -19,4 +19,22 @@ config BR2_TOOLCHAIN_EXTERNAL_STRIP
         prompt "Strip shared libraries"
 	help
 	  Strip shared libraries copied from the external toolchain.
+
+config BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIBS
+	string "Extra libraries to copy from the external toolchain"
+	default ""
+	help
+	  A list of extra libraries to copy from the external toolchain, beyond
+	  the C library. If C++ support has been selected, that will automatically
+	  be copied and does not need to be specified here.
+
+config BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIB_DIRS
+	string "Directories to search for extra libraries"
+	default ""
+	help
+	  Directories under the toolchain path to search for the extra libraries to copy.
+	  Only lib is searched by default. usr/lib will be added if C++ support has been
+	  selected.
+	  Do not put a leading /
+
 endif
toolchain/external-toolchain/ext-tool.mk +28 -13

85 lines not on this page · raw message

#6 lore raw
Quoted 3 lines · Cameron Hutchison

Alternatively, I could put all the libraries
in /lib and just forget about /usr/lib (I prefer to on embedded systems, but that's probably not a commonly accepted idea).

Here's a patch that does just that and nothing else. It's much smaller and might be more useful to others:

toolchain/external-toolchain/ext-tool.mk +2 -2
index 1f5aa19..e39979f 100644
@@ -45,8 +45,8 @@ copy_toolchain_lib_root = \
 	DST="$(strip $3)"; \
 	STRIP="$(strip $4)"; \
  \
-	LIB_DIR="$${SYSROOT_DIR}/lib" ; \
-	for FILE in `find $${LIB_DIR} -maxdepth 1 -name "$${LIB}.*"`; do \
+	for FILE in `find $${SYSROOT_DIR} -name "$${LIB}.*"`; do \
+		LIB_DIR=`dirname $${FILE}`; \
 		LIB=`basename $${FILE}`; \
 		while test \! -z "$${LIB}"; do \
 			rm -fr $(TARGET_DIR)$${DST}/$${LIB}; \