* [Buildroot] Copying extra libs into image using external toolchain
@ 2010-02-02 23:07 Cameron Hutchison
2010-02-03 0:04 ` Grant Edwards
0 siblings, 1 reply; 7+ messages in thread
From: Cameron Hutchison @ 2010-02-02 23:07 UTC (permalink / raw)
To: buildroot
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-02 23:07 [Buildroot] Copying extra libs into image using external toolchain Cameron Hutchison
@ 2010-02-03 0:04 ` Grant Edwards
2010-02-03 22:13 ` Cameron Hutchison
0 siblings, 1 reply; 7+ messages in thread
From: Grant Edwards @ 2010-02-03 0:04 UTC (permalink / raw)
To: buildroot
On 2010-02-02, Cameron Hutchison <lists@xdna.net> wrote:
> 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/
> 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
> 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.
--
Grant Edwards grante Yow! I'm dressing up in
at an ill-fitting IVY-LEAGUE
visi.com SUIT!! Too late...
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-03 0:04 ` Grant Edwards
@ 2010-02-03 22:13 ` Cameron Hutchison
2010-02-04 0:01 ` Lionel Landwerlin
0 siblings, 1 reply; 7+ messages in thread
From: Cameron Hutchison @ 2010-02-03 22:13 UTC (permalink / raw)
To: buildroot
Grant Edwards <grant.b.edwards@gmail.com> writes:
>On 2010-02-02, Cameron Hutchison <lists@xdna.net> wrote:
>> 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...
>> 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-03 22:13 ` Cameron Hutchison
@ 2010-02-04 0:01 ` Lionel Landwerlin
2010-02-06 16:02 ` Thomas Petazzoni
0 siblings, 1 reply; 7+ messages in thread
From: Lionel Landwerlin @ 2010-02-04 0:01 UTC (permalink / raw)
To: buildroot
Le mercredi 03 f?vrier 2010 ? 22:13 +0000, Cameron Hutchison a ?crit :
> Grant Edwards <grant.b.edwards@gmail.com> writes:
>
> >On 2010-02-02, Cameron Hutchison <lists@xdna.net> wrote:
>
> >> 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...
>
> >> 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
--
Lionel Landwerlin <llandwerlin@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-04 0:01 ` Lionel Landwerlin
@ 2010-02-06 16:02 ` Thomas Petazzoni
2010-02-08 5:38 ` Cameron Hutchison
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2010-02-06 16:02 UTC (permalink / raw)
To: buildroot
On Thu, 04 Feb 2010 01:01:28 +0100
Lionel Landwerlin <llandwerlin@gmail.com> wrote:
> 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.
> 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
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-06 16:02 ` Thomas Petazzoni
@ 2010-02-08 5:38 ` Cameron Hutchison
2010-02-08 6:34 ` Cameron Hutchison
0 siblings, 1 reply; 7+ messages in thread
From: Cameron Hutchison @ 2010-02-08 5:38 UTC (permalink / raw)
To: buildroot
Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
>Lionel Landwerlin <llandwerlin@gmail.com> wrote:
>> 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'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]
diff --git a/toolchain/external-toolchain/Config.in b/toolchain/external-toolchain/Config.in
index efc8378..9c157f3 100644
--- a/toolchain/external-toolchain/Config.in
+++ b/toolchain/external-toolchain/Config.in
@@ -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
diff --git a/toolchain/external-toolchain/ext-tool.mk b/toolchain/external-toolchain/ext-tool.mk
index 1f5aa19..f9a610a 100644
--- a/toolchain/external-toolchain/ext-tool.mk
+++ b/toolchain/external-toolchain/ext-tool.mk
@@ -36,36 +36,40 @@
#
# $1: sysroot directory
# $2: library name
-# $3: destination directory
+# $3: source directories under sysroot to search for library
# $4: strip (y|n), default is to strip
#
copy_toolchain_lib_root = \
SYSROOT_DIR="$(strip $1)"; \
LIB="$(strip $2)"; \
- DST="$(strip $3)"; \
+ SRCDIRS="$(strip $3)"; \
STRIP="$(strip $4)"; \
\
- LIB_DIR="$${SYSROOT_DIR}/lib" ; \
- for FILE in `find $${LIB_DIR} -maxdepth 1 -name "$${LIB}.*"`; do \
+ LIBS=`(cd $${SYSROOT_DIR}; find $${SRCDIRS} -maxdepth 1 -name "$${LIB}.*")`; \
+ echo $${LIBS}; \
+ for FILE in $${LIBS}; do \
LIB=`basename $${FILE}`; \
+ LIB_DIR=`dirname $${FILE}`; \
+ SRC_PATH="$${SYSROOT_DIR}/$${LIB_DIR}"; \
+ DST_PATH="$(TARGET_DIR)/$${LIB_DIR}"; \
while test \! -z "$${LIB}"; do \
- rm -fr $(TARGET_DIR)$${DST}/$${LIB}; \
- mkdir -p $(TARGET_DIR)$${DST}; \
- if test -h $${LIB_DIR}/$${LIB}; then \
- cp -d $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/; \
- elif test -f $${LIB_DIR}/$${LIB}; then \
- $(INSTALL) -D -m0755 $${LIB_DIR}/$${LIB} $(TARGET_DIR)$${DST}/$${LIB}; \
+ rm -fr $${DST_PATH}/$${LIB}; \
+ mkdir -p $${DST_PATH}; \
+ if test -h $${SRC_PATH}/$${LIB}; then \
+ cp -d $${SRC_PATH}/$${LIB} $${DST_PATH}/; \
+ elif test -f $${SRC_PATH}/$${LIB}; then \
+ $(INSTALL) -D -m0755 $${SRC_PATH}/$${LIB} $${DST_PATH}/$${LIB}; \
case "$${STRIP}" in \
(0 | n | no) \
;; \
(*) \
- $(TARGET_CROSS)strip "$(TARGET_DIR)$${DST}/$${LIB}"; \
+ $(TARGET_CROSS)strip "$${DST_PATH}/$${LIB}"; \
;; \
esac; \
else \
exit -1; \
fi; \
- LIB="`readlink $${LIB_DIR}/$${LIB}`"; \
+ LIB="`readlink $${SRC_PATH}/$${LIB}`"; \
done; \
done; \
\
@@ -195,14 +199,25 @@ 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 libpthread.so libresolv.so librt.so libutil.so
+EXTERNAL_LIB_DIRS=lib
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_UCLIBC),y)
EXTERNAL_LIBS+=ld-uClibc.so
+EXTERNAL_LIB_DIRS+=usr/$(ARCH)-$(BR2_GNU_TARGET_SUFFIX)/lib
else
EXTERNAL_LIBS+=ld-linux.so libnss_files.so libnss_dns.so
endif
ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
EXTERNAL_LIBS+=libstdc++.so
+EXTERNAL_LIB_DIRS+=usr/lib
+endif
+
+ifneq ($(BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIBS),)
+EXTERNAL_LIBS+=$(BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIBS)
+endif
+
+ifneq ($(BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIB_DIRS),)
+EXTERNAL_LIB_DIRS+=$(BR2_TOOLCHAIN_EXTERNAL_EXTRA_LIB_DIRS)
endif
SYSROOT_DIR=$(shell LANG=C $(TARGET_CC) -v 2>&1 | grep ^Configured | tr " " "\n" | grep -- "--with-sysroot" | cut -f2 -d=)
@@ -225,7 +240,7 @@ 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,$(SYSROOT_DIR),$$libs,/lib,$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
+ $(call copy_toolchain_lib_root,$(SYSROOT_DIR),$$libs,$(EXTERNAL_LIB_DIRS),$(BR2_TOOLCHAIN_EXTERNAL_STRIP)); \
done
@echo "Copy external toolchain sysroot to staging..."
$(Q)$(call copy_toolchain_sysroot,$(SYSROOT_DIR))
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] Copying extra libs into image using external toolchain
2010-02-08 5:38 ` Cameron Hutchison
@ 2010-02-08 6:34 ` Cameron Hutchison
0 siblings, 0 replies; 7+ messages in thread
From: Cameron Hutchison @ 2010-02-08 6:34 UTC (permalink / raw)
To: buildroot
Cameron Hutchison <lists@xdna.net> writes:
>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:
diff --git a/toolchain/external-toolchain/ext-tool.mk b/toolchain/external-toolchain/ext-tool.mk
index 1f5aa19..e39979f 100644
--- a/toolchain/external-toolchain/ext-tool.mk
+++ b/toolchain/external-toolchain/ext-tool.mk
@@ -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}; \
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-02-08 6:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-02 23:07 [Buildroot] Copying extra libs into image using external toolchain Cameron Hutchison
2010-02-03 0:04 ` Grant Edwards
2010-02-03 22:13 ` Cameron Hutchison
2010-02-04 0:01 ` Lionel Landwerlin
2010-02-06 16:02 ` Thomas Petazzoni
2010-02-08 5:38 ` Cameron Hutchison
2010-02-08 6:34 ` Cameron Hutchison
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox