SunOS linking (was: Re: Outstanding GTK+ patches)



On 18 Feb 2000, Owen Taylor wrote:

> Fixes requiring further evaluation
> ==================================
> 
> glib-guy-990920-0
> 
>  Adds -R to the output of glib-config; I think one of the GNU info
>  pages has some manifesto as to why -R is evil... but otherwise
>  might be OK. (Would require the corresponding change to gtk 
>  to be useful)


the info section in question is ld.info-1.gz:

`-rpath DIR'
     Add a directory to the runtime library search path.  This is used
     when linking an ELF executable with shared objects.  All `-rpath'
     arguments are concatenated and passed to the runtime linker, which
     uses them to locate shared objects at runtime.  The `-rpath'
     option is also used when locating shared objects which are needed
     by shared objects explicitly included in the link; see the
     description of the `-rpath-link' option.  If `-rpath' is not used
     when linking an ELF executable, the contents of the environment
     variable `LD_RUN_PATH' will be used if it is defined.

     The `-rpath' option may also be used on SunOS.  By default, on
     SunOS, the linker will form a runtime search patch out of all the
     `-L' options it is given.  If a `-rpath' option is used, the
     runtime search path will be formed exclusively using the `-rpath'
     options, ignoring the `-L' options.  This can be useful when using
     gcc, which adds many `-L' options which may be on NFS mounted
     filesystems.

     For compatibility with other ELF linkers, if the `-R' option is
     followed by a directory name, rather than a file name, it is
     treated as the `-rpath' option.


so, according to the ld info pages, -L is sufficient, however the patch
by Guy Harris claims (for Solaris 2.5.1):
  
  The "-L" flag is insufficient, with Sun's linker (and possibly with the
  linker on other systems, e.g. other SVR4 derivatives, IRIX, and even
  Linux or BSD systems where the library is being installed in a directory
  the run-time linker isn't configured to search by default), to find
  libraries; the linker will find the library when it builds a program,
  but the run-time linker won't find the library when the program is run,
  unless the user sets LD_LIBRARY_PATH or LD_RUN_PATH.
  
  This can get in the way of trying to build and run a program if Glib
  isn't installed in one of the directories searched by default.
  
  On Solaris, the "-R" flag should be used, in addition to the "-L" flag;
  an IRIX user claims that "-rpath" should be used on IRIX, and indicates
  that "--rpath" should be used on FreeBSD - and FreeBSD uses, I think,
  the GNU binutils, so "--rpath" is probably what would be used on other
  systems using the GNU binutils.
  
  I'll only include the change for Solaris, though, as I don't have an
  IRIX system on which to try this, and the Linux and FreeBSD systems I
  use are configured to search "/usr/local/lib" for shared libraries, and
  I have Glib and GTK+ installed there.


and thusly, it does:


--- glib-config.in      1999/08/26 22:36:01     1.1
+++ glib-config.in      1999/09/21 01:43:32
@@ -107,5 +107,24 @@
                libsp="@G_MODULE_LDFLAGS@ -lgmodule $libsp"
                libsa="$libsa @G_MODULE_LIBS@"
        fi
-       echo -L@libdir@ $libsp $libsa
+
+       case "`(uname -sr) 2>/dev/null`" in
+       "SunOS 5"*)
+               #
+               # XXX - "autoconf" 2.13 thinks that "some versions of Sun
+               # CC require a space after -R and others require no space";
+               # I don't know if this is a problem with Sun C, or with
+               # Sun's linker (which GCC may also use), but, for now,
+               # we ignore the problem and assume "-R" works like
+               # "-L".  This needs to be checked in "configure"
+               # (but, then, "autoconf" should provide some nice way
+               # to deal with "-R").
+               #
+               echo -L@libdir@ -R@libdir@ $libsp $libsa
+               ;;
+
+       *)
+               echo -L@libdir@ $libsp $libsa
+               ;;
+       esac
 fi


can we have confirmation/refusals from other SunOS people on this topic?

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]