Gentoo Archives: gentoo-soc

From: Luca Barbato <lu_zero@g.o>
To: Jing Huang <jing.huang.pku@×××××.com>
Cc: gentoo-soc@l.g.o
Subject: [gentoo-soc] Re: cross_container_support - progress report #10
Date: Tue, 07 Aug 2012 21:06:12
Message-Id: 502174A8.2060304@gentoo.org
In Reply to: [gentoo-soc] cross_container_support - progress report #10 by Jing Huang
1 On 08/07/2012 06:37 PM, Jing Huang wrote:
2 > Hi,
3 >
4 > == Progress of last Week ==
5 >
6 > In the last week, I made armv7a-hardfloat-linux-gnueabi-gcc [ELF
7 > 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically
8 > linked (uses shared libs), for GNU/Linux 2.6.9, stripped] run in the
9 > arm chroot.
10 >
11 > Firstly, I think it is very difficult to switch dynamic libraries
12 > using ld.so.conf and ldconfig, because the generated ld.so.cache
13 > always includes /lib.
14 > My investigation shows:
15 >
16 > glibc-2.14.1/Makeconfig:
17 > # Where to install the shared library and dynamic linker.
18 > ifndef slibdir
19 > slibdir = $(exec_prefix)/lib
20 > endif
21 >
22
23 slibdir can be lib in arm and lib64 in stock amd64, that's the trick I'm
24 using currently.
25
26 > glibc-2.14.1/elf/Makefile:
27 > CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
28 > -D'SLIBDIR="$(slibdir)"' -DIS_IN_ldconfig=1
29 >
30 > glibc-2.14.1/elf/ldconfig.c:
31 > if (!opt_only_cline)
32 > {
33 > parse_conf (config_file, true);
34 >
35 > /* Always add the standard search paths. */
36 > add_system_dir (SLIBDIR);
37 > if (strcmp (SLIBDIR, LIBDIR))
38 > add_system_dir (LIBDIR);
39 > }
40 >
41 > Therefore, ldconfig will always include /lib library path unless using
42 > "ldconfig -n xxx". But "ldconfig -n" won't generate new ld.so.cache.
43
44 Probably patching ldconfig could be an option if using the env var does not.
45
46 > Actually, the linker seeks libraries following the sequence:
47 > a. DT_RPATH in dynamic section.
48 > b. LD_LIBRARY_PATH environment variable.
49 > c. ld.so.cache
50 >
51 > Instead, I was using LD_LIBRARY_PATH rather than ld.so.conf. The steps are:
52 >
53 > 1. mount native libs to chroot
54 > mount --bind /lib gentoo-rootfs/native/lib
55 > mount --bind /usr/lib gentoo-rootfs/native/usr/lib
56 > mount --bind /usr/local/lib gentoo-rootfs/native/usr/local/lib
57 > mount --bind /usr/i686-pc-linux-gnu gentoo-rootfs/native/usr/i686-pc-linux-gnu
58 >
59 > 2. start arm chroot and link native libs
60 > ./lxc.sh start -n gentoo-arm
61 > export LD_LIBRARY_PATH="/native/lib:/native/usr/lib:/native/usr/local/lib"
62 >
63 > 3. set up dynamic library interpreter
64 > ln -s /native/lib/ld-2.14.1.so /lib/ld-linux.so.2
65 >
66 > 4. running native armv7a-hardfloat-linux-gnueabi-gcc
67 > ./native/usr/i686-pc-linux-gnu/armv7a-hardfloat-linux-gnueabi/gcc-bin/4.5.3/armv7a-hardfloat-linux-gnueabi-gcc
68 > build an arm program using armv7a-hardfloat-linux-gnueabi-gcc successfully
69
70 That is a passable solution, pending some bashrc tricks in portage.
71
72 > == Plans for this week ==
73 >
74 > 1. Integrate my progress into lxc.sh script
75 > 2. get some valuations comparing native gcc and emulated gcc
76 > 3. document all the steps in the wiki
77
78 Sounds good. The impressive difference is made by native coreutils
79 (beware to not override uname), make and such.
80
81 lu