Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Cc: mgorny@g.o, tommy@g.o
Subject: Re: [gentoo-dev] Re: [RFC] multilib-build.eclass and restricting unsupported ABIs
Date: Sat, 09 Mar 2013 10:10:23
Message-Id: 20130309111011.2e1044f3@portable
In Reply to: Re: [gentoo-dev] Re: [RFC] multilib-build.eclass and restricting unsupported ABIs by "Michał Górny"
1 On Fri, 8 Mar 2013 17:30:10 +0100
2 Michał Górny <mgorny@g.o> wrote:
3
4 > On Thu, 7 Mar 2013 17:25:23 +0100
5 > Alexis Ballier <aballier@g.o> wrote:
6 >
7 > > On Mon, 4 Mar 2013 21:49:48 +0100
8 > > Michał Górny <mgorny@g.o> wrote:
9 > >
10 > > > I'm afraid that's the first potential point of failure. Relying
11 > > > on argv[0] is a poor idea and means that any application calling
12 > > > exec() with changed argv[0] on a wrapped binary will fail
13 > > > terribly.
14 > >
15 > > Go tell that to those that wrote busybox, tex or git: They all use
16 > > that argv trick :) I'm sure there are plenty of other examples and
17 > > don't consider that a poor idea. Note that the wrapper does not lie
18 > > on argv: it just makes the binary think it has its original name (by
19 > > passing argv as is) while it has been moved to allow parallel
20 > > installation of different flavors of it.
21 >
22 > We're talking about two different tricks.
23 >
24 > Busybox checks argv to support symlinking for a standard tool. With
25 > invalid argv[0], it still runs as the standard busybox binary. You can
26 > use it that way, the 'safe way'.
27 >
28 > Unless I'm missing something, git checks argv to support symlinking
29 > into a few dozen tools which is optional. I doubt most of our users
30 > rely on that rather than using the 'git foo' syntax.
31 >
32 > A wrapper needs valid argv[0] to find the actual executable. Since
33 > argv[0] is unlikely to contain a path, that's either reinventing some
34 > logic or execvp() which is a bit fragile. Plus symlink resolution
35 > loop. Hard links do not work at all.
36 >
37 > And that's just theory. I may be missing some of the dangers.
38
39 abiwrapper with invalid argv will print a standard help message too :)
40 I don't see why you consider execvp fragile: Don't tell me you run all
41 your binaries with full path.
42
43 Of course you can break it, but the question is more: Is it likely to
44 break in a real life situation?
45
46 If you consider the argv trick fragile, which is understandable, the
47 same wrapper idea can be used differently: If you want to wrap a
48 binary foo, move it to foo_${abi} and build a wrapper with hardcoded
49 'foo' instead of argv[0] that you install as foo. You can even hardcode
50 its path and use execv instead of execvp. That would invalidate all
51 your above objections I think :)
52
53 > > > I'm afraid you are actually starting to go the other way.
54 > > >
55 > > > Global wrapper means that it is potentially useful to our users.
56 > > > However I don't really see people who want to compile 32-bit
57 > > > executables think of setting some custom variable like ABI.
58 > >
59 > > They will not: Users will call the name-suffixed version directly.
60 > > If they call the non-suffixed version then the above logic will run
61 > > the DEFAULT_ABI version. There's no variable to set.
62 >
63 > So there's no benefit from the wrapper to the users. We're talking
64 > about a solution which is purely disadvantageous to them.
65
66 The wrapper is not for users at all...
67
68 You can very well have two different ways of installing
69 multilib-binaries also: one with an array mapping (abi,binary) to
70 (renamed_binary), without wrapping at all, which is what you seem to
71 want for glxinfo. Another one with the full wrapping mechanism to make
72 multilib builds of dependent packages easier/doable.
73
74 > > The variable is more so that ebuilds/eclasses can set the variable
75 > > and be done. Exactly like EPYTHON I think.
76 >
77 > Python is almost a completely different issue. Most importantly, we
78 > support multiple Python versions, and have to maintain all of them.
79 > That support is extended to all packages in the tree, and is achieved
80 > with no major losses.
81 >
82 > We're talking about having multilib for a few chosen packages, and yet
83 > introducing a tree-wide solution to hack-around even less of them.
84 > A hack-around which has visible disadvantages.
85
86 That's why we are currently discussing how to do it properly :P
87 Let alone qmake, how do you suggest dealing with *-config scripts?
88 Some packages are just not written with multilib in mind, or have
89 to maintain historical compatibility which was not, wrapping the
90 problematic binaries is one solution to this. I've not seen any other
91 solution.
92
93 > > [...]
94 > > > > That's why I asked for examples :)
95 > > > > qmake may do it, I don't think its sane, but that's life for
96 > > > > now. having glxinfo for each abi is useful from a user
97 > > > > perspective (it does not need the wrapper a priori though)
98 > > >
99 > > > Yep, I intended to just have the additional variant of glxinfo
100 > > > directly callable, with a name chosen specifically by the X11
101 > > > team. Wrapper would be more confusing than beneficial here IMO.
102 > >
103 > > Having a wrapper or not, for the end user that does not know the
104 > > internal variable name, the end-result will be exactly the same :)
105 >
106 > Unless he symlinked the tool. Then it simply won't work for him
107 > anymore.
108
109 Well, this is a non-issue with the 'one wrapper with hardcoded names
110 per binary' approach above.
111
112 > > This is an extreme and stupid example, but without any wrapper and
113 > > with ABI-specific output used within ebuilds and build systems, you
114 > > have to be *very* careful that the correct tool is *always* called.
115 > > The wrapper is only a way to ensure that after all :)
116 >
117 > The main point is to enforce ebuild developers to be careful while
118 > handling multilib. This is the main difference from Tommy's solution
119 > -- I don't want people to switch the 'multilib' flag on ebuilds
120 > thoughtlessly and expect everything to work without changing the
121 > ebuild.
122
123 Yes, and we want to do it properly. So far the only solution I've seen
124 for *-config scripts is a wrapper. The qmake case has to be analyzed,
125 maybe its doable in a better way without wrapper.
126 Unless someone comes with a sane different solution for *-config
127 scripts, I still think the wrapper is the only solution to these.
128
129 Alexis.

Replies