1 |
On Sun, Oct 2, 2016 at 9:54 AM, Michael Orlitzky <mjo@g.o> wrote: |
2 |
> On 10/02/2016 01:18 AM, Meino.Cramer@×××.de wrote: |
3 |
>> |
4 |
>> One curious question remains: |
5 |
>> If -as-needed is included, all libs will be "delinked" :), which |
6 |
>> are not used...so I am throwing away stuff, which no code calls: |
7 |
>> WHY should this cause trouble? |
8 |
>> Or is it again oversimplified by me? :) ;) 8) |
9 |
>> |
10 |
> |
11 |
> Suppose I write a program called "foo" and a library that it uses called |
12 |
> "libfoo". If the libfoo library uses OpenSSL and the main executable has |
13 |
> -lssl in its link command, everything will work fine by default. But, if |
14 |
> you add --as-needed to your linker flags and don't specifically link |
15 |
> libfoo against OpenSSL, the result will be underlinked. |
16 |
> |
17 |
|
18 |
Typically the problems that come up result from using a library |
19 |
without explicitly linking it, assuming that it will be there because |
20 |
something else will pull it in. There may be niche situations where |
21 |
problems are unavoidable, but for the most part it comes down to |
22 |
always passing libraries to the linker if you use them. |
23 |
|
24 |
In Gentoo lowering the number of unnecessary linked libraries is |
25 |
highly desirable, because anytime one of those libraries changes its |
26 |
SONAME any packages that use it must be rebuilt. When you have a lot |
27 |
of overlinking that greatly increases the amount of rebuilding you end |
28 |
up with, and more circular dependency issues and such, etc. This is |
29 |
why --as-needed became the default (after a lot of build system |
30 |
fixing). Gentoo has a tendency to find bugs in build systems because |
31 |
we run them in a variety of environments/etc. Binary distros can |
32 |
afford to just fuss with it until they somehow manage to get something |
33 |
built, and then forget about it. That said, some distros have better |
34 |
tools for finding missing dependencies, like blocking access to files |
35 |
that aren't part of a declared dependency during the build process. |
36 |
I've looked at the portage jail and that actually wouldn't be hard to |
37 |
add to Gentoo. Right now portage configures the jail to give read |
38 |
access to everything by default. If you disabled that you could |
39 |
instead pass a configuration that explicitly gives read access to |
40 |
every single file in the build dependencies (and @system I suppose), |
41 |
and denied everything else. Implementation is left as an exercise to |
42 |
the reader. |
43 |
|
44 |
-- |
45 |
Rich |