1 |
This is getting really long, so I'm going to remove more things I'm not |
2 |
answering directly. |
3 |
|
4 |
On Sun, Mar 28, 2021 at 07:31:02PM -0400, Joshua Kinard wrote: |
5 |
> > The problem is, there's a chicken-and-egg problem in the scenario where |
6 |
> > / and /usr are on separate partitions, and this is why a number of linux |
7 |
> > distros have moved to requiring an initramfs in this situation. |
8 |
> > I'm linking systemd's description here, only because it is the best |
9 |
> > writeup of the issue I've found [1]. |
10 |
> > Anything that is needed in the early boot process requires all of its libraries, |
11 |
> > dependent libraries, binaries, data files, etc to be on /, and this has |
12 |
> > become a moving target. |
13 |
> |
14 |
> Yeah, I've read systemd's explanation, and generally disagree with it. They |
15 |
> created the problem in the first place, then invented their own solution for |
16 |
> it, and now everyone acts like they're the wise men on the mountain for it. |
17 |
|
18 |
http://lists.busybox.net/pipermail/busybox/2010-December/074114.html |
19 |
|
20 |
Rob Landley had a lot to say about how linux should be using initramfs |
21 |
to handle early boot long before systemd came along, so this has been |
22 |
an issue a lot longer than systemd; the systemd guys just amplified it. |
23 |
|
24 |
> I still don't see the connection to the static *.a libs and whether they're |
25 |
> on /lib or /usr/lib, though. Unless we're implying that where the *.a's go, |
26 |
> so too do the *.so's go, then THAT makes sense because *.so's ARE needed at |
27 |
> program runtime, whereas *.a's are not. |
28 |
|
29 |
It is a linker behavior issue we discovered and worked around. |
30 |
|
31 |
In the past, Gentoo has gone an extra mile to make some things useable |
32 |
by people who have separate /usr without an initramfs by moving only |
33 |
shared libraries to /lib*. We leave everything else that would be in |
34 |
libdir in the default location which is /usr/lib*. This includes things |
35 |
like static libs, pkgconfig files etc. |
36 |
|
37 |
When we started doing this we found that the linker favors libraries in |
38 |
/usr/lib* over libraries in /lib*, so if you are linking to libfoo and |
39 |
there's a static version in /usr/lib* and a shared version in /lib* you |
40 |
will link to the static version. That's what bug 4411 is about. |
41 |
|
42 |
gen_usr_ldscript gets around this by creating a linker script at the |
43 |
original location of the shared library in /usr/lib* when it moves the |
44 |
shared library to /lib*. |
45 |
See /usr/lib64/libbz2.so for an example of the generated linker script. |
46 |
|
47 |
Getting rid of gen_usr_ldscript would move the shared libraries back to |
48 |
their upstream location (/usr/lib*) and remove the linker scripts. This |
49 |
would also allow the removal of the usr-ldscript eclass and the |
50 |
gen_usr_ldscript function from eutils.eclass. |
51 |
|
52 |
The up side of this is that it allows us to get rid of some of our |
53 |
custom code in ebuilds, and it is completely transparent to most of our |
54 |
user base. |
55 |
|
56 |
The down side is that if you are using separate /usr with no |
57 |
initramfs, libraries that you were accessing in /lib* during early boot will |
58 |
moved to /usr/lib* and not be available before /usr is mounted. |
59 |
This would cause breakage until you reconfigured your system to boot |
60 |
with an initramfs and mount / and /usr before jumping into the real |
61 |
system. |
62 |
|
63 |
> I wonder if we couldn't shovel all static libs off to a dedicated folder |
64 |
> somewhere, like '/usr/lib/static/<pkg>/*.a', similar to the way debug files |
65 |
> are now consolidated under '/usr/lib/debug'. Since they're only needed |
66 |
> during a specific kind of compilation that we don't support out-of-the-box |
67 |
> that happens long after the system is fully booted, stuffing them off |
68 |
> somewhere unimportant would make some sense. Most modern software should be |
69 |
> using shared libs by default, and if it ain't, that's either a bug or that |
70 |
> software is for a very specific function (like a bootloader). |
71 |
|
72 |
If you started creating separate static libs folders you would need one per |
73 |
abi, so it would end up being pretty ugly. We don't build that many |
74 |
static libraries right now, so I'm not sure it is worth moving them to |
75 |
some other folder. |
76 |
|
77 |
If we put the shared libs back in the upstream expected location |
78 |
(/usr/lib*) we would eliminate the linker issue. |
79 |
|
80 |
*snip* |
81 |
|
82 |
> > The way I see it, when we start to remove the gen_usr_ldscript calls, |
83 |
> > people using a sep-usr mount without an initramfs will run into one or |
84 |
> > both of these issues: |
85 |
> > |
86 |
> > - they might have to increase the size of their root partition depending |
87 |
> > on what gets added to /lib* |
88 |
> > - if one package in that list drops gen_usr_ldscript without installing |
89 |
> > libraries in /lib*, it will mean they need an initramfs. |
90 |
> |
91 |
> I tend to make my root partitions ~4GB, which has often been plenty of room |
92 |
> for well over 15 years. But again, location of the *.a static libs is |
93 |
> irrelevant during system boot. They are not needed nor referenced when a |
94 |
> program executes. A statically-compiled program has all of its dependencies |
95 |
> lumped inside of it, so you could put it pretty much anywhere on the |
96 |
> filesystem and run it (ignoring for a moment 'noexec' potentially being |
97 |
> set). Or even more to the point, you could e-mail a static binary to |
98 |
> someone else on a different distro and it'll probably execute just fine. |
99 |
|
100 |
I think I wasn't very clear. In the second bullet point above I meant |
101 |
shared libraries, which leads to what you say below. |
102 |
|
103 |
> The important bit here is certain software packages defaulting their install |
104 |
> into /usr that are needed to bring the system up (like encryption, lvm, |
105 |
> etc). It's when using those setups that you pretty much have to use an |
106 |
> initramfs, sometimes regardless if you have /usr on another partition or not. |
107 |
|
108 |
Correct, and this is the issue. Gentoo has done extra work in the past |
109 |
to make more things useable without an initramfs, and a good part of that |
110 |
work is in the gen_usr_ldscript function. |
111 |
|
112 |
If I start removing calls to that function, more shared libraries will |
113 |
move back to /usr/lib*, breaking systems that use separate /usr without |
114 |
initramfs. |
115 |
|
116 |
If I override the build systems of these packages and install all of the |
117 |
library info in /$(get_libdir), I would have to develop custom code to |
118 |
move unnecessary things back to /usr/$(get_libdir). This would also be a |
119 |
bandaid because separate /usr without initramfs would be impossibly |
120 |
broken if we do the /usr merge eventually. |
121 |
|
122 |
If I do go forward with removing gen_usr_ldscript, I want to be reasonable |
123 |
about how I do it, so let me know what your thoughts are about how it should |
124 |
happen. |
125 |
|
126 |
Let me know what you think. |
127 |
|
128 |
William |