Gentoo Archives: gentoo-soc

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

Replies

Subject Author
Re: [gentoo-soc] Gentoo on Android, Summary for 2013.6.28-7.1 heroxbd <heroxbd@×××××.com>