[visit-developers] $$ORIGIN in rpath directive to linker

Gunther H. Weber ghweber at lbl.gov
Sat Oct 25 17:11:00 EDT 2008


The token is interpreted at run time by the dynamic linker ld.so. This  
feature is documented in more detail on the ld.so(8) man page:
---
PATH TOKEN EXPANSION
      The  runtime linker provides a number of tokens that can be used  
in an rpath specification (DT_RPATH
      or DT_RUNPATH).

      $ORIGIN
             ld.so understands the string $ORIGIN (or equivalently $ 
{ORIGIN}) in an rpath specification to
             mean  the  directory  containing  the application  
executable. Thus, an application located in
             somedir/app could be compiled with gcc -Wl,- 
rpath,’$ORIGIN/../lib’ so that it finds an  asso‐
             ciated  shared  library  in  somedir/lib  no matter where  
somedir is located in the directory
             hierarchy.

      $PLATFORM
             The string $PLATFORM (or equivalently ${PLATFORM}) in an  
rpath specifcation  expands  to  the
             processor  type of the current machine. Please note that  
on some architectures the Linux ker‐
             nel doesn’t provide a platform string to the dynamic  
linker.

      $LIB   The string $LIB (or equivalently ${LIB}) in an rpath   
corresponds  to  the  system  libraries
             directory, which is /lib for the native architecture on  
FHS compliant GNU/Linux systems.
---
I added it to get VisIt running with MPICH's p4 device, since that  
does not pass the environment and also does not work with VisIt's "- 
setupenv" mechanism since command line arguments are not visible  
before calling MPI_Init() so that the VisIt launcher script cannot see  
the real command line arguments.

Gunther

On Oct 21, 2008, at 8:33 AM, Mark Miller wrote:

> Hi Tom,
>
> By 'special linker variable' do you mean it is a variable  
> interpreted by
> a linker when the executable or .so gets created? By 'isn't set until
> load time', I think you mean that ORIGIN does not get interpreted  
> until
> the executable is actually loaded prior to run. Is that what you mean?
> Finally, is 'ORIGIN' specific to Franklin tools or more generally to  
> an
> 'ld' and/or dlopen (if the latter is relevant)?
>
> Mark
>
> PS: Sorry to sound uninformed but I am pretty clueless and am  
> primarily
> curious.
>
>
> On Tue, 2008-10-21 at 08:52 -0600, tom fogal wrote:
>> Mark Miller <miller86 at llnl.gov> writes:
>>> I've noticed that we are getting --rpath
>>> directives when linking .so's and executables that include a  
>>> reference
>>> to a (shell) variable $ORIGIN as in...
>>
>> It has been like this since mid/late summer.  Gunther needed to make
>> the change so that VisIt worked well on a NERSC system (franklin?),
>> though I needed it for something I can't remember at the time, too.
>>
>> [snip]
>>> What puzzles me is I don't see anywhere where ORIGIN is set to some
>>> value. Also, is it truly a shell variable, or a make variable?
>>
>> It is a special linker variable, not a shell or make variable.  It
>> means, `the path the binary is in', and thus isn't set until
>> load-time.
>>
>> HTH,
>>
>> -tom
> -- 
> Mark C. Miller, Lawrence Livermore National Laboratory
> email: mailto:miller86 at llnl.gov
> (M/T/W) (925)-423-5901 (!!LLNL BUSINESS ONLY!!)
> (Th/F)  (530)-753-8511 (!!LLNL BUSINESS ONLY!!)
>



More information about the visit-developers mailing list