On Sun, Mar 21, 2010 at 04:14:41PM +0300, Dmitry V. Levin wrote: > On Sun, Mar 21, 2010 at 01:19:10PM +0300, Evgeny Sinelnikov wrote: > > 21 марта 2010 г. 13:11 пользователь Andrey Rahmatullin написал: > > > On Sun, Mar 21, 2010 at 01:04:53PM +0300, Stanislav Ievlev wrote: > > >> >> Вместо того чтобы усовершенствовать систему библиотек откатывают > > >> >> разработку на C на уровень прошлого столетия. > > >> > А в чём регрессия? Что и как стоит усовершенствовать? > > >> Я бы предпочёл не знать, с кем там линкуется библиотека, которую я использую. > > > > Так тут ведь и не предлагают знать. Наоборот, предлагают ещё и не > > линковаться явно с той библиотекой, которую ты используешь, если её > > использует другая библиотека, которую ты тоже используешь. > > > > > А при чём тут? Речь о том, что если ты используешь библиотеку, тебе > > > обязательно надо линковаться с ней явно. > > > > Ну, да... > > --copy-dt-needed-entries можно рассматривать как дополнение к --as-needed: > > Первый параметр заставляет линковать свою программу со всеми > библиотеками, котрые эта программа непосредственно использует. In ld(1) manpage, perhaps the description is not quite clear. And we should strive for very accurate wording in order to avoid a total mess. (E.g. we'd better avoid anthropomorphic clauses like "zastavlyaet".) | --copy-dt-needed-entries | --no-copy-dt-needed-entries | This option affects the treatment of dynamic libraries | referred to by DT_NEEDED tags inside ELF dynamic libraries | mentioned on the command line. Normally the linker will add | a DT_NEEDED tag to the output binary for each library | mentioned in a DT_NEEDED tag in an input dynamic library. So, "normally" what's happening is something like a "shallow closure". E.g. when I link with libgtk+2, glib2 is going to be linked in, too, automatically. | With --no-copy-dt-needed-entries specified on the command | line however any dynamic libraries that follow it will have | their DT_NEEDED entries ignored. The default behaviour can | be restored with --copy-dt-needed-entries. So --copy-dt-needed-entries is the default - which is to link in more dependencies automatically; --no-copy-dt-needed-entries reverts this logic to its bare minimum - only what you specified on the command line gets actually linked in (so you must specify e.g. both libgtk+2 and glib2). | This option also has an effect on the resolution of symbols in | dynamic libraries. With the default setting dynamic libraries | mentioned on the command line will be recursively searched, | following their DT_NEEDED tags to other libraries, in | order to resolve symbols required by the output binary. With | --no-copy-dt-needed-entries specified however the searching of | dynamic libraries that follow it will stop with the dynamic | library itself. No DT_NEEDED links will be traversed to | resolve symbols. Again, "this option also has an effect on the resolution of symbols" is a poor wording. Does this option affect only DT_NEEDED entries, or does it also set some other flags in the output binary? Does this paragraph address the ld(1) behaviour or rather ld.so(8) behaviour? > Второй параметр не дает слинковать свою программу с библиотеками, которые > эта программа не использует непосредственно. > > В результате программа должна получиться слинкованной с теми и только с > теми библиотеками, которые она непосредственно использует, т.е. должна > произойти правильная оптимальная линковка. So, contrary to the initial message, with --as-needed on, there seems to be NO REASON to enable --no-copy-dt-needed-entries by default.