Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Wrong rpath after linking with libmysqlclient
@ 2015-12-13 20:07 Arnout Vandecappelle
  2015-12-13 20:13 ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: Arnout Vandecappelle @ 2015-12-13 20:07 UTC (permalink / raw)
  To: buildroot

 Hi all,

 First of all, the symptomps: build the defconfig in attachment, run with

qemu-system-arm -M nuri -kernel output/images/zImage -append \
 "console=ttySAC1,115200" -smp 2 -serial null -serial stdio

and you'll see:

Starting php-fpm /usr/sbin/php-fpm: error while loading shared libraries:
libmysqlclient.so.16: cannot open shared object file: No such file or directory


 readelf reveals:

Library rpath: [.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql]

 i.e. rpath points to staging instead of the on-target directory.

 Indeed, in libmysqlclient.la we find:

libdir='.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql'


 This happens because our 'Fixing libtool files' step makes sure that all
absolute paths have STAGING_DIR prepended to them.


 This problem will occur for any library that doesn't install in /lib or
/usr/lib and that uses libtool.


 My first idea was to install libmysqlclient.so in /usr/lib instead, but that's
probably a great idea. So the next idea is to skip the libdir= line when fixing
up the libtool files. However, I'm not sure if that won't have some other
effects (i.e. missing required link flags). But worse, it doesn't even work:
php's libtool still converts it into
-Wl,--rpath -Wl,.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql
(and gives warnings that the libraries have moved.

 Any idea?

 A final option is to fix up the rpaths of all ELF files in the target after
build. I believe Yann has a series that does exactl that, no?

 Regards,
 Arnout
-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
--
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_FPU_VFPV3D16=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttySAC1"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="3.10.92"
BR2_LINUX_KERNEL_DEFCONFIG="exynos4"
BR2_LINUX_KERNEL_ZIMAGE=y
BR2_PACKAGE_PHP=y
# BR2_PACKAGE_PHP_EXT_SESSION is not set
# BR2_PACKAGE_PHP_EXT_ZLIB is not set
BR2_PACKAGE_PHP_EXT_MYSQLI=y
BR2_PACKAGE_PHP_SAPI_CLI_FPM=y
BR2_TARGET_ROOTFS_INITRAMFS=y
# BR2_TARGET_ROOTFS_TAR is not set

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] Wrong rpath after linking with libmysqlclient
  2015-12-13 20:07 [Buildroot] Wrong rpath after linking with libmysqlclient Arnout Vandecappelle
@ 2015-12-13 20:13 ` Yann E. MORIN
  2015-12-13 21:22   ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2015-12-13 20:13 UTC (permalink / raw)
  To: buildroot

Arnout, All,

On 2015-12-13 21:07 +0100, Arnout Vandecappelle spake thusly:
>  First of all, the symptomps: build the defconfig in attachment, run with
> 
> qemu-system-arm -M nuri -kernel output/images/zImage -append \
>  "console=ttySAC1,115200" -smp 2 -serial null -serial stdio
> 
> and you'll see:
> 
> Starting php-fpm /usr/sbin/php-fpm: error while loading shared libraries:
> libmysqlclient.so.16: cannot open shared object file: No such file or directory
> 
> 
>  readelf reveals:
> 
> Library rpath: [.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql]
> 
>  i.e. rpath points to staging instead of the on-target directory.
> 
>  Indeed, in libmysqlclient.la we find:
> 
> libdir='.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql'
> 
> 
>  This happens because our 'Fixing libtool files' step makes sure that all
> absolute paths have STAGING_DIR prepended to them.
> 
> 
>  This problem will occur for any library that doesn't install in /lib or
> /usr/lib and that uses libtool.
> 
> 
>  My first idea was to install libmysqlclient.so in /usr/lib instead, but that's
> probably a great idea.

that's what Thomas and I were discussing the other day: why are those
libraries not in /usr/lib to start with? We believe this should be the
case.

> So the next idea is to skip the libdir= line when fixing
> up the libtool files. However, I'm not sure if that won't have some other
> effects (i.e. missing required link flags). But worse, it doesn't even work:
> php's libtool still converts it into
> -Wl,--rpath -Wl,.../host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/mysql
> (and gives warnings that the libraries have moved.
> 
>  Any idea?
> 
>  A final option is to fix up the rpaths of all ELF files in the target after
> build. I believe Yann has a series that does exactl that, no?

The fixup I've been doing is to just get rid of rpath since it should
not be needed on the target, as we should expect all NEEDED libraries to
either be in /usr/lib or /lib .

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] Wrong rpath after linking with libmysqlclient
  2015-12-13 20:13 ` Yann E. MORIN
@ 2015-12-13 21:22   ` Thomas Petazzoni
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2015-12-13 21:22 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 13 Dec 2015 21:13:58 +0100, Yann E. MORIN wrote:

> >  My first idea was to install libmysqlclient.so in /usr/lib instead, but that's
> > probably a great idea.
> 
> that's what Thomas and I were discussing the other day: why are those
> libraries not in /usr/lib to start with? We believe this should be the
> case.

Agreed, all libraries should be in /lib or /usr/lib, so that we can get
rid of /etc/ld.so.conf and /etc/ld.so.cache handling, which doesn't
work since there is no cross-ldconfig. Yes, it could work without
ld.so.conf configuration using rpath, but I don't think it's a good
idea.

It would really be preferable if libmysqlclient.so was in /usr/lib like
any other libraries.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-13 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 20:07 [Buildroot] Wrong rpath after linking with libmysqlclient Arnout Vandecappelle
2015-12-13 20:13 ` Yann E. MORIN
2015-12-13 21:22   ` Thomas Petazzoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox