public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Olaf van der Spek <olafvdspek@gmail.com>, binutils@sourceware.org
Subject: Re: Support for automatic linking via pragma
Date: Fri, 04 Mar 2011 18:40:00 -0000	[thread overview]
Message-ID: <mcrhbbi20h8.fsf@google.com> (raw)
In-Reply-To: <AANLkTikkzeZPg1cV8f_rUAUXgo_mScRcF=mVCzayENta@mail.gmail.com>	(H. J. Lu's message of "Fri, 4 Mar 2011 08:55:48 -0800")

"H.J. Lu" <hjl.tools@gmail.com> writes:

> On Fri, Mar 4, 2011 at 8:52 AM, Ian Lance Taylor <iant@google.com> wrote:
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>>> On Fri, Mar 4, 2011 at 8:29 AM, Olaf van der Spek <olafvdspek@gmail.com> wrote:
>>>> MSVC supports the following pragma, which can be used to automatically link a
>>>> library when a header file is included. This is used by for example Boost.
>>>>
>>>> It makes linking with the right lib a lot simpler. No more fiddling
>>>> with autoconf to detect the right lib name.
>>>>
>>>
>>> Not necessarily.  Unlike DSO, object files don't have ABI/API
>>> information. You may not link foo.o compiled with glibc 2.5/libbar
>>> 1.3 against glibc 2.13/libbar 1.9
>>
>> I don't see how that is relevant to what Olaf is talking about.
>>
>> What Olaf is saying is that he wants to be able to have a .h file
>> automatically a -l option to the link command line.
>
> Don't you need to store such information in object files?

Yes, but so what?  The meaning of the information in the object file is
"when linking, add this -l option".  That is not different from what
exists today, except that today you have to remember to add the -l
option yourself.  Today, if you have an old object file, and you add the
-l option yourself on the link line, you will have trouble.  This
proposal does not change that.  It addresses a different issue.

In the hopes of being more clear, the issue that this proposal addresses
is that if your code does a #include <glib.h>, you have to also add
-lglib on your command line.  If this proposal were implemented, the
second step would be unnecessary.  This makes writing Makefiles simpler.


>> What you are saying is that if that you have a .o file, you have to link
>> against the -l which corresponds to the .h file which was used when the
>> .o file was compiled.  That is of course a real problem, but it's a
>> problem that exists whether or not we implement the MSVC pragma.
>>
>
> There is no such problem for DSO since we can encode ABI/API
> info in DSO.

Yes, of course, but irrelevant to the issue at hand.

Ian

  parent reply	other threads:[~2011-03-04 18:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 18:17 Olaf van der Spek
2011-03-04 16:30 ` Olaf van der Spek
2011-03-04 16:44   ` H.J. Lu
2011-03-04 16:52     ` Ian Lance Taylor
2011-03-04 16:55       ` H.J. Lu
2011-03-04 17:31         ` Kai Tietz
2011-03-04 17:35           ` Olaf van der Spek
2011-03-04 18:40         ` Ian Lance Taylor [this message]
2011-03-04 17:31     ` Olaf van der Spek

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=mcrhbbi20h8.fsf@google.com \
    --to=iant@google.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=olafvdspek@gmail.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).