public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@cygnus.com>
To: oliva@dcc.unicamp.br
Cc: tot@trema.com, egcs@cygnus.com
Subject: Re: Shared library runpath trouble in Solaris.
Date: Tue, 11 Nov 1997 09:10:00 -0000	[thread overview]
Message-ID: <199711111710.MAA13467@subrogation.cygnus.com> (raw)
In-Reply-To: <orzpncdr3b.fsf@grupiara.dcc.unicamp.br>

   From: Alexandre Oliva <oliva@dcc.unicamp.br>
   Date: 11 Nov 1997 01:52:56 -0200

   >    ld -R/path/to/libstdc++ -R/usr/lib -R/whatever/-R/flags/issued/by/the/user

   > It seems to me that the user's -R options should go first.

   So it seemed to me, but you said -R would add a directory to the
   beginning of the search path...  If this is not correct, the reverse
   order should be used.

Sorry for the confusion.  The -R options are all concatenated together
in the order in which they appear.  They are then all searched.  Then
LD_LIBRARY_PATH is searched.  Then /usr/lib is searched.

Note that if we always use a -R /usr/lib option, it will break certain
uses of LD_LIBRARY_PATH.  I've used LD_LIBRARY_PATH to force programs
to use a shared library I had instrumented in some way.  If /usr/lib
is built into the program, there is no way to override that short of
using a special dynamic linker, or relinking the program which may be
difficult.

   > Perhaps I misunderstand, but it seems to me that it would break for
   > the same reason we've been discussing: the program would have a -R
   > option it does not need.

   So what?  If it doesn't ever search that directory, there's no problem
   at all.  So, if it is the last directory in the search path, there's
   no problem to solve: either the library will not be found at all, or
   it will be found in this last directory.  If the NFS-server for that
   directory is down, the program wouldn't be able to run anyway.

We need to test dynamic linkers to see how they behave.  I do not
trust all dynamic linkers to not look through directories they do not
need to look through.  There is also the -R vs. LD_LIBRARY_PATH
problem I mention above.

   > That's the bad situation I want to avoid:
   > the compiler should never silently insert a unnecessary -R option.

   I'd consider that a necessary -R option.  Consider what kind of damage
   it would cause to you if libgcc were shared, and try to understand my
   position as a C++ programmer.

I do understand the problem.  Honest.  However, if libstdc++ is not
shared, then it is an unnecessary -R option.  libstdc++ is not always
shared, and we should not assume that it is.  People may deliberately
choose to use a static libstdc++ to avoid shared library problems.
People may deliberately link with -Bstatic -lstdc++ -Bdynamic to avoid
shared library problems.  If we use -R, we force a particular instance
of shared library problems onto them even though they've tried to
avoid it.

   There are lots of questions like this in bug-g++, gnu.gcc.help.
   Several people have had trouble with that recently.  Wouldn't it be
   much better to make it work in the general case, and let people with
   special needs to fulfill them with extra switches?

Yes, of course.  I'm not arguing against that, (provided the extra
switches are natural and clear).

I'm just pointing out a serious problem I've seen with automatically
adding -R options.  I've even described a solution which could be
implemented in collect2.  What's wrong with the solution I described?
(To repeat: do the library searching in collect2, add a -R option if a
shared library will be used; I'm happy to make this a special case for
libstdc++, but I think it would also be reasonable to act otherwise).

Ian

  reply	other threads:[~1997-11-11  9:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-10  6:04 Teemu Torma
1997-11-10  8:42 ` Ian Lance Taylor
1997-11-10  9:08   ` Teemu Torma
1997-11-10  9:08     ` Ian Lance Taylor
1997-11-10 13:47       ` Alexandre Oliva
1997-11-10 13:47         ` Ian Lance Taylor
1997-11-10 18:41           ` Alexandre Oliva
1997-11-10 19:19             ` Ian Lance Taylor
1997-11-10 19:57               ` Alexandre Oliva
1997-11-11  9:10                 ` Ian Lance Taylor [this message]
1997-11-11 12:28                   ` Alexandre Oliva
1997-11-11 22:42                     ` Alexandre Oliva
1997-11-12  4:01                   ` Teemu Torma
1997-11-11  2:26             ` Swen Thuemmler
1997-11-10 10:17   ` Jeffrey A Law

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=199711111710.MAA13467@subrogation.cygnus.com \
    --to=ian@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=oliva@dcc.unicamp.br \
    --cc=tot@trema.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).