Gentoo Archives: gentoo-soc

From: heroxbd <heroxbd@×××××.com>
To: gentoo-soc@l.g.o
Cc: redlizard@×××××××××.nl
Subject: Re: [gentoo-soc] Gentoo on Android, Summary for 2013.6.28-7.1
Date: Sun, 18 Aug 2013 12:18:47
Message-Id: 871u5r19fj.fsf@proton.in.awa.tohoku.ac.jp
In Reply to: Re: [gentoo-soc] Gentoo on Android, Summary for 2013.6.28-7.1 by Luca Barbato
1 Dear Luca,
2
3 Picking up gcc again.
4
5 Luca Barbato <lu_zero@g.o> writes:
6
7 > Upstream can be difficult, supporting multiple c runtime is _quite_
8 > problematic and requires pointless patching in too many part of the
9 > codebase nowadays =/
10
11 Yes, for example, the *link section of gcc amd64:
12
13 *link:
14
15 %{!static:--eh-frame-hdr} %{m32|mx32:;:-m elf_x86_64} %{m32:-m elf_i386}
16 %{ mx32:-m elf32_x86_64} %{shared:-shared} %{!shared: %{!static:
17 %{rdynamic:-export-dynamic} %{m 32:-dynamic-linker
18 %{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:/opt/gentoo/lib/ld-linux.so.2}}}
19 %{m32|mx32:;:-dynamic-linker
20 %{muclibc:/lib/ld64-uClibc.so.0;:%{mbionic:/system/bin/linker64;:/opt/gentoo/l
21 ib64/ld-linux-x86-64.so.2}}} %{mx32:-dynamic-linker
22 %{muclibc:/lib/ldx32-uClibc.so.0;:%{mbionic:/system/bin
23 /linkerx32;:/opt/gentoo/libx32/ld-linux-x32.so.2}}}} %{static:-static}}
24
25 >> An alternative: Given the similar situation in binutils, I am thinking
26 >> of another switch (like --{enable,with}-native-sysroot) to turn
27 >> --with-sysroot into a native (non-cross) version for our purpose. (GLEP
28 >> draft follows) What do you say?
29 >
30 > Worth a try, sadly you need to coordinate with upstream.
31
32 I spent a whole day trying to get a solution to specify dynamic
33 linker via configure.
34
35 The plan was:
36
37 1. let all the ports of gcc have dynamic_linker section in specs,
38 like that of x86.
39
40 2. add a configure option, --with-extra-specs to specify an
41 additional EXTRA_SPECS to gcc.c.
42
43 3. use toolchain-funcs.eclass to generate dynamic linker specs, as
44
45 +# Returns location of dynamic linker
46 +gcc-specs-gen-dynamic-linker() {
47 + echo '*dynamic_linker:'
48 +
49 + local dlinkers
50 + case $(tc-arch)-${CTARGET##*-} in
51 + amd64-gnu*)
52 + for abi in ${MULTILIB_ABIS}; do
53 + case ${abi} in
54 + amd64) dlinkers+=( "m32|mx32:;:/lib64/ld-linux-x86-64.so.2" ) ;;
55 + x86) dlinkers+=( m32:/lib/ld-linux.so.2 ) ;;
56 + x32) dlinkers+=( mx32:/libx32/ld-linux-x32.so.2 ) ;;
57 + esac
58 + done
59 + ;;
60 + x86-gnu*) dlinkers=( /lib/ld-linux.so.2 ) ;;
61 + arm-gnu*)
62 + case ${CTARGET//_/-} in
63 + *-hardfloat-*) dlinkers=( /lib/ld-linux-armhf.so.3 ) ;;
64 + *-softfloat-*) dlinkers=( /lib/ld-linux.so.3 ) ;;
65 + esac
66 + ;;
67 + esac
68 +
69 + for dlinker in ${dlinkers[@]}; do
70 + local ldso=${dlinker##*:}
71 + if [[ ${ldso} == ${dlinker} ]]; then
72 + echo -n "${EPREFIX}"${ldso}
73 + else
74 + local switch=${dlinker%:*}
75 + echo -n "%{${switch}:${EPREFIX}${ldso}}"
76 + fi
77 + done
78 +}
79
80 But there are intrinsic difficulties. The default specs of gcc
81 are all preprocessed as C macros, which means we cannot pass a
82 specs file to make it default. Furthermore, I could not find a
83 way to pass a customized specs file for building (which is
84 necessary that we have to build gcc against glibc from
85 RAP). Therefore, we have to pass raw C into configure options,
86 like,
87
88 econf --with-extra-specs='{ "dynamic-linker", "/opt/gentoo/lib/ld-linux.so.2" }'
89
90 However, GNU autoconf/automake system automatically quote this to
91 a string, while we want to pass an array of structures.
92
93 Another solution is to prepend sysroot to dynamic linker, which is
94 indifferent to the runtime-prefix patch from Google, criticized by you
95 earlier.
96
97 Up to this point, the solution becomes complex and artificial. I
98 would rather use the present patch'n'prefixify method, as we used
99 in many ebuild, like:
100
101 --- gcc/config/i386/linux.h 2011-06-04 03:30:39.000000000 +0900
102 +++ gcc/config/i386/linux.h.new 2013-07-16 19:55:09.610399047 +0900
103 @@ -21,4 +21,4 @@ along with GCC; see the file COPYING3.
104 <http://www.gnu.org/licenses/>. */
105
106 #define GNU_USER_LINK_EMULATION "elf_i386"
107 -#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
108 +#define GLIBC_DYNAMIC_LINKER "@GENTOO_PORTAGE_EPREFIX@/lib/ld-linux.so.2"
109
110 Cheers,
111 Benda

Replies

Subject Author
Re: [gentoo-soc] Gentoo on Android, Summary for 2013.6.28-7.1 Luca Barbato <lu_zero@g.o>