public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: Howard Chu <hyc@symas.com>
Cc: Nick Clifton <nickc@redhat.com>, binutils@sourceware.org
Subject: Re: [PATCH] dependency list for static libraries
Date: Tue, 22 Sep 2020 10:16:38 -0700	[thread overview]
Message-ID: <20200922171638.kkapdimub5iled5o@gmail.com> (raw)
In-Reply-To: <c743f4ed-11a8-53aa-5c1b-96b9e5b65f5e@symas.com>

Did the thread start at
https://sourceware.org/legacy-ml/binutils/2017-09/msg00158.html ?

If all dependencies are specified on the command line but there are
"backward references", we can step back and think about loosing the
requirement like some other binary formats:
https://sourceware.org/pipermail/binutils/2020-September/113194.html "Memoryless" archive processing of ld

If some archives want system libraries (e.g. -lm -lpthread), MSVC style
#pragma comment(lib, "pthread")
may be convenient. clang supports the syntax for ELF and the syntax has
been used in several places in libc++. LLD supports .deplibs (
http://lists.llvm.org/pipermail/llvm-dev/2019-March/131004.html
http://llvm.1065342.n5.nabble.com/llvm-dev-RFC-ELF-Autolinking-td126998.html )

On 2020-09-22, Howard Chu wrote:
>Nick Clifton wrote:
>> Hi Howard,
>>
>>>>   * It is not clear to me why you create a binary bfd for Libdeps_bfd but
>>>>     then convert it to a plugin type bfd.  Can you explain what you are
>>>>     doing here ?
>>>
>>> This was a major hassle, I should have commented it. The bfd gets created
>>> with type "plugin", and that refuses the bfd_bwrite() call. (Just fails.)
>>> The write only succeeded if I set it to "binary" type first. But then, trying
>>> to add this bfd to the archive failed unless I changed the type back to "plugin."
>>
>> OK - please could you add a comment to this effect to enlighten future readers.
>
>OK, new patch attached. Added comments, NEWS entry, texi doc, test case.
>
>>>>   * The change to the code to call ar_emul_replace() inside replace_members()
>>>>     looks wrong to me.  The current code will try to replace all of the entries
>>>>     on the files_to_move list, and will set changed to TRUE if any of the
>>>>     replacements succeeds.  The patched code will changed to FALSE if any
>>>>     replacement fails, even if earlier ones succeeded.
>>>
>>> No, that's not correct. The patched code ORs in the result, so it will not
>>> change any previous success into a failure.
>>
>> Doh - OK, I misread this.  But I think that there is still a possible problem.
>> Since the result is ORed in, if there is a failed call to ar_emul_replace after
>> a successful one, changed will still be TRUE, and the failed element will be
>> removed from the chain.  This differs from the old behaviour where the element
>> would not be removed if ar_emul_replace() fails.  (I am not sure however what
>> the impact of this change will be).
>
>OK, fixed this to preserve the original behavior for failed elements.
>
>>> OK. Any suggestions on what exactly to check?
>>
>> Sure.  I would suggest adding a test that checks to see that:
>>
>>  ar cvL libfoo.a "/foo/bar/" foo.o
>>
>> (something like that) actually creates a library with a libdeps element
>> in it.  Take a look at binutils/testsuite/binutils-all/ar.exp where other
>> tests on ar are run.  Basically you need to create a new proc to the file
>> and then invoke it at the end of the file.  The new proc would probably
>> look something like this:
>
>Thanks. Had to tweak 2 lines but otherwise this worked.
>
>> proc test_add_dependencies { } {

  reply	other threads:[~2020-09-22 17:16 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 15:49 Howard Chu
2017-09-19 15:52 ` Simon Richter
     [not found]   ` <WM!bae999665f49907786872b93f01ac98d53e7b97e29b4228399d8baadf9ec0ab33db74467d73c998225b250ba1d00a4c0!@mailstronghold-3.zmailcloud.com>
2017-09-19 16:04     ` Howard Chu
2017-09-20  1:42       ` R0b0t1
2017-09-19 16:54 ` Joseph Myers
     [not found]   ` <WM!83b6ad7285aa96ce69fcd1944d4eae8f20e5f19dfbf161f45313f5393bcffe1b77231520b8f4e24145a3f85eeafb39ed!@mailstronghold-1.zmailcloud.com>
2017-09-19 22:01     ` Howard Chu
2017-09-20  0:20       ` Joseph Myers
2020-09-03 20:42       ` Howard Chu
2020-09-22 10:39         ` Nick Clifton
2020-09-22 11:42           ` Howard Chu
2020-09-22 13:12             ` Nick Clifton
2020-09-22 16:23               ` [PATCH] " Howard Chu
2020-09-22 17:16                 ` Fangrui Song [this message]
2020-09-22 17:55                   ` Howard Chu
2020-09-22 20:46                 ` Howard Chu
2020-09-23 11:52                   ` Nick Clifton
2020-09-23 15:29                     ` Howard Chu
2020-09-24  5:21                       ` Fangrui Song
2020-09-24  9:19                         ` Howard Chu
2020-09-24  9:30                           ` Howard Chu
2020-09-28 11:07                           ` Howard Chu
2020-10-28 14:56                     ` Howard Chu
2020-11-03 15:14                       ` Nick Clifton
2020-11-03 15:31                         ` Howard Chu
2020-11-08  1:39                           ` Alan Modra
2020-11-08 15:07                             ` Howard Chu
2020-11-09  0:01                               ` Alan Modra
2020-11-10  2:44                                 ` Howard Chu
2020-11-10 11:07                                   ` Alan Modra
2020-11-11 14:57                                     ` Howard Chu
2020-11-11 14:59                                       ` Howard Chu
2020-11-17 14:01                                         ` Nick Clifton
2020-11-04  0:33                         ` Howard Chu
2020-11-04 11:01                           ` Nick Clifton
2020-11-04 14:50                             ` Howard Chu
2020-11-06 12:38                               ` Nick Clifton
2020-11-13 14:40                               ` Howard Chu
2020-11-24 17:49                                 ` Howard Chu
2020-11-25 11:17                                   ` Nick Clifton
2020-12-01  0:08                                     ` Howard Chu
2020-12-14 14:28                                       ` Nick Clifton
2020-12-15 16:17                                         ` Jim Wilson
2020-12-15 16:22                                           ` Jeff Law
2020-12-15 16:50                                             ` Nick Clifton
2020-12-15 19:11                                               ` Jeff Law
2020-12-15 20:04                                                 ` Jim Wilson
2020-12-15 20:22                                               ` Cary Coutant
2020-12-15 20:51                                                 ` Howard Chu
2020-12-16 11:16                                                   ` Nick Clifton
2020-12-16 14:49                                                     ` [PATCH] ld: Call plugin hooks only if they are available H.J. Lu
2020-12-16 18:34                                                       ` Howard Chu
2020-12-16 18:40                                                         ` H.J. Lu
2020-12-16 19:06                                                           ` Howard Chu
2020-12-16 19:11                                                             ` [PATCH] ld: Skip libdep plugin if not all plugin hooks " H.J. Lu
2020-12-16 21:26                                                               ` Howard Chu
2020-12-16 21:47                                                                 ` H.J. Lu
2020-12-16 18:44                                                         ` [PATCH] ld: Call plugin hooks only if they " Howard Chu
2020-12-15 20:33                             ` [PATCH] dependency list for static libraries Cary Coutant
2020-12-15 20:53                               ` Howard Chu
2020-12-16 11:18                                 ` Nick Clifton
2020-12-23 13:27                         ` Matthias Klose
2020-12-23 18:23                           ` Howard Chu
2020-09-30 10:33 Peter Smith
2020-10-28 14:35 ` Howard Chu

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=20200922171638.kkapdimub5iled5o@gmail.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    --cc=hyc@symas.com \
    --cc=nickc@redhat.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).