public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Cary Coutant <ccoutant@google.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	Ian Lance Taylor <iant@google.com>,
		Binutils <binutils@sourceware.org>
Subject: Re: [PATCH 2/2 v5] gold: enable new dtags by default
Date: Wed, 05 Feb 2014 00:12:00 -0000	[thread overview]
Message-ID: <CAHACq4oNM-JyjMXtJJmjfLq3PJG2a7C+t9O=8M=ifOvp+h6L=w@mail.gmail.com> (raw)
In-Reply-To: <201302201340.48380.vapier@gentoo.org>

Where did we end up on this issue? As far as I can tell, the
discussion just died with no clear consensus, and I'm still not sure
what changes I should make to gold.

It sounds like the community really isn't ready to move away from
DT_RPATH, but I'm not sure why. As I understand it, there are two
differences between DT_RPATH and DT_RUNPATH:

(1) DT_RUNPATH is searched after LD_LIBRARY_PATH, while DT_RPATH is
searched before. The DT_RUNPATH behavior makes sense to me -- having
an environment variable that can't override the search path embedded
in the binary seems useless.

(2) DT_RUNPATH is used only to search for direct dependencies of the
object it's contained in, while DT_RPATH is used for indirect
dependencies as well. (This difference is *not* mentioned in the
gABI.) Again, the DT_RUNPATH behavior makes sense -- an object
shouldn't have any awareness of its indirect dependencies, which may
change over time.

It seems to me that the cases where DT_RUNPATH causes breakage are
broken as intended, and the second-level libraries that depend on
third-level libraries should have an embedded DT_RUNPATH that says
where to find them. Of course, since they've been working for so long,
we need an option to allow them to continue working, but I don't see
why we shouldn't change the default.

In gold, --enable-new-dtags applies only to DT_RUNPATH vs. DT_RPATH.
We always generate DT_FLAGS, but also DT_TEXTREL and DT_SYMBOLIC when
those bits are set. I have no problem with renaming the option to
--{en,dis}able-dt-runpath.

-cary


