[Buildroot] [PATCH 2/2] microperl: install host-microperl in $(HOST_DIR)/opt/perl

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Wed Mar 28 12:52:11 UTC 2012


Le Wed, 28 Mar 2012 12:55:47 +0200,
Thomas Petazzoni <thomas.petazzoni at free-electrons.com> a écrit :

> In the past, we had the problem that when we were building target
> packages that required host utilities installed in $(HOST_DIR)/usr/bin,
> those utilities were not able to find their libraries in
> $(HOST_DIR)/usr/lib. We tried using LD_LIBRARY_PATH, but libtool used
> it as the search path for libraries when compiling target stuff. So, we
> decided to hardcode the correct rpath in all binaries built and
> installed in $(HOST_DIR)/usr/bin.

I had a quick look at this, and here the Perl dynamic module that
depends on libexpat.so.1 is built with the correct RPATH:

$ arm-linux-gnueabi-readelf -a host/usr/lib/perl/auto/XML/Parser/Expat/Expat.so | grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [/opt/outputs/perl/host/usr/lib]

So normally, when this Expat.so library is dlopen'ed by Perl, it should
use the RPATH of Expat.so to find where libexpat.so.1 is located. And
on my system, it does:

$ PERLLIB=/opt/outputs/perl/host/usr/lib/perl/ LD_DEBUG=libs perl -e 'require XML::Parser;'
      9529:	find library=libperl.so.5.10 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/usr/lib/libperl.so.5.10
      9529:	
      9529:	find library=libdl.so.2 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/lib/x86_64-linux-gnu/libdl.so.2
      9529:	
      9529:	find library=libm.so.6 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/lib/x86_64-linux-gnu/libm.so.6
      9529:	
      9529:	find library=libpthread.so.0 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/lib/x86_64-linux-gnu/libpthread.so.0
      9529:	
      9529:	find library=libc.so.6 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/lib/x86_64-linux-gnu/libc.so.6
      9529:	
      9529:	find library=libcrypt.so.1 [0]; searching
      9529:	 search cache=/etc/ld.so.cache
      9529:	  trying file=/lib/x86_64-linux-gnu/libcrypt.so.1
      9529:	
      9529:	
      9529:	calling init: /lib/x86_64-linux-gnu/libpthread.so.0
      9529:	calling init: /lib/x86_64-linux-gnu/libc.so.6
      9529:	calling init: /lib/x86_64-linux-gnu/libcrypt.so.1
      9529:	calling init: /lib/x86_64-linux-gnu/libm.so.6
      9529:	calling init: /lib/x86_64-linux-gnu/libdl.so.2
      9529:	calling init: /usr/lib/libperl.so.5.10
      9529:	
      9529:	
      9529:	initialize program: perl
      9529:	transferring control: perl
      9529:	
      9529:	find library=libexpat.so.1 [0]; searching
      9529:	 search path=/opt/outputs/perl/host/usr/lib/tls/x86_64:/opt/outputs/perl/host/usr/lib/tls:/opt/outputs/perl/host/usr/lib/x86_64:/opt/outputs/perl/host/usr/lib		(RPATH from file /opt/outputs/perl/host/usr/lib/perl//auto/XML/Parser/Expat/Expat.so)
      9529:	  trying file=/opt/outputs/perl/host/usr/lib/tls/x86_64/libexpat.so.1
      9529:	  trying file=/opt/outputs/perl/host/usr/lib/tls/libexpat.so.1
      9529:	  trying file=/opt/outputs/perl/host/usr/lib/x86_64/libexpat.so.1
      9529:	  trying file=/opt/outputs/perl/host/usr/lib/libexpat.so.1
      9529:	
      9529:	calling init: /opt/outputs/perl/host/usr/lib/libexpat.so.1
      9529:	calling init: /opt/outputs/perl/host/usr/lib/perl//auto/XML/Parser/Expat/Expat.so
      9529:	calling fini: perl [0]
      9529:	calling fini: /usr/lib/libperl.so.5.10 [0]
      9529:	calling fini: /lib/x86_64-linux-gnu/libdl.so.2 [0]
      9529:	calling fini: /lib/x86_64-linux-gnu/libm.so.6 [0]
      9529:	calling fini: /lib/x86_64-linux-gnu/libpthread.so.0 [0]
      9529:	calling fini: /lib/x86_64-linux-gnu/libcrypt.so.1 [0]
      9529:	calling fini: /opt/outputs/perl/host/usr/lib/perl//auto/XML/Parser/Expat/Expat.so [0]
      9529:	calling fini: /opt/outputs/perl/host/usr/lib/libexpat.so.1 [0]
      9529:	calling fini: /lib/x86_64-linux-gnu/libc.so.6 [0]

As you can see here, it clearly looks in the RPATH encoded into
Expat.so to find where libexpat.so.1 is located. In my
case /opt/outputs/perl/ in the Buildroot output directory, and it
clearly uses the libexpat.so.1 from this output directory, and not the
one from my system.

Are you sure you don't have any value set in your LD_LIBRARY_PATH
environment variable (outside of Buildroot)? Can you try the commands
above (check the RPATH of Expat.so and check the resolution of
libraries when asking Perl to require the XML::Parser module, when
PERLLIB points to the Perl modules built by Buildroot), and post the
results?

Thanks,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


More information about the buildroot mailing list