Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] Generate soname dependency metadata (282639)
Date: Fri, 30 Jan 2015 02:02:34
Message-Id: 54CAE633.9010001@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH] Generate soname dependency metadata (282639) by "Anthony G. Basile"
1 On 01/29/2015 04:54 PM, Anthony G. Basile wrote:
2 > On 01/26/15 22:16, Zac Medico wrote:
3 > ELF gets us like 99% of the way but will eventually have to think about
4 > Mach-O for gentoo-on-mac etc. Maybe COFF, a.out. Not sure where to
5 > draw the line.
6
7 Yeah, I guess we can let the Prefix team decide on that stuff.
8
9 > I'm a bit confused here. So PROVIDES and REQUIRES are new files in
10 > /var/db/pkg/<cat>/<pkg>?
11
12 Right.
13
14 > And the format of NEEDED.ELF.2 is not changing? Correct?
15
16 It has one new field, for the multilib category (same as the abstract
17 abi identifier discussed in bug 534206). I didn't bother to document it,
18 since is was already completely undocumented. I suppose it would be nice
19 to have it documented in portage.5, though.
20
21 > We should note at some point that arm_32 means EABI and not OABI which
22 > are two different 32-bit arm abis. We don't support oabi in gentoo
23 > anymore, but still this can be confusing. If it did come up in some
24 > context, we could distinguish it as arm_o32 like mips below.
25
26 Yeah, I'm inclined to just wait for someone to request support for
27 something like this, and deal with it then.
28
29 > We probably don't have to note that arm_64 is aarch6 which is really a
30 > different ISA, not backwards compatible to 32-bit arm. As you say below
31 > this is just a naming convention, but in every other case each line does
32 > refer to one ISA, except maybe ia_32 can be confused with x86.
33
34 Well, wikipedia says "AArch64 provides user-space compatibility with
35 ARMv7-A ISA" [1], so I think that's a good enough reason to stick with
36 arm_{32,64} for now.
37
38 >> +# hppa_{32,64}
39 >> +# ia_{32,64}
40 >> +# m68k_{32,64}
41 >> +# mips_{eabi32,eabi64,n32,n64,o32,o64}
42 >> +# ppc_{32,64}
43 >> +# s390_{32,64}
44 >> +# sh_{32,64}
45 >> +# sparc_{32,64}
46 >> +# x86_{32,64,x32}
47 >> +#
48 >> +# NOTES:
49 >> +#
50 >> +# * The ABIs referenced by some of the above *_32 and *_64 categories
51 >> +# may be imaginary, but they are listed anyway, since the goal is to
52 >> +# establish a naming convention that is as consistent and uniform as
53 >> +# possible.
54 >> +#
55 >> +# * The Elf header's e_ident[EI_OSABI] byte is completely ignored,
56 >> +# since OS-independence is one of the goals. The assumption is that,
57 >> +# for given installation, we are only interested in tracking multilib
58 >> +# ABIs for a single OS.
59 >
60 > If you run readelf -h on (say) bash in any of our stage3's tarballs you
61 > always get "OS/ABI: UNIX - System V" irrespective of arch and abi. I
62 > don't know what you would get on BSD, but the field is totally
63 > irrelevant for our purposes despite the name. As far as I can tell, it
64 > is totally invariant across arches and abis.
65 >
66 > You can even unpack the the stage3's on an amd64 host and run readelf
67 > form the host on the chroot target and you'll get the elf header, so you
68 > don't need access to native hardware.
69 >
70 > The comment suggests that there might be some interesting information
71 > there, but there isn't. Maybe I'm just reading too much into it.
72
73 Well, a quick google search seems to indicate that FreeBSD uses
74 EI_OSABI. I was specifically thinking about FreeBSD when I wrote that
75 comment, because I was aware that Gentoo/FBSD was using ELF, and I just
76 assumed that they would have a different EI_OSABI than Linux.
77
78 >> diff --git a/pym/portage/util/_dyn_libs/NeededEntry.py
79 >> b/pym/portage/util/_dyn_libs/NeededEntry.py
80 >> new file mode 100644
81 >> index 0000000..5de59a0
82 >> --- /dev/null
83 >> +++ b/pym/portage/util/_dyn_libs/NeededEntry.py
84 >> @@ -0,0 +1,83 @@
85 >> +# Copyright 2015 Gentoo Foundation
86 >> +# Distributed under the terms of the GNU General Public License v2
87 >> +
88 >> +from __future__ import unicode_literals
89 >> +
90 >> +import sys
91 >> +
92 >> +from portage import _encodings, _unicode_encode
93 >> +from portage.exception import InvalidData
94 >> +from portage.localization import _
95 >> +
96 >> +class NeededEntry(object):
97 >> + """
98 >> + Represents one entry (line) from a NEEDED.ELF.2 file. The entry
99 >> + must have 5 or more semicolon-delimited fields in order to be
100 >> + considered valid. The sixth field is optional, corresponding
101 >> + to the multilib category. The multilib_category attribute is
102 >> + None if the corresponding field is either empty or missing.
103 >> + """
104 >> +
105 >> + __slots__ = ("arch", "filename", "multilib_category", "needed",
106 >> + "runpaths", "soname")
107 >
108 > Looks like this answers my question above about the format of NEEDED.ELF.2
109
110 Yeah, maybe this is enough documentation for those who would be interested.
111
112 > Nice logic here :) The only thing that I don't get is why we might need
113 > {provides,requires}_exclude patterns. I guess its good design
114 > principles but I can't think of a use case.
115
116 I copied the idea from Fedora [2]. Since the soname dependencies are
117 automatically generated, we want to be able to filter them if necessary,
118 though hopefully it won't be needed very often.
119
120 >> b/pym/portage/util/elf/constants.py
121 >> new file mode 100644
122 >> index 0000000..3857b71
123 >> --- /dev/null
124 >> +++ b/pym/portage/util/elf/constants.py
125 >
126 > Document where these are coming from else we'll loose the connection to
127 > the standard. They should all be in <elf.h> provided by elfutils, but
128 > I'm sure standard is documented somewhere officially. Even if you just
129 > say "see <elf.h>" that might be enough to clue people where to look for
130 > these definitions.
131
132 Okay, will do. I wasn't really sure where they originated, since so many
133 packages seem to have an elf.h, but elfutils sounds good to me.
134
135 >> diff --git a/pym/portage/util/elf/header.py
136 >> b/pym/portage/util/elf/header.py
137 >> new file mode 100644
138 >> index 0000000..3310eeb
139 >> --- /dev/null
140 >> +++ b/pym/portage/util/elf/header.py
141 >> @@ -0,0 +1,62 @@
142 >
143 > Looks good. I'm going to perf test this but I don't think it will be
144 > too big a hit. I don't know how we would get to this point in the code
145 > tree, but let me ask you this: am I right in thinking you won't hit
146 > ELFHeader.read() with every file that's being installed by portage?
147 > You'll only get here for elf objects? Correct?
148
149 Yeah, it's only called in doebuild.py for the ELF files that were
150 previously recorded in NEEDED.ELF.2, based on scanelf output.
151
152 [1] http://en.wikipedia.org/wiki/ARM_architecture#ARMv8-A
153 [2] http://fedoraproject.org/wiki/Packaging:AutoProvidesAndRequiresFiltering
154 --
155 Thanks,
156 Zac

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH] Generate soname dependency metadata (282639) "Anthony G. Basile" <basile@××××××××××××××.edu>
Re: [gentoo-portage-dev] [PATCH] Generate soname dependency metadata (282639) Zac Medico <zmedico@g.o>