Gentoo Archives: gentoo-dev

From: Jason Stubbs <jstubbs@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Cross Compilation and Dynamic Slots
Date: Thu, 12 Aug 2004 13:09:18
Message-Id: 200408122212.10225.jstubbs@gentoo.org
In Reply to: Re: [gentoo-dev] Cross Compilation and Dynamic Slots by "Ilya A. Volynets-Evenbakh"
1 On Thursday 12 August 2004 01:17, Ilya A. Volynets-Evenbakh wrote:
2 > Let me try to understand multilib on MIPS example (which is probably
3 > most complex ABI screw-up case).
4 > For starters, standrard mips toolchain, when compiled with multilibs
5 > enabled, is capable of producing binaries for any ABI. At the same time,
6 > this imposes specific file system layout
7 > (o32 libraries go into /lib /usr/lib /usr/lib/gcc-lib/lib,
8 > n32 - /lib32 /usr/lib32 /usr/lib/gcc-lib/lib32,
9 > n64 - /lib64 /usr/lib64 /usr/lib/gcc-lib/lib64).
10 >
11 > On one hand this is good - different ABIs can coexist, and even mix in
12 > some cases.
13
14 Sounds pretty much the same as AMD64 so far...
15
16 > On the other hand thus is bad - many programs do not expect to have
17 > libraried not in /lib /usr/lib places.
18
19 This issue affects any user of multilib and perhaps any user wishing to cross
20 compile. This point hasn't really been addressed yet.
21
22 > As it is now, I have special patch, that makes glibc and gcc
23 > use /lib /usr/lib layout when using N32 and not using multilibs.
24
25 So N32 is the "default", then?
26
27 > So, for one thing, we should probably add another variable - ABI - since
28 > ARCH will be mips in all three cases.
29
30 ARCH comes from the expansion of the keyword, as per GLEP 22. For portage to
31 be able to pass the ABI, under this proposal, keywords would need to be
32 extended to include it - something like mips-n64-gnu-linux-glibc.
33 Architectures not supporting more than one ABI could use be called "std".
34
35 However, to get this included you will need to convince the general developer
36 community that it is a Good Thing. It'd help if you can find another
37 supported architecture that could make use of it.
38
39 > How do we handle the case, where we have two different apps, depending
40 > on same lib, and one is requested to be compiled as o32 and another as n32?
41
42 I covered this in the proposal but I'll cover it again below.
43
44 > And in general, how do we allow user to specify which ABI he wants to use
45 > for this specific compile (Yes - it is possible some will want to compile
46 > different apps with different ABIs - i.e. n32 is generally faster then n64
47 > because it has lmaller pointer size, but for that same reason its addressing
48 > is limited. Thus in order to utilize all 8G of ram in my origin, I will need
49 > certain apps to be n64).
50
51 I covered this too, but to sum it up "emerge mem-hungry-app&mips-n64"
52
53
54 I'll edit what I posted last time in order to clear up issues others have
55 brought up (thanks solar & lv!)
56
57 On Wednesday 11 August 2004 23:21, Jason Stubbs wrote:
58 === GENERAL ===
59
60 > EBUILDS
61 > pkg_select()
62 > This function configures the system to use this package by default. If
63 > it is successful or if there is no need to do so, it should return 0.
64 > It should also export any information needed to revert the system back
65 > to its original state. If it is not successful, it should do any
66 > cleanup required immediately and return 1.
67 > pkg_revert()
68 > This function reverts the system to back to the state it was in before
69 > running pkg_select() based on information exported by pkg_select().
70
71 > PROFILE GLOBALS
72 keywords.desc
73 Each "old" keyword gets two new fields. One field defines what the keyword
74 is expanded to by default. The other field defines what class of keyword
75 will match the "old" keyword. Using MIPS as an example, the three fields
76 would look something like:
77 mips mips-n32-gnu-linux-glibc mips-*-gnu-linux-glibc
78
79
80 === DYNAMIC SLOTTING ===
81
82 > ATOMS
83 > cat/pkg{atom [atom]}
84 > The braced atom specifies extra bounds for a matching cat/pkg's DSLOT.
85 This is used to specify a particular combination of a package and one or
86 more of the packages it is dynamically slotted.
87
88 > EBUILDS
89 > DSLOT="atom [atom ...]"
90 > Portage scans installed and to be installed packages against the
91 > specified atom(s) and builds the DSLOTted package once for each
92 > individual package match, passing the matched package name to the
93 > ebuild in the DSLOT variable.
94
95 > INSTALLED DB
96 > /var/db/pkg/.../pkg-ver[--cat--pkg--slot]
97 The --cat--pkg--slot represents the package that pkg-ver was DLOTted
98 against.
99
100
101 === CROSS COMPILATION & MULTILIB ===
102
103 > PROFILES
104 make.defaults
105 KEYWORDS will be replace ARCH to allow multiple keywords. When portage
106 checks the masking status of a set of packages, it checks all packages
107 against each keyword from first to last and stops when it finds a match.
108 Any ACCEPT_KEYWORDS settings will also be reordered to match the ordering
109 of KEYWORDS so that the profile defined precedence is adhered to.
110 > packages.cc
111 > Defines a set of atoms that must be on the host system to be able to
112 > compile for this profile.
113 > bashrc - available as of portage-2.0.51_pre17
114 ARCH, ABI, USERLAND, LIBC & KERNEL are defined as those required for the
115 package that is about to be compiled when sourced. These will be defined
116 as per the keyword matched or the keyword specified by the requesting
117 atom. Bashrc should define aliases, set up CFLAGS or anything required to
118 compile for the passed (expanded) keyword using the packages defined in
119 packages.cc.
120
121 > ATOMS
122 > cat/pkg&keyword
123 > Defines that a package needs to be compiled as the specified keyword.
124 A package will only match if it has keyword (or a derivative) listed in its
125 KEYWORDS. This overrides the ordering set by the profile's KEYWORDS. If the
126 specified keyword (or a derivative) does not exist in the profile's
127 KEYWORDS, the atom will not match any packages.
128
129 > GCC
130 >
131 > To build a cross compiler, the atom would be "sys-devel/gcc&keyword". Gcc
132
133 This is wrong and is the result of lack of sleep. "sys-devel/gcc&keyword"
134 would result in the package not being installed if 'keyword' did not exist in
135 the profile's KEYWORDS. The only workaround I can think of for this is a
136 per-profile package.keywords and have the profile specify all keywords for
137 sys-devel/gcc. Gcc would then still be able to contain the following logic.
138
139 > would then receive the keyword in the form of ARCH, USERLAND, LIBC & KERNEL
140 > but would still be able to tell the host architecture by way of the keyword
141 > 'USE flag'. Portage would then slot the compiler into /var/db/pkg/keyword/.
142 > Gcc would also define pkg_select() and pkg_revert() to do the same as
143 > ocaml.
144
145 If anybody can think of a better way to do this, I'd love to hear it. As it
146 stands, gcc is the only sore thumb to this whole proposal.
147
148 > INSTALLED DB
149 > /var/db/pkg/keyword/cat/...
150 The keyword field is the KEYWORD that was matched when selecting the
151 package to be installed. The keyword is always in its full form as per
152 GLEP 22 (with any approved ABI extension).
153
154 DEPENDENCY RESOLUTION
155 When portage resolves a package, all dependencies and sub dependencies are
156 only matched against the keyword that the top package was matched against.
157 For example, if the profile's KEYWORDS is "foo bar" and a user does emerge
158 somepkg&bar (or the package does not have KEYWORDS="foo") somepkg and any
159 of its dependencies will be installed as "bar".
160
161
162 === EXAMPLE ===
163
164 I'll only cover cross compilation and multilib as I think the others speak for
165 themselves. For the example, I'll theoretically go through the cross
166 compilation of a package for both mips-n32 and mips-n64 into the one altroot.
167
168
169 -- Start --
170 * The user sets up ${alt} root with the mips profile to be compiled for.
171 - The profile has KEYWORDS="mips-n32 mips-o32 mips-n64"
172 * The user executes "ROOT=${alt} emerge some/pkg some/pkg&mips-n64"
173 - The some/pkg ebuild has KEYWORDS="mips"
174 * Portage checks ${alt} profile's package.cc and ensures that all packages
175 are installed.
176 - packages.cc would contain sys-devel/gcc&mips and whatever else
177 - If they weren't installed, they would be in the same fashion as the
178 following.
179
180 -- some/pkg --
181 * Portage scans the profile's KEYWORDS and finds the first to be mips
182 * Portage scans the global keywords.desc to find mips expands to
183 mips-n32-gnu-linux-glibc.
184 * Portage scans the ebuild's KEYWORDS and when it finds mips,
185 * Portage scans the global keywords.desc to find the mips keyword will
186 match mips-*-gnu-linux-glibc.
187 * Portage chooses mips-n32-gnu-linux-glibc for this package.
188 * Portage runs pkg_select() for each of packages.cc's installed packages on
189 the host to prepare for cross compilation.
190 * Portage expands the keyword into variables and passes them to ${alt}'s
191 bashrc.
192 * Bashrc sets up for n32 compilation.
193 * The ebuild does it's regular thing.
194 * Portage records the package to
195 ${alt}/var/db/pkg/mips-n32-gnu-linux-glibc/some/pkg
196 * Portage runs pkg_revert() on each of the earlier successful pkg_select()s
197
198 -- some/pkg&mips-n64 --
199 * Portage scans the global keywords.desc to find mips-n64 expands to
200 mips-n64-gnu-linux-glibc.
201 * Portage scans and expands each of the profile's KEYWORDS to find that
202 mips matches.
203 * Portage scans the ebuild's KEYWORDS and when it finds mips,
204 * Portage scans the global keywords.desc to find the mips keyword will
205 match mips-*-gnu-linux-glibc.
206 * Portage chooses mips-n64-gnu-linux-glibc for this package.
207 * Portage runs pkg_select() for each of packages.cc's installed packages on
208 the host to prepare for cross compilation.
209 * Portage expands the keyword into variables and passes them to ${alt}'s
210 bashrc.
211 * Bashrc sets up for n64 compilation.
212 * The ebuild does it's regular thing.
213 * Portage records the package to
214 ${alt}/var/db/pkg/mips-n64-gnu-linux-glibc/some/pkg
215 * Portage runs pkg_revert() on each of the earlier successful pkg_select()s
216
217
218 Yes, I realize that mips-n32 and mips-n64 were almost the same - that's the
219 beauty of it! ;)
220
221 Regards,
222 Jason Stubbs
223
224 --
225 gentoo-dev@g.o mailing list

Replies