* [gentoo-soc] cross_container_support - progress report #10
@ 2012-08-07 16:37 Jing Huang
2012-08-07 20:03 ` [gentoo-soc] " Luca Barbato
0 siblings, 1 reply; 2+ messages in thread
From: Jing Huang @ 2012-08-07 16:37 UTC (permalink / raw
To: gentoo-soc, lu_zero
Hi,
== Progress of last Week ==
In the last week, I made armv7a-hardfloat-linux-gnueabi-gcc [ELF
32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.9, stripped] run in the
arm chroot.
Firstly, I think it is very difficult to switch dynamic libraries
using ld.so.conf and ldconfig, because the generated ld.so.cache
always includes /lib.
My investigation shows:
glibc-2.14.1/Makeconfig:
# Where to install the shared library and dynamic linker.
ifndef slibdir
slibdir = $(exec_prefix)/lib
endif
glibc-2.14.1/elf/Makefile:
CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
-D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
glibc-2.14.1/elf/ldconfig.c:
if (!opt_only_cline)
{
parse_conf (config_file, true);
/* Always add the standard search paths. */
add_system_dir (SLIBDIR);
if (strcmp (SLIBDIR, LIBDIR))
add_system_dir (LIBDIR);
}
Therefore, ldconfig will always include /lib library path unless using
"ldconfig -n xxx". But "ldconfig -n" won't generate new ld.so.cache.
Actually, the linker seeks libraries following the sequence:
a. DT_RPATH in dynamic section.
b. LD_LIBRARY_PATH environment variable.
c. ld.so.cache
Instead, I was using LD_LIBRARY_PATH rather than ld.so.conf. The steps are:
1. mount native libs to chroot
mount --bind /lib gentoo-rootfs/native/lib
mount --bind /usr/lib gentoo-rootfs/native/usr/lib
mount --bind /usr/local/lib gentoo-rootfs/native/usr/local/lib
mount --bind /usr/i686-pc-linux-gnu gentoo-rootfs/native/usr/i686-pc-linux-gnu
2. start arm chroot and link native libs
./lxc.sh start -n gentoo-arm
export LD_LIBRARY_PATH="/native/lib:/native/usr/lib:/native/usr/local/lib"
3. set up dynamic library interpreter
ln -s /native/lib/ld-2.14.1.so /lib/ld-linux.so.2
4. running native armv7a-hardfloat-linux-gnueabi-gcc
./native/usr/i686-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.5.3/armv7a-hardfloat-linux-gnueabi-gcc
build an arm program using armv7a-hardfloat-linux-gnueabi-gcc successfully
== Plans for this week ==
1. Integrate my progress into lxc.sh script
2. get some valuations comparing native gcc and emulated gcc
3. document all the steps in the wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gentoo-soc] Re: cross_container_support - progress report #10
2012-08-07 16:37 [gentoo-soc] cross_container_support - progress report #10 Jing Huang
@ 2012-08-07 20:03 ` Luca Barbato
0 siblings, 0 replies; 2+ messages in thread
From: Luca Barbato @ 2012-08-07 20:03 UTC (permalink / raw
To: Jing Huang; +Cc: gentoo-soc
On 08/07/2012 06:37 PM, Jing Huang wrote:
> Hi,
>
> == Progress of last Week ==
>
> In the last week, I made armv7a-hardfloat-linux-gnueabi-gcc [ELF
> 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically
> linked (uses shared libs), for GNU/Linux 2.6.9, stripped] run in the
> arm chroot.
>
> Firstly, I think it is very difficult to switch dynamic libraries
> using ld.so.conf and ldconfig, because the generated ld.so.cache
> always includes /lib.
> My investigation shows:
>
> glibc-2.14.1/Makeconfig:
> # Where to install the shared library and dynamic linker.
> ifndef slibdir
> slibdir = $(exec_prefix)/lib
> endif
>
slibdir can be lib in arm and lib64 in stock amd64, that's the trick I'm
using currently.
> glibc-2.14.1/elf/Makefile:
> CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
> -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
>
> glibc-2.14.1/elf/ldconfig.c:
> if (!opt_only_cline)
> {
> parse_conf (config_file, true);
>
> /* Always add the standard search paths. */
> add_system_dir (SLIBDIR);
> if (strcmp (SLIBDIR, LIBDIR))
> add_system_dir (LIBDIR);
> }
>
> Therefore, ldconfig will always include /lib library path unless using
> "ldconfig -n xxx". But "ldconfig -n" won't generate new ld.so.cache.
Probably patching ldconfig could be an option if using the env var does not.
> Actually, the linker seeks libraries following the sequence:
> a. DT_RPATH in dynamic section.
> b. LD_LIBRARY_PATH environment variable.
> c. ld.so.cache
>
> Instead, I was using LD_LIBRARY_PATH rather than ld.so.conf. The steps are:
>
> 1. mount native libs to chroot
> mount --bind /lib gentoo-rootfs/native/lib
> mount --bind /usr/lib gentoo-rootfs/native/usr/lib
> mount --bind /usr/local/lib gentoo-rootfs/native/usr/local/lib
> mount --bind /usr/i686-pc-linux-gnu gentoo-rootfs/native/usr/i686-pc-linux-gnu
>
> 2. start arm chroot and link native libs
> ./lxc.sh start -n gentoo-arm
> export LD_LIBRARY_PATH="/native/lib:/native/usr/lib:/native/usr/local/lib"
>
> 3. set up dynamic library interpreter
> ln -s /native/lib/ld-2.14.1.so /lib/ld-linux.so.2
>
> 4. running native armv7a-hardfloat-linux-gnueabi-gcc
> ./native/usr/i686-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.5.3/armv7a-hardfloat-linux-gnueabi-gcc
> build an arm program using armv7a-hardfloat-linux-gnueabi-gcc successfully
That is a passable solution, pending some bashrc tricks in portage.
> == Plans for this week ==
>
> 1. Integrate my progress into lxc.sh script
> 2. get some valuations comparing native gcc and emulated gcc
> 3. document all the steps in the wiki
Sounds good. The impressive difference is made by native coreutils
(beware to not override uname), make and such.
lu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-07 21:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-07 16:37 [gentoo-soc] cross_container_support - progress report #10 Jing Huang
2012-08-07 20:03 ` [gentoo-soc] " Luca Barbato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox