Add -rpath option for host package compilation

In c1b6242fdc, we added
$(HOST_DIR)/usr/lib to LD_LIBRARY_PATH when building target packages,
because the build of target packages sometimes require host tools
installed in $(HOST_DIR)/usr/bin which themselves require host
libaries installed in $(HOST_DIR)/usr/lib.

Unfortunately, this solution didn't work, as libtool then tried to
link target binaries against host libraries. So $(HOST_DIR)/usr/lib
got removed from LD_LIBRARY_PATH in
0d1830b07d.

However, this meant that we went back to the previous situation, in
which host tools used during compilation of target components might
require host libraries. An example :

make[2]: Entering directory `/home/test/buildroot/output.ctng-arm-eglibc-2010-05-04-12-41-00/build/xfont_font-adobe-100dpi-1.0.1'
/home/test/buildroot/output.ctng-arm-eglibc-2010-05-04-12-41-00/host/usr/bin/mkfontdir /home/test/buildroot/output.ctng-arm-eglibc-2010-05-04-12-41-00/target/usr/share/fonts/X11/100dpi
/home/test/buildroot/output.ctng-arm-eglibc-2010-05-04-12-41-00/host/usr/bin/mkfontscale: error while loading shared libraries: libfontenc.so.1: cannot open shared object file: No such file or directory

Therefore, we try another solution: make sure that host binaries are
linked with an -rpath option, so that $(HOST_DIR)/usr/lib doesn't need
to be in LD_LIBRARY_PATH for them to find their libraries.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Thomas Petazzoni 2010-05-06 19:54:49 +02:00
parent d701a82321
commit 6b939d40f6

View File

@ -77,6 +77,11 @@ ifeq ($(BR2_LARGEFILE),y)
TARGET_CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 TARGET_CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif endif
# Host packages are sometimes linked against host libraries installed
# in $(HOST_DIR)/usr/lib. As we cannot add $(HOST_DIR)/usr/lib to
# LD_LIBRARY_PATH when building target packages because it causes
# libtool breakage, we force a rpath to be added to host binaries.
HOST_CFLAGS+=-Wl,-rpath -Wl,$(HOST_DIR)/usr/lib
######################################################################### #########################################################################
ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)