On Wed, Feb 20, 2013 at 10:40 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday 20 February 2013 12:16:51 H.J. Lu wrote:
>> On Tue, Feb 19, 2013 at 10:15 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > On Tuesday 05 February 2013 00:43:04 Ian Lance Taylor wrote:
>> >> On Mon, Feb 4, 2013 at 5:44 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> >> > This caused:
>> >> >
>> >> > http://www.sourceware.org/bugzilla/show_bug.cgi?id=15098
>> >> >
>> >> > I changed BFD linker not set new dtags with -rpath.
>> >>
>> >> I don't see why that is the right fix.  Since DT_RPATH/DT_RUNPATH are
>> >> only ever set by the linker's -rpath option, it seems like the right
>> >> fix is to always use DT_RPATH and never use DT_RUNPATH.
>> >>
>> >> Of course, since the only thing --new-dtags does in gold is select
>> >> DT_RUNPATH rather than DT_RPATH, this makes new--dtags completely
>> >> useless in gold.
>> >>
>> >> It seems that we have made sensible-seeming decisions to wind up in an
>> >> absurd place.  It seems that we should now make --new-dtags a no-op
>> >> and drop all support for generating DT_RUNPATH.  Which makes me wonder
>> >> why DT_RUNPATH was invented in the first place.
>> >
>> > sorry, but my main comp hd died, so i've been offline for a while.  it
>> > seems that the current status is that the linker no longer defaults to
>> > --enable-new- dtags, but bfd still only specifies DT_RUNPATH if the flag
>> > is enabled (rather than using both).  is that correct ?
>> >
>> > DT_RUNPATH is preferable to DT_RPATH because the latter is searched
>> > *before* LD_LIBRARY_PATH which is bad.  most of the use cases i've seen
>> > with rpath fall
>> >
>> > into two categories:
>> >  - people want to generate libraries with a custom path to loadable
>> >  plugins --
>> >
>> > DT_RUNPATH works great
>> >
>> >  - people want their application to search a local path for all of its
>> >  libs --
>> >
>> > DT_RPATH works here w/$ORIGIN
>> >
>> >  - people want to install their shared libs into a non-searchable path
>> >  and
>> >
>> > have their application use it -- DT_RUNPATH works here
>> >
>> > i've seen build cases where DT_RPATH actively causes problems when there
>> > is a version already installed.  they compile their local binary and its
>> > shared libs, then attempt to use LD_LIBRARY_PATH to force the binary to
>> > use the local libs.  unfortunately, the DT_RPATH kicks in and loads
>> > everything from / instead and it falls down.
>> >
>> > considering Gentoo has been defaulting to --enable-new-dtags since at
>> > least 2004 and i have yet to see a bug report related to it, i wonder
>> > what actually broke that caused you to notice this ?  and if it's a
>> > minor case, is a better answer to tell people to use --disable-new-dtags
>> > if they really don't want the new DT_RUNPATH behavior ?  seems like the
>> > DT_RPATH behavior is the exception rather than the rule ... the only
>> > thing it has going for it is historical precedence.
>> >
>> > similarly, i don't think it generally makes sense for libraries to
>> > utilize DT_RPATH.  dare i suggest that a middle ground might be to
>> > default to DT_RUNPATH when -shared is in use, and DT_RPATH otherwise ?
>>
>> Since DT_RPATH != DT_RUNPATH. we need a new option to
>> specify DT_RUNPATH.
>
> i'm aware "DT_RPATH != DT_RUNPATH" is a true statement.  however, my point
> still stands that for the majority of cases, people want runpath tags to
> specify custom paths for loading libraries and in that regard, DT_RUNPATH is
> the same as DT_RPATH.  imo, the example you posted is the exception rather
> than the rule when it comes to expected behavior and already works w/the
> patches i posted -- if you want that behavior, use -rpath --disable-new-dtags.
> hence the idea is to improve the default rather than requiring everyone to
> change flags.
> -mike

  reply	other threads:[~2014-02-05  0:12 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-25  7:29 [PATCH] [RFC] ld: add new --enable-new-dtags-only flag Mike Frysinger
2013-01-08  9:32 ` Alan Modra
2013-01-08 11:25   ` Mike Frysinger
2013-01-11  6:03 ` [PATCH v2] " Mike Frysinger
2013-01-11  9:22   ` John Marino
2013-01-11 16:34     ` Mike Frysinger
2013-01-12  6:30 ` [PATCH 1/2 v3] ld: add new --{dis,en}able-new-dtags-only flag Mike Frysinger
2013-01-12  6:30   ` [PATCH 2/2] gold: enable new dtags by default Mike Frysinger
2013-01-15 14:47     ` Ian Lance Taylor
2013-01-15 17:37       ` Mike Frysinger
2013-01-15 19:06         ` Ian Lance Taylor
2013-01-15 19:32           ` Mike Frysinger
2013-01-15 20:02             ` Ian Lance Taylor
2013-01-15 21:06               ` Mike Frysinger
2013-01-17  3:42               ` Alan Modra
2013-01-17  4:09                 ` Mike Frysinger
2013-01-17  4:42                   ` Alan Modra
2013-01-17 13:10                     ` Michael Matz
2013-01-17 19:19                     ` Mike Frysinger
2013-01-17 22:19                       ` Alan Modra
2013-01-17 19:19 ` [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags Mike Frysinger
2013-01-17 19:18   ` [PATCH 2/2 v4] gold: enable new dtags by default Mike Frysinger
2013-01-17 21:33   ` [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags Alan Modra
2013-01-17 22:26     ` Mike Frysinger
2013-01-18  4:23 ` [PATCH 1/2 v5] " Mike Frysinger
2013-01-18  4:23   ` [PATCH 2/2 v5] gold: enable new dtags by default Mike Frysinger
2013-01-18  6:24     ` Ian Lance Taylor
2013-02-05  1:44       ` H.J. Lu
2013-02-05  5:43         ` Ian Lance Taylor
2013-02-05  9:39           ` Alan Modra
2013-02-05 14:19             ` Ian Lance Taylor
2013-02-05 21:50               ` Alan Modra
2013-02-06 16:24                 ` H.J. Lu
2013-02-05 14:20             ` Ian Lance Taylor
2013-02-05 16:33               ` H.J. Lu
2013-02-05 21:57                 ` Alan Modra
2013-02-06  8:24                   ` Andreas Schwab
2013-02-06 16:37                     ` H.J. Lu
2013-02-06 16:28                   ` H.J. Lu
2013-02-06 21:44                     ` Alan Modra
2013-02-05 16:47             ` H.J. Lu
2013-02-05 17:41               ` H.J. Lu
2013-02-20  6:15           ` Mike Frysinger
2013-02-20 17:17             ` H.J. Lu
2013-02-20 18:40               ` Mike Frysinger
2014-02-05  0:12                 ` Cary Coutant [this message]
2014-02-05  2:29                   ` Joseph S. Myers
2014-02-05 16:53                     ` Cary Coutant
2014-02-05 17:01                       ` Joseph S. Myers
2013-01-18 14:00   ` [PATCH 1/2 v5] ld: change --enable-new-dtags to only generate new dtags Alan Modra
2013-01-18 21:02 ` [PATCH] ld: enable new dtags by default for linux/gnu targets Mike Frysinger
2013-01-19  6:42   ` Alan Modra
2013-01-19  8:40   ` Andreas Schwab
2013-01-19 16:12     ` Mike Frysinger
2013-01-21  8:26       ` Mike Frysinger
2013-01-31  0:47   ` Hans-Peter Nilsson
2013-01-31  0:58     ` Hans-Peter Nilsson
2013-01-31  9:58       ` Hans-Peter Nilsson
2013-02-04 18:15   ` H.J. Lu

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='CAHACq4oNM-JyjMXtJJmjfLq3PJG2a7C+t9O=8M=ifOvp+h6L=w@mail.gmail.com' \
    --to=ccoutant@google.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=iant@google.com \
    --cc=vapier@gentoo.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
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).