Gentoo Archives: gentoo-dev

From: heroxbd <heroxbd@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] RFC: GLEP rap (Prefix/libc)
Date: Mon, 12 Aug 2013 07:48:33
Message-Id: 87li47z70r.fsf@proton.in.awa.tohoku.ac.jp
1 Dear all,
2
3 I have made a GLEP draft to standardize our recent effort on using our
4 own libc from portage inside Prefix.
5
6 At present only glibc on linux is supported. While the idea is quite
7 extensible to other kernel/libc combo. I've got no reply from GLEP team
8 for 3 weeks. Here I post the draft for peer review.
9
10 The rst text are included inline.
11
12 Cheers,
13 Benda
14
15 GLEP: XXX
16 Title: Prefix with libc
17 Version:
18 Last-Modified:
19 Author: Benda Xu <heroxbd@g.o>,
20 Discussions-To: gentoo-alt@l.g.o
21 Status: Draft
22 Type: Standards Track
23 Content-Type: text/x-rst
24 Created: 20-Jul-2013
25 Post-History:
26
27
28 Credits
29 =======
30
31 The work roots in Google Summer of Code 2013 project `Gentoo on
32 Android`_, mentored by Luca Barbato, and inspired by Ruud Koolen.
33
34 Abstract
35 ========
36
37 This GLEP provides a solution to have libc within `Gentoo Prefix`_ on
38 Linux kernel.
39
40
41 Motivation
42 ==========
43
44 Traditionally, Linux variant of Prefix (Prefix Linux) uses the libc
45 from the host OS. Problems arise when the version of glibc is as old
46 as 2.5, like RHEL/CentOS 5 and many ancient GNU/Linux still in duty
47 [#centos5]_ [#fortify]_. The present solution is to disable automatic
48 fortify, leaving fortify to be broken [#fortify]_.
49
50 The only way to address this issue is to use newer libc from within
51 Prefix.
52
53 RAP
54 Literally means *Rap Ain't Prefix*. It serves as an acronym of
55 *Prefix with libc* and is used interchangeably in this GLEP.
56
57 Userspace of RAP is identical to Gentoo Linux, therefore more uniform
58 and robust. RAP helps the ongoing effort of merging prefix and gx86
59 portage trees [#pgx86]_.
60
61 Thanks to the completely independent userspace, RAP can run on any
62 kernel that glibc was ported to, giving a full functional GNU
63 environment in parallel to the host. Candidates include GNU Hurd,
64 Google Android (Linux kernel) and BSD (using Debian/kFreeBSD patched
65 glibc).
66
67 Rationale
68 =========
69
70 Gentoo Linux, though often cited as *metadistribution*, originates
71 from a Linux distribution. Linux is supported better in Gentoo. In
72 Prefix community, the merging of prefix and gx86 portage trees
73 [#pgx86]_ is brought back by non-Linux systems such as Mac OS X and
74 Solaris.
75
76 To make the effort more incremental, we can decompose the merging into
77 two stages by first focusing on Prefix Linux. RAP based Prefix Linux
78 serves as Stage 1, where only directory prefixes are focused upon.
79 Kernel-dependent patches for non-Linux are merged at Stage 2.
80
81 Exploiting the identical userspace, we can use implicit keywording by
82 merging presently used Prefix keyword ${ARCH}-linux into ${ARCH},
83 ${ARCH} being `amd64`, `x86`, `arm`, etc.
84
85
86 Backwards Compatibility
87 =======================
88
89 RAP cannot be mixed with present Prefix Linux implementation based on
90 rpath if version of the host glibc is too low.
91
92 ABI is incompatible between, e.g. glibc-2.5 and glibc-2.17, especially
93 in that dynamic loader of glibc-2.5 cannot load libc.so.6 of
94 glibc-2.17.
95
96 We, however, do not have a complete survey of ABI and header
97 compatibility across glibc versions.
98
99 To coexist with present Prefix Linux, a use flag `rap` is defined in
100 addition to the `prefix` flag to represent using of libc from within
101 Prefix.
102
103
104 Specification
105 =============
106
107 Present Prefix Linux uses *rpath mechanism* [#rpath]_, namely encode a
108 prefixed library path into RPATH and RUNPATH in dynamic section of
109 ELF. RAP, on the other hand, encode a prefixed dynamic loader into
110 INTERP in the program header of ELF.
111
112 The dynamic loader is provided by glibc.
113
114 RAP is different with present Prefix Linux in toolchain, while
115 identical in portage tree and portage itself.
116
117 Toolchain includes kernel headers(trivial), libc(glibc), compiler(gcc)
118 and linker(binutils). We focus our discussion on the last three parts
119 as well as portage profile to hold things together.
120
121 The sysroot features of gcc and binutils are designed for cross
122 compiling, treating a directory as root of target rootfs. We make use
123 of sysroot with adjustments for native use towards our need.
124
125
126 Glibc
127 -----
128
129 Glibc is ready if Prefix support is accepted [#glibcpfx]_.
130
131
132 Gcc
133 ---
134
135 Sysroot is used by passing --with-sysroot=${EPREFIX} to econf. In
136 addition, the dynamic linker specified by GLIBC_DYNAMIC_LINKER should
137 be prepended by ${EPREFIX}.
138
139
140 Binutils
141 --------
142
143 Sysroot is used by passing --with-sysroot=${EPREFIX} to econf. In
144 addition, the following feature of ld script should be disabled
145 [#ldinfo]_:
146
147 In case a "sysroot prefix" is configured, and the filename starts
148 with the / character, and the script being processed was located
149 inside the "sysroot prefix", the filename will be looked for in
150 the "sysroot prefix".
151
152 Similarly, the feature of prepending sysroot to rpath should also be
153 disabled.
154
155
156 Portage Profile
157 ---------------
158
159 Profile of RAP is put into features/rap, it defines `prefix` and `rap`
160 keywords.
161
162 Arch specific profiles are put into default/linux/${ARCH}/13.0/rap,
163 and having features/rap as parent.
164
165
166 Implementation
167 ==============
168
169 A reference implementation can found at developer `overlay of
170 heroxbd`_.
171
172 The native variant of sysroot feature of binutils and gcc discussed in
173 this GLEP will be submitted upstream after thorough testing.
174
175 References
176 ==========
177
178 .. _Gentoo on Android: http://www.awa.tohoku.ac.jp/~benda/projects/android.html
179
180 .. _Gentoo Prefix: http://prefix.gentoo.org
181
182 .. [#centos5] emerge gcc 4.4.x/4.5.x fails ...,
183 http://thread.gmane.org/gmane.linux.gentoo.alt/6110
184
185 .. [#fortify] >=sys-devel/gcc-4.3 fails ...,
186 https://bugs.gentoo.org/show_bug.cgi?id=289757
187
188 .. [#pgx86] Moving prefix/EAPI-3 support into the gentoo-x86 tree,
189 https://bugs.gentoo.org/show_bug.cgi?id=315803
190
191 .. [#rpath] gcc/ld wrappers injecting correct flags stuff,
192 http://article.gmane.org/gmane.linux.gentoo.alt/1125
193
194 .. [#glibcpfx] sys-libs/glibc Prefix support,
195 https://bugs.gentoo.org/show_bug.cgi?id=473728
196
197 .. [#ldinfo] ld Info Section 3.4.2, Commands Dealing with Files
198
199 .. _overlay of heroxbd: http://git.overlays.gentoo.org/gitweb/?p=dev/heroxbd.git
200
201 .. _Android: http://www.android.com
202
203 Copyright
204 =========
205
206 This document has been placed in the public domain.

Replies

Subject Author
[gentoo-dev] Re: RFC: GLEP rap (Prefix/libc) Duncan <1i5t5.duncan@×××.net>