Gentoo Archives: gentoo-mips

From: "Anthony G. Basile" <basile@××××××××××××××.edu>
To: gentoo-mips@l.g.o
Subject: Re: [gentoo-mips] multilib problems on mips64 profiles
Date: Mon, 22 Sep 2014 10:53:47
Message-Id: 541FFFB0.3020307@opensource.dyc.edu
In Reply to: Re: [gentoo-mips] multilib problems on mips64 profiles by Joshua Kinard
1 On 09/21/14 21:49, Joshua Kinard wrote:
2 > On 09/21/2014 21:11, Anthony G. Basile wrote:
3 >> On 09/21/14 18:53, Joshua Kinard wrote:
4 >>> On 09/21/2014 17:55, Anthony G. Basile wrote:
5 >>>> On 09/17/14 16:19, Anthony G. Basile wrote:
6 >>> [snip]
7 >>>>
8 >>>> This isn't going to work. The problem is that the above structure doesn't
9 >>>> distinguish between mips/o32 and mips64/o32 (and equivalent el versions). Now
10 >>>> mips64/o32 is funny, but possible: it would be o32 (a 32-bit abi) on 64 bit
11 >>>> arch/kernel, like ppc64-32ul. The structure is possible at the level of
12 >>>> profile/arch, but it would mean a deep restructuring of
13 >>>> default/linux/mips/13.0.
14 >>>
15 >>> Err, I've been using this setup for the last 9+ years? My Octane and O2 both
16 >>> boot mips64 kernels and run an o32-only userland. It works fine with the
17 >>> current profile setup. You just use a mips-unknown-linux-gnu CHOST. I may not
18 >>> be able to fully utilize all of the CPU registers like I would under n32, but
19 >>> that's never been an issue for me.
20 >>>
21 >>> So there should be no need to differentiate at the userland level between
22 >>> mips/o32 and mips64/o32. As long as the CHOST is set correctly, o32 will work
23 >>> fine under a mips64 kernel (caveat: make sure CONFIG_MIPS32_O32 is set in the
24 >>> kernel).
25 >>
26 >> I agree that there shouldn't be any userland difference, but I'm not 100%
27 >> sure. Anyhow, let's go with that assumption for now.
28 >
29 > There isn't. If there is a difference that can be detected (meaning, with a
30 > machine that can run in 32-bit or 64-bit mode with the same userland), then
31 > you're looking at a kernel problem and that would get handled via upstream
32 > channels. You're actually at a big disadvantage running o32 under a 64-bit
33 > kernel, because of not being able to use all of the registers in the CPU, can
34 > only pass the first four function args via registers (8 in n32), etc. o32 is
35 > for all intents and purposes, the MIPS-I and MIPS-II ISAs, which are core to
36 > the overall ISA set, and so all MIPS CPUs to date should (in theory, because I
37 > do not have access to mips64r* hardware) run o32 just fine.
38 >
39 > You can compile o32 with higher ISAs, i.e., mips3 and mips4, but it's always
40 > been debatable how much extra that helps you (Debian used to question our logic
41 > on this back in the day). Can't use 64-bit features of 64-bit CPUs via that,
42 > but it is supposed to enable things like the square-root instructions available
43 > at the mips4 level.
44 >
45 > The only reason I'm still running o32 is I just haven't been motivated enough
46 > to do a full re-install of both systems. Even if I switch to n32, I'll
47 > probably keep o32 chroots around just to make sure things don't break there.
48 > Might do this soon, though, as I just bought ten new hard drives for all of my
49 > MIPS systems. Just need to get the right brackets for them (because they're
50 > 2.5" 10K SCA drives) so I can mount everything and do data migration.
51 >
52 >
53 >>>
54 >>> Correct me if wrong, but it seems the core problem here is that multilib
55 >>> inherits from the o32 base profile. While I think the proper longterm fix is
56 >>> to have more discrete, modular/pluggable profile components (like OOP and
57 >>> multiple base classes), that's not going to happen in Portage for a long time.
58 >>
59 >> Not exactly. The problem is that everything inherits from profiles/arch/mips
60 >> and currently that forces o32 with mgorny's multilib stuff. We need to get
61 >> that out of the way for the other profiles that inherit it.
62 >>
63 >
64 > Agreed. This worked fine in the past when o32 was our primary focus and
65 > n32/n64 were still experimental (and multilib didn't exist). Nowadays, the
66 > base profile shouldn't prescribe a default ABI at all. That needs to be
67 > handled under a subprofile somehow.
68 >
69 > The real problem is Portage's stacking profiles feature, while soving a lot of
70 > problems that the previous profile system had, wasn't thought up with all of
71 > MIPS' happyfun included. Because endianness, ABI, ISA, kernel, libc, compiler,
72 > and even specific machine support can all be interchangeable in MIPS, this
73 > causes the stacking profile system to become a thing that would frighten
74 > Yog-Sothoth itself, if we were to fully implement all of the combinations
75 > possible under this system.
76 >
77 >
78 >>> So I think the solution is to split the profiles into "mips" and "mips64",
79 >>> i.e., 32/ and 64/ under the 'mips' base profile folder. 32/ contains
80 >>> everything needed to run pure o32-only under either a mips or mips64 kernel.
81 >>> I.e., mips-unknown-linux-gnu CHOST. So on my Octane, /etc/portage/make.profile
82 >>> symlinks to /usr/portage/default/linux/mips/32/<VERSION>/
83 >>
84 >> That's one approach, but I'm trying to find the least intrusive. I do have the
85 >> problem fixed with the following:
86 >>
87 >> [1] default/linux/mips/13.0/o32
88 >> [2] default/linux/mips/13.0/n32
89 >> [3] default/linux/mips/13.0/n64
90 >> [4] default/linux/mips/13.0/multilib/o32
91 >> [5] default/linux/mips/13.0/multilib/n32
92 >> [6] default/linux/mips/13.0/multilib/n64
93 >> [7] default/linux/mips/13.0/mipsel/o32
94 >> [8] default/linux/mips/13.0/mipsel/n32
95 >> [9] default/linux/mips/13.0/mipsel/n64
96 >> [10] default/linux/mips/13.0/mipsel/multilib/o32
97 >> [11] default/linux/mips/13.0/mipsel/multilib/n32
98 >> [12] default/linux/mips/13.0/mipsel/multilib/n64
99 >>
100 >> and would like to push this through as a fix for now. 1 and 4 have
101 >> CHOST=mips-unknown-linux-gnu and mipsel-unknown-linux-gnu respectively. 2,3
102 >> and 8,9 have mips64-unknown-linux-gnu and mips64el-unknown-linux-gnu
103 >> respectively. Only users of profiles 1 and 7 need to change their sym link one
104 >> level down to ../o32. That was necessary to move the o32 stuff out of the way
105 >> of profiles/arch/mips.
106 >
107 > This sounds reasonable. I've got the Octane tasked again on building glibc to
108 > hunt down the R10000 bug I've been stuck on for the past three months, but I
109 > can sync later and test this under your hardened overlay...maybe. I just tried
110 > overlays on Gentoo/FreeBSD for nigoro's 9.3 profiles and gave up in utter
111 > frustration.
112 >
113 > I still think these need to be under a separate versioned directory structure,
114 > though. 14.0/ or 15.0/ or testing/ or pikachu/, whatever. Then we mark 13.0
115 > as deprecated and allow time for users to migrate off before purging them out
116 > of the tree in a month or two. It makes for a messy commit (thanks, CVS), but
117 > it avoids breaking people's systems out there who may not be on this mailing list.
118 >
119 > Also, we should get a news item added as well, specific to MIPS systems only.
120 >
121 >
122 >>>
123 >>> 64/ is where the fun is at. I think the default ABI there should be n32 at the
124 >>> base, with a subprofile for multilib that itself contains subprofiles to handle
125 >>> the combinations of ABIs desired. Still have to workout what CHOST you use for
126 >>> the base (GNU standard for n32 is mips64-unknown-linux-gnueabin32). multilib
127 >>> would just use mips64-unknown-linux-gnu, and -mabi would be passed to gcc to
128 >>> pick the ABI to build for.
129 >>>
130 >>> Also, if we are going to do any kind of reorganizing of the profiles, let's not
131 >>> do it under 13.0. Personally, I'd like to get away from datestamps as profile
132 >>> versions (13.0 refers to 2013) and either pick a fixed version number that we
133 >>> increment or come up with some other kind of versioning scheme. Or just do
134 >>> away with it altogether and have something like a "stable" profile where things
135 >>> work and an "unstable" branch that only exists when we're doing insane changes
136 >>> to the profiles, which after testing, becomes "stable" (and current "stable"
137 >>> becomes "oldstable" or such).
138 >>>
139 >>> If we have to stick with datestamped versions, then use 15.0. Cause it'll be
140 >>> 2015 by the time this goes active.
141 >>>
142 >>> rough draft of the top-level layout. Doesn't care about chosen libc, ISA, or
143 >>> <VERSION>, but does reflect endianness.
144 >>>
145 >>> default/linux/mips
146 >>> |
147 >>> |-32/
148 >>> | |-be/
149 >>> | |-le/
150 >>> |
151 >>> |-64/
152 >>> | |-be/
153 >>> | |-le/
154 >>> | |
155 >>> | |-multilib/
156 >>> | | |-be/
157 >>> | | |-le/
158 >>> | |
159 >>> |
160 >>>
161 >>
162 >> I like this, but the problem is disentangling the situation under arch/mips,
163 >> not under default/linux/mips. Again, the inheritance problem stems from
164 >> everything under profiles/arch/mips inheriting from profiles/arch/mips. So
165 >> even if you do implement the above, you still have to address the issue of how
166 >> the arch/mips stuff is stacking.
167 >
168 > I'll poke around arch/mips later and see if some of this can't be extruded
169 > there. I don't know if arch/mips is for us exclusively, or if we share it with
170 > a few other project teams (other than -embedded -- do we have an OpenBSD MIPS
171 > team or such??).
172 >
173 >
174
175 I don't think anyone really "owns" any of the profiles exclusively
176 because arch teams often have to mask things in other profiles. We do
177 own the default/linux/mips more than arch/mips because there is less
178 reason for arch testers to modify the former compared to the latter [1].
179 However, the profile are fragile and I've had to ask people to not do
180 stuff in hardened for example because of the cooky stacking problem.
181
182 I'll send out an email to all gentoo-dev@ about it, and prepare a news
183 item for only mips users. I do want to move on this because its
184 blocking the upgrade of my lemotes yeeloong images.
185
186 One final point, there's also a set of hardened mips profiles which I
187 haven't listed under profiles.desc. I'm testing them too and they seem
188 to be doing fine with the above structure.
189
190 Note:
191 [1] An example here is a package which builds on amd64 and mips, but
192 only has some optimization in amd64 assembly which you can enable with a
193 USE flag. That flag needs to be masked on mips because there is no
194 equivalent mips assembly. I've seen this before.
195
196 --
197 Anthony G. Basile, Ph. D.
198 Chair of Information Technology
199 D'Youville College
200 Buffalo, NY 14201
201 (716) 829-8197