ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] Q: --no-copy-dt-needed-entries
Date: Sun, 21 Mar 2010 22:18:34 +0300
Message-ID: <20100321191834.GE30094@altlinux.org> (raw)
In-Reply-To: <20100321153442.GA21854@wo.int.altlinux.org>

[-- Attachment #1: Type: text/plain, Size: 5427 bytes --]

On Sun, Mar 21, 2010 at 06:34:43PM +0300, Dmitry V. Levin wrote:
> > > --no-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".)
> 
> With --no-copy-dt-needed-entries in effect, each ELF output executable will
> have to be linked with every library it uses directly.

I have to indicate that "will have to be linked" and "uses directly"
is still too vague and rather anthropomorphic language.

As far as I can see, there's no definite and formal description of
what these options are supposed to do.  (I haven't looked at the source
code yet.)

> > |       --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).
> 
> If your application doesn't use glib2, there is no need to link with
> glib2.

Again, "using" glib2 is just a poor wording - using glib2 API calls
in the source code is not exactly the same as linking with glib2 ABI.
For example, since libgtk+2 header files include glib2 header files,
glib2 ABI calls might happen inadvertently.  This is due to macros,
static inline functions etc.  So you may not even know that you're
"using" glib2.

Remember pkg-config issues and --disable-recursion flag.
This is just it.

$ pkg-config --disable-recursion --libs gtk+-2.0
-lgtk-x11-2.0
$ pkg-config --libs gtk+-2.0                    
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpangoft2-1.0 -lpango-1.0 -lm -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lglib-2.0  
$ 

So pkg-config makes a "closure" by default, based on additional
information from package configuration files.  ld(1) now does a similar
thing, "shallow closure" based on the information from the libraries
themselves.  Also remember once you told it is possible to recover *.la
files based on the information from corresponding *.so files alone.

> > |	  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?
> 
> The abovementioned options affects the ld(1) behaviour only.

They say "No DT_NEEDED links will be traversed to resolve symbols."
This is like, cool, you know.  Shall I believe it?

> > > Второй параметр не дает слинковать свою программу с библиотеками, которые
> > > эта программа не использует непосредственно.
> > > 
> > > В результате программа должна получиться слинкованной с теми и только с
> > > теми библиотеками, которые она непосредственно использует, т.е. должна
> > > произойти правильная оптимальная линковка.
> > 
> > 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.
> 
> Just the opposite, there is a reason to link ELF executables with all
> libraries they use directly.  Applications should be neither overlinked
> nor underlinked.  The first problem is solved by --as-needed, the second
> issue will be fixed by enabling --no-copy-dt-needed-entries by default.

Give me a good reason, with examples, why we should change the default.
There was a good reason for --as-needed - extra dependencies and extra
lookup costs.  I see no good reason for --no-copy-dt-needed-entries.

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2010-03-21 19:18 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-18 22:14 [devel] Q: --no-add-needed Kirill A. Shutemov
2010-03-18 22:22 ` Dmitry V. Levin
2010-03-19  0:36 ` Max Ivanov
2010-03-19  8:40   ` Kirill A. Shutemov
2010-03-19 12:29     ` Max Ivanov
2010-03-19 12:51       ` Kirill A. Shutemov
2010-03-19 20:49         ` Dmitry V. Levin
2010-03-19 21:24           ` Kirill A. Shutemov
2010-03-21  9:54         ` Stanislav Ievlev
2010-03-21 10:02           ` Evgeny Sinelnikov
2010-03-21 10:04             ` Stanislav Ievlev
2010-03-21 10:11               ` Andrey Rahmatullin
2010-03-21 10:19                 ` Evgeny Sinelnikov
2010-03-21 13:14                   ` [devel] Q: --copy-dt-needed-entries Dmitry V. Levin
2010-03-21 14:51                     ` Alexey Tourbin
2010-03-21 15:34                       ` [devel] Q: --no-copy-dt-needed-entries Dmitry V. Levin
2010-03-21 19:18                         ` Alexey Tourbin [this message]
2010-03-22  0:26                           ` Kirill A. Shutemov
2010-03-22  0:27                             ` Kirill A. Shutemov
2010-03-22  8:11                             ` Alexey Tourbin
2010-03-22 11:00                               ` Kirill A. Shutemov
2010-03-22 13:58                                 ` Alexey Tourbin
2010-03-22 15:41                                   ` Kirill A. Shutemov
2010-03-22 17:19                                     ` Alexey Tourbin
2010-03-22 18:31                                       ` Kirill A. Shutemov
2010-03-22 14:15                                 ` Sergei Epiphanov
2010-03-22 14:31                                   ` Vitaly Kuznetsov
2010-03-22 14:41                                   ` Kirill A. Shutemov
2010-03-22  7:23                           ` [devel] Q: --no-copy-dt-needed-entries. " Любит-не =?windows-1251?b?IOv+4ejy?=". И? Sergei Epiphanov
2010-03-22  7:28                             ` Kirill A. Shutemov
2010-03-22  8:23                               ` Alexey Tourbin
2010-03-24 18:04                                 ` [devel] Q: --no-copy-dt-needed-entries Dmitry V. Levin
2010-03-24 18:24                                   ` Alexey Tourbin
2010-03-24 19:01                                     ` Kirill A. Shutemov
2010-03-24 22:01                                       ` Dmitry V. Levin
2010-03-25 17:14                                         ` Michael Shigorin
2010-03-24 18:15                         ` Dmitry V. Levin
2010-03-24 18:24                           ` Kirill A. Shutemov
2010-03-24 18:28                             ` Dmitry V. Levin
2010-03-24 18:40                               ` Kirill A. Shutemov
2010-03-22 14:48                 ` [devel] Q: --no-add-needed Stanislav Ievlev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100321191834.GE30094@altlinux.org \
    --to=at@altlinux.ru \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